tribunal-kit 5.7.0 → 5.8.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.
Files changed (56) hide show
  1. package/.agent/ARCHITECTURE.md +6 -7
  2. package/.agent/agents/frontend-reviewer.md +13 -0
  3. package/.agent/agents/frontend-specialist.md +14 -0
  4. package/.agent/agents/logic-reviewer.md +11 -0
  5. package/.agent/agents/orchestrator.md +15 -0
  6. package/.agent/agents/security-auditor.md +13 -0
  7. package/.agent/agents/ui-ux-auditor.md +7 -31
  8. package/.agent/history/memory/.memory.idx +766 -0
  9. package/.agent/history/memory/MEMORY.md +62 -0
  10. package/.agent/routing_index.json +694 -714
  11. package/.agent/rules/GEMINI.md +58 -8
  12. package/.agent/scripts/_colors.js +131 -89
  13. package/.agent/scripts/_utils.js +163 -128
  14. package/.agent/scripts/auto_preview.js +207 -197
  15. package/.agent/scripts/bundle_analyzer.js +227 -192
  16. package/.agent/scripts/case_law_manager.js +991 -689
  17. package/.agent/scripts/checklist.js +233 -190
  18. package/.agent/scripts/context_broker.js +930 -605
  19. package/.agent/scripts/dependency_analyzer.js +275 -184
  20. package/.agent/scripts/graph_builder.js +412 -341
  21. package/.agent/scripts/graph_visualizer.js +392 -390
  22. package/.agent/scripts/graph_zoom.js +198 -156
  23. package/.agent/scripts/inner_loop_validator.js +523 -445
  24. package/.agent/scripts/lint_runner.js +199 -157
  25. package/.agent/scripts/marathon_harness.js +819 -661
  26. package/.agent/scripts/minify_context.js +115 -100
  27. package/.agent/scripts/mutation_runner.js +321 -280
  28. package/.agent/scripts/prompt_compiler.js +62 -42
  29. package/.agent/scripts/schema_validator.js +373 -280
  30. package/.agent/scripts/security_scan.js +333 -190
  31. package/.agent/scripts/session_manager.js +306 -270
  32. package/.agent/scripts/skill_evolution.js +810 -637
  33. package/.agent/scripts/skill_integrator.js +327 -307
  34. package/.agent/scripts/strengthen_skills.js +203 -193
  35. package/.agent/scripts/swarm_dispatcher.js +558 -457
  36. package/.agent/scripts/test_runner.js +178 -152
  37. package/.agent/scripts/verify_all.js +200 -168
  38. package/.agent/skills/fabel-protocol/SKILL.md +235 -0
  39. package/.agent/skills/thinking-protocol/SKILL.md +27 -0
  40. package/.agent/workflows/generate.md +1 -1
  41. package/.agent/workflows/tribunal-speed.md +1 -1
  42. package/README.md +53 -53
  43. package/bin/mcp-server.js +460 -175
  44. package/bin/tribunal-kit.js +1245 -987
  45. package/bin/wrapper.js +104 -74
  46. package/dist/cli.js +31 -0
  47. package/dist/commands/case.js +23 -0
  48. package/dist/commands/compile.js +84 -0
  49. package/dist/commands/init.js +42 -0
  50. package/dist/commands/learn.js +57 -0
  51. package/dist/commands/memory.js +456 -0
  52. package/package.json +2 -2
  53. package/scripts/benchmark.js +162 -125
  54. package/scripts/changelog.js +196 -168
  55. package/scripts/sync-version.js +94 -81
  56. package/scripts/validate-payload.js +85 -78
@@ -14,221 +14,312 @@
14
14
  * node .agent/scripts/dependency_analyzer.js . --check-unused
15
15
  */
16
16
 
17
- 'use strict';
17
+ "use strict";
18
18
 
19
- const fs = require('fs');
20
- const path = require('path');
19
+ const fs = require("fs");
20
+ const path = require("path");
21
21
 
