instrlint 0.2.3 → 0.2.4

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/README.md CHANGED
@@ -8,24 +8,33 @@
8
8
 
9
9
  **instrlint lints itself.**
10
10
 
11
- Lint and optimize your `CLAUDE.md` / `AGENTS.md` — find dead rules, token waste, and structural issues. One command, one score, one report.
11
+ ## Why instrlint?
12
12
 
13
- ## Quick Start
13
+ Your `CLAUDE.md` grows over time. Rules get copied from templates, duplicated across sections, or left pointing at files that no longer exist. Some rules repeat what `tsconfig.json` or `.editorconfig` already enforces — burning token budget with no benefit.
14
14
 
15
- **Global install (recommended):**
15
+ instrlint scans your instruction files and tells you exactly what to fix. One command, one score, one actionable report.
16
16
 
17
- ```bash
18
- npm install -g instrlint
19
- instrlint
20
- ```
17
+ Two things make it different from a line counter:
21
18
 
22
- Install once, run from any project. Or use `npx` to run without installing:
19
+ - **Host-orchestrated LLM verification** — run `/instrlint --verify` in Claude Code and the host model judges ambiguous findings itself. No API key. No separate service. The model already running your session *is* the verifier.
20
+ - **Refactoring walkthrough** — when your root file is too long, instrlint doesn't just say "split this." It walks you through each section, classifies it into one of four buckets, and guides the decision — because not every long CLAUDE.md should be split the same way.
21
+
22
+ Supports Claude Code, Codex, and Cursor. 487 tests. Dogfoods itself since v0.2.3.
23
+
24
+ ## Quick start
23
25
 
24
26
  ```bash
25
27
  npx instrlint
26
28
  ```
27
29
 
28
- Run from your project root where `CLAUDE.md` or `AGENTS.md` lives.
30
+ Run from the directory where your `CLAUDE.md` or `AGENTS.md` lives. No install required.
31
+
32
+ Or install globally and run from any project:
33
+
34
+ ```bash
35
+ npm install -g instrlint
36
+ instrlint
37
+ ```
29
38
 
30
39
  ## Output example
31
40
 
@@ -59,19 +68,17 @@ Run from your project root where `CLAUDE.md` or `AGENTS.md` lives.
59
68
  ── 1 critical · 9 warnings · 12 suggestions ────────
