@moon791017/neo-skills 1.0.42 → 1.0.43
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.
- package/AGENTS.md +14 -5
- package/README.md +2 -2
- package/package.json +1 -1
- package/skills/neo-azure-pipelines/SKILL.md +1 -1
- package/skills/neo-clarification/SKILL.md +50 -54
- package/skills/neo-clarification/assets/clarification-template.md +40 -0
- package/skills/neo-clarification/evals/eval_queries.json +26 -0
- package/skills/neo-clarification/evals/evals.json +30 -0
- package/skills/neo-clarification/references/5w1h-framework.md +43 -0
- package/skills/neo-clarification/scripts/validate-requirements.py +130 -0
- package/skills/neo-code-review/SKILL.md +73 -73
- package/skills/neo-code-review/evals/eval_queries.json +26 -0
- package/skills/neo-code-review/evals/evals.json +30 -0
- package/skills/neo-code-review/references/review-checklist.md +76 -0
- package/skills/neo-code-review/scripts/git-diff-reviewer.py +171 -0
- package/skills/neo-rust/SKILL.md +88 -28
- package/skills/neo-rust/evals/eval_queries.json +42 -0
- package/skills/neo-rust/evals/evals.json +27 -0
package/AGENTS.md
CHANGED
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
**Neo Skills** 是一個專為 **Antigravity CLI (AGY)** 設計的擴充外掛,旨在將 Agent 轉化為**全方位專家代理 (Universal Expert Agent)**。它利用 Model Context Protocol (MCP) 提供特定領域的專業知識 (Skills)。目前配備了專業的 **DevOps**(Azure Pipelines)與 **Frontend/Backend** 多語系(.NET, Python, Swift, TypeScript/JavaScript, Rust, Vue)等領域的模組,其架構設計可託管任何領域的技能。
|
|
4
4
|
|
|
5
5
|
## 回應風格
|
|
6
|
-
使用「繁體中文 (台灣)」
|
|
6
|
+
- 使用「繁體中文 (台灣)」
|
|
7
|
+
- commit訊息必須是「繁體中文 (台灣)」
|
|
7
8
|
|
|
8
9
|
---
|
|
9
10
|
|
|
10
11
|
# Repository Guidelines
|
|
11
12
|
|
|
12
13
|
## Project Structure & Module Organization
|
|
13
|
-
`src/` contains runtime TypeScript: [`src/server.ts`](file:///
|
|
14
|
+
`src/` contains runtime TypeScript: [`src/server.ts`](file:///Users/ben/Projects/neo-skills/src/server.ts) is the MCP entrypoint and `src/hooks/` holds CLI safety hooks such as `secret-guard.ts`. `bin/` contains the installer CLI and shared helpers. `skills/<skill-name>/` is the main content surface for contributors; each skill centers on a `SKILL.md` file and may also include `reference/` or `references/` docs, `assets/` templates, or reusable helper `scripts/`. Tests live in `test/*.test.js`. `dist/` is generated output from Bun builds and should not be edited manually.
|
|
14
15
|
|
|
15
16
|
## Build, Test, and Development Commands
|
|
16
17
|
Use `npm install` for local setup; CI uses `npm ci`. Run `bun run dev` for quick local iteration against `src/server.ts`. Run `bun run build` to bundle the server and hooks into `dist/`, and `bun run typecheck` for strict TypeScript validation without emitting files. Use `npm test` to run the Node test suite (`node --test`). After a build, `npm start` smoke-tests the bundled server from `dist/server.js`.
|
|
@@ -18,6 +19,12 @@ Use `npm install` for local setup; CI uses `npm ci`. Run `bun run dev` for quick
|
|
|
18
19
|
## Coding Style & Naming Conventions
|
|
19
20
|
Use ESM modules, 2-space indentation, and keep code ASCII unless a file already uses localized text. Follow the existing style of the file you touch instead of reformatting unrelated lines; current JS utilities mostly use single quotes, while some TS sources use double quotes. Prefer `camelCase` for functions and variables, `UPPER_SNAKE_CASE` for shared constants, and `kebab-case` for skill directories and hook filenames (for example, `neo-python`, `secret-guard.ts`). Keep comments brief and only where intent is not obvious.
|
|
20
21
|
|
|
22
|
+
### AI Helper Script Specifications (scripts/)
|
|
23
|
+
When writing scripts under `skills/<skill-name>/scripts/` or global helper scripts:
|
|
24
|
+
1. **STRICTLY Non-Interactive**: Accept inputs only via command-line arguments (using `argparse`), environment variables, or stdin. **Do NOT use interactive prompts (like `input()` or TTY confirmation dialogs), as they will hang the agent indefinitely.**
|
|
25
|
+
2. **Stdout & Stderr Separation**: Write diagnostic messages, progress logs, and errors to `stderr`. Write only clean, programmatically parseable data (such as JSON or CSV) to `stdout`.
|
|
26
|
+
3. **Inline Dependencies (PEP 723)**: Python scripts must include an inline PEP 723 dependency block (e.g., `# /// script ...`) to enable self-contained runs via `uv run`.
|
|
27
|
+
|
|
21
28
|
## Testing Guidelines
|
|
22
29
|
Add or update tests whenever you change installer behavior, filesystem layout, or hook logic. Place tests in `test/` and name them `*.test.js`. Mirror existing patterns: use temp directories, assert on exit codes, and verify real files were created. There is no published coverage threshold, but PR CI must pass both `npm test` and `bun run build`.
|
|
23
30
|
|
|
@@ -40,9 +47,11 @@ Do not commit secrets, sample credentials, or unsafe prompts. If you change secr
|
|
|
40
47
|
|
|
41
48
|
### 2. 知識庫 (`skills/` & `.agents/skills`)
|
|
42
49
|
每個子目錄代表一個包含專家知識的「技能模組」。
|
|
43
|
-
*
|
|
44
|
-
* `SKILL.md`:**大腦**。定義該領域的 **Perceive-Reason-Act**
|
|
45
|
-
* `
|
|
50
|
+
* **結構與漸進式揭露 (Progressive Disclosure) 規範:**
|
|
51
|
+
* `SKILL.md`:**大腦**。定義該領域的 **Perceive-Reason-Act** 迴圈。**其第一行必須是 YAML frontmatter 分界符 `---`**,並包含正確的 `name`(必須與其父目錄名稱完全一致以利 Discovery 自動偵測)與 trigger-focused 的 `description`。
|
|
52
|
+
* `references/`:**深度知識**。將詳細的檢核表、分析框架或長文檔放於此處,僅在 Reason 階段依需求由 Agent 動態載入。
|
|
53
|
+
* `assets/`:**輸出範本**。提供標準的 Markdown 結構範本,降低 Token 開銷。
|
|
54
|
+
* `evals/`:**評估集**。必須包含 `evals.json` 與 `eval_queries.json` 用於檢測技能的觸發率與輸出品質。
|
|
46
55
|
* **載入邏輯:**
|
|
47
56
|
* **全域技能**: 載入自 `~/.gemini/antigravity-cli/plugins/`。
|
|
48
57
|
* **專案專屬技能**: 載入自專案根目錄下的 `.agents/skills/`(遷移自舊有的 `.gemini/skills/`)。
|
package/README.md
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
<img src="images/banner.png" alt="leak-hunter repository secret scanner banner" width="100%">
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
|
-
**Neo Skills**
|
|
10
|
+
**Neo Skills** 是一個專為現代 **AI Agent** 設計的**企業級全方位能力擴充套件**。本專案基於 Model Context Protocol (MCP) 與標準化代理治理架構 (Agent Harness),為 AI 代理安裝高可靠、可插拔的「專家技能模組 (Skills)」,使其不僅僅是個聊天機器人,而是能深度融入本地開發與運維環境,轉化為具備「感知-推理-行動 (Perceive-Reason-Act)」自主決策能力的**跨領域專家**。
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
無論是複雜的 DevOps 自動化(Azure Pipelines)、代碼品質安全審查、需求還原與分析釐清,或是多語系的現代化開發,Neo Skills 都能透過模組化的外部知識庫、AI 專用非互動式腳本與品質評估集 (Evals),讓 AI 代理在安全、受控的 Harness 治理下,成為您最強大的全能數位助手。
|
|
13
13
|
|
|
14
14
|
## 🚀 核心願景
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -1,72 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
---
|
|
2
|
+
name: neo-clarification
|
|
3
|
+
description: >
|
|
4
|
+
Reconstructs chaotic, emotional, or unstructured user requests and screenshots into structured, professional requirement clarification reports. Use this skill when the user provides vague feedback, fragmented descriptions, error screenshots, or raw complaints, and wants to translate them into actionable specifications or a list of clarifying questions.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Requirement Clarification Specifications
|
|
8
|
+
|
|
9
|
+
You are a Senior System Analyst and Requirement Translation Expert (Inversion & Generator Pattern). Follow this protocol strictly to translate raw, chaotic user complaints and screenshots into clean, structured system specifications.
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
- **Background**: When general users report system issues or propose new requirements, they often lack context, providing fragmented text, emotional complaints, or simply tossing out one/multiple screenshots without specific explanations.
|
|
8
|
-
- **Objective**: To translate this raw information, which resembles a "disaster scene", into "structured requirement documents" that are clear at a glance for the development team (RD), product managers (PM), and quality assurance (QA) through logical induction and image analysis.
|
|
9
|
-
- **Audience**: IT development and project management teams that require precise system specifications.
|
|
11
|
+
---
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
1. **Receive Input**: Receive "raw, chaotic requirements" provided by users, including text descriptions, system screenshots, or any unstructured report information.
|
|
13
|
-
2. **Information Deconstruction & Image Analysis**: Analyze the text and screenshots input by the user. Filter out emotions and noise, and precisely extract: "Objective facts (what is on the screen/what happened)" and "User expectations (what they originally wanted to do)".
|
|
13
|
+
## 1. Perceive Phase
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
1. **Information Extraction**:
|
|
16
|
+
- Carefully read the user's text and inspect any attached screenshots or logs.
|
|
17
|
+
- Filter out emotional noise, frustrations, and blame.
|
|
18
|
+
- Separate objective facts (what is currently happening or visible) from user expectations (what they wanted to accomplish).
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
2. **Identify System Boundaries**:
|
|
21
|
+
- Determine the scope, domain, and potential technical layers affected by the feedback (e.g., frontend rendering, network APIs, database states, permission groups).
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
*(Bullet-point summary of the objective phenomena and issues extracted from text and images)*
|
|
23
|
+
---
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
- **身為**:[User Role]
|
|
28
|
-
- **我想要**:[Specific operation or function]
|
|
29
|
-
- **以便於**:[Business value or pain point solved]
|
|
25
|
+
## 2. Reason Phase
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
1. **Load Analysis Framework**:
|
|
28
|
+
- **Always read** the external analysis guide before starting your deduction:
|
|
29
|
+
[5w1h-framework.md](file:///Users/ben/Projects/neo-skills/skills/neo-clarification/references/5w1h-framework.md)
|
|
30
|
+
|
|
31
|
+
2. **Context Reconstruction (5W1H)**:
|
|
32
|
+
- Map the extracted facts to the 5W1H framework (Who, Where, When, What, Why, How).
|
|
33
|
+
- Formulate logical hypotheses on the root causes of UI anomalies or system behaviors.
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
3. **Identify Gaps**:
|
|
36
|
+
- Pinpoint critical missing information (e.g., browser environment, specific action steps, parameters, error logs).
|
|
37
|
+
- Prepare a list of clarifying questions to ask the user.
|
|
36
38
|
|
|
37
39
|
---
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
- **Must Include**: Context restoration, User Story, system requirement speculation, and a list of open questions.
|
|
41
|
-
- **Strictly Prohibited**:
|
|
42
|
-
- Do NOT invent "brand new features" not mentioned by the user.
|
|
43
|
-
- Do NOT bring the user's emotional words into the final requirement document.
|
|
44
|
-
- Do NOT directly judge it as a "System Bug" without confirmation (please describe it using objective phenomena).
|
|
45
|
-
- **Language and Length**: Mandatory use of Traditional Taiwanese Chinese (繁體中文), professional and well-organized, avoiding overly academic or obscure vocabulary.
|
|
41
|
+
## 3. Act Phase
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
Generate a structured "Requirement Translation and Clarification Report" strictly in **Traditional Chinese (Taiwan)**. Follow these steps:
|
|
48
44
|
|
|
49
|
-
|
|
45
|
+
1. **Load Output Template**:
|
|
46
|
+
- Read the standard markdown structure from:
|
|
47
|
+
[clarification-template.md](file:///Users/ben/Projects/neo-skills/skills/neo-clarification/assets/clarification-template.md)
|
|
50
48
|
|
|
51
|
-
**
|
|
52
|
-
|
|
49
|
+
2. **Compile the Report**:
|
|
50
|
+
- Fill in the template using Traditional Chinese.
|
|
51
|
+
- **Context Restoration**: Present objective facts concisely without emotional adjectives.
|
|
52
|
+
- **User Story**: Use the strict format: "身為... 我想要... 以便於..."
|
|
53
|
+
- **System Requirements & Hypotheses**: Highlight key rendering, API, and validation checkpoints for the development team.
|
|
54
|
+
- **Open Questions**: List between 2 and 10 polite, precise, and constructive clarifying questions.
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
|
|
56
|
+
3. **Self-Validation**:
|
|
57
|
+
- Proactively validate your report using the non-interactive python script:
|
|
58
|
+
```bash
|
|
59
|
+
uv run skills/neo-clarification/scripts/validate-requirements.py -i <path_to_saved_report>
|
|
60
|
+
```
|
|
61
|
+
*(Or verify mentally that all sections exist and the number of questions is between 2 and 10 before final output).*
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
- **身為**:報表使用者
|
|
62
|
-
- **我想要**:在報表查詢畫面上看到並點擊「匯出/下載」按鈕
|
|
63
|
-
- **以便於**:我能順利產出報表檔案,完成下午的業務交辦事項。
|
|
63
|
+
---
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
- **UI/UX 檢查**:確認右上角(原綠色按鈕處)的元件渲染邏輯,是否因權限、資料狀態或版更導致隱藏 (Hidden) 或未載入。
|
|
67
|
-
- **功能檢查**:確認報表匯出 API 狀態是否正常。
|
|
65
|
+
## 4. Communication Guidelines
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
- 請問您的使用者帳號是否有異動過權限?其他同事看得到該按鈕嗎?
|
|
72
|
-
- 請問在按鈕消失前,您有進行過什麼特定的查詢條件設定嗎?
|
|
67
|
+
- **Maintain Empathetic Neutrality**: Acknowledge the user's difficulty, but never agree that the system is "broken" or "a disaster" in the official report. Use neutral, objective descriptions.
|
|
68
|
+
- **Strictly No Guesswork**: Do NOT invent features that the user did not hint at. Ask clarifying questions instead.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
### 1. 🌟 現況還原 (Context)
|
|
2
|
+
<!--
|
|
3
|
+
請客觀、條理化地還原使用者所遭遇的具體現象與痛點。
|
|
4
|
+
- 發生位置:[例如:報表查詢與匯出畫面]
|
|
5
|
+
- 發生問題:[例如:右上角的「匯出綠色按鈕」未渲染或消失,點擊無回應]
|
|
6
|
+
- 業務影響:[例如:無法取得實體報表,阻斷了下午的業務繳交程序]
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
- **發生位置**:
|
|
10
|
+
- **發生問題**:
|
|
11
|
+
- **使用者影響**:
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
### 2. 📝 使用者故事 (User Story)
|
|
16
|
+
<!--
|
|
17
|
+
請遵循敏捷開發標準格式,以使用者視角定義核心需求。
|
|
18
|
+
-->
|
|
19
|
+
- **身為**:[使用者角色 / 例如:報表操作人員]
|
|
20
|
+
- **我想要**:[具體操作或期待的功能 / 例如:在報表畫面上看見並順利點擊「匯出」按鈕]
|
|
21
|
+
- **以便於**:[解決的痛點或業務價值 / 例如:能順利產出報表,準時交付任務]
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### 3. ⚙️ 系統需求與推測 (System Requirements)
|
|
26
|
+
<!--
|
|
27
|
+
列出技術與開發團隊 (RD/PM/QA) 應關注的技術切入點、UI 調整或潛在驗證點。
|
|
28
|
+
-->
|
|
29
|
+
- **UI/UX 元件渲染邏輯**:
|
|
30
|
+
- **API 與後端功能邏輯**:
|
|
31
|
+
- **測試與驗證重點**:
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### 4. ❓ 待釐清問題 (Open Questions)
|
|
36
|
+
<!--
|
|
37
|
+
列出 2 到 10 個核心釐清問題,語氣須委婉、專業且具備建設性。
|
|
38
|
+
-->
|
|
39
|
+
- [ ]
|
|
40
|
+
- [ ]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"should_trigger": [
|
|
3
|
+
"使用者丟來一串抱怨說按鈕沒反應,幫我把需求梳理乾淨",
|
|
4
|
+
"老闆給了我一張系統錯誤的截圖,說要趕快修,我該怎麼釐清問題?",
|
|
5
|
+
"幫我把這段客戶跟客服的碎碎念對話整理成工程師看得懂的 spec",
|
|
6
|
+
"這是一封客戶發來的抱怨信,幫我還原成系統規格與提問單",
|
|
7
|
+
"我們收到了使用者對於新功能的反饋,請幫忙進行需求翻譯與釐清",
|
|
8
|
+
"這個 Bug report 太過簡略了,幫我還原現況並生成澄清問題清單",
|
|
9
|
+
"請根據這張網頁異常的截圖,幫我寫一份 PM 與 RD 可以討論的釐清報告",
|
|
10
|
+
"幫我分析一下這個 Fragmented 的功能提議,還原成標準的 User Story",
|
|
11
|
+
"使用者抱怨說匯出速度很慢,幫我釐清背後可能的系統需求",
|
|
12
|
+
"梳理一下這個混亂的產品需求回饋,幫我列出待釐清問題"
|
|
13
|
+
],
|
|
14
|
+
"should_not_trigger": [
|
|
15
|
+
"幫我寫一個能夠在畫面上拖曳元件的 React 元件",
|
|
16
|
+
"請告訴我什麼是敏捷開發 (Agile) 的核心理念?",
|
|
17
|
+
"寫一個 Python 腳本來解析日誌檔案",
|
|
18
|
+
"請幫我對這段 Java 程式碼進行靜態安全審查",
|
|
19
|
+
"在 Docker 中如何配置 Nginx 負載均衡?",
|
|
20
|
+
"如何把 Excel 檔案轉換為 CSV?",
|
|
21
|
+
"請幫我翻譯這篇英文論文的摘要",
|
|
22
|
+
"在專案中安裝 Bun 的具體步驟是什麼?",
|
|
23
|
+
"請說明什麼是 SQL 注入與如何防範",
|
|
24
|
+
"幫我寫一個 Python 快速排序演算法"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "neo-clarification",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"prompt": "我想要一個新的後端上傳功能,因為使用者常說他們上傳很大檔案時會連線逾時中斷,這很煩人,我們到底要怎麼做?[附帶了一張空白的上傳失敗進度條截圖]",
|
|
7
|
+
"expected_output": "結構化的需求還原與澄清報告。必須還原為 5W1H,將痛苦點轉換為標準的 User Story 語法,提出可能的系統技術推測(如分片上傳、加大 timeout、後端 chunk 組合等),並列出至少 2 到 10 個核心澄清問題(例如:檔案平均與最大限制是多少、目前使用的上傳 API timeout 時間是多少)。報告全為繁體中文。",
|
|
8
|
+
"assertions": [
|
|
9
|
+
"輸出包含 '現況還原'",
|
|
10
|
+
"輸出包含 '使用者故事'",
|
|
11
|
+
"輸出包含 '系統需求'",
|
|
12
|
+
"輸出包含 '待釐清問題'",
|
|
13
|
+
"報告使用繁體中文 (台灣)",
|
|
14
|
+
"待釐清問題清單非空,且包含至少 2 個具體的澄清問題",
|
|
15
|
+
"報告中客觀描述上傳逾時現象,不夾雜使用者情緒性字眼"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": 2,
|
|
20
|
+
"prompt": "老闆丟了一張網頁截圖,說這個圓餅圖畫得很奇怪,好像比例都不對,下午開會就要用,這怎麼辦?[附帶了一張圓餅圖比例完全相同的截圖]",
|
|
21
|
+
"expected_output": "理智客觀的需求翻譯報告。能夠從圓餅圖截圖識別問題(如:所有扇區比例看似相同,可能是後端回傳 mock 資料或前端渲染計算邏輯出錯),並在 Open Questions 中提問確認資料來源與開會重點。全繁體中文輸出。",
|
|
22
|
+
"assertions": [
|
|
23
|
+
"輸出包含 '現況還原'",
|
|
24
|
+
"輸出包含 '待釐清問題'",
|
|
25
|
+
"報告列出關於圓餅圖資料來源 (Data Source) 或 API 渲染邏輯的推測",
|
|
26
|
+
"提出委婉且具體的澄清問題,例如詢問此圖表在其他時間點是否也呈現相同比例,或後端資料庫的具體數值是否為全等"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 5W1H & Gap Analysis Framework
|
|
2
|
+
|
|
3
|
+
This reference guide outlines the systematic methodology for translating chaotic, emotional, or unstructured user complaints and screenshots into clean, structured system specifications.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Context Restoration via 5W1H
|
|
8
|
+
|
|
9
|
+
When a user submits a raw request (e.g., "The green button is gone! System is broken!"), the AI must reconstruct the context by mapping the input to the 5W1H dimensions:
|
|
10
|
+
|
|
11
|
+
| Dimension | Description | How to Extract / Infer |
|
|
12
|
+
| :--- | :--- | :--- |
|
|
13
|
+
| **Who** | The user role or persona facing the issue. | Identify based on the target module, UI elements in screenshots, or context (e.g., financial reporting, general member, administrator). |
|
|
14
|
+
| **Where** | The specific module, screen, or functional path. | Infer from URL paths, headers in screenshots, page titles, or context keywords. |
|
|
15
|
+
| **When** | The occurrence timing or trigger event. | Identify when the action took place (e.g., during query, upon button click, right after software update). |
|
|
16
|
+
| **What** | The objective phenomena or issue. | Separate facts from emotions. What actually happened? (e.g., a component failed to render, API timed out, validation error triggered). |
|
|
17
|
+
| **Why** | The business impact or operational pain point. | Why is this critical? (e.g., blocks weekly report submission, prevents tax filing). |
|
|
18
|
+
| **How** | The action or steps taken leading to the state. | How did they reach this screen? What specific parameters did they input? |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 2. Gap Analysis (Identifying Missing Information)
|
|
23
|
+
|
|
24
|
+
Unstructured complaints are often full of gaps. A skilled analyst must systematically detect what is missing before attempting to design a solution.
|
|
25
|
+
|
|
26
|
+
### Core Checklist for Detecting Gaps:
|
|
27
|
+
1. **Environment Gaps**: Is the OS, browser, device type, or environment (production, staging, UAT) unknown?
|
|
28
|
+
2. **Reproduction Gaps**: Are the exact steps leading to the error vague or unspecified?
|
|
29
|
+
3. **Data Gaps**: Are there query inputs, parameters, or test accounts that were not disclosed?
|
|
30
|
+
4. **Error Details Gaps**: Is there an error code, stack trace, or console log hidden or unprovided?
|
|
31
|
+
5. **Scope Gaps**: Is it unclear if the issue affects a single user or all users? Has their permission group changed?
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 3. Formulating Tactful Open Questions
|
|
36
|
+
|
|
37
|
+
Once gaps are identified, they must be converted into clear, professional, and empathetic clarifying questions.
|
|
38
|
+
|
|
39
|
+
### Guidelines for Formulating Questions:
|
|
40
|
+
* **Be Polite and Constructive**: Avoid technical jargon that might intimidate the user.
|
|
41
|
+
* **Be Specific**: Instead of asking "What did you do?", ask "Could you please share the specific search filters or inputs you used right before the button disappeared?"
|
|
42
|
+
* **One Step at a Time**: Group questions logically and list them clearly in a bulleted format. Keep the total number of questions between 2 and 10.
|
|
43
|
+
* **Provide Context for the Question**: Explain *why* you are asking (e.g., "To help us check if this is related to account permission permissions, other than your account, are your colleagues able to see this button?").
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# /// script
|
|
3
|
+
# requires-python = ">=3.11"
|
|
4
|
+
# dependencies = []
|
|
5
|
+
# ///
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
AI Agentic Requirement Report Validator (Non-interactive)
|
|
9
|
+
專為 AI Agent 設計的非互動式需求釐清報告完整性驗證工具。
|
|
10
|
+
|
|
11
|
+
設計要點:
|
|
12
|
+
1. 嚴禁任何互動式提示詞 (input(), confirm())。
|
|
13
|
+
2. 診斷日誌、錯誤訊息一律寫入 sys.stderr。
|
|
14
|
+
3. 處理結果一律以乾淨的 JSON 結構輸出至 sys.stdout。
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import sys
|
|
18
|
+
import argparse
|
|
19
|
+
import re
|
|
20
|
+
import os
|
|
21
|
+
import json
|
|
22
|
+
from typing import Dict, List, Any
|
|
23
|
+
|
|
24
|
+
def log_diagnostic(message: str) -> None:
|
|
25
|
+
"""將診斷日誌印至 stderr,避免污染 stdout 的 JSON。"""
|
|
26
|
+
print(f"[LOG] {message}", file=sys.stderr)
|
|
27
|
+
|
|
28
|
+
def validate_markdown(file_content: str) -> List[str]:
|
|
29
|
+
"""靜態驗證 Markdown 內容是否符合規格要求。"""
|
|
30
|
+
errors = []
|
|
31
|
+
|
|
32
|
+
# 1. 驗證必要區段(不論是 H3 還是普通標題,檢查關鍵字)
|
|
33
|
+
required_sections = {
|
|
34
|
+
"現況還原": r"(現況還原|Context)",
|
|
35
|
+
"使用者故事": r"(使用者故事|User Story)",
|
|
36
|
+
"系統需求": r"(系統需求|System Requirements)",
|
|
37
|
+
"待釐清問題": r"(待釐清問題|Open Questions)"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
for section_name, pattern in required_sections.items():
|
|
41
|
+
if not re.search(pattern, file_content, re.IGNORECASE):
|
|
42
|
+
errors.append(f"缺少必要區段: {section_name}")
|
|
43
|
+
|
|
44
|
+
# 2. 驗證「待釐清問題」的項目數量是否介於 2 ~ 10 個之間
|
|
45
|
+
# 我們抓取「待釐清問題」或「Open Questions」區段後方的清單項目
|
|
46
|
+
try:
|
|
47
|
+
# 尋找待釐清問題區段的起始位置
|
|
48
|
+
match = re.search(r"待釐清問題|Open Questions", file_content, re.IGNORECASE)
|
|
49
|
+
if match:
|
|
50
|
+
start_index = match.end()
|
|
51
|
+
# 取得該區段後的文字(直到下一個大標題或結尾)
|
|
52
|
+
remaining_content = file_content[start_index:]
|
|
53
|
+
next_section = re.search(r"\n#", remaining_content)
|
|
54
|
+
section_text = remaining_content[:next_section.start()] if next_section else remaining_content
|
|
55
|
+
|
|
56
|
+
# 計算該區段內部的 bullet points/checkbox 數量 (- [ ], -, *, 1.)
|
|
57
|
+
items = re.findall(r"^\s*[-*+]\s+.*|^\s*\d+\.\s+.*", section_text, re.MULTILINE)
|
|
58
|
+
# 過濾掉空白項目或純註解項目
|
|
59
|
+
valid_items = [item for item in items if not re.match(r"^\s*[-*+]\s+\[\s*\]\s*$", item)]
|
|
60
|
+
|
|
61
|
+
log_diagnostic(f"偵測到待釐清問題數量: {len(valid_items)}")
|
|
62
|
+
if len(valid_items) < 2:
|
|
63
|
+
errors.append(f"待釐清問題過少。當前數量: {len(valid_items)} 個(規範要求至少 2 個,最多 10 個)")
|
|
64
|
+
elif len(valid_items) > 10:
|
|
65
|
+
errors.append(f"待釐清問題過多。當前數量: {len(valid_items)} 個(規範要求至少 2 個,最多 10 個)")
|
|
66
|
+
else:
|
|
67
|
+
errors.append("無法驗證待釐清問題數量,因為找不到該區段。")
|
|
68
|
+
except Exception as e:
|
|
69
|
+
log_diagnostic(f"解析待釐清問題數量時出錯: {str(e)}")
|
|
70
|
+
errors.append(f"解析問題數量失敗: {str(e)}")
|
|
71
|
+
|
|
72
|
+
return errors
|
|
73
|
+
|
|
74
|
+
def parse_args() -> argparse.Namespace:
|
|
75
|
+
parser = argparse.ArgumentParser(
|
|
76
|
+
description="需求釐清報告靜態完整性驗證工具 (AI 專用非互動式)。",
|
|
77
|
+
epilog="使用範例: uv run validate-requirements.py -i report.md"
|
|
78
|
+
)
|
|
79
|
+
parser.add_argument(
|
|
80
|
+
"-i", "--input",
|
|
81
|
+
required=True,
|
|
82
|
+
help="待驗證的需求釐清報告 Markdown 檔案路徑。"
|
|
83
|
+
)
|
|
84
|
+
return parser.parse_args()
|
|
85
|
+
|
|
86
|
+
def main() -> None:
|
|
87
|
+
try:
|
|
88
|
+
args = parse_args()
|
|
89
|
+
|
|
90
|
+
if not os.path.exists(args.input):
|
|
91
|
+
log_diagnostic(f"[錯誤] 檔案不存在: {args.input}")
|
|
92
|
+
result = {
|
|
93
|
+
"status": "error",
|
|
94
|
+
"error_message": f"檔案不存在: {args.input}"
|
|
95
|
+
}
|
|
96
|
+
print(json.dumps(result, indent=2))
|
|
97
|
+
sys.exit(1)
|
|
98
|
+
|
|
99
|
+
log_diagnostic(f"開始驗證檔案: {args.input}")
|
|
100
|
+
|
|
101
|
+
with open(args.input, "r", encoding="utf-8", errors="ignore") as f:
|
|
102
|
+
content = f.read()
|
|
103
|
+
|
|
104
|
+
errors = validate_markdown(content)
|
|
105
|
+
|
|
106
|
+
result: Dict[str, Any] = {}
|
|
107
|
+
if not errors:
|
|
108
|
+
log_diagnostic("驗證成功!報告完全符合規格。")
|
|
109
|
+
result["status"] = "success"
|
|
110
|
+
result["errors"] = []
|
|
111
|
+
print(json.dumps(result, indent=2))
|
|
112
|
+
sys.exit(0)
|
|
113
|
+
else:
|
|
114
|
+
log_diagnostic(f"驗證失敗,發現 {len(errors)} 個問題。")
|
|
115
|
+
result["status"] = "fail"
|
|
116
|
+
result["errors"] = errors
|
|
117
|
+
print(json.dumps(result, indent=2))
|
|
118
|
+
sys.exit(1)
|
|
119
|
+
|
|
120
|
+
except Exception as e:
|
|
121
|
+
log_diagnostic(f"[致命錯誤] 執行失敗: {str(e)}")
|
|
122
|
+
error_result = {
|
|
123
|
+
"status": "error",
|
|
124
|
+
"error_message": str(e)
|
|
125
|
+
}
|
|
126
|
+
print(json.dumps(error_result, indent=2))
|
|
127
|
+
sys.exit(1)
|
|
128
|
+
|
|
129
|
+
if __name__ == "__main__":
|
|
130
|
+
main()
|
|
@@ -1,78 +1,78 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: neo-code-review
|
|
3
|
-
description:
|
|
2
|
+
name: neo-code-review
|
|
3
|
+
description: >
|
|
4
|
+
Systematically reviews source code for quality, performance, security, and style issues. Use this skill when the user submits code for review, asks for feedback or a code audit, wants to identify bugs/vulnerabilities, or requests a review of recent changes (such as git diff, staged changes, or a specific commit).
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Code Review Specifications
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
2.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- Be constructive and
|
|
77
|
-
-
|
|
78
|
-
- Focus on the *code*, not the *coder*.
|
|
9
|
+
You are a senior code review expert (Reviewer Pattern). Follow this protocol strictly to systematically, objectively, and constructively review the user's code changes.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Perceive Phase
|
|
14
|
+
|
|
15
|
+
1. **Identify the Input Source**:
|
|
16
|
+
- **Scenario A: Specific files are provided**
|
|
17
|
+
- If the user provides specific file paths or directly attaches code snippets in the conversation, use them as the primary targets for review.
|
|
18
|
+
- **Scenario B: No files are specified but inside a Git repository**
|
|
19
|
+
- If the user asks to "review changes", "review PR", or asks for a review without providing explicit code but the project is a Git repository, **proactively run the helper script** to fetch the changes:
|
|
20
|
+
```bash
|
|
21
|
+
uv run skills/neo-code-review/scripts/git-diff-reviewer.py
|
|
22
|
+
```
|
|
23
|
+
- To review only the staging area, append the `--staged` argument.
|
|
24
|
+
- To review a specific commit range, append the `--commit <range>` argument.
|
|
25
|
+
- **Scenario C: No changes detected and not a Git repository**
|
|
26
|
+
- If no code input is detected and the environment is not a Git repository, gracefully prompt the user: "No code changes detected. Please provide a specific code snippet or file path." and terminate the review.
|
|
27
|
+
|
|
28
|
+
2. **Identify Programming Languages & Frameworks**:
|
|
29
|
+
- Identify the programming language (e.g., TypeScript, C#, Python) and relevant frameworks in the code changes to apply language-specific style standards in subsequent phases.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 2. Reason Phase
|
|
34
|
+
|
|
35
|
+
1. **Load the Review Checklist**:
|
|
36
|
+
- Before evaluating any code, **always read** the external review checklist reference:
|
|
37
|
+
[review-checklist.md](file:///Users/ben/Projects/neo-skills/skills/neo-code-review/references/review-checklist.md)
|
|
38
|
+
|
|
39
|
+
2. **Systematically Evaluate Code**:
|
|
40
|
+
- Analyze the code logic deeply and compare it against the 5 dimensions in the checklist (Correctness, Security, Performance, Maintainability, Style).
|
|
41
|
+
- Filter out **🔴 Critical Issues (Must-fix)**, especially security vulnerabilities (e.g., SQL injections, hardcoded keys, unclosed resource connections).
|
|
42
|
+
- For architectural recommendations, code duplication, or high cyclomatic complexity, classify them under **🟡 Suggestions**.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 3. Act Phase
|
|
47
|
+
|
|
48
|
+
Generate a highly structured and elegant Code Review Report in **Traditional Chinese (Taiwan)**. The report must strictly follow this format:
|
|
49
|
+
|
|
50
|
+
### 🔍 審查摘要 (Summary)
|
|
51
|
+
- **整體評估 (Overall Assessment)**: Provide a brief summary and a clear status rating (e.g., "🔴 需要重大修正後合併" (Needs major changes before merging), "🟡 建議修正後合併" (Recommended to fix before merging), "🟢 結構優良,隨時可合併" (Excellent structure, ready to merge)).
|
|
52
|
+
- **變更概述 (Change Overview)**: Briefly describe the main purpose and scope of this change.
|
|
53
|
+
|
|
54
|
+
### 🔴 嚴重問題 (Critical Issues)
|
|
55
|
+
*This section must ONLY contain **Must-fix** items (security vulnerabilities, critical logic bugs, or severe flaws that may cause system failure). If none are found, write "無" (None).*
|
|
56
|
+
- **[檔案路徑 / 程式碼區段]** (File Path / Code Snippet)
|
|
57
|
+
- **問題描述 (Problem Description)**: Clearly state what the problem is.
|
|
58
|
+
- **嚴重原因 (Severity Reason)**: Explain *why* this is a critical issue and its potential consequences.
|
|
59
|
+
- **修復方案 (Remediation)**: Provide a **concrete corrected code snippet (Code Snippet)** comparing it with the original or showing the fixed version.
|
|
60
|
+
|
|
61
|
+
### 🟡 改進建議 (Suggestions)
|
|
62
|
+
*Includes suggestions for performance optimization, clean code refactoring, edge-case handling, and comment improvements.*
|
|
63
|
+
- **[檔案路徑 / 程式碼區段]** (File Path / Code Snippet)
|
|
64
|
+
- **建議事項 (Recommendation)**: How to optimize the code for performance, readability, or maintainability.
|
|
65
|
+
- **推薦做法 (Proposed Fix)**: Provide an optimized code example.
|
|
66
|
+
|
|
67
|
+
### 🟢 優秀之處 (Praise) (Optional)
|
|
68
|
+
- Highlight exceptionally well-written, elegant, highly readable, or well-tested code sections to encourage best practices.
|
|
69
|
+
|
|
70
|
+
### ❓ 疑問與釐清 (Questions) (Optional)
|
|
71
|
+
- Ask objective questions regarding business logic or unexpected implementations to seek clarification from the user.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 4. Communication Guidelines
|
|
76
|
+
|
|
77
|
+
- **Focus on the Code, not the Coder**: Be constructive, objective, respectful, and humble.
|
|
78
|
+
- **Provide Code Snippets**: Always provide a "corrected code example" for identified issues where applicable. Avoid purely theoretical descriptions.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"should_trigger": [
|
|
3
|
+
"請幫我對這個拉取請求 (PR) 進行代碼審查",
|
|
4
|
+
"這段程式碼有沒有潛在的 Bug 或記憶體洩漏?",
|
|
5
|
+
"幫我看一下這個 JavaScript 檔案的安全性寫得怎麼樣",
|
|
6
|
+
"audit this python script for potential SQL injection or security flaws",
|
|
7
|
+
"我們今天的 git 變更寫得如何?執行 code review",
|
|
8
|
+
"review my latest git commit changes",
|
|
9
|
+
"幫我重構並審查這段 C# 程式碼,看有沒有違反 SOLID 原則",
|
|
10
|
+
"這段 TypeScript 程式碼寫得好嗎?有沒有改進空間?",
|
|
11
|
+
"檢查一下這段 SQL 查詢的效能,會不會有慢查詢或缺少索引的問題",
|
|
12
|
+
"進行靜態代碼分析,指出這個 Go 專案中的問題"
|
|
13
|
+
],
|
|
14
|
+
"should_not_trigger": [
|
|
15
|
+
"如何安裝 git?",
|
|
16
|
+
"請幫我寫一個能夠上傳檔案的 FastAPI 後端介面",
|
|
17
|
+
"解釋一下什麼是 N+1 查詢問題與如何解決",
|
|
18
|
+
"幫我建立一個全新的 React 專案",
|
|
19
|
+
"請推薦好用的 Python Linter 工具",
|
|
20
|
+
"如何配置 tsconfig.json 來支援 ESM?",
|
|
21
|
+
"在 MacOS 上如何部署 Docker 容器?",
|
|
22
|
+
"幫我把這段 Python 代碼翻譯成 Rust",
|
|
23
|
+
"什麼是 SQL Injection 的原理?",
|
|
24
|
+
"幫我產生一份今天的開發進度週報"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "neo-code-review",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"prompt": "請幫我審查這段 Python 程式碼:\n```python\nimport sqlite3\n\ndef get_user_data(user_id):\n conn = sqlite3.connect('users.db')\n cursor = conn.cursor()\n # 存在 SQL 注入風險與資源未關閉\n query = f\"SELECT * FROM users WHERE id = '{user_id}'\"\n cursor.execute(query)\n return cursor.fetchall()\n```",
|
|
7
|
+
"expected_output": "結構化的代碼審查報告。必須明確指出 `user_id` 的 SQL 注入漏洞 (🔴 嚴重問題),指出資料庫連接未釋放的效能/資源問題 (🟡 改進建議),並提供參數化查詢與 `with` 語法糖的修正程式碼範例。報告應全為繁體中文,且包含標準的審查摘要與結構標題。",
|
|
8
|
+
"assertions": [
|
|
9
|
+
"輸出包含 '🔍 審查摘要'",
|
|
10
|
+
"輸出包含 '🔴 嚴重問題'",
|
|
11
|
+
"輸出包含 '🟡 改進建議'",
|
|
12
|
+
"報告使用繁體中文 (台灣)",
|
|
13
|
+
"報告中指出 SQL 注入 (SQL Injection) 漏洞",
|
|
14
|
+
"報告中指出資料庫連接或 cursor 未正確釋放/關閉的問題",
|
|
15
|
+
"提供使用參數化查詢 (parameterized query) 或 with 語法的修復代碼範例"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": 2,
|
|
20
|
+
"prompt": "審查這段沒有明顯問題的 TypeScript 程式碼,並給出建議:\n```typescript\nexport interface User {\n id: string;\n name: string;\n email: string;\n}\n\nexport function formatUserGreeting(user: User): string {\n return `Hello, ${user.name}! Welcome back.`;\n}\n```",
|
|
21
|
+
"expected_output": "給予正面評價的繁體中文審查報告,包含摘要、優秀之處 (🟢 優秀之處),且無嚴重的 Must-fix 問題。可能包含一些關於型別定義或未來擴充性的輕微建議。",
|
|
22
|
+
"assertions": [
|
|
23
|
+
"輸出包含 '🔍 審查摘要'",
|
|
24
|
+
"報告中沒有將此代碼列為 '🔴 嚴重問題' (Must-fix)",
|
|
25
|
+
"輸出包含 '🟢 優秀之處'",
|
|
26
|
+
"報告中讚賞其簡單明瞭、型別定義清晰與具備良好的可讀性"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Code Review Checklist
|
|
2
|
+
|
|
3
|
+
This checklist serves as a systematic guideline for AI reviewers. During the review process, compare the code changes against these criteria and categorize findings by severity: Critical Issues (🔴 Must-fix), Suggestions (🟡 Clean Code/Performance), and Praise (🟢 High Quality).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Correctness & Logic
|
|
8
|
+
|
|
9
|
+
- [ ] **Functional Completeness**: Does the code fully implement the intended requirements? Are there any missing business logic paths?
|
|
10
|
+
- [ ] **Edge Cases**: Are extreme inputs handled properly (e.g., `null`, `undefined`, empty strings, empty arrays, maximum/minimum values, negative numbers, special characters)?
|
|
11
|
+
- [ ] **Exception Handling**:
|
|
12
|
+
- Are error-prone operations (e.g., I/O, network requests, parsing) wrapped in appropriate `try-catch` blocks?
|
|
13
|
+
- Are caught exceptions handled gracefully (e.g., recovering state, user-friendly notifications, or safe logging) instead of being swallowed silently?
|
|
14
|
+
- [ ] **Concurrency & Thread Safety**: In multi-threaded or asynchronous environments, are there potential race conditions, deadlocks, or unawaited async operations?
|
|
15
|
+
- [ ] **State Management**: Are variable lifecycles correct? Are there any unintended side effects or global namespace pollution?
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 2. Security — 🔴 Critical
|
|
20
|
+
|
|
21
|
+
- [ ] **Injection Defenses**:
|
|
22
|
+
- **SQL Injection**: Are parameterized queries or ORM used? Direct string concatenation for SQL queries is strictly prohibited.
|
|
23
|
+
- **XSS (Cross-Site Scripting)**: Is data rendered to the frontend properly escaped or sanitized?
|
|
24
|
+
- **Command Injection**: Are user inputs directly concatenated into system commands?
|
|
25
|
+
- [ ] **Sensitive Data Protection**:
|
|
26
|
+
- Are there any hardcoded secrets, API tokens, passwords, database connection strings, or private keys?
|
|
27
|
+
- Does logging accidentally capture Personally Identifiable Information (PII, e.g., SSN, phone numbers, passwords, credit cards) or sensitive internal system structures?
|
|
28
|
+
- [ ] **Authentication & Authorization**:
|
|
29
|
+
- Are appropriate authorization and authentication checks performed for sensitive operations and APIs?
|
|
30
|
+
- Does it follow the "Principle of Least Privilege"?
|
|
31
|
+
- [ ] **Insecure Practices & Dependencies**:
|
|
32
|
+
- Are known insecure functions used (e.g., `eval()` in JavaScript, `exec()` in Python)?
|
|
33
|
+
- Do dependency libraries have known major vulnerabilities?
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 3. Performance & Resource Management
|
|
38
|
+
|
|
39
|
+
- [ ] **Algorithms & Complexity**: Are time and space complexities reasonable? Are there unnecessary nested loops (e.g., $O(n^2)$ or worse)?
|
|
40
|
+
- [ ] **Database Interaction Efficiency**:
|
|
41
|
+
- Are there N+1 query issues?
|
|
42
|
+
- Do database queries utilize indexes properly, or do they fetch unnecessary columns/rows?
|
|
43
|
+
- [ ] **Resource Lifecycle Management**:
|
|
44
|
+
- Are file handles, database connections, network sockets, and streams explicitly closed/released after use?
|
|
45
|
+
- Are resources released in `finally` blocks or using structural patterns like `using` (.NET) or `with` (Python)?
|
|
46
|
+
- [ ] **Memory Leaks**:
|
|
47
|
+
- Are there unregistered event listeners, infinitely growing global caches, or long-lived objects retaining references to short-lived objects?
|
|
48
|
+
- [ ] **Caching & Lazy Loading**: Is an appropriate caching strategy used for high-frequency, low-variance expensive computations or I/O operations?
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 4. Maintainability & Readability
|
|
53
|
+
|
|
54
|
+
- [ ] **Clear Naming**: Are variables, functions, and classes named intuitively and descriptively? Are single-character or meaningless names avoided?
|
|
55
|
+
- [ ] **Complexity Control**:
|
|
56
|
+
- Is the length of a single function/method reasonable (ideally under 50 lines)?
|
|
57
|
+
- Is the cyclomatic complexity too high (e.g., excessive nesting, too many branch conditions)?
|
|
58
|
+
- [ ] **Modularity & Architecture**:
|
|
59
|
+
- Does the code follow the **DRY (Don't Repeat Yourself)** principle?
|
|
60
|
+
- Does the code follow **SOLID principles** (especially the Single Responsibility Principle - SRP)?
|
|
61
|
+
- [ ] **Testability**:
|
|
62
|
+
- Is the code easy to unit test?
|
|
63
|
+
- Is there appropriate dependency injection or decoupling to facilitate mocking external dependencies?
|
|
64
|
+
- Are there corresponding test cases for new features or bug fixes?
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 5. Style & Standards
|
|
69
|
+
|
|
70
|
+
- [ ] **Idiomatic Best Practices**: Does the code leverage modern features of the language/framework (e.g., TypeScript utility types, Python type hints, pattern matching)?
|
|
71
|
+
- [ ] **Formatting & Style Consistency**:
|
|
72
|
+
- Do indentation, spacing, and quotes match the existing patterns in the codebase?
|
|
73
|
+
- Does the code pass local Linter checks (e.g., ESLint, Ruff)?
|
|
74
|
+
- [ ] **Comment Quality**:
|
|
75
|
+
- Do comments explain "Why" the code is written this way, rather than restating "What" the code does?
|
|
76
|
+
- Has obsolete or commented-out dead code been cleaned up?
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# /// script
|
|
3
|
+
# requires-python = ">=3.11"
|
|
4
|
+
# dependencies = []
|
|
5
|
+
# ///
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
AI Agentic Git Diff & Code Reader Tool (Non-interactive)
|
|
9
|
+
專為 AI Agent 設計的非互動式程式碼變更與內容擷取腳本。
|
|
10
|
+
|
|
11
|
+
設計要點:
|
|
12
|
+
1. 嚴禁任何互動式提示詞 (input(), confirm())。
|
|
13
|
+
2. 診斷日誌、錯誤訊息一律寫入 sys.stderr。
|
|
14
|
+
3. 處理結果一律以乾淨的 JSON 結構輸出至 sys.stdout (或寫入指定 --output 檔案)。
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import sys
|
|
18
|
+
import argparse
|
|
19
|
+
import subprocess
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
from typing import Dict, List, Any
|
|
23
|
+
|
|
24
|
+
def log_diagnostic(message: str) -> None:
|
|
25
|
+
"""將診斷日誌印至 stderr,避免污染 stdout 的 JSON。"""
|
|
26
|
+
print(f"[LOG] {message}", file=sys.stderr)
|
|
27
|
+
|
|
28
|
+
def run_command(cmd: List[str]) -> str:
|
|
29
|
+
"""執行 shell 命令並返回 stdout,出錯時拋出異常。"""
|
|
30
|
+
try:
|
|
31
|
+
result = subprocess.run(
|
|
32
|
+
cmd,
|
|
33
|
+
capture_output=True,
|
|
34
|
+
text=True,
|
|
35
|
+
check=True
|
|
36
|
+
)
|
|
37
|
+
return result.stdout
|
|
38
|
+
except subprocess.CalledProcessError as e:
|
|
39
|
+
error_msg = f"命令執行失敗: {' '.join(cmd)}\nStderr: {e.stderr}"
|
|
40
|
+
raise RuntimeError(error_msg)
|
|
41
|
+
|
|
42
|
+
def get_git_diff(staged_only: bool = False, commit_range: str = None) -> str:
|
|
43
|
+
"""根據參數獲取 git diff 內容。"""
|
|
44
|
+
cmd = ["git", "diff"]
|
|
45
|
+
if commit_range:
|
|
46
|
+
cmd.append(commit_range)
|
|
47
|
+
elif staged_only:
|
|
48
|
+
cmd.append("--cached")
|
|
49
|
+
|
|
50
|
+
log_diagnostic(f"執行 Git 命令: {' '.join(cmd)}")
|
|
51
|
+
return run_command(cmd)
|
|
52
|
+
|
|
53
|
+
def read_files_content(paths: List[str]) -> List[Dict[str, str]]:
|
|
54
|
+
"""讀取指定檔案的完整內容。"""
|
|
55
|
+
contents = []
|
|
56
|
+
for path in paths:
|
|
57
|
+
if not os.path.exists(path):
|
|
58
|
+
log_diagnostic(f"[警告] 檔案不存在,跳過: {path}")
|
|
59
|
+
continue
|
|
60
|
+
if os.path.isdir(path):
|
|
61
|
+
log_diagnostic(f"[警告] 路徑是目錄,跳過: {path}")
|
|
62
|
+
continue
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
log_diagnostic(f"讀取檔案內容: {path}")
|
|
66
|
+
with open(path, "r", encoding="utf-8", errors="ignore") as f:
|
|
67
|
+
contents.append({
|
|
68
|
+
"path": path,
|
|
69
|
+
"content": f.read()
|
|
70
|
+
})
|
|
71
|
+
except Exception as e:
|
|
72
|
+
log_diagnostic(f"[錯誤] 無法讀取檔案 {path}: {str(e)}")
|
|
73
|
+
|
|
74
|
+
return contents
|
|
75
|
+
|
|
76
|
+
def parse_args() -> argparse.Namespace:
|
|
77
|
+
parser = argparse.ArgumentParser(
|
|
78
|
+
description="專為 AI Agent 設計的非互動式代碼變更與內容擷取工具。",
|
|
79
|
+
epilog="使用範例: uv run git-diff-reviewer.py --staged"
|
|
80
|
+
)
|
|
81
|
+
parser.add_argument(
|
|
82
|
+
"-i", "--input",
|
|
83
|
+
nargs="*",
|
|
84
|
+
help="選填。指定審查的檔案路徑列表。若未指定,將預設讀取 Git 變更。"
|
|
85
|
+
)
|
|
86
|
+
parser.add_argument(
|
|
87
|
+
"--staged",
|
|
88
|
+
action="store_true",
|
|
89
|
+
help="僅讀取已暫存 (Staged) 的 Git 變更。"
|
|
90
|
+
)
|
|
91
|
+
parser.add_argument(
|
|
92
|
+
"--commit",
|
|
93
|
+
help="選填。指定 Commit 雜湊值或範圍(例如 HEAD~1..HEAD 或 commit_sha),獲取該範圍內的變更。"
|
|
94
|
+
)
|
|
95
|
+
parser.add_argument(
|
|
96
|
+
"-o", "--output",
|
|
97
|
+
help="選填。將 JSON 結果寫入指定檔案,而非輸出至 stdout。"
|
|
98
|
+
)
|
|
99
|
+
parser.add_argument(
|
|
100
|
+
"--dry-run",
|
|
101
|
+
action="store_true",
|
|
102
|
+
help="模擬執行模式,僅在 stderr 輸出分析計畫,不輸出最終的代碼內容。"
|
|
103
|
+
)
|
|
104
|
+
return parser.parse_args()
|
|
105
|
+
|
|
106
|
+
def main() -> None:
|
|
107
|
+
try:
|
|
108
|
+
args = parse_args()
|
|
109
|
+
|
|
110
|
+
# 準備回傳的結構化資料
|
|
111
|
+
result: Dict[str, Any] = {
|
|
112
|
+
"mode": "git-diff",
|
|
113
|
+
"diff": "",
|
|
114
|
+
"files": [],
|
|
115
|
+
"status": "success"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
# 1. 如果指定了具體檔案
|
|
119
|
+
if args.input:
|
|
120
|
+
result["mode"] = "specific-files"
|
|
121
|
+
log_diagnostic(f"指定檔案審查模式。目標檔案數: {len(args.input)}")
|
|
122
|
+
if not args.dry_run:
|
|
123
|
+
result["files"] = read_files_content(args.input)
|
|
124
|
+
|
|
125
|
+
# 2. 否則,預設使用 Git 變更模式
|
|
126
|
+
else:
|
|
127
|
+
result["mode"] = "git-diff"
|
|
128
|
+
log_diagnostic("未指定特定檔案,進入 Git 變更審查模式。")
|
|
129
|
+
|
|
130
|
+
# 先檢查是否為 git 專案
|
|
131
|
+
try:
|
|
132
|
+
run_command(["git", "rev-parse", "--is-inside-work-tree"])
|
|
133
|
+
except Exception:
|
|
134
|
+
result["status"] = "error"
|
|
135
|
+
result["error_message"] = "當前目錄非 Git 專案,且未指定輸入檔案。"
|
|
136
|
+
print(json.dumps(result, indent=2))
|
|
137
|
+
log_diagnostic("[錯誤] 當前目錄非 Git 專案。")
|
|
138
|
+
sys.exit(1)
|
|
139
|
+
|
|
140
|
+
if not args.dry_run:
|
|
141
|
+
diff_content = get_git_diff(staged_only=args.staged, commit_range=args.commit)
|
|
142
|
+
if not diff_content.strip():
|
|
143
|
+
log_diagnostic("未偵測到任何 Git 變更(diff 為空)。")
|
|
144
|
+
result["status"] = "empty"
|
|
145
|
+
else:
|
|
146
|
+
result["diff"] = diff_content
|
|
147
|
+
|
|
148
|
+
# 3. 輸出結果
|
|
149
|
+
output_str = json.dumps(result, indent=2)
|
|
150
|
+
if args.output:
|
|
151
|
+
with open(args.output, "w", encoding="utf-8") as f:
|
|
152
|
+
f.write(output_str)
|
|
153
|
+
log_diagnostic(f"已成功將代碼變更 JSON 寫入至: {args.output}")
|
|
154
|
+
else:
|
|
155
|
+
# 乾淨地將結果印在 stdout
|
|
156
|
+
print(output_str)
|
|
157
|
+
|
|
158
|
+
sys.exit(0)
|
|
159
|
+
|
|
160
|
+
except Exception as e:
|
|
161
|
+
log_diagnostic(f"[致命錯誤] 執行失敗: {str(e)}")
|
|
162
|
+
# 確保即使出錯也輸出 JSON 錯誤,使調用端不易崩潰
|
|
163
|
+
error_result = {
|
|
164
|
+
"status": "error",
|
|
165
|
+
"error_message": str(e)
|
|
166
|
+
}
|
|
167
|
+
print(json.dumps(error_result, indent=2))
|
|
168
|
+
sys.exit(1)
|
|
169
|
+
|
|
170
|
+
if __name__ == "__main__":
|
|
171
|
+
main()
|
package/skills/neo-rust/SKILL.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: neo-rust
|
|
3
|
-
description:
|
|
3
|
+
description: >
|
|
4
|
+
Develop, refactor, or audit Rust code, covering ownership, borrowing, lifetimes, Result/Option error handling, and modern Rust design patterns. Use this skill when the user needs to write Rust programs, perform Rust Code Reviews, optimize performance (e.g., avoiding unnecessary .clone()), or discuss Rust system architecture, even if they do not explicitly say "Rust" as long as .rs files or a Cargo project are involved.
|
|
5
|
+
license: MIT
|
|
6
|
+
compatibility: Requires environment with Rust toolchain (rustc, cargo) installed
|
|
4
7
|
metadata:
|
|
5
8
|
pattern: tool-wrapper, reviewer
|
|
6
9
|
domain: rust
|
|
@@ -8,37 +11,94 @@ metadata:
|
|
|
8
11
|
|
|
9
12
|
# Neo Rust Expert
|
|
10
13
|
|
|
11
|
-
You are an expert Rust developer. Your goal is to write safe, maintainable, and idiomatic Rust code by strictly following the official design patterns and avoiding anti-patterns.
|
|
14
|
+
You are an expert Rust developer. Your goal is to write safe, maintainable, and idiomatic Rust code by strictly following the official design patterns, leveraging Rust's powerful type system, and avoiding anti-patterns.
|
|
12
15
|
|
|
13
|
-
##
|
|
16
|
+
## Gotchas
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
* **Gotcha 1 (Async Mutex Deadlock / Send Error)**:
|
|
19
|
+
In an `async` function, using the standard library's `std::sync::Mutex` and holding its `MutexGuard` across an `.await` boundary will cause a compiler error because `MutexGuard` does not implement `Send` and cannot be transferred across threads.
|
|
20
|
+
* *Solution*: Use a local block `{}` to limit the MutexGuard lifetime before the `.await`, or use `tokio::sync::Mutex` instead.
|
|
21
|
+
* **Gotcha 2 (Excessive Cloning)**:
|
|
22
|
+
To satisfy the Borrow Checker, beginners often call `.clone()` excessively, which introduces significant memory allocation and copy overhead.
|
|
23
|
+
* *Solution*: Prioritize passing borrowed references (e.g., `&str` instead of `String`, `&[T]` instead of `Vec<T>`), or refactor ownership structures and lifetimes.
|
|
24
|
+
* **Gotcha 3 (Unsafe Unwrapping)**:
|
|
25
|
+
Using `.unwrap()` or `panic!()` directly in library or production-grade code will cause the application to crash, violating Rust's safety-first principle.
|
|
26
|
+
* *Solution*: Always return `Result<T, E>` or `Option<T>` for graceful error propagation, and use the `?` operator or `match` expression to handle them.
|
|
16
27
|
|
|
17
|
-
|
|
18
|
-
2. **Reason**: Load the appropriate reference files based on the task:
|
|
19
|
-
- For writing new code or architecture design, load `reference/patterns.md` and `reference/coding-style.md`.
|
|
20
|
-
- For code review or debugging, load `reference/anti-patterns.md` to spot common mistakes.
|
|
21
|
-
3. **Act**: Execute the task adhering strictly to the loaded guidelines.
|
|
28
|
+
## Workflow Checklist
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
- Ensure resource cleanup using RAII/Drop.
|
|
29
|
-
- Prefer explicit composition over shared mutable state. Default to single ownership.
|
|
30
|
+
Progress:
|
|
31
|
+
- [ ] Step 1: Perceive & Inventory (Check if `Cargo.toml` and `.rs` files exist in the project, and clarify whether the task is "feature development", "refactoring", or "Code Review").
|
|
32
|
+
- [ ] Step 2: Load Reference (Based on the task type, dynamically load corresponding reference files: load `reference/patterns.md` and `reference/coding-style.md` for writing new code, and load `reference/anti-patterns.md` for reviews and debugging).
|
|
33
|
+
- [ ] Step 3: Implement & Validate (After writing or modifying code, compile and analyze it locally using `cargo check` and `cargo clippy`. Fix any warnings or errors until compilation passes cleanly without warnings).
|
|
34
|
+
- [ ] Step 4: Format & Finalize (Run `cargo fmt` to format the code according to official guidelines, and present output using the Output Templates).
|
|
30
35
|
|
|
31
|
-
##
|
|
32
|
-
1. Load `reference/anti-patterns.md`.
|
|
33
|
-
2. Check for unnecessary `.clone()`, excessive use of `String`, and improper error handling.
|
|
34
|
-
3. Verify that `Arc<Mutex<T>>` is not overused where message passing or simple ownership would suffice.
|
|
35
|
-
4. Check naming conventions against `reference/coding-style.md`.
|
|
36
|
-
5. Provide actionable feedback with code examples demonstrating the "Good" approach.
|
|
36
|
+
## Detailed Guidelines
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
### Step 1 — Parse & Inventory
|
|
39
|
+
1. Inspect the current directory to verify if `Cargo.toml` exists.
|
|
40
|
+
2. Analyze the task. For Code Review tasks, read existing changes; for feature development, determine the target modules to create or modify.
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
### Step 2 — Dynamic Reference Loading
|
|
43
|
+
To save context space, only this `SKILL.md` is loaded initially. Once executing the task, the Agent **must** load the following resources:
|
|
44
|
+
* **Development & Architecture**: Load [patterns.md](file:///Users/ben/Projects/neo-skills/skills/neo-rust/reference/patterns.md) and [coding-style.md](file:///Users/ben/Projects/neo-skills/skills/neo-rust/reference/coding-style.md).
|
|
45
|
+
* **Review, Refactoring & Debugging**: Load [anti-patterns.md](file:///Users/ben/Projects/neo-skills/skills/neo-rust/reference/anti-patterns.md).
|
|
46
|
+
|
|
47
|
+
### Step 3 — Compile & Clippy Validation Loop
|
|
48
|
+
Verify newly written or modified Rust code to ensure it is 100% compilable:
|
|
49
|
+
1. Run `cargo check` to verify syntax and type checking.
|
|
50
|
+
2. Run `cargo clippy --all-targets -- -D warnings` to perform strict static analysis and catch potential code smells.
|
|
51
|
+
3. If validation fails:
|
|
52
|
+
- Carefully inspect the `stderr` compiler errors or Clippy suggestions.
|
|
53
|
+
- Modify the corresponding code.
|
|
54
|
+
- Re-run validation until it passes cleanly.
|
|
55
|
+
|
|
56
|
+
## Output Templates
|
|
57
|
+
|
|
58
|
+
Present your output using the following structured templates depending on the task type.
|
|
59
|
+
|
|
60
|
+
### Template A: Code Review Report
|
|
61
|
+
```markdown
|
|
62
|
+
# Rust Code Review Report
|
|
63
|
+
|
|
64
|
+
## 1. Executive Summary
|
|
65
|
+
* **Score**: [1-10 rating]
|
|
66
|
+
* **Summary**: [Overall feedback on code quality, ownership usage, and error handling]
|
|
67
|
+
|
|
68
|
+
## 2. Findings
|
|
69
|
+
> [!IMPORTANT]
|
|
70
|
+
> Order findings by severity (Error > Warning > Info).
|
|
71
|
+
|
|
72
|
+
* **[Severity] Location: `src/main.rs:L12` - [Finding Title]**
|
|
73
|
+
* **Description**: [Why is this an issue? Which Rust best practice is violated?]
|
|
74
|
+
* **Recommendation**:
|
|
75
|
+
```rust
|
|
76
|
+
// Idiomatic Rust example demonstrating the fix
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 3. Top 3 Recommendations
|
|
80
|
+
1. [First actionable improvement]
|
|
81
|
+
2. [Second actionable improvement]
|
|
82
|
+
3. [Third actionable improvement]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Template B: Implementation & Refactoring Summary
|
|
86
|
+
```markdown
|
|
87
|
+
# Rust Implementation / Refactoring Summary
|
|
88
|
+
|
|
89
|
+
## 1. Overview of Changes
|
|
90
|
+
[Briefly summarize what Rust modules, structs, or traits were added or refactored]
|
|
91
|
+
|
|
92
|
+
## 2. Applied Design Patterns & Best Practices
|
|
93
|
+
* [e.g., Applied the Typestate Pattern to ensure state safety]
|
|
94
|
+
* [e.g., Replaced `.clone()` with `&str` for performance gains]
|
|
95
|
+
|
|
96
|
+
## 3. Local Verification Results
|
|
97
|
+
- [x] `cargo check` passed
|
|
98
|
+
- [x] `cargo clippy` passed with zero warnings
|
|
99
|
+
- [x] `cargo fmt` completed successfully
|
|
100
|
+
|
|
101
|
+
## 4. Next Steps
|
|
102
|
+
1. [Recommended next action, e.g., run cargo test]
|
|
103
|
+
2. [Other relevant suggestions]
|
|
104
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"query": "Please review this Rust code for any unnecessary clones or security issues.",
|
|
4
|
+
"should_trigger": true
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
"query": "I want to implement a safe state machine in Rust using the Typestate Pattern, can you give me an example?",
|
|
8
|
+
"should_trigger": true
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"query": "How do I resolve a compile error in Rust where a `MutexGuard` crossing an `await` causes an issue?",
|
|
12
|
+
"should_trigger": true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"query": "Write a highly efficient serialization module for my .rs project.",
|
|
16
|
+
"should_trigger": true
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"query": "I am getting compile errors in my Cargo build, here is the log. Please help me debug it.",
|
|
20
|
+
"should_trigger": true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"query": "Please help me write a user database Repository with exception handling in C#.",
|
|
24
|
+
"should_trigger": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"query": "What is the Borrow Checker? What role does it play in memory management?",
|
|
28
|
+
"should_trigger": false
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"query": "Please help me write a Python script to automate deploying compiled Rust binaries to AWS S3.",
|
|
32
|
+
"should_trigger": false
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"query": "How do I install rustc and cargo?",
|
|
36
|
+
"should_trigger": false
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"query": "Please write a technical research report comparing the performance between Rust and Go.",
|
|
40
|
+
"should_trigger": false
|
|
41
|
+
}
|
|
42
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "neo-rust",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"prompt": "Please help me refactor this code to avoid excessive cloning:\n```rust\nfn process(name: String) {\n println!(\"{}\", name);\n}\nfn main() {\n let name = String::from(\"Alice\");\n process(name.clone());\n process(name.clone());\n}\n```",
|
|
7
|
+
"expected_output": "Refactored code with the `process` function parameter changed to a borrowed reference `&str` (or `&String`) and passing `&name` at call sites, completely removing `.clone()`.",
|
|
8
|
+
"assertions": [
|
|
9
|
+
"The output code completely removes the `.clone()` calls",
|
|
10
|
+
"The signature of the `process` function is modified to accept a reference (e.g., `&str`)",
|
|
11
|
+
"The call sites `process(&name)` use borrowed reference syntax",
|
|
12
|
+
"Accompanied by a brief explanation of Borrow Checker and ownership best practices"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": 2,
|
|
17
|
+
"prompt": "Please perform a Code Review on this code:\n```rust\nfn get_user_role(id: i32) -> String {\n let users = vec![\"admin\", \"user\"];\n users[id as usize].to_string()\n}\n```",
|
|
18
|
+
"expected_output": "Points out array out-of-bounds access risks (no boundary checks) and suggests returning `Option` or adding safety checks; formatting follows the Code Review report template.",
|
|
19
|
+
"assertions": [
|
|
20
|
+
"The review report clearly identifies array out-of-bounds access and panic risks",
|
|
21
|
+
"Suggests refactoring the return type to `Option<String>` or `Result<String, E>`",
|
|
22
|
+
"Provides a corrected, idiomatic Rust example",
|
|
23
|
+
"The Markdown output format strictly follows the structure of Template A: Code Review Report"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|