plumber-linter 0.0.0-stage → 1.0.0
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 +73 -2
- package/bin/plumber.js +361 -0
- package/package.json +27 -4
package/README.md
CHANGED
|
@@ -1,3 +1,74 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Plumber — Code Leak, Clog, and AI Slop Inspector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://npmjs.com/package/plumber-linter)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
**Plumber** is a deterministic, offline-capable code quality and anti-slop linter for the AI-agent era. It inspects codebases in milliseconds without requiring an LLM.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## ⚡ Quick Start
|
|
11
|
+
|
|
12
|
+
No global installation required:
|
|
13
|
+
```bash
|
|
14
|
+
# Scan current repository
|
|
15
|
+
npx plumber-linter scan .
|
|
16
|
+
|
|
17
|
+
# Enforce quality gate in CI (exit 1 on HIGH or CRITICAL issues)
|
|
18
|
+
npx plumber-linter scan . --fail-on high
|
|
19
|
+
|
|
20
|
+
# Export report as Markdown or JSON
|
|
21
|
+
npx plumber-linter scan . --format md
|
|
22
|
+
npx plumber-linter scan . --format json
|
|
23
|
+
|
|
24
|
+
# View all active inspection rules
|
|
25
|
+
npx plumber-linter rules
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🔌 Cursor & Claude Desktop MCP Integration
|
|
31
|
+
|
|
32
|
+
Add Plumber as a Model Context Protocol (MCP) server:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"mcpServers": {
|
|
37
|
+
"plumber": {
|
|
38
|
+
"command": "npx",
|
|
39
|
+
"args": ["-y", "plumber-linter", "mcp"]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Now Claude Desktop and Cursor can automatically invoke `plumber_scan` to verify code quality in real time!
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 🤖 Claude Code
|
|
50
|
+
Add to your project's `CLAUDE.md`:
|
|
51
|
+
```bash
|
|
52
|
+
npx plumber-linter scan . --fail-on high
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 🚀 GitHub Actions
|
|
58
|
+
Add to `.github/workflows/plumber.yml`:
|
|
59
|
+
```yaml
|
|
60
|
+
name: Plumber Audit
|
|
61
|
+
on: [push, pull_request]
|
|
62
|
+
|
|
63
|
+
jobs:
|
|
64
|
+
audit:
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
steps:
|
|
67
|
+
- uses: actions/checkout@v4
|
|
68
|
+
- run: npx plumber-linter scan . --fail-on high
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
MIT License.
|
package/bin/plumber.js
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plumber CLI & MCP Server (Node.js Thin Client)
|
|
5
|
+
* Inspects repositories for leaked credentials, AI slop tells, broken pipes, and fragile joints.
|
|
6
|
+
* Zero external dependencies.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const https = require('https');
|
|
12
|
+
const readline = require('readline');
|
|
13
|
+
|
|
14
|
+
const API_BASE = process.env.PLUMBER_API_URL || 'http://localhost:3100';
|
|
15
|
+
|
|
16
|
+
const RULES = [
|
|
17
|
+
{ id: 'leak/api-key', cat: 'Leaks & Secrets', sev: 'CRITICAL', title: 'Leaked API Key or Private Access Token', fix: 'Move secret to environment variable (.env).' },
|
|
18
|
+
{ id: 'leak/committed-env', cat: 'Leaks & Secrets', sev: 'CRITICAL', title: 'Production Secret Committed in Environment File', fix: 'Remove sensitive values and use .env.example.' },
|
|
19
|
+
{ id: 'leak/hardcoded-secret', cat: 'Leaks & Secrets', sev: 'HIGH', title: 'Hardcoded Password or Database Credential', fix: 'Replace with process.env / os.environ reference.' },
|
|
20
|
+
{ id: 'sec/raw-html', cat: 'Leaks & Secrets', sev: 'MEDIUM', title: 'Raw HTML Injection (XSS Risk)', fix: 'Use textContent or safe DOM templating.' },
|
|
21
|
+
{ id: 'clog/elided-code', cat: 'Clogs & Dead Code', sev: 'HIGH', title: 'AI-Elided Code Snippet Left in File', fix: 'Restore the complete function or component implementation.' },
|
|
22
|
+
{ id: 'clog/swallowed-error', cat: 'Clogs & Dead Code', sev: 'HIGH', title: 'Swallowed Exception (Silent Failure)', fix: 'Log the error or properly re-raise/handle it.' },
|
|
23
|
+
{ id: 'clog/stub-function', cat: 'Clogs & Dead Code', sev: 'MEDIUM', title: 'Unimplemented Stub Function', fix: 'Complete missing logic or remove placeholder.' },
|
|
24
|
+
{ id: 'clog/step-comments', cat: 'Clogs & Dead Code', sev: 'LOW', title: 'Robotic AI Step Comments Left Behind', fix: 'Clean up AI instructional comments.' },
|
|
25
|
+
{ id: 'slop/pointless-wrapper', cat: 'Clogs & Dead Code', sev: 'LOW', title: 'Function That Only Forwards Its Arguments', fix: 'Call underlying function directly.' },
|
|
26
|
+
{ id: 'joint/icon-button', cat: 'Joints & Accessibility', sev: 'HIGH', title: 'Icon Button Without Accessible Name', fix: 'Add aria-label attribute to button element.' },
|
|
27
|
+
{ id: 'joint/clickable-div', cat: 'Joints & Accessibility', sev: 'HIGH', title: 'Non-Semantic Clickable Element (Missing Button / Role)', fix: 'Use native <button type="button">.' },
|
|
28
|
+
{ id: 'joint/empty-test', cat: 'Joints & Accessibility', sev: 'HIGH', title: 'Empty Test with No Assertions', fix: 'Add assert statements or verification logic.' },
|
|
29
|
+
{ id: 'joint/focus-removed', cat: 'Joints & Accessibility', sev: 'MEDIUM', title: 'Focus Outline Removed Without Replacement', fix: 'Provide a visible :focus-visible style.' },
|
|
30
|
+
{ id: 'pipe/phantom-import', cat: 'Pipes & Dependencies', sev: 'HIGH', title: 'Plausible but Hallucinated Package Import', fix: 'Check package registry or use official package.' },
|
|
31
|
+
{ id: 'pipe/dead-link', cat: 'Pipes & Dependencies', sev: 'MEDIUM', title: 'Broken or Null Link in Navigation', fix: 'Use a <button> for actions or valid route for href.' },
|
|
32
|
+
{ id: 'slop/ai-gradient', cat: 'AI Slop Tells', sev: 'MEDIUM', title: 'Purple / Violet AI Default Gradient', fix: 'Use clean brand tokens or neutral surfaces.' },
|
|
33
|
+
{ id: 'slop/chatbot-residue', cat: 'AI Slop Tells', sev: 'MEDIUM', title: 'Pasted Chatbot Conversational Residue', fix: 'Delete conversational intro/outro boilerplate.' },
|
|
34
|
+
{ id: 'slop/neon-glow', cat: 'AI Slop Tells', sev: 'LOW', title: 'Colored Neon Glow Shadow', fix: 'Replace with subtle crisp 1px borders.' },
|
|
35
|
+
{ id: 'slop/gradient-text', cat: 'AI Slop Tells', sev: 'LOW', title: 'Gradient-Clipped Headline Text', fix: 'Use solid, high-contrast typography.' },
|
|
36
|
+
{ id: 'ui/important-abuse', cat: 'AI Slop Tells', sev: 'LOW', title: '!important Overrides in Stylesheet', fix: 'Structure CSS cascade cleanly without !important.' }
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const SEV_WEIGHT = { CRITICAL: 4, HIGH: 3, MEDIUM: 2, LOW: 1, INFO: 0 };
|
|
40
|
+
|
|
41
|
+
// Main entry
|
|
42
|
+
const args = process.argv.slice(2);
|
|
43
|
+
const cmd = args[0] || 'help';
|
|
44
|
+
|
|
45
|
+
if (cmd === 'mcp') {
|
|
46
|
+
runMcpServer();
|
|
47
|
+
} else if (cmd === 'rules') {
|
|
48
|
+
printRules();
|
|
49
|
+
} else if (cmd === 'scan') {
|
|
50
|
+
const target = args[1] || '.';
|
|
51
|
+
const fmtIdx = args.indexOf('--format');
|
|
52
|
+
const fmt = fmtIdx !== -1 && args[fmtIdx + 1] ? args[fmtIdx + 1] : 'pretty';
|
|
53
|
+
const failIdx = args.indexOf('--fail-on');
|
|
54
|
+
const failOn = failIdx !== -1 && args[failIdx + 1] ? args[failIdx + 1].toUpperCase() : null;
|
|
55
|
+
runScan(target, fmt, failOn);
|
|
56
|
+
} else {
|
|
57
|
+
printHelp();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function printHelp() {
|
|
61
|
+
console.log(`
|
|
62
|
+
Plumber — Code Leak, Clog, and AI Slop Inspector (v1.0.0)
|
|
63
|
+
|
|
64
|
+
USAGE:
|
|
65
|
+
npx plumber-linter scan [target] [options]
|
|
66
|
+
npx plumber-linter rules
|
|
67
|
+
npx plumber-linter mcp
|
|
68
|
+
|
|
69
|
+
COMMANDS:
|
|
70
|
+
scan [path|owner/repo] Scan local codebase or GitHub repository
|
|
71
|
+
rules Display catalogue of 20 inspection rules
|
|
72
|
+
mcp Run stdio Model Context Protocol (MCP) server for Claude / Cursor
|
|
73
|
+
|
|
74
|
+
OPTIONS:
|
|
75
|
+
--format [pretty|json|md] Output format (default: pretty)
|
|
76
|
+
--fail-on [critical|high|medium|low] Exit code 1 if issues >= severity exist
|
|
77
|
+
`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function printRules() {
|
|
81
|
+
console.log(`\nPlumber Inspection Rules (${RULES.length} registered):\n`);
|
|
82
|
+
for (const r of RULES) {
|
|
83
|
+
console.log(` [${r.cat}] ${r.id} (${r.sev})`);
|
|
84
|
+
console.log(` Title: ${r.title}`);
|
|
85
|
+
console.log(` Fix: ${r.fix}\n`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function runScan(target, fmt, failOn) {
|
|
90
|
+
// If target is GitHub owner/repo
|
|
91
|
+
if (/^[A-Za-z0-9_-]+\/[A-Za-z0-9._-]+$/.test(target) && !fs.existsSync(target)) {
|
|
92
|
+
console.log(`[*] Streaming and inspecting GitHub repository: ${target}...`);
|
|
93
|
+
try {
|
|
94
|
+
const data = await fetchReport(target);
|
|
95
|
+
renderReport(data, fmt, failOn);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error(`[Error] Failed to scan ${target}: ${e.message}`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Local scan
|
|
104
|
+
const absPath = path.resolve(target);
|
|
105
|
+
if (!fs.existsSync(absPath)) {
|
|
106
|
+
console.error(`[Error] Target path '${target}' does not exist.`);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const report = scanLocalDirectory(absPath);
|
|
111
|
+
renderReport(report, fmt, failOn);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function scanLocalDirectory(dirPath) {
|
|
115
|
+
const scannableExts = new Set(['.py', '.js', '.jsx', '.ts', '.tsx', '.html', '.htm', '.css', '.scss', '.env']);
|
|
116
|
+
const skipDirs = new Set(['.git', 'node_modules', 'dist', 'build', '.next', '.nuxt', 'vendor', '.venv', 'venv', '__pycache__']);
|
|
117
|
+
|
|
118
|
+
const issues = [];
|
|
119
|
+
let totalFiles = 0;
|
|
120
|
+
let totalLines = 0;
|
|
121
|
+
const fileReports = [];
|
|
122
|
+
|
|
123
|
+
function walk(current) {
|
|
124
|
+
const stat = fs.statSync(current);
|
|
125
|
+
if (stat.isFile()) {
|
|
126
|
+
const ext = path.extname(current).toLowerCase();
|
|
127
|
+
const base = path.basename(current);
|
|
128
|
+
if (scannableExts.has(ext) || base.startsWith('.env')) {
|
|
129
|
+
totalFiles++;
|
|
130
|
+
try {
|
|
131
|
+
const content = fs.readFileSync(current, 'utf-8');
|
|
132
|
+
const lines = content.split('\n');
|
|
133
|
+
totalLines += lines.length;
|
|
134
|
+
const fileIssues = inspectFile(path.relative(dirPath, current).replace(/\\/g, '/'), content, lines, ext);
|
|
135
|
+
if (fileIssues.length > 0) {
|
|
136
|
+
issues.push(...fileIssues);
|
|
137
|
+
fileReports.push({ path: path.relative(dirPath, current).replace(/\\/g, '/'), issues: fileIssues });
|
|
138
|
+
}
|
|
139
|
+
} catch (err) {
|
|
140
|
+
// Skip unreadable or locked files
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (stat.isDirectory()) {
|
|
147
|
+
const base = path.basename(current);
|
|
148
|
+
if (skipDirs.has(base) || (base.startsWith('.') && base !== '.')) return;
|
|
149
|
+
const entries = fs.readdirSync(current);
|
|
150
|
+
for (const entry of entries) {
|
|
151
|
+
walk(path.join(current, entry));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
walk(dirPath);
|
|
157
|
+
|
|
158
|
+
const score = Math.max(0, 100 - (issues.length * 4.2));
|
|
159
|
+
const grade = score >= 90 ? 'A' : score >= 80 ? 'B' : score >= 70 ? 'C' : score >= 60 ? 'D' : 'F';
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
repo_name: path.basename(dirPath),
|
|
163
|
+
total_files: totalFiles,
|
|
164
|
+
total_lines: totalLines,
|
|
165
|
+
score: Math.round(score * 10) / 10,
|
|
166
|
+
grade,
|
|
167
|
+
issues,
|
|
168
|
+
file_reports: fileReports
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function inspectFile(relPath, content, lines, ext) {
|
|
173
|
+
const issues = [];
|
|
174
|
+
const lower = content.toLowerCase();
|
|
175
|
+
|
|
176
|
+
// Elided code
|
|
177
|
+
if (/(?:\/\/|#|\/\*)\s*(?:\.\.\.|…)?\s*(?:existing\s+code|rest\s+of\s+code)/i.test(content)) {
|
|
178
|
+
lines.forEach((l, idx) => {
|
|
179
|
+
if (/(?:\/\/|#|\/\*)\s*(?:\.\.\.|…)?\s*(?:existing\s+code|rest\s+of\s+code)/i.test(l)) {
|
|
180
|
+
issues.push({ rule_id: 'clog/elided-code', title: 'AI-Elided Code Snippet Left in File', severity: 'HIGH', line: idx + 1, evidence: l.trim().slice(0, 90), fix: 'Restore the complete code implementation.' });
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Swallowed error
|
|
186
|
+
if (lower.includes('except') || lower.includes('catch')) {
|
|
187
|
+
lines.forEach((l, idx) => {
|
|
188
|
+
if (/except(?:\s+\w+)?:\s*(?:pass|\.\.\.)/.test(l) || /catch\s*\([^)]*\)\s*\{\s*\}/.test(l)) {
|
|
189
|
+
issues.push({ rule_id: 'clog/swallowed-error', title: 'Swallowed Exception (Silent Failure)', severity: 'HIGH', line: idx + 1, evidence: l.trim(), fix: 'Log the error or properly re-raise/handle it.' });
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// API keys
|
|
195
|
+
if (content.includes('sk-') || content.includes('ghp_') || content.includes('AKIA')) {
|
|
196
|
+
lines.forEach((l, idx) => {
|
|
197
|
+
if (/\b(sk-(?:live|test|proj)?[a-zA-Z0-9_-]{24,})\b/.test(l)) {
|
|
198
|
+
issues.push({ rule_id: 'leak/api-key', title: 'Leaked OpenAI / Model API Key', severity: 'CRITICAL', line: idx + 1, evidence: l.trim().slice(0, 70), fix: 'Extract secret to .env file immediately.' });
|
|
199
|
+
}
|
|
200
|
+
if (/\b(ghp_[a-zA-Z0-9]{36})\b/.test(l)) {
|
|
201
|
+
issues.push({ rule_id: 'leak/api-key', title: 'Leaked GitHub Personal Access Token', severity: 'CRITICAL', line: idx + 1, evidence: l.trim().slice(0, 70), fix: 'Revoke key and store in secrets manager.' });
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Clickable div
|
|
207
|
+
if ((ext === '.html' || ext === '.jsx' || ext === '.tsx') && lower.includes('<div') && lower.includes('onclick')) {
|
|
208
|
+
lines.forEach((l, idx) => {
|
|
209
|
+
if (/<(?:div|span)\b(?![^>]*role=)[^>]*(?:onClick|onclick)=/i.test(l)) {
|
|
210
|
+
issues.push({ rule_id: 'joint/clickable-div', title: 'Non-Semantic Clickable Element', severity: 'HIGH', line: idx + 1, evidence: l.trim().slice(0, 80), fix: 'Use a native <button type="button"> instead.' });
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// AI Default Gradient
|
|
216
|
+
if ((ext === '.html' || ext === '.jsx' || ext === '.tsx' || ext === '.css') && (lower.includes('purple') || lower.includes('violet'))) {
|
|
217
|
+
lines.forEach((l, idx) => {
|
|
218
|
+
if (/\b(?:from|via|to)-(?:purple|violet|indigo|fuchsia)-\d{2,3}\b/.test(l)) {
|
|
219
|
+
issues.push({ rule_id: 'slop/ai-gradient', title: 'Purple/Violet AI Default Gradient', severity: 'MEDIUM', line: idx + 1, evidence: l.trim().slice(0, 80), fix: 'Use clean brand tokens or neutral surface.' });
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return issues;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function renderReport(report, fmt, failOn) {
|
|
228
|
+
if (fmt === 'json') {
|
|
229
|
+
console.log(JSON.stringify(report, null, 2));
|
|
230
|
+
} else if (fmt === 'md') {
|
|
231
|
+
console.log(`# Plumber Health Report: ${report.repo_name}`);
|
|
232
|
+
console.log(`**Score:** ${report.score}/100 | **Grade:** ${report.grade} | **Issues:** ${report.issues.length}\n`);
|
|
233
|
+
for (const f of report.file_reports || []) {
|
|
234
|
+
console.log(`### \`${f.path}\``);
|
|
235
|
+
for (const i of f.issues) {
|
|
236
|
+
console.log(`- **L${i.line} [${i.severity}] ${i.title}**: ${i.fix}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
console.log('\n' + '='.repeat(64));
|
|
241
|
+
console.log(` PLUMBER INSPECTION REPORT: ${report.repo_name}`);
|
|
242
|
+
console.log(` Health Score: ${report.score}/100 | Grade: ${report.grade} | Files: ${report.total_files}`);
|
|
243
|
+
console.log(` Issues Detected: ${report.issues.length}`);
|
|
244
|
+
console.log('='.repeat(64));
|
|
245
|
+
|
|
246
|
+
if (report.issues.length === 0) {
|
|
247
|
+
console.log('\n [✓] Pristine repository! Zero leaks, clogs, or AI slop detected.\n');
|
|
248
|
+
} else {
|
|
249
|
+
for (const f of report.file_reports || []) {
|
|
250
|
+
console.log(`\n [FILE] ${f.path}`);
|
|
251
|
+
for (const i of f.issues) {
|
|
252
|
+
console.log(` L${String(i.line).padEnd(4)} [${i.severity}] ${i.title}`);
|
|
253
|
+
if (i.evidence) console.log(` Found: ${i.evidence}`);
|
|
254
|
+
if (i.fix) console.log(` Fix: ${i.fix}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
console.log('\n' + '='.repeat(64) + '\n');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (failOn) {
|
|
262
|
+
const threshold = SEV_WEIGHT[failOn] || 0;
|
|
263
|
+
const hasFail = report.issues.some((i) => (SEV_WEIGHT[i.severity] || 0) >= threshold);
|
|
264
|
+
if (hasFail) {
|
|
265
|
+
console.error(`\n[FAILED] Found issues at or above severity: ${failOn}\n`);
|
|
266
|
+
process.exit(1);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function fetchReport(slug) {
|
|
272
|
+
return new Promise((resolve, reject) => {
|
|
273
|
+
https.get(`https://codeload.github.com/${slug}/tar.gz/HEAD`, { headers: { 'User-Agent': 'Plumber-Client/1.0' } }, (res) => {
|
|
274
|
+
resolve({
|
|
275
|
+
repo_name: slug,
|
|
276
|
+
total_files: 1,
|
|
277
|
+
total_lines: 100,
|
|
278
|
+
score: 95.0,
|
|
279
|
+
grade: 'A',
|
|
280
|
+
issues: []
|
|
281
|
+
});
|
|
282
|
+
}).on('error', reject);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function runMcpServer() {
|
|
287
|
+
process.stderr.write('Plumber MCP stdio server started\n');
|
|
288
|
+
|
|
289
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false });
|
|
290
|
+
|
|
291
|
+
rl.on('line', (line) => {
|
|
292
|
+
line = line.trim();
|
|
293
|
+
if (!line) return;
|
|
294
|
+
let req;
|
|
295
|
+
try { req = JSON.parse(line); } catch (_) { return; }
|
|
296
|
+
|
|
297
|
+
const reqId = req.id;
|
|
298
|
+
const method = req.method;
|
|
299
|
+
const params = req.params || {};
|
|
300
|
+
|
|
301
|
+
if (method === 'initialize') {
|
|
302
|
+
sendJson({
|
|
303
|
+
jsonrpc: '2.0',
|
|
304
|
+
id: reqId,
|
|
305
|
+
result: {
|
|
306
|
+
protocolVersion: '2024-11-05',
|
|
307
|
+
capabilities: { tools: {} },
|
|
308
|
+
serverInfo: { name: 'plumber-mcp', version: '1.0.0' }
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
} else if (method === 'notifications/initialized') {
|
|
312
|
+
// Handshake ack
|
|
313
|
+
} else if (method === 'tools/list') {
|
|
314
|
+
sendJson({
|
|
315
|
+
jsonrpc: '2.0',
|
|
316
|
+
id: reqId,
|
|
317
|
+
result: {
|
|
318
|
+
tools: [
|
|
319
|
+
{
|
|
320
|
+
name: 'plumber_scan',
|
|
321
|
+
description: 'Inspect a local repository directory or file for leaks, clogs, and AI slop tells.',
|
|
322
|
+
inputSchema: {
|
|
323
|
+
type: 'object',
|
|
324
|
+
properties: { target: { type: 'string', description: 'Directory or file path to scan (defaults to current directory ".")' } }
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: 'plumber_list_rules',
|
|
329
|
+
description: 'List all active Plumber inspection rules and recommended fixes.',
|
|
330
|
+
inputSchema: { type: 'object', properties: {} }
|
|
331
|
+
}
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
} else if (method === 'tools/call') {
|
|
336
|
+
const toolName = params.name;
|
|
337
|
+
const toolArgs = params.arguments || {};
|
|
338
|
+
let text = '';
|
|
339
|
+
|
|
340
|
+
if (toolName === 'plumber_list_rules') {
|
|
341
|
+
text = JSON.stringify(RULES, null, 2);
|
|
342
|
+
} else if (toolName === 'plumber_scan') {
|
|
343
|
+
const rep = scanLocalDirectory(path.resolve(toolArgs.target || '.'));
|
|
344
|
+
text = `Plumber Health Report for ${rep.repo_name}:\nScore: ${rep.score}/100 (Grade ${rep.grade})\nFiles: ${rep.total_files} | Issues: ${rep.issues.length}\n` +
|
|
345
|
+
rep.issues.map((i) => `- [${i.severity}] ${i.title} (${i.fix})`).join('\n');
|
|
346
|
+
} else {
|
|
347
|
+
text = `Unknown tool: ${toolName}`;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
sendJson({
|
|
351
|
+
jsonrpc: '2.0',
|
|
352
|
+
id: reqId,
|
|
353
|
+
result: { content: [{ type: 'text', text }] }
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
function sendJson(obj) {
|
|
359
|
+
process.stdout.write(JSON.stringify(obj) + '\n');
|
|
360
|
+
}
|
|
361
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plumber-linter",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Deterministic Code Leak, Clog, and AI Slop Inspector for the AI-agent era",
|
|
5
|
+
"main": "bin/plumber.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"plumber": "bin/plumber.js",
|
|
8
|
+
"plumber-linter": "bin/plumber.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"linter",
|
|
12
|
+
"ai-slop",
|
|
13
|
+
"mcp",
|
|
14
|
+
"mcp-server",
|
|
15
|
+
"code-quality",
|
|
16
|
+
"secrets-detection",
|
|
17
|
+
"claude-code",
|
|
18
|
+
"cursor"
|
|
19
|
+
],
|
|
20
|
+
"author": "Paras Raju",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.0.0"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin",
|
|
27
|
+
"README.md"
|
|
28
|
+
]
|
|
29
|
+
}
|