60
69
  ```
61
70
 
62
- ## Features
71
+ ## What it finds
63
72
 
64
- **Token Budget** — counts tokens across all your instruction files using `cl100k_base` encoding (falls back to character estimation). Flags files over 200 lines and baseline context over 25% of your window.
73
+ **Token budget** — measures tokens across all instruction files and MCP servers using `cl100k_base` encoding. Flags root files over 200 lines and baselines above 25% of your context window.
65
74
 
66
- **Dead Rules** — detects rules already enforced by your config files. ~15 overlap patterns covering TypeScript strict mode, Prettier formatting, ESLint rules, conventional commits, EditorConfig, and more.
75
+ **Dead rules** — rules your config files already enforce: TypeScript strict mode, Prettier formatting, ESLint, EditorConfig, conventional commits, C# `.csproj`/`.editorconfig` settings, and more. ~20 patterns covering JS/TS and C# ecosystems.
67
76
 
68
- **Structure** — finds contradicting rules, stale file references, exact and near-duplicate rules, and path-scoping opportunities.
77
+ **Structural issues** — contradicting rules, stale file references, near-duplicate rules, and path-scoping opportunities.
69
78
 
70
- **Auto-fix** — `--fix` safely removes dead rules, stale refs, and exact duplicates. Requires a clean git working tree.
79
+ **Auto-fix** — `--fix` removes dead rules, stale refs, and exact duplicates. Requires a clean git working tree.
71
80
 
72
- **LLM Verification** — `/instrlint --verify` (Claude Code / Codex skill) runs a two-pass protocol: instrlint emits low-confidence findings as `candidates.json`, you (the host agent) judge each one and write `verdicts.json`, then instrlint merges results — filtering false positives and attaching `✓ confirmed` / `❓ uncertain` badges. No API key required; the host model is the verifier.
73
-
74
- **CI Integration** — `instrlint ci` exits 0 or 1 based on findings severity, with SARIF output for GitHub Code Scanning.
81
+ **CI integration** — `instrlint ci` exits non-zero based on severity. SARIF output for GitHub Code Scanning. Generate a workflow with `instrlint init-ci --github`.
75
82
 
76
83
  ## Supported tools
77
84
 
@@ -83,116 +90,58 @@ Run from your project root where `CLAUDE.md` or `AGENTS.md` lives.
83
90
 
84
91
  Auto-detected from project structure. Override with `--tool`.
85
92
 
86
- ## Commands
87
-
88
- ```bash
89
- instrlint # Full health check — score, grade, top issues
90
- instrlint budget # Token budget analysis only
91
- instrlint deadrules # Dead rule detection only
92
- instrlint structure # Structural analysis only
93
- instrlint --fix # Auto-fix safe issues
94
- instrlint --fix --force # Skip git clean check
95
-
96
- instrlint --format json # JSON output (for CI, scripts)
97
- instrlint --format markdown # Markdown output (for PR comments)
98
- instrlint --lang zh-TW # Traditional Chinese output
99
-
100
- instrlint ci # CI mode: exit 1 on critical findings
101
- instrlint ci --fail-on warning # Exit 1 on warnings too
102
- instrlint ci --format sarif # SARIF output for GitHub Code Scanning
103
- instrlint ci --output report.sarif # Write to file
104
-
105
- instrlint init-ci --github # Generate .github/workflows/instrlint.yml
106
- instrlint init-ci --gitlab # Print GitLab CI snippet to stdout
107
-
108
- instrlint install --claude-code # Install as global Claude Code skill
109
- instrlint install --claude-code --project # Install into project
110
- instrlint install --codex # Install as Codex skill
111
-
112
- # Host-orchestrated LLM verification (two-pass, no API key needed)
113
- instrlint --emit-candidates instrlint-candidates.json # Write low-confidence findings for host LLM to judge
114
- instrlint --emit-candidates instrlint-candidates.json --skip-report # Same, without printing the report
115
- instrlint --apply-verdicts instrlint-verdicts.json # Apply host LLM verdicts and re-render report
116
- ```
117
-
118
- ## CI Integration
119
-
120
- ### GitHub Actions
121
-
122
- ```bash
123
- npx instrlint init-ci --github
124
- ```
125
-
126
- This creates `.github/workflows/instrlint.yml` with:
127
- - Triggers on changes to `CLAUDE.md`, `.claude/**`, `AGENTS.md`, etc.
128
- - Runs `instrlint ci --fail-on warning --format sarif`
129
- - Uploads SARIF to GitHub Code Scanning
130
-
131
- Or add it to your existing CI:
132
-
133
- ```yaml
134
- - name: Run instrlint
135
- run: npx instrlint@latest ci --fail-on warning
136
- ```
93
+ ## Supported ecosystems (dead rule detection)
137
94
 
138
- ### GitLab CI
95
+ | Ecosystem | Config files checked |
96
+ |-----------|----------------------|
97
+ | JavaScript / TypeScript | `tsconfig.json`, `.eslintrc.*`, `.prettierrc.*`, `.editorconfig`, `commitlint.config.*` |
98
+ | C# / .NET | `.csproj`, `Directory.Build.props`, `.editorconfig` (`dotnet_*`, `csharp_*` keys) |
139
99
 
140
- ```bash
141
- npx instrlint init-ci --gitlab
142
- ```
100
+ More ecosystems (Python, Go, Rust) are planned. See [Contributing](#contributing) to add patterns.
143
101
 
144
- ## Skill installation
102
+ ## Use in Claude Code or Codex
145
103
 
146
- Use instrlint directly from Claude Code or Codex without leaving the editor:
104
+ Install the skill once:
147
105
 
148
106
  ```bash
149
- # Claude Code (global)
150
- npx instrlint install --claude-code
151
-
152
- # Claude Code (project only)
153
- npx instrlint install --claude-code --project
154
-
155
- # Codex
107
+ npx instrlint install --claude-code # global (~/.claude/commands/)
108
+ npx instrlint install --claude-code --project # project only
156
109
  npx instrlint install --codex
157
110
  ```
158
111
 
159
- Then **restart Claude Code** to activate the command. Then in your editor:
112
+ Restart your editor to load the command, then:
160
113
 
161
114
  ```
162
- /instrlint
163
- /instrlint --fix
164
- /instrlint ci --fail-on warning
165
- /instrlint --verify
115
+ /instrlint # full report
116
+ /instrlint --fix # auto-fix safe issues
117
+ /instrlint --verify # LLM-verified report — no API key needed
166
118
  ```
167
119
 
168
120
  > **Note:** Claude Code only loads custom commands at startup. `/reload-plugins` does not pick up newly installed commands.
169
121
 
170
- ### LLM verification (`/instrlint --verify`)
171
-
172
- The `--verify` flag triggers a two-pass protocol where the host agent (Claude Code or Codex) judges low-confidence findings to eliminate false positives:
122
+ The skill auto-detects when your report needs deeper review. `/instrlint --verify` triggers a two-pass protocol: instrlint writes low-confidence findings as `candidates.json`, the host model judges each one, and instrlint merges the verdicts — filtering false positives and attaching `✓` / `❓` badges. No API key; the model already running your session is the verifier.
173
123
 
174
- 1. **Emit candidates** instrlint writes `instrlint-candidates.json` with contradiction/duplicate findings that need semantic review
175
- 2. **Judge** — you (or the host agent) read the file and determine `confirmed` / `rejected` / `uncertain` for each
176
- 3. **Write verdicts** — save decisions to `instrlint-verdicts.json`
177
- 4. **Apply** — instrlint merges verdicts, filters rejected findings, and re-renders the report with `✓` / `❓` badges
124
+ When your root file is too long, `/instrlint` walks you through a splitting decision: each section is classified as worth extracting (low load rate), extractable but always-loaded, should delete not move, or must stay. You choose the scope; the skill executes.
178
125
 
179
- instrlint never calls an LLM API. It delegates judgment to whatever model is already running the session.
126
+ ## Common commands
180
127
 
181
- ### Refactoring walkthrough (`/instrlint` interactive)
128
+ ```bash
129
+ instrlint # full health check
130
+ instrlint --fix # auto-fix dead rules, stale refs, duplicates
131
+ instrlint --format markdown # Markdown output for PR comments
132
+ instrlint --lang zh-TW # Traditional Chinese output
182
133
 
183
- After the report, the skill can walk you through CLAUDE.md splitting decisions interactively. Each section is classified into one of four buckets: worth extracting (load rate < 30%), extractable but always-loaded (> 80%, no token saving), should delete not move (duplicates source code), or must stay (cross-conversation context). Run `/instrlint` and follow the prompts.
134
+ instrlint ci --fail-on warning # CI mode: exit 1 on warnings
135
+ instrlint init-ci --github # generate GitHub Actions workflow
184
136
 
185
- ## Score and grade
137
+ instrlint install --claude-code # install as Claude Code skill
186
138
 
187
- | Grade | Score | Meaning |
188
- |-------|-------|---------|
189
- | A | 90–100 | Excellent |
190
- | B | 80–89 | Good |
191
- | C | 70–79 | Fair |
192
- | D | 60–69 | Poor |
193
- | F | < 60 | Critical |
139
+ # LLM verification (two-pass, no API key)
140
+ instrlint --emit-candidates instrlint-candidates.json
141
+ instrlint --apply-verdicts instrlint-verdicts.json
142
+ ```
194
143
 
195
- Deductions: critical finding −10 (cap −40), warning −5 (cap −30), info −1 (cap −10). Root file length penalty: proportional above 200 lines (201–300: −5, 301–400: −8, 401–500: −10, 501–600: −15, 601+: −20, cap −30). Budget penalty: continuous above 25% of context window (cap −30).
144
+ See all options: `instrlint --help`
196
145
 
197
146
  ## Contributing
198
147
 
@@ -200,7 +149,7 @@ The primary differentiator is the config overlap patterns in `src/detectors/conf
200
149
 
201
150
  1. Add a new entry to the `OVERLAP_PATTERNS` array
202
151
  2. Map the rule keywords to the config file + field that enforces them
203
- 3. Add a test fixture in `tests/fixtures/sample-project/` that triggers the pattern
152
+ 3. Add a test fixture in `tests/fixtures/` that triggers the pattern
204
153
  4. Add a test case in `tests/detectors/config-overlap.test.ts`
205
154
 
206
155
  See [CLAUDE.md](CLAUDE.md) for full architecture documentation.
package/README.zh-TW.md CHANGED
@@ -8,24 +8,33 @@
8
8
 
9
9
  **instrlint 會 lint 自己。**
10
10
 
11
- Lint 並優化你的 `CLAUDE.md` / `AGENTS.md` — 找出冗餘規則、token 浪費和結構問題。一個指令、一個分數、一份報告。
11
+ ## 為什麼需要 instrlint?
12
12
 
13
- ## 快速開始
13
+ `CLAUDE.md` 會隨時間膨脹。規則從範本複製過來、在不同段落重複出現、或留著指向早已不存在的檔案。有些規則默默地和 `tsconfig.json`、`.editorconfig` 重複——白白佔用 token 預算,什麼好處也沒有。
14
14
 
15
- **全域安裝(建議):**
15
+ instrlint 掃描你的指令檔,告訴你哪裡要修。一個指令、一個分數、一份可執行的報告。
16
16
 
17
- ```bash
18
- npm install -g instrlint
19
- instrlint
20
- ```
17
+ 有兩件事讓它和單純的行數計算工具不同:
21
18
 
22
- 安裝一次,在任何專案都能直接使用。或用 `npx` 免安裝執行:
19
+ - **Host 協調的 LLM 驗證** — 在 Claude Code 執行 `/instrlint --verify`,host model 自己判斷有疑義的 findings。不需要 API key,不需要外部服務。當前 session 裡已在運行的模型就是驗證者。
20
+ - **拆分決策引導** — 根指令檔太長時,instrlint 不只說「去拆一拆」,而是逐段引導你做決定:每個段落會被分入四個桶,再依你選擇的範圍執行——因為並非每份過長的 CLAUDE.md 都該用同一種方式拆。
21
+
22
+ 支援 Claude Code、Codex 和 Cursor。487 個測試。從 v0.2.3 開始用自己 lint 自己。
23
+
24
+ ## 快速開始
23
25
 
24
26
  ```bash
25
27
  npx instrlint
26
28
  ```
27
29
 
28
- 在含有 `CLAUDE.md` 或 `AGENTS.md` 的專案根目錄執行即可。
30
+ 在含有 `CLAUDE.md` 或 `AGENTS.md` 的專案根目錄執行即可,免安裝。
31
+
32
+ 或全域安裝,在任何專案都能直接使用:
33
+
34
+ ```bash
35
+ npm install -g instrlint
36
+ instrlint
37
+ ```
29
38
 
30
39
  ## 輸出範例
31
40
 
@@ -65,19 +74,17 @@ npx instrlint
65
74
  npx instrlint --lang zh-TW
66
75
  ```
67
76
 
68
- ## 功能特色
77
+ ## 能找出什麼問題
69
78
 
70
- **Token 預算** — 使用 `cl100k_base` encoding 計算所有指令檔的 token 用量(無法載入時自動降級為字元估算)。標記超過 200 行的檔案,以及 baseline context 超過視窗 25% 的情況。
79
+ **Token 預算** — 使用 `cl100k_base` encoding 計算所有指令檔和 MCP server 的 token 用量。標記超過 200 行的根指令檔,以及超過 context 視窗 25% 的情況。
71
80
 
72
- **冗餘規則偵測** — 偵測已被 config 檔強制執行的規則。涵蓋 TypeScript strict mode、Prettier 格式化、ESLint 規則、conventional commits、EditorConfig 等約 15 種重疊模式。
81
+ **冗餘規則** — 偵測已被 config 檔強制執行的規則:TypeScript strict mode、Prettier 格式化、ESLint、EditorConfig、conventional commits、C# `.csproj`/`.editorconfig` 設定等,約 20 種模式,涵蓋 JS/TS 和 C# 生態系。
73
82
 
74
- **結構分析**找出互相矛盾的規則、過時的檔案參照、完全相同和高度相似的重複規則,以及路徑範圍化的優化機會。
83
+ **結構問題**互相矛盾的規則、過時的檔案參照、高度相似的重複規則,以及路徑範圍化的優化機會。
75
84
 
76
85
  **自動修復** — `--fix` 安全地移除冗餘規則、過時參照和完全重複的規則。需要乾淨的 git 工作目錄。
77
86
 
78
- **LLM 驗證**`/instrlint --verify`(Claude Code / Codex skill)執行兩段式驗證協議:instrlint 將低信心的 findings 輸出為 `candidates.json`,由你(host agent)逐一判斷後寫入 `verdicts.json`,再由 instrlint 合併結果 — 過濾 false positive,並附上 `✓ confirmed` / `❓ uncertain` badge。不需要任何 API key;host model 本身就是驗證者。
79
-
80
- **CI 整合** — `instrlint ci` 依 findings 嚴重程度回傳 exit code 0 或 1,並支援 SARIF 輸出供 GitHub Code Scanning 使用。
87
+ **CI 整合**`instrlint ci` 依嚴重程度回傳 exit code。支援 SARIF 輸出供 GitHub Code Scanning 使用。使用 `instrlint init-ci --github` 產生 workflow 設定。
81
88
 
82
89
  ## 支援工具
83
90
 
@@ -89,116 +96,58 @@ npx instrlint --lang zh-TW
89
96
 
90
97
  從專案結構自動偵測。可用 `--tool` 強制指定。
91
98
 
92
- ## 指令
93
-
94
- ```bash
95
- instrlint # 完整健康檢查 — 分數、等級、首要問題
96
- instrlint budget # 僅 token 預算分析
97
- instrlint deadrules # 僅冗餘規則偵測
98
- instrlint structure # 僅結構分析
99
- instrlint --fix # 自動修復安全問題
100
- instrlint --fix --force # 跳過 git clean 檢查
101
-
102
- instrlint --format json # JSON 輸出(供 CI、腳本使用)
103
- instrlint --format markdown # Markdown 輸出(供 PR 留言使用)
104
- instrlint --lang zh-TW # 繁體中文輸出
105
-
106
- instrlint ci # CI 模式:嚴重問題時 exit 1
107
- instrlint ci --fail-on warning # 警告也 exit 1
108
- instrlint ci --format sarif # SARIF 輸出供 GitHub Code Scanning
109
- instrlint ci --output report.sarif # 寫入檔案
110
-
111
- instrlint init-ci --github # 產生 .github/workflows/instrlint.yml
112
- instrlint init-ci --gitlab # 輸出 GitLab CI 設定片段
113
-
114
- instrlint install --claude-code # 安裝為全域 Claude Code skill
115
- instrlint install --claude-code --project # 安裝到專案
116
- instrlint install --codex # 安裝為 Codex skill
117
-
118
- # 由 host 協調的 LLM 驗證(兩段式,不需要 API key)
119
- instrlint --emit-candidates instrlint-candidates.json # 將低信心 findings 輸出供 host LLM 判斷
120
- instrlint --emit-candidates instrlint-candidates.json --skip-report # 同上,不印報告
121
- instrlint --apply-verdicts instrlint-verdicts.json # 套用 host LLM 的判斷結果並重新呈現報告
122
- ```
123
-
124
- ## CI 整合
99
+ ## 支援生態系(冗餘規則偵測)
125
100
 
126
- ### GitHub Actions
101
+ | 生態系 | 檢查的 config 檔 |
102
+ |--------|------------------|
103
+ | JavaScript / TypeScript | `tsconfig.json`、`.eslintrc.*`、`.prettierrc.*`、`.editorconfig`、`commitlint.config.*` |
104
+ | C# / .NET | `.csproj`、`Directory.Build.props`、`.editorconfig`(`dotnet_*`、`csharp_*` 欄位)|
127
105
 
128
- ```bash
129
- npx instrlint init-ci --github
130
- ```
106
+ 更多生態系(Python、Go、Rust)列入規劃。歡迎參閱[貢獻](#貢獻)新增規則。
131
107
 
132
- 此指令會建立 `.github/workflows/instrlint.yml`,包含:
133
- - 在 `CLAUDE.md`、`.claude/**`、`AGENTS.md` 等檔案變更時觸發
134
- - 執行 `instrlint ci --fail-on warning --format sarif`
135
- - 上傳 SARIF 至 GitHub Code Scanning
108
+ ## 在 Claude Code 或 Codex 中使用
136
109
 
137
- 或加入現有 CI
138
-
139
- ```yaml
140
- - name: Run instrlint
141
- run: npx instrlint@latest ci --fail-on warning
142
- ```
143
-
144
- ### GitLab CI
110
+ 安裝一次 skill
145
111
 
146
112
  ```bash
147
- npx instrlint init-ci --gitlab
148
- ```
149
-
150
- ## Skill 安裝
151
-
152
- 不離開編輯器直接從 Claude Code 或 Codex 使用 instrlint:
153
-
154
- ```bash
155
- # Claude Code(全域)
156
- npx instrlint install --claude-code
157
-
158
- # Claude Code(僅專案)
159
- npx instrlint install --claude-code --project
160
-
161
- # Codex
113
+ npx instrlint install --claude-code # 全域(~/.claude/commands/)
114
+ npx instrlint install --claude-code --project # 僅專案
162
115
  npx instrlint install --codex
163
116
  ```
164
117
 
165
- 安裝後**重新啟動 Claude Code** 以啟用指令,然後在編輯器中使用:
118
+ 重新啟動編輯器以載入指令,然後使用:
166
119
 
167
120
  ```
168
- /instrlint
169
- /instrlint --fix
170
- /instrlint ci --fail-on warning
171
- /instrlint --verify
121
+ /instrlint # 完整報告
122
+ /instrlint --fix # 自動修復安全問題
123
+ /instrlint --verify # LLM 驗證報告 — 不需要 API key
172
124
  ```
173
125
 
174
126
  > **注意:** Claude Code 只在啟動時載入 custom commands。`/reload-plugins` 無法載入新安裝的指令。
175
127
 
176
- ### LLM 驗證(`/instrlint --verify`)
177
-
178
- `--verify` 觸發兩段式協議,由 host agent(Claude Code 或 Codex)判斷低信心的 findings 以消除 false positive:
128
+ 當報告需要更深入的審查,skill 會自動觸發兩段式驗證:instrlint 將低信心的 findings 寫成 `candidates.json`,host model 逐一判斷後寫 `verdicts.json`,再由 instrlint 合併結果——過濾 false positive,並附上 `✓` / `❓` badge。不需要 API key;當前 session 的模型就是驗證者。
179
129
 
180
- 1. **輸出 candidates** — instrlint 將需要語意審查的 contradiction / duplicate findings 寫成 `instrlint-candidates.json`
181
- 2. **判斷** — 你(或 host agent)讀取檔案,對每筆 finding 決定 `confirmed` / `rejected` / `uncertain`
182
- 3. **寫 verdicts** — 將判斷結果儲存為 `instrlint-verdicts.json`
183
- 4. **套用** — instrlint 合併 verdicts,過濾被 rejected 的 findings,並重新輸出附有 `✓` / `❓` badge 的報告
130
+ 根指令檔過長時,`/instrlint` 會引導你做拆分決策:每個段落被分入四個桶——值得抽出(低載入率)、可抽出但不省 token、該刪不是該搬、或必須留在原檔。你選範圍,skill 執行。
184
131
 
185
- instrlint 從不呼叫任何 LLM API,而是將判斷委託給當前 session 中正在運行的 model。
132
+ ## 常用指令
186
133
 
187
- ### CLAUDE.md 拆分引導(`/instrlint` 互動模式)
134
+ ```bash
135
+ instrlint # 完整健康檢查
136
+ instrlint --fix # 自動修復冗餘規則、過時參照、重複規則
137
+ instrlint --format markdown # Markdown 輸出(供 PR 留言使用)
138
+ instrlint --lang zh-TW # 繁體中文輸出
188
139
 
189
- 報告結束後,skill 可以互動引導你決定 CLAUDE.md 的拆分方式。每個段落會被分入四個桶:值得抽出(載入率 < 30%)、可抽出但不省 token(> 80%,一律載入)、該刪不是該搬(與原始碼或 config 重複)、或必須留在 CLAUDE.md(跨 conversation 的上下文)。執行 `/instrlint` 後依提示操作即可。
140
+ instrlint ci --fail-on warning # CI 模式:警告也 exit 1
141
+ instrlint init-ci --github # 產生 GitHub Actions workflow
190
142
 
191
- ## 分數與等級
143
+ instrlint install --claude-code # 安裝為 Claude Code skill
192
144
 
193
- | 等級 | 分數 | 說明 |
194
- |------|------|------|
195
- | A | 90–100 | 優秀 |
196
- | B | 80–89 | 良好 |
197
- | C | 70–79 | 尚可 |
198
- | D | 60–69 | 較差 |
199
- | F | < 60 | 嚴重 |
145
+ # LLM 驗證(兩段式,不需要 API key)
146
+ instrlint --emit-candidates instrlint-candidates.json
147
+ instrlint --apply-verdicts instrlint-verdicts.json
148
+ ```
200
149
 
201
- 扣分規則:嚴重問題 −10(上限 −40)、警告 −5(上限 −30)、建議 −1(上限 −10)。根指令檔行數懲罰:超過 200 行後按比例扣分(201–300 行 −5、301–400 −8、401–500 −10、501–600 −15、601+ −20,上限 −30)。預算懲罰:超過 context 視窗 25% 後連續計算(上限 −30)。
150
+ 所有選項請執行:`instrlint --help`
202
151
 
203
152
  ## 貢獻
204
153
 
@@ -206,7 +155,7 @@ instrlint 從不呼叫任何 LLM API,而是將判斷委託給當前 session
206
155
 
207
156
  1. 在 `OVERLAP_PATTERNS` 陣列新增一筆
208
157
  2. 將規則關鍵字對應到強制執行它的 config 檔 + 欄位
209
- 3. 在 `tests/fixtures/sample-project/` 新增觸發該規則的 fixture
158
+ 3. 在 `tests/fixtures/` 新增觸發該規則的 fixture
210
159
  4. 在 `tests/detectors/config-overlap.test.ts` 新增測試案例
211
160
 
212
161
  完整架構文件請參閱 [CLAUDE.md](CLAUDE.md)。
package/dist/cli.cjs CHANGED
@@ -119,11 +119,21 @@ function scanProject(projectRoot, forceTool) {
119
119
  if (byFile != null) {
120
120
  return { ...byFile, confidence: "low" };
121
121
  }
122
- return { tool: "unknown", rootFilePath: null, configDir: null, confidence: "low" };
122
+ return {
123
+ tool: "unknown",
124
+ rootFilePath: null,
125
+ configDir: null,
126
+ confidence: "low"
127
+ };
123
128
  }
124
129
  if (detections.length === 1) {
125
130
  const d = detections[0];
126
- return { tool: d.tool, rootFilePath: d.rootFilePath, configDir: d.configDir, confidence: "high" };
131
+ return {
132
+ tool: d.tool,
133
+ rootFilePath: d.rootFilePath,
134
+ configDir: d.configDir,
135
+ confidence: "high"
136
+ };
127
137
  }
128
138
  const first = detections[0];
129
139
  return {
@@ -2511,7 +2521,9 @@ function printStructureSuggestions(suggestions, projectRoot, output) {
2511
2521
  } else {
2512
2522
  const dir = s.pathDir ?? "src";
2513
2523
  const { filePath, content } = buildPathScopedFile(dir, s.ruleText);
2514
- output.log(` ${import_chalk3.default.cyan(t("fix.pathScopedCreate", { path: filePath }))}`);
2524
+ output.log(
2525
+ ` ${import_chalk3.default.cyan(t("fix.pathScopedCreate", { path: filePath }))}`
2526
+ );
2515
2527
  terminalCodeBlock(content, output);
2516
2528
  if (lineNum > 0) {
2517
2529
  output.log(
@@ -2534,7 +2546,14 @@ function markdownStructureSuggestions(suggestions, projectRoot) {
2534
2546
  ""
2535
2547
  );
2536
2548
  if (s.type === "hook") {
2537
- lines.push(t("fix.hookCreate"), "", "```json", buildHookSnippet(s.ruleText), "```", "");
2549
+ lines.push(
2550
+ t("fix.hookCreate"),
2551
+ "",
2552
+ "```json",
2553
+ buildHookSnippet(s.ruleText),
2554
+ "```",
2555
+ ""
2556
+ );
2538
2557
  lines.push(`> ${t("fix.hookWarning")}`, "");
2539
2558
  if (lineNum > 0) {
2540
2559
  lines.push(
@@ -2842,18 +2861,30 @@ var import_fs12 = require("fs");
2842
2861
  var import_path10 = require("path");
2843
2862
  var import_os2 = require("os");
2844
2863
  var import_url2 = require("url");
2845
- function resolveSkillFile(target) {
2864
+ function resolveSkillFile() {
2846
2865
  const thisFile = (0, import_url2.fileURLToPath)(importMetaUrl);
2847
- const subDir = target === "claude-code" ? "claude-code" : "codex";
2848
- for (const levels of [2, 3]) {
2866
+ const levelCandidates = [2, 3];
2867
+ for (const levels of levelCandidates) {
2849
2868
  const parts = Array(levels).fill("..");
2850
- const candidate = (0, import_path10.join)(thisFile, ...parts, "skills", subDir, "SKILL.md");
2869
+ const candidate = (0, import_path10.join)(
2870
+ thisFile,
2871
+ ...parts,
2872
+ "skills",
2873
+ "instrlint",
2874
+ "SKILL.md"
2875
+ );
2851
2876
  if ((0, import_fs12.existsSync)(candidate)) return candidate;
2852
2877
  }
2853
- return (0, import_path10.join)(thisFile, "..", "..", "skills", subDir, "SKILL.md");
2878
+ return (0, import_path10.join)(
2879
+ thisFile,
2880
+ ...Array(levelCandidates[0]).fill(".."),
2881
+ "skills",
2882
+ "instrlint",
2883
+ "SKILL.md"
2884
+ );
2854
2885
  }
2855
- function readSkillContent(target) {
2856
- const skillPath = resolveSkillFile(target);
2886
+ function readSkillContent() {
2887
+ const skillPath = resolveSkillFile();
2857
2888
  try {
2858
2889
  const raw = (0, import_fs12.readFileSync)(skillPath, "utf8");
2859
2890
  return injectVersion(raw, CURRENT_VERSION);
@@ -2890,14 +2921,14 @@ function installCodex(content, projectRoot, force, output) {
2890
2921
  function runInstall(opts, output = console) {
2891
2922
  const projectRoot = opts.projectRoot ?? process.cwd();
2892
2923
  const force = opts.force ?? false;
2924
+ let content;
2925
+ try {
2926
+ content = readSkillContent();
2927
+ } catch (err) {
2928
+ output.error(String(err));
2929
+ return { exitCode: 1, errorMessage: String(err) };
2930
+ }
2893
2931
  if (opts.claudeCode) {
2894
- let content;
2895
- try {
2896
- content = readSkillContent("claude-code");
2897
- } catch (err) {
2898
- output.error(String(err));
2899
- return { exitCode: 1, errorMessage: String(err) };
2900
- }
2901
2932
  return installClaudeCode(
2902
2933
  content,
2903
2934
  projectRoot,
@@ -2907,13 +2938,6 @@ function runInstall(opts, output = console) {
2907
2938
  );
2908
2939
  }
2909
2940
  if (opts.codex) {
2910
- let content;
2911
- try {
2912
- content = readSkillContent("codex");
2913
- } catch (err) {
2914
- output.error(String(err));
2915
- return { exitCode: 1, errorMessage: String(err) };
2916
- }
2917
2941
  return installCodex(content, projectRoot, force, output);
2918
2942
  }
2919
2943
  output.error(t("install.unknownTarget"));