22
22
  const {
23
- RED, GREEN, YELLOW, BLUE, BOLD, DIM, CYAN, RESET,
24
- banner, sectionHeader, timer, formatMs,
25
- ok, fail, warn, skip,
26
- } = require('./_colors');
27
-
28
- const { walkDir, loadJson, runCommand } = require('./_utils');
29
-
30
- const SOURCE_EXTENSIONS = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
23
+ BOLD,
24
+ DIM,
25
+ CYAN,
26
+ RESET,
27
+ banner,
28
+ sectionHeader,
29
+ timer,
30
+ formatMs,
31
+ ok,
32
+ fail,
33
+ warn,
34
+ skip,
35
+ } = require("./_colors");
36
+
37
+ const { walkDir, loadJson, runCommand } = require("./_utils");
38
+
39
+ const SOURCE_EXTENSIONS = new Set([
40
+ ".ts",
41
+ ".tsx",
42
+ ".js",
43
+ ".jsx",
44
+ ".mjs",
45
+ ".cjs",
46
+ ]);
31
47
 
32
48
  const NODE_BUILTINS = new Set([
33
- "fs", "path", "os", "crypto", "http", "https", "url", "util",
34
- "stream", "events", "child_process", "cluster", "net", "dns",
35
- "tls", "readline", "zlib", "buffer", "querystring", "string_decoder",
36
- "assert", "perf_hooks", "worker_threads", "timers", "v8",
37
- "node:fs", "node:path", "node:os", "node:crypto", "node:http",
38
- "node:https", "node:url", "node:util", "node:stream", "node:events",
39
- "node:child_process", "node:net", "node:dns", "node:tls",
40
- "node:readline", "node:zlib", "node:buffer", "node:assert",
41
- "node:perf_hooks", "node:worker_threads", "node:timers"
49
+ "fs",
50
+ "path",
51
+ "os",
52
+ "crypto",
53
+ "http",
54
+ "https",
55
+ "url",
56
+ "util",
57
+ "stream",
58
+ "events",
59
+ "child_process",
60
+ "cluster",
61
+ "net",
62
+ "dns",
63
+ "tls",
64
+ "readline",
65
+ "zlib",
66
+ "buffer",
67
+ "querystring",
68
+ "string_decoder",
69
+ "assert",
70
+ "perf_hooks",
71
+ "worker_threads",
72
+ "timers",
73
+ "v8",
74
+ "node:fs",
75
+ "node:path",
76
+ "node:os",
77
+ "node:crypto",
78
+ "node:http",
79
+ "node:https",
80
+ "node:url",
81
+ "node:util",
82
+ "node:stream",
83
+ "node:events",
84
+ "node:child_process",
85
+ "node:net",
86
+ "node:dns",
87
+ "node:tls",
88
+ "node:readline",
89
+ "node:zlib",
90
+ "node:buffer",
91
+ "node:assert",
92
+ "node:perf_hooks",
93
+ "node:worker_threads",
94
+ "node:timers",
42
95
  ]);
43
96
 
44
97
  function extractImports(projectRoot) {
45
- const imports = new Set();
46
- const importPatterns = [
47
- /(?:import|export)\s+.*?\s+from\s+["']([^"'.][^"']*)["']/g,
48
- /require\s*\(\s*["']([^"'.][^"']*)["']/g,
49
- /import\s*\(\s*["']([^"'.][^"']*)["']/g
50
- ];
51
-
52
- // Use shared walkDir from _utils.js
53
- const files = walkDir(projectRoot, { extensions: SOURCE_EXTENSIONS });
54
-
55
- for (const fullPath of files) {
56
- let content;
57
- try { content = fs.readFileSync(fullPath, 'utf8'); } catch { continue; }
58
-
59
- for (const pattern of importPatterns) {
60
- // Reset regex state for each file
61
- pattern.lastIndex = 0;
62
- let match;
63
- while ((match = pattern.exec(content)) !== null) {
64
- let pkg = match[1];
65
- if (pkg.startsWith("@")) {
66
- const parts = pkg.split("/");
67
- pkg = parts.length >= 2 ? `${parts[0]}/${parts[1]}` : pkg;
68
- } else {
69
- pkg = pkg.split("/")[0];
70
- }
71
- imports.add(pkg);
72
- }
98
+ const imports = new Set();
99
+ const importPatterns = [
100
+ /(?:import|export)\s+.*?\s+from\s+["']([^"'.][^"']*)["']/g,
101
+ /require\s*\(\s*["']([^"'.][^"']*)["']/g,
102
+ /import\s*\(\s*["']([^"'.][^"']*)["']/g,
103
+ ];
104
+
105
+ // Use shared walkDir from _utils.js
106
+ const files = walkDir(projectRoot, { extensions: SOURCE_EXTENSIONS });
107
+
108
+ for (const fullPath of files) {
109
+ let content;
110
+ try {
111
+ content = fs.readFileSync(fullPath, "utf8");
112
+ } catch {
113
+ continue;
114
+ }
115
+
116
+ for (const pattern of importPatterns) {
117
+ // Reset regex state for each file
118
+ pattern.lastIndex = 0;
119
+ let match;
120
+ while ((match = pattern.exec(content)) !== null) {
121
+ let pkg = match[1];
122
+ if (pkg.startsWith("@")) {
123
+ const parts = pkg.split("/");
124
+ pkg = parts.length >= 2 ? `${parts[0]}/${parts[1]}` : pkg;
125
+ } else {
126
+ pkg = pkg.split("/")[0];
73
127
  }
128
+ imports.add(pkg);
129
+ }
74
130
  }
131
+ }
75
132
 
76
- return imports;
133
+ return imports;
77
134
  }
78
135
 
79
136
  function checkUnused(pkg, usedImports) {
80
- const allDeps = new Set([
81
- ...Object.keys(pkg.dependencies || {}),
82
- ...Object.keys(pkg.devDependencies || {})
83
- ]);
84
-
85
- const implicitPackages = new Set([
86
- "typescript", "eslint", "prettier", "vitest", "jest", "ts-node",
87
- "@types/node", "@types/react", "tailwindcss", "postcss", "autoprefixer",
88
- "nodemon", "tsx", "vite", "next", "webpack", "babel", "@babel/core"
89
- ]);
90
-
91
- const unused = [];
92
- for (const d of allDeps) {
93
- if (!implicitPackages.has(d) && !d.startsWith("@types/") && !usedImports.has(d)) {
94
- unused.push(d);
95
- }
137
+ const allDeps = new Set([
138
+ ...Object.keys(pkg.dependencies || {}),
139
+ ...Object.keys(pkg.devDependencies || {}),
140
+ ]);
141
+
142
+ const implicitPackages = new Set([
143
+ "typescript",
144
+ "eslint",
145
+ "prettier",
146
+ "vitest",
147
+ "jest",
148
+ "ts-node",
149
+ "@types/node",
150
+ "@types/react",
151
+ "tailwindcss",
152
+ "postcss",
153
+ "autoprefixer",
154
+ "nodemon",
155
+ "tsx",
156
+ "vite",
157
+ "next",
158
+ "webpack",
159
+ "babel",
160
+ "@babel/core",
161
+ ]);
162
+
163
+ const unused = [];
164
+ for (const d of allDeps) {
165
+ if (
166
+ !implicitPackages.has(d) &&
167
+ !d.startsWith("@types/") &&
168
+ !usedImports.has(d)
169
+ ) {
170
+ unused.push(d);
96
171
  }
97
- return unused.sort();
172
+ }
173
+ return unused.sort();
98
174
  }
99
175
 
100
176
  function checkPhantom(pkg, usedImports) {
101
- const allDeps = new Set([
102
- ...Object.keys(pkg.dependencies || {}),
103
- ...Object.keys(pkg.devDependencies || {})
104
- ]);
105
-
106
- const phantom = [];
107
- for (const imp of usedImports) {
108
- if (!NODE_BUILTINS.has(imp) && !allDeps.has(imp)) {
109
- phantom.push(imp);
110
- }
177
+ const allDeps = new Set([
178
+ ...Object.keys(pkg.dependencies || {}),
179
+ ...Object.keys(pkg.devDependencies || {}),
180
+ ]);
181
+
182
+ const phantom = [];
183
+ for (const imp of usedImports) {
184
+ if (!NODE_BUILTINS.has(imp) && !allDeps.has(imp)) {
185
+ phantom.push(imp);
111
186
  }
112
- return phantom.sort();
187
+ }
188
+ return phantom.sort();
113
189
  }
114
190
 
115
191
  function runNpmAudit(projectRoot) {
116
- const result = runCommand('npm', ['audit', '--json'], {
117
- cwd: projectRoot,
118
- timeout: 60000,
119
- });
120
-
121
- if (result.status === null && !result.stdout) {
122
- skip("npm not installed — skipping audit");
123
- return true;
192
+ const result = runCommand("npm", ["audit", "--json"], {
193
+ cwd: projectRoot,
194
+ timeout: 60000,
195
+ });
196
+
197
+ if (result.status === null && !result.stdout) {
198
+ skip("npm not installed — skipping audit");
199
+ return true;
200
+ }
201
+
202
+ try {
203
+ const auditData = JSON.parse(result.stdout);
204
+ const vulns =
205
+ (auditData.metadata && auditData.metadata.vulnerabilities) || {};
206
+ const critical = vulns.critical || 0;
207
+ const high = vulns.high || 0;
208
+ const moderate = vulns.moderate || 0;
209
+ const low = vulns.low || 0;
210
+
211
+ if (critical + high > 0) {
212
+ fail(
213
+ `npm audit: ${critical} critical, ${high} high, ${moderate} moderate, ${low} low`,
214
+ );
215
+ return false;
216
+ } else if (moderate + low > 0) {
217
+ warn(`npm audit: ${moderate} moderate, ${low} low vulnerabilities`);
218
+ return true;
219
+ } else {
220
+ ok("npm audit — no known vulnerabilities");
221
+ return true;
124
222
  }
125
-
126
- try {
127
- const auditData = JSON.parse(result.stdout);
128
- const vulns = (auditData.metadata && auditData.metadata.vulnerabilities) || {};
129
- const critical = vulns.critical || 0;
130
- const high = vulns.high || 0;
131
- const moderate = vulns.moderate || 0;
132
- const low = vulns.low || 0;
133
-
134
- if (critical + high > 0) {
135
- fail(`npm audit: ${critical} critical, ${high} high, ${moderate} moderate, ${low} low`);
136
- return false;
137
- } else if (moderate + low > 0) {
138
- warn(`npm audit: ${moderate} moderate, ${low} low vulnerabilities`);
139
- return true;
140
- } else {
141
- ok("npm audit — no known vulnerabilities");
142
- return true;
143
- }
144
- } catch {
145
- if (result.ok) {
146
- ok("npm audit — clean");
147
- return true;
148
- }
149
- fail("npm audit returned errors");
150
- return false;
223
+ } catch {
224
+ if (result.ok) {
225
+ ok("npm audit clean");
226
+ return true;
151
227
  }
228
+ fail("npm audit returned errors");
229
+ return false;
230
+ }
152
231
  }
153
232
 
154
233
  function main() {
155
- const args = process.argv.slice(2);
156
- let targetPath = null;
157
- let auditFlag = false;
158
- let checkUnusedFlag = false;
159
-
160
- for (let i = 0; i < args.length; i++) {
161
- if (args[i] === '--audit') auditFlag = true;
162
- else if (args[i] === '--check-unused') checkUnusedFlag = true;
163
- else if (args[i] === '-h' || args[i] === '--help') {
164
- console.log("Usage: node dependency_analyzer.js <path> [--audit] [--check-unused]");
165
- process.exit(0);
166
- } else if (!args[i].startsWith('-') && !targetPath) {
167
- targetPath = args[i];
168
- }
169
- }
170
-
171
- if (!targetPath) {
172
- console.log("Usage: node dependency_analyzer.js <path> [--audit] [--check-unused]");
173
- process.exit(1);
174
- }
175
-
176
- const projectRoot = path.resolve(targetPath);
177
- if (!fs.existsSync(projectRoot) || !fs.statSync(projectRoot).isDirectory()) {
178
- fail(`Directory not found: ${projectRoot}`);
179
- process.exit(1);
180
- }
181
-
182
- console.log(banner('dependency_analyzer.js', { Project: projectRoot }));
183
-
184
- const pkg = loadJson(path.join(projectRoot, 'package.json'));
185
- if (!pkg) {
186
- skip("No package.json found — dependency analysis requires a Node.js project");
187
- process.exit(0);
234
+ const args = process.argv.slice(2);
235
+ let targetPath = null;
236
+ let auditFlag = false;
237
+ let checkUnusedFlag = false;
238
+
239
+ for (let i = 0; i < args.length; i++) {
240
+ if (args[i] === "--audit") auditFlag = true;
241
+ else if (args[i] === "--check-unused") checkUnusedFlag = true;
242
+ else if (args[i] === "-h" || args[i] === "--help") {
243
+ console.log(
244
+ "Usage: node dependency_analyzer.js <path> [--audit] [--check-unused]",
245
+ );
246
+ process.exit(0);
247
+ } else if (!args[i].startsWith("-") && !targetPath) {
248
+ targetPath = args[i];
188
249
  }
189
-
190
- let issues = 0;
191
- const elapsed = timer();
192
- const usedImports = extractImports(projectRoot);
193
- const scanMs = elapsed();
194
-
195
- console.log(`\n ${DIM}Found ${usedImports.size} unique external imports in ${formatMs(scanMs)}${RESET}`);
196
-
197
- if (!checkUnusedFlag) {
198
- console.log(sectionHeader('Phantom Imports (not in package.json)'));
199
- const phantom = checkPhantom(pkg, usedImports);
200
- if (phantom.length > 0) {
201
- for (const p of phantom) fail(`'${p}' is imported but not in package.json — possible hallucination`);
202
- issues += phantom.length;
203
- } else {
204
- ok("All imports found in package.json");
205
- }
206
- }
207
-
208
- console.log(sectionHeader('Unused Dependencies'));
209
- const unused = checkUnused(pkg, usedImports);
210
- if (unused.length > 0) {
211
- for (const u of unused) warn(`'${u}' is in package.json but never imported — may be unused`);
250
+ }
251
+
252
+ if (!targetPath) {
253
+ console.log(
254
+ "Usage: node dependency_analyzer.js <path> [--audit] [--check-unused]",
255
+ );
256
+ process.exit(1);
257
+ }
258
+
259
+ const projectRoot = path.resolve(targetPath);
260
+ if (!fs.existsSync(projectRoot) || !fs.statSync(projectRoot).isDirectory()) {
261
+ fail(`Directory not found: ${projectRoot}`);
262
+ process.exit(1);
263
+ }
264
+
265
+ console.log(banner("dependency_analyzer.js", { Project: projectRoot }));
266
+
267
+ const pkg = loadJson(path.join(projectRoot, "package.json"));
268
+ if (!pkg) {
269
+ skip(
270
+ "No package.json found — dependency analysis requires a Node.js project",
271
+ );
272
+ process.exit(0);
273
+ }
274
+
275
+ let issues = 0;
276
+ const elapsed = timer();
277
+ const usedImports = extractImports(projectRoot);
278
+ const scanMs = elapsed();
279
+
280
+ console.log(
281
+ `\n ${DIM}Found ${usedImports.size} unique external imports in ${formatMs(scanMs)}${RESET}`,
282
+ );
283
+
284
+ if (!checkUnusedFlag) {
285
+ console.log(sectionHeader("Phantom Imports (not in package.json)"));
286
+ const phantom = checkPhantom(pkg, usedImports);
287
+ if (phantom.length > 0) {
288
+ for (const p of phantom)
289
+ fail(
290
+ `'${p}' is imported but not in package.json — possible hallucination`,
291
+ );
292
+ issues += phantom.length;
212
293
  } else {
213
- ok("No obviously unused dependencies found");
214
- }
215
-
216
- if (auditFlag) {
217
- console.log(sectionHeader('Vulnerability Audit'));
218
- if (!runNpmAudit(projectRoot)) issues += 1;
294
+ ok("All imports found in package.json");
219
295
  }
220
-
221
- console.log(`\n${BOLD}${CYAN}━━━ Dependency Analysis Summary ━━━${RESET}`);
222
- if (issues === 0) {
223
- ok("All dependency checks passed");
224
- } else {
225
- fail(`${issues} issue(s) found review above`);
226
- }
227
- console.log();
228
-
229
- process.exit(issues > 0 ? 1 : 0);
296
+ }
297
+
298
+ console.log(sectionHeader("Unused Dependencies"));
299
+ const unused = checkUnused(pkg, usedImports);
300
+ if (unused.length > 0) {
301
+ for (const u of unused)
302
+ warn(`'${u}' is in package.json but never imported — may be unused`);
303
+ } else {
304
+ ok("No obviously unused dependencies found");
305
+ }
306
+
307
+ if (auditFlag) {
308
+ console.log(sectionHeader("Vulnerability Audit"));
309
+ if (!runNpmAudit(projectRoot)) issues += 1;
310
+ }
311
+
312
+ console.log(`\n${BOLD}${CYAN}━━━ Dependency Analysis Summary ━━━${RESET}`);
313
+ if (issues === 0) {
314
+ ok("All dependency checks passed");
315
+ } else {
316
+ fail(`${issues} issue(s) found — review above`);
317
+ }
318
+ console.log();
319
+
320
+ process.exit(issues > 0 ? 1 : 0);
230
321
  }
231
322
 
232
323
  if (require.main === module) {
233
- main();
324
+ main();
234
325
  }