tribunal-kit 4.4.1 → 4.4.3
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/.agent/history/architecture-graph.yaml +140 -0
- package/.agent/history/graph-cache.json +262 -0
- package/.agent/history/snapshots/bin__tribunal-kit.js.json +19 -0
- package/.agent/history/snapshots/eslint.config.js.json +9 -0
- package/.agent/history/snapshots/migrate_refs.js.json +11 -0
- package/.agent/history/snapshots/scripts__changelog.js.json +13 -0
- package/.agent/history/snapshots/scripts__sync-version.js.json +12 -0
- package/.agent/history/snapshots/scripts__validate-payload.js.json +12 -0
- package/.agent/history/snapshots/test__integration__bridges.test.js.json +14 -0
- package/.agent/history/snapshots/test__integration__init.test.js.json +14 -0
- package/.agent/history/snapshots/test__integration__routing.test.js.json +12 -0
- package/.agent/history/snapshots/test__integration__swarm_dispatcher.test.js.json +14 -0
- package/.agent/history/snapshots/test__integration__wave2.test.js.json +14 -0
- package/.agent/history/snapshots/test__unit__args.test.js.json +20 -0
- package/.agent/history/snapshots/test__unit__case_law_manager.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__context_broker.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__copyDir.test.js.json +23 -0
- package/.agent/history/snapshots/test__unit__graph_tools.test.js.json +12 -0
- package/.agent/history/snapshots/test__unit__inner_loop_validator.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__selfInstall.test.js.json +23 -0
- package/.agent/history/snapshots/test__unit__semver.test.js.json +20 -0
- package/.agent/history/snapshots/test__unit__swarm_dispatcher.test.js.json +12 -0
- package/.agent/scripts/_colors.js +170 -18
- package/.agent/scripts/_utils.js +244 -42
- package/.agent/scripts/bundle_analyzer.js +261 -290
- package/.agent/scripts/case_law_manager.js +1 -7
- package/.agent/scripts/checklist.js +278 -266
- package/.agent/scripts/colors.js +11 -17
- package/.agent/scripts/context_broker.js +1 -7
- package/.agent/scripts/dependency_analyzer.js +234 -272
- package/.agent/scripts/graph_builder.js +46 -18
- package/.agent/scripts/graph_visualizer.js +10 -4
- package/.agent/scripts/graph_zoom.js +6 -4
- package/.agent/scripts/inner_loop_validator.js +2 -8
- package/.agent/scripts/lint_runner.js +186 -187
- package/.agent/scripts/marathon_harness.js +799 -0
- package/.agent/scripts/prompt_compiler.js +56 -0
- package/.agent/scripts/schema_validator.js +8 -25
- package/.agent/scripts/security_scan.js +276 -303
- package/.agent/scripts/session_manager.js +1 -7
- package/.agent/scripts/skill_evolution.js +1 -8
- package/.agent/scripts/skill_integrator.js +1 -7
- package/.agent/scripts/test_runner.js +186 -193
- package/.agent/scripts/utils.js +17 -32
- package/.agent/scripts/verify_all.js +248 -257
- package/.agent/skills/agent-organizer/SKILL.md +42 -0
- package/.agent/skills/agentic-patterns/SKILL.md +42 -0
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +42 -0
- package/.agent/skills/api-patterns/SKILL.md +42 -0
- package/.agent/skills/api-security-auditor/SKILL.md +42 -0
- package/.agent/skills/app-builder/SKILL.md +42 -0
- package/.agent/skills/appflow-wireframe/SKILL.md +42 -0
- package/.agent/skills/architecture/SKILL.md +42 -0
- package/.agent/skills/authentication-best-practices/SKILL.md +42 -0
- package/.agent/skills/backend-security-expert/SKILL.md +122 -0
- package/.agent/skills/bash-linux/SKILL.md +42 -0
- package/.agent/skills/behavioral-modes/SKILL.md +42 -0
- package/.agent/skills/brainstorming/SKILL.md +42 -0
- package/.agent/skills/building-native-ui/SKILL.md +42 -0
- package/.agent/skills/clean-code/SKILL.md +42 -0
- package/.agent/skills/code-review-checklist/SKILL.md +42 -0
- package/.agent/skills/config-validator/SKILL.md +42 -0
- package/.agent/skills/csharp-developer/SKILL.md +42 -0
- package/.agent/skills/data-validation-schemas/SKILL.md +42 -0
- package/.agent/skills/database-design/SKILL.md +42 -0
- package/.agent/skills/deployment-procedures/SKILL.md +42 -0
- package/.agent/skills/devops-engineer/SKILL.md +42 -0
- package/.agent/skills/devops-incident-responder/SKILL.md +42 -0
- package/.agent/skills/documentation-templates/SKILL.md +42 -0
- package/.agent/skills/edge-computing/SKILL.md +42 -0
- package/.agent/skills/error-resilience/SKILL.md +42 -0
- package/.agent/skills/extract-design-system/SKILL.md +42 -0
- package/.agent/skills/framer-motion-expert/SKILL.md +42 -0
- package/.agent/skills/frontend-design/SKILL.md +42 -0
- package/.agent/skills/frontend-security-expert/SKILL.md +123 -0
- package/.agent/skills/game-design-expert/SKILL.md +42 -0
- package/.agent/skills/game-engineering-expert/SKILL.md +42 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +42 -0
- package/.agent/skills/github-operations/SKILL.md +42 -0
- package/.agent/skills/gsap-core/SKILL.md +42 -0
- package/.agent/skills/gsap-frameworks/SKILL.md +42 -0
- package/.agent/skills/gsap-performance/SKILL.md +42 -0
- package/.agent/skills/gsap-plugins/SKILL.md +42 -0
- package/.agent/skills/gsap-react/SKILL.md +42 -0
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +42 -0
- package/.agent/skills/gsap-timeline/SKILL.md +42 -0
- package/.agent/skills/gsap-utils/SKILL.md +42 -0
- package/.agent/skills/i18n-localization/SKILL.md +42 -0
- package/.agent/skills/intelligent-routing/SKILL.md +42 -0
- package/.agent/skills/knowledge-graph/SKILL.md +42 -0
- package/.agent/skills/lint-and-validate/SKILL.md +42 -0
- package/.agent/skills/llm-engineering/SKILL.md +42 -0
- package/.agent/skills/local-first/SKILL.md +42 -0
- package/.agent/skills/mcp-builder/SKILL.md +42 -0
- package/.agent/skills/mobile-design/SKILL.md +42 -0
- package/.agent/skills/monorepo-management/SKILL.md +42 -0
- package/.agent/skills/motion-engineering/SKILL.md +42 -0
- package/.agent/skills/nextjs-react-expert/SKILL.md +42 -0
- package/.agent/skills/nodejs-best-practices/SKILL.md +42 -0
- package/.agent/skills/observability/SKILL.md +42 -0
- package/.agent/skills/parallel-agents/SKILL.md +42 -0
- package/.agent/skills/performance-profiling/SKILL.md +42 -0
- package/.agent/skills/plan-writing/SKILL.md +42 -0
- package/.agent/skills/platform-engineer/SKILL.md +42 -0
- package/.agent/skills/playwright-best-practices/SKILL.md +42 -0
- package/.agent/skills/powershell-windows/SKILL.md +42 -0
- package/.agent/skills/project-idioms/SKILL.md +42 -0
- package/.agent/skills/python-patterns/SKILL.md +42 -0
- package/.agent/skills/python-pro/SKILL.md +42 -0
- package/.agent/skills/react-specialist/SKILL.md +42 -0
- package/.agent/skills/readme-builder/SKILL.md +42 -0
- package/.agent/skills/realtime-patterns/SKILL.md +42 -0
- package/.agent/skills/red-team-tactics/SKILL.md +42 -0
- package/.agent/skills/rust-pro/SKILL.md +42 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +42 -0
- package/.agent/skills/server-management/SKILL.md +42 -0
- package/.agent/skills/shadcn-ui-expert/SKILL.md +42 -0
- package/.agent/skills/skill-creator/SKILL.md +42 -0
- package/.agent/skills/sql-pro/SKILL.md +42 -0
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +42 -0
- package/.agent/skills/swiftui-expert/SKILL.md +42 -0
- package/.agent/skills/systematic-debugging/SKILL.md +42 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +42 -0
- package/.agent/skills/tdd-workflow/SKILL.md +42 -0
- package/.agent/skills/test-result-analyzer/SKILL.md +42 -0
- package/.agent/skills/testing-patterns/SKILL.md +42 -0
- package/.agent/skills/trend-researcher/SKILL.md +42 -0
- package/.agent/skills/typescript-advanced/SKILL.md +42 -0
- package/.agent/skills/ui-ux-pro-max/SKILL.md +42 -0
- package/.agent/skills/ui-ux-researcher/SKILL.md +42 -0
- package/.agent/skills/vue-expert/SKILL.md +42 -0
- package/.agent/skills/vulnerability-scanner/SKILL.md +42 -0
- package/.agent/skills/web-accessibility-auditor/SKILL.md +42 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +42 -0
- package/.agent/skills/webapp-testing/SKILL.md +42 -0
- package/.agent/skills/whimsy-injector/SKILL.md +42 -0
- package/.agent/skills/workflow-optimizer/SKILL.md +42 -0
- package/.agent/workflows/marathon.md +247 -0
- package/.agent/workflows/super-prompt.md +27 -0
- package/bin/tribunal-kit.js +47 -1
- package/package.json +3 -2
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
12
|
|
|
13
|
+
const { RED, GREEN, DIM, RESET } = require('./_colors');
|
|
14
|
+
|
|
13
15
|
const AGENT_DIR = path.join(process.cwd(), '.agent');
|
|
14
16
|
const HISTORY_DIR = path.join(AGENT_DIR, 'history');
|
|
15
17
|
const CACHE_FILE = path.join(HISTORY_DIR, 'graph-cache.json');
|
|
@@ -17,7 +19,7 @@ const HTML_FILE = path.join(HISTORY_DIR, 'architecture-explorer.html');
|
|
|
17
19
|
|
|
18
20
|
function main() {
|
|
19
21
|
if (!fs.existsSync(CACHE_FILE)) {
|
|
20
|
-
console.error(
|
|
22
|
+
console.error(`${RED}✖ Error: graph-cache.json not found. Run graph_builder.js first.${RESET}`);
|
|
21
23
|
process.exit(1);
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -377,8 +379,12 @@ function main() {
|
|
|
377
379
|
</html>`;
|
|
378
380
|
|
|
379
381
|
fs.writeFileSync(HTML_FILE, htmlContent);
|
|
380
|
-
console.log(
|
|
381
|
-
console.log(`
|
|
382
|
+
console.log(`${GREEN}✔ Interactive visualizer generated.${RESET}`);
|
|
383
|
+
console.log(` ${DIM}Saved to: ${HTML_FILE}${RESET}`);
|
|
382
384
|
}
|
|
383
385
|
|
|
384
|
-
main
|
|
386
|
+
module.exports = { main };
|
|
387
|
+
|
|
388
|
+
if (require.main === module) {
|
|
389
|
+
main();
|
|
390
|
+
}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
12
|
|
|
13
|
+
const { RED, CYAN, RESET } = require('./_colors');
|
|
14
|
+
|
|
13
15
|
function getFlag(name) {
|
|
14
16
|
const idx = process.argv.indexOf(name);
|
|
15
17
|
return (idx !== -1 && process.argv[idx + 1]) ? process.argv[idx + 1] : null;
|
|
@@ -18,14 +20,14 @@ function getFlag(name) {
|
|
|
18
20
|
const targetFile = getFlag('--focus');
|
|
19
21
|
|
|
20
22
|
if (!targetFile) {
|
|
21
|
-
console.error(
|
|
23
|
+
console.error(`${RED}✖ Error: Provide a file to zoom into. Usage: node graph_zoom.js --focus <filepath>${RESET}`);
|
|
22
24
|
process.exit(1);
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const absolutePath = path.resolve(process.cwd(), targetFile);
|
|
26
28
|
|
|
27
29
|
if (!fs.existsSync(absolutePath)) {
|
|
28
|
-
console.error(
|
|
30
|
+
console.error(`${RED}✖ Error: File not found at ${absolutePath}${RESET}`);
|
|
29
31
|
process.exit(1);
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -119,7 +121,7 @@ function extractSkeleton(content) {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
function main() {
|
|
122
|
-
console.log(
|
|
124
|
+
console.log(`${CYAN}✦ Zooming into: ${targetFile}${RESET}`);
|
|
123
125
|
|
|
124
126
|
try {
|
|
125
127
|
const content = fs.readFileSync(absolutePath, 'utf8');
|
|
@@ -142,7 +144,7 @@ function main() {
|
|
|
142
144
|
console.log('--- SKELETON END ---\n');
|
|
143
145
|
|
|
144
146
|
} catch (e) {
|
|
145
|
-
console.error(
|
|
147
|
+
console.error(`${RED}✖ Error parsing file: ${e.message}${RESET}`);
|
|
146
148
|
// Fallback Logic: Return truncated raw on hard failure
|
|
147
149
|
const rawContent = fs.readFileSync(absolutePath, 'utf8').split('\n').slice(0, 100).join('\n');
|
|
148
150
|
console.log('\n--- RAW FILE FALLBACK (100 lines) ---');
|
|
@@ -120,14 +120,8 @@ const SYNTAX_HEURISTICS = [
|
|
|
120
120
|
},
|
|
121
121
|
];
|
|
122
122
|
|
|
123
|
-
// ── ANSI colors (
|
|
124
|
-
const GREEN
|
|
125
|
-
const YELLOW = '\x1b[93m';
|
|
126
|
-
const RED = '\x1b[91m';
|
|
127
|
-
const CYAN = '\x1b[96m';
|
|
128
|
-
const BOLD = '\x1b[1m';
|
|
129
|
-
const DIM = '\x1b[2m';
|
|
130
|
-
const RESET = '\x1b[0m';
|
|
123
|
+
// ── ANSI colors (centralized via _colors.js) ─────────────────────────────
|
|
124
|
+
const { GREEN, YELLOW, RED, CYAN, BOLD, DIM, RESET } = require('./_colors');
|
|
131
125
|
|
|
132
126
|
// ── Core scanning ─────────────────────────────────────────────────────────
|
|
133
127
|
|
|
@@ -1,187 +1,186 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* lint_runner.js — Standalone lint runner for the Tribunal Agent Kit.
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* node .agent/scripts/lint_runner.js .
|
|
7
|
-
* node .agent/scripts/lint_runner.js . --fix
|
|
8
|
-
* node .agent/scripts/lint_runner.js . --files src/index.ts src/utils.ts
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const fs = require('fs');
|
|
14
|
-
const path = require('path');
|
|
15
|
-
const { spawnSync } = require('child_process');
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
if (result.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (!runLinter("
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* lint_runner.js — Standalone lint runner for the Tribunal Agent Kit.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node .agent/scripts/lint_runner.js .
|
|
7
|
+
* node .agent/scripts/lint_runner.js . --fix
|
|
8
|
+
* node .agent/scripts/lint_runner.js . --files src/index.ts src/utils.ts
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const { spawnSync } = require('child_process');
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
RED, GREEN, YELLOW, BLUE, BOLD, DIM, CYAN, RESET,
|
|
19
|
+
banner, sectionHeader, summaryTable, timer, formatMs,
|
|
20
|
+
ok, fail, skip,
|
|
21
|
+
} = require('./_colors');
|
|
22
|
+
|
|
23
|
+
const RESULTS = [];
|
|
24
|
+
|
|
25
|
+
function runLinter(label, cmd, cwd) {
|
|
26
|
+
const elapsed = timer();
|
|
27
|
+
try {
|
|
28
|
+
const executable = process.platform === 'win32' && cmd[0] === 'npx' ? 'npx.cmd' : cmd[0];
|
|
29
|
+
const result = spawnSync(executable, cmd.slice(1), {
|
|
30
|
+
cwd,
|
|
31
|
+
encoding: 'utf8',
|
|
32
|
+
timeout: 120000,
|
|
33
|
+
shell: process.platform === 'win32'
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const ms = elapsed();
|
|
37
|
+
if (result.status === 0) {
|
|
38
|
+
ok(`${label} — clean ${DIM}(${formatMs(ms)})${RESET}`);
|
|
39
|
+
RESULTS.push({ name: label, status: 'pass', ms });
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fail(`${label} — issues found ${DIM}(${formatMs(ms)})${RESET}`);
|
|
44
|
+
RESULTS.push({ name: label, status: 'fail', ms });
|
|
45
|
+
if (result.error) {
|
|
46
|
+
console.log(` Error: ${result.error.message}`);
|
|
47
|
+
}
|
|
48
|
+
const out = result.stdout ? result.stdout.toString() : '';
|
|
49
|
+
const err = result.stderr ? result.stderr.toString() : '';
|
|
50
|
+
const output = (out + "\n" + err).trim();
|
|
51
|
+
if (output) {
|
|
52
|
+
const lines = output.split('\n');
|
|
53
|
+
for (const line of lines.slice(0, 15)) {
|
|
54
|
+
console.log(` ${line}`);
|
|
55
|
+
}
|
|
56
|
+
if (lines.length > 15) {
|
|
57
|
+
console.log(` ... and ${lines.length - 15} more lines`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
} catch {
|
|
62
|
+
skip(`${label} — tool not installed`);
|
|
63
|
+
RESULTS.push({ name: label, status: 'skip' });
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function detectLinters(projectRoot) {
|
|
69
|
+
const available = {};
|
|
70
|
+
const pkgJson = path.join(projectRoot, "package.json");
|
|
71
|
+
|
|
72
|
+
if (fs.existsSync(pkgJson)) {
|
|
73
|
+
const eslintFiles = [".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml", "eslint.config.js", "eslint.config.mjs"];
|
|
74
|
+
available.eslint = eslintFiles.some(f => fs.existsSync(path.join(projectRoot, f)));
|
|
75
|
+
|
|
76
|
+
const prettierFiles = [".prettierrc", ".prettierrc.js", ".prettierrc.json", "prettier.config.js"];
|
|
77
|
+
available.prettier = prettierFiles.some(f => fs.existsSync(path.join(projectRoot, f)));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
available.ruff = fs.existsSync(path.join(projectRoot, "pyproject.toml")) || fs.existsSync(path.join(projectRoot, "ruff.toml"));
|
|
81
|
+
available.flake8 = fs.existsSync(path.join(projectRoot, ".flake8")) || fs.existsSync(path.join(projectRoot, "setup.cfg"));
|
|
82
|
+
|
|
83
|
+
return available;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function main() {
|
|
87
|
+
const args = process.argv.slice(2);
|
|
88
|
+
let targetPath = null;
|
|
89
|
+
let fixFlag = false;
|
|
90
|
+
let fileArgs = [];
|
|
91
|
+
|
|
92
|
+
let i = 0;
|
|
93
|
+
while (i < args.length) {
|
|
94
|
+
if (args[i] === '--fix') fixFlag = true;
|
|
95
|
+
else if (args[i] === '--files') {
|
|
96
|
+
i++;
|
|
97
|
+
while (i < args.length && !args[i].startsWith('--')) {
|
|
98
|
+
fileArgs.push(args[i++]);
|
|
99
|
+
}
|
|
100
|
+
continue;
|
|
101
|
+
} else if (!targetPath && !args[i].startsWith('-')) {
|
|
102
|
+
targetPath = args[i];
|
|
103
|
+
}
|
|
104
|
+
i++;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!targetPath) {
|
|
108
|
+
console.log("Usage: node lint_runner.js <path> [--fix] [--files <file1> <file2> ...]");
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const projectRoot = path.resolve(targetPath);
|
|
113
|
+
if (!fs.existsSync(projectRoot) || !fs.statSync(projectRoot).isDirectory()) {
|
|
114
|
+
fail(`Directory not found: ${projectRoot}`);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
console.log(banner('lint_runner.js', { Project: projectRoot, Mode: fixFlag ? 'fix' : 'check' }));
|
|
119
|
+
|
|
120
|
+
const available = detectLinters(projectRoot);
|
|
121
|
+
if (!Object.values(available).some(Boolean)) {
|
|
122
|
+
skip("No linter configuration detected in this project");
|
|
123
|
+
process.exit(0);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
RESULTS.length = 0;
|
|
127
|
+
let failures = 0;
|
|
128
|
+
|
|
129
|
+
if (available.eslint) {
|
|
130
|
+
console.log(sectionHeader('ESLint'));
|
|
131
|
+
const cmd = ["npx", "eslint"];
|
|
132
|
+
if (fixFlag) cmd.push("--fix");
|
|
133
|
+
if (fileArgs.length) cmd.push(...fileArgs);
|
|
134
|
+
else cmd.push(".", "--max-warnings=0");
|
|
135
|
+
if (!runLinter("ESLint", cmd, projectRoot)) failures++;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (available.prettier) {
|
|
139
|
+
console.log(sectionHeader('Prettier'));
|
|
140
|
+
const cmd = ["npx", "prettier"];
|
|
141
|
+
if (fixFlag) cmd.push("--write");
|
|
142
|
+
else cmd.push("--check");
|
|
143
|
+
if (fileArgs.length) cmd.push(...fileArgs);
|
|
144
|
+
else cmd.push(".");
|
|
145
|
+
if (!runLinter("Prettier", cmd, projectRoot)) failures++;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (available.ruff) {
|
|
149
|
+
console.log(sectionHeader('Ruff (Python)'));
|
|
150
|
+
const cmd = ["ruff", "check"];
|
|
151
|
+
if (fixFlag) cmd.push("--fix");
|
|
152
|
+
if (fileArgs.length) cmd.push(...fileArgs);
|
|
153
|
+
else cmd.push(".");
|
|
154
|
+
if (!runLinter("Ruff", cmd, projectRoot)) failures++;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (available.flake8 && !available.ruff) {
|
|
158
|
+
console.log(sectionHeader('Flake8 (Python)'));
|
|
159
|
+
const cmd = ["flake8"];
|
|
160
|
+
if (fileArgs.length) cmd.push(...fileArgs);
|
|
161
|
+
else cmd.push(".");
|
|
162
|
+
if (!runLinter("Flake8", cmd, projectRoot)) failures++;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (fs.existsSync(path.join(projectRoot, "tsconfig.json"))) {
|
|
166
|
+
console.log(sectionHeader('TypeScript'));
|
|
167
|
+
if (!runLinter("TypeScript", ["npx", "tsc", "--noEmit"], projectRoot)) failures++;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
console.log(`\n${BOLD}${CYAN}━━━ Lint Summary ━━━${RESET}`);
|
|
171
|
+
if (RESULTS.length > 0) {
|
|
172
|
+
summaryTable(RESULTS);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (failures === 0) {
|
|
176
|
+
console.log(`\n${GREEN}${BOLD} ✔ All linters passed.${RESET}\n`);
|
|
177
|
+
} else {
|
|
178
|
+
console.log(`\n${RED}${BOLD} ✖ ${failures} linter(s) reported issues.${RESET}\n`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
process.exit(failures > 0 ? 1 : 0);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (require.main === module) {
|
|
185
|
+
main();
|
|
186
|
+
}
|