instrlint 0.2.2 → 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 +56 -103
- package/README.zh-TW.md +55 -102
- package/dist/cli.cjs +49 -25
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +53 -29
- package/dist/cli.js.map +1 -1
- package/package.json +3 -3
- package/skills/instrlint/SKILL.md +63 -0
- package/skills/instrlint/references/judgment-framework.md +130 -0
- package/skills/claude-code/SKILL.md +0 -163
- package/skills/codex/SKILL.md +0 -122
package/README.md
CHANGED
|
@@ -8,24 +8,33 @@
|
|
|
8
8
|
|
|
9
9
|
**instrlint lints itself.**
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Why instrlint?
|
|
12
12
|
|
|
13
|
-
|
|
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
|
-
|
|
15
|
+
instrlint scans your instruction files and tells you exactly what to fix. One command, one score, one actionable report.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
npm install -g instrlint
|
|
19
|
-
instrlint
|
|
20
|
-
```
|
|
17
|
+
Two things make it different from a line counter:
|
|
21
18
|
|
|
22
|
-
|
|
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
|
|
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
|
-
##
|
|
71
|
+
## What it finds
|
|
63
72
|
|
|
64
|
-
**Token
|
|
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
|
|
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
|
-
**
|
|
77
|
+
**Structural issues** — contradicting rules, stale file references, near-duplicate rules, and path-scoping opportunities.
|
|
69
78
|
|
|
70
|
-
**Auto-fix** — `--fix`
|
|
79
|
+
**Auto-fix** — `--fix` removes dead rules, stale refs, and exact duplicates. Requires a clean git working tree.
|
|
71
80
|
|
|
72
|
-
**
|
|
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,112 +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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
141
|
-
npx instrlint init-ci --gitlab
|
|
142
|
-
```
|
|
100
|
+
More ecosystems (Python, Go, Rust) are planned. See [Contributing](#contributing) to add patterns.
|
|
143
101
|
|
|
144
|
-
##
|
|
102
|
+
## Use in Claude Code or Codex
|
|
145
103
|
|
|
146
|
-
|
|
104
|
+
Install the skill once:
|
|
147
105
|
|
|
148
106
|
```bash
|
|
149
|
-
#
|
|
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
|
-
|
|
112
|
+
Restart your editor to load the command, then:
|
|
160
113
|
|
|
161
114
|
```
|
|
162
|
-
/instrlint
|
|
163
|
-
/instrlint --fix
|
|
164
|
-
/instrlint
|
|
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
|
-
|
|
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.
|
|
123
|
+
|
|
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.
|
|
171
125
|
|
|
172
|
-
|
|
126
|
+
## Common commands
|
|
173
127
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
|
178
133
|
|
|
179
|
-
instrlint
|
|
134
|
+
instrlint ci --fail-on warning # CI mode: exit 1 on warnings
|
|
135
|
+
instrlint init-ci --github # generate GitHub Actions workflow
|
|
180
136
|
|
|
181
|
-
|
|
137
|
+
instrlint install --claude-code # install as Claude Code skill
|
|
182
138
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
| C | 70–79 | Fair |
|
|
188
|
-
| D | 60–69 | Poor |
|
|
189
|
-
| 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
|
+
```
|
|
190
143
|
|
|
191
|
-
|
|
144
|
+
See all options: `instrlint --help`
|
|
192
145
|
|
|
193
146
|
## Contributing
|
|
194
147
|
|
|
@@ -196,7 +149,7 @@ The primary differentiator is the config overlap patterns in `src/detectors/conf
|
|
|
196
149
|
|
|
197
150
|
1. Add a new entry to the `OVERLAP_PATTERNS` array
|
|
198
151
|
2. Map the rule keywords to the config file + field that enforces them
|
|
199
|
-
3. Add a test fixture in `tests/fixtures
|
|
152
|
+
3. Add a test fixture in `tests/fixtures/` that triggers the pattern
|
|
200
153
|
4. Add a test case in `tests/detectors/config-overlap.test.ts`
|
|
201
154
|
|
|
202
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
|
-
|
|
11
|
+
## 為什麼需要 instrlint?
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`CLAUDE.md` 會隨時間膨脹。規則從範本複製過來、在不同段落重複出現、或留著指向早已不存在的檔案。有些規則默默地和 `tsconfig.json`、`.editorconfig` 重複——白白佔用 token 預算,什麼好處也沒有。
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
instrlint 掃描你的指令檔,告訴你哪裡要修。一個指令、一個分數、一份可執行的報告。
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
npm install -g instrlint
|
|
19
|
-
instrlint
|
|
20
|
-
```
|
|
17
|
+
有兩件事讓它和單純的行數計算工具不同:
|
|
21
18
|
|
|
22
|
-
|
|
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
|
|
79
|
+
**Token 預算** — 使用 `cl100k_base` encoding 計算所有指令檔和 MCP server 的 token 用量。標記超過 200 行的根指令檔,以及超過 context 視窗 25% 的情況。
|
|
71
80
|
|
|
72
|
-
|
|
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
|
-
**
|
|
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,112 +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
|
-
|
|
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
|
-
|
|
129
|
-
npx instrlint init-ci --github
|
|
130
|
-
```
|
|
106
|
+
更多生態系(Python、Go、Rust)列入規劃。歡迎參閱[貢獻](#貢獻)新增規則。
|
|
131
107
|
|
|
132
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
118
|
+
重新啟動編輯器以載入指令,然後使用:
|
|
166
119
|
|
|
167
120
|
```
|
|
168
|
-
/instrlint
|
|
169
|
-
/instrlint --fix
|
|
170
|
-
/instrlint
|
|
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
|
-
|
|
128
|
+
當報告需要更深入的審查,skill 會自動觸發兩段式驗證:instrlint 將低信心的 findings 寫成 `candidates.json`,host model 逐一判斷後寫 `verdicts.json`,再由 instrlint 合併結果——過濾 false positive,並附上 `✓` / `❓` badge。不需要 API key;當前 session 的模型就是驗證者。
|
|
129
|
+
|
|
130
|
+
根指令檔過長時,`/instrlint` 會引導你做拆分決策:每個段落被分入四個桶——值得抽出(低載入率)、可抽出但不省 token、該刪不是該搬、或必須留在原檔。你選範圍,skill 執行。
|
|
177
131
|
|
|
178
|
-
|
|
132
|
+
## 常用指令
|
|
179
133
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
134
|
+
```bash
|
|
135
|
+
instrlint # 完整健康檢查
|
|
136
|
+
instrlint --fix # 自動修復冗餘規則、過時參照、重複規則
|
|
137
|
+
instrlint --format markdown # Markdown 輸出(供 PR 留言使用)
|
|
138
|
+
instrlint --lang zh-TW # 繁體中文輸出
|
|
184
139
|
|
|
185
|
-
instrlint
|
|
140
|
+
instrlint ci --fail-on warning # CI 模式:警告也 exit 1
|
|
141
|
+
instrlint init-ci --github # 產生 GitHub Actions workflow
|
|
186
142
|
|
|
187
|
-
|
|
143
|
+
instrlint install --claude-code # 安裝為 Claude Code skill
|
|
188
144
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
| C | 70–79 | 尚可 |
|
|
194
|
-
| D | 60–69 | 較差 |
|
|
195
|
-
| F | < 60 | 嚴重 |
|
|
145
|
+
# LLM 驗證(兩段式,不需要 API key)
|
|
146
|
+
instrlint --emit-candidates instrlint-candidates.json
|
|
147
|
+
instrlint --apply-verdicts instrlint-verdicts.json
|
|
148
|
+
```
|
|
196
149
|
|
|
197
|
-
|
|
150
|
+
所有選項請執行:`instrlint --help`
|
|
198
151
|
|
|
199
152
|
## 貢獻
|
|
200
153
|
|
|
@@ -202,7 +155,7 @@ instrlint 從不呼叫任何 LLM API,而是將判斷委託給當前 session
|
|
|
202
155
|
|
|
203
156
|
1. 在 `OVERLAP_PATTERNS` 陣列新增一筆
|
|
204
157
|
2. 將規則關鍵字對應到強制執行它的 config 檔 + 欄位
|
|
205
|
-
3. 在 `tests/fixtures
|
|
158
|
+
3. 在 `tests/fixtures/` 新增觸發該規則的 fixture
|
|
206
159
|
4. 在 `tests/detectors/config-overlap.test.ts` 新增測試案例
|
|
207
160
|
|
|
208
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 {
|
|
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 {
|
|
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(
|
|
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(
|
|
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(
|
|
2864
|
+
function resolveSkillFile() {
|
|
2846
2865
|
const thisFile = (0, import_url2.fileURLToPath)(importMetaUrl);
|
|
2847
|
-
const
|
|
2848
|
-
for (const levels of
|
|
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)(
|
|
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)(
|
|
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(
|
|
2856
|
-
const skillPath = resolveSkillFile(
|
|
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"));
|