tribunal-kit 4.4.0 → 4.4.2

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 (90) hide show
  1. package/.agent/agents/api-architect.md +66 -66
  2. package/.agent/agents/db-latency-auditor.md +216 -216
  3. package/.agent/agents/precedence-reviewer.md +250 -250
  4. package/.agent/agents/resilience-reviewer.md +88 -88
  5. package/.agent/agents/schema-reviewer.md +67 -67
  6. package/.agent/agents/throughput-optimizer.md +299 -299
  7. package/.agent/agents/ui-ux-auditor.md +292 -292
  8. package/.agent/agents/vitals-reviewer.md +223 -223
  9. package/.agent/history/architecture-graph.yaml +32 -1
  10. package/.agent/history/graph-cache.json +66 -19
  11. package/.agent/history/snapshots/bin__tribunal-kit.js.json +19 -0
  12. package/.agent/history/snapshots/eslint.config.js.json +9 -0
  13. package/.agent/history/snapshots/migrate_refs.js.json +3 -3
  14. package/.agent/history/snapshots/scripts__changelog.js.json +2 -1
  15. package/.agent/history/snapshots/scripts__sync-version.js.json +2 -1
  16. package/.agent/history/snapshots/scripts__validate-payload.js.json +1 -0
  17. package/.agent/history/snapshots/test__integration__bridges.test.js.json +2 -1
  18. package/.agent/history/snapshots/test__integration__init.test.js.json +1 -0
  19. package/.agent/history/snapshots/test__integration__routing.test.js.json +1 -0
  20. package/.agent/history/snapshots/test__integration__swarm_dispatcher.test.js.json +2 -1
  21. package/.agent/history/snapshots/test__integration__wave2.test.js.json +2 -1
  22. package/.agent/history/snapshots/test__unit__args.test.js.json +11 -1
  23. package/.agent/history/snapshots/test__unit__case_law_manager.test.js.json +1 -0
  24. package/.agent/history/snapshots/test__unit__context_broker.test.js.json +11 -0
  25. package/.agent/history/snapshots/test__unit__copyDir.test.js.json +11 -1
  26. package/.agent/history/snapshots/test__unit__graph_tools.test.js.json +1 -0
  27. package/.agent/history/snapshots/test__unit__inner_loop_validator.test.js.json +11 -0
  28. package/.agent/history/snapshots/test__unit__selfInstall.test.js.json +11 -1
  29. package/.agent/history/snapshots/test__unit__semver.test.js.json +11 -1
  30. package/.agent/history/snapshots/test__unit__swarm_dispatcher.test.js.json +1 -0
  31. package/.agent/scripts/_colors.js +154 -2
  32. package/.agent/scripts/_utils.js +205 -3
  33. package/.agent/scripts/append_flow.js +72 -72
  34. package/.agent/scripts/auto_preview.js +197 -197
  35. package/.agent/scripts/bundle_analyzer.js +90 -119
  36. package/.agent/scripts/case_law_manager.js +18 -13
  37. package/.agent/scripts/checklist.js +100 -88
  38. package/.agent/scripts/colors.js +7 -13
  39. package/.agent/scripts/compress_skills.js +141 -141
  40. package/.agent/scripts/consolidate_skills.js +149 -149
  41. package/.agent/scripts/context_broker.js +605 -609
  42. package/.agent/scripts/deep_compress.js +150 -150
  43. package/.agent/scripts/dependency_analyzer.js +68 -106
  44. package/.agent/scripts/graph_builder.js +341 -311
  45. package/.agent/scripts/graph_visualizer.js +390 -384
  46. package/.agent/scripts/graph_zoom.js +6 -4
  47. package/.agent/scripts/inner_loop_validator.js +445 -465
  48. package/.agent/scripts/lint_runner.js +27 -28
  49. package/.agent/scripts/minify_context.js +100 -100
  50. package/.agent/scripts/mutation_runner.js +280 -280
  51. package/.agent/scripts/patch_skills_meta.js +156 -156
  52. package/.agent/scripts/patch_skills_output.js +244 -244
  53. package/.agent/scripts/schema_validator.js +280 -297
  54. package/.agent/scripts/security_scan.js +37 -64
  55. package/.agent/scripts/session_manager.js +270 -276
  56. package/.agent/scripts/skill_evolution.js +637 -644
  57. package/.agent/scripts/skill_integrator.js +307 -313
  58. package/.agent/scripts/strengthen_skills.js +193 -193
  59. package/.agent/scripts/strip_tribunal.js +47 -47
  60. package/.agent/scripts/swarm_dispatcher.js +360 -360
  61. package/.agent/scripts/test_runner.js +32 -39
  62. package/.agent/scripts/utils.js +10 -25
  63. package/.agent/scripts/verify_all.js +84 -92
  64. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +1 -1
  65. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +1 -1
  66. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +1 -1
  67. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +1 -1
  68. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +1 -1
  69. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +1 -1
  70. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +1 -1
  71. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +1 -1
  72. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +1 -1
  73. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +1 -1
  74. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +1 -1
  75. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +1 -1
  76. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +1 -1
  77. package/.agent/skills/doc.md +1 -1
  78. package/.agent/skills/knowledge-graph/SKILL.md +52 -52
  79. package/.agent/skills/ui-ux-pro-max/SKILL.md +562 -562
  80. package/.agent/workflows/generate.md +183 -183
  81. package/.agent/workflows/tribunal-speed.md +183 -183
  82. package/README.md +1 -1
  83. package/bin/tribunal-kit.js +76 -87
  84. package/package.json +6 -3
  85. package/scripts/changelog.js +167 -167
  86. package/scripts/sync-version.js +81 -81
  87. package/.agent/history/architecture-explorer.html +0 -352
  88. package/.agent/scripts/__pycache__/_colors.cpython-311.pyc +0 -0
  89. package/.agent/scripts/__pycache__/_utils.cpython-311.pyc +0 -0
  90. package/.agent/scripts/__pycache__/case_law_manager.cpython-311.pyc +0 -0
@@ -27,21 +27,15 @@
27
27
  const fs = require('fs');
28
28
  const path = require('path');
29
29
 
30
- // ━━━ ANSI colors ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
31
- const RED = '\x1b[91m';
32
- const GREEN = '\x1b[92m';
33
- const YELLOW = '\x1b[93m';
34
- const BLUE = '\x1b[94m';
35
- const MAGENTA = '\x1b[95m';
36
- const BOLD = '\x1b[1m';
37
- const RESET = '\x1b[0m';
38
-
39
- const SOURCE_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.java', '.rb']);
40
- const SKIP_DIRS = new Set([
41
- 'node_modules', '.git', 'dist', 'build', '__pycache__', '.agent',
42
- '.next', 'vendor', 'coverage', 'lcov-report', '.nyc_output',
43
- 'test-results', '.jest-cache',
44
- ]);
30
+ const {
31
+ RED, GREEN, YELLOW, BLUE, MAGENTA, BOLD, DIM, CYAN, RESET,
32
+ banner, sectionHeader, timer, formatMs,
33
+ } = require('./_colors');
34
+
35
+ const { walkDir, SOURCE_EXTENSIONS } = require('./_utils');
36
+
37
+ // ── Security-specific source extensions (broader than default) ──────────────
38
+ const SCAN_EXTENSIONS = new Set([...SOURCE_EXTENSIONS, '.py', '.go', '.java', '.rb']);
45
39
 
46
40
  const SEVERITY_COLORS = {
47
41
  critical: RED + BOLD,
@@ -135,36 +129,11 @@ function scanFile(filepath, projectRoot) {
135
129
  }
136
130
 
137
131
 
138
- /**
139
- * Recursively walk a directory yield file paths.
140
- * @param {string} dir - Directory to walk.
141
- * @param {Set<string>} skipDirs - Directory names to skip.
142
- * @returns {string[]} Array of file paths.
143
- */
144
- function walkDir(dir, skipDirs) {
145
- const results = [];
146
- let entries;
147
- try {
148
- entries = fs.readdirSync(dir, { withFileTypes: true });
149
- } catch {
150
- return results;
151
- }
152
-
153
- for (const entry of entries) {
154
- if (entry.isDirectory()) {
155
- if (!skipDirs.has(entry.name)) {
156
- results.push(...walkDir(path.join(dir, entry.name), skipDirs));
157
- }
158
- } else if (entry.isFile()) {
159
- results.push(path.join(dir, entry.name));
160
- }
161
- }
162
- return results;
163
- }
164
-
165
-
166
132
  /**
167
133
  * Scan all source files in a directory.
134
+ * PERFORMANCE FIX: Uses shared walkDir from _utils.js and pushes findings
135
+ * individually instead of using spread operator (eliminates O(n²) array growth).
136
+ *
168
137
  * @param {string} projectRoot - Root directory to scan.
169
138
  * @param {string[]|null} targetFiles - Specific files to scan, or null for full scan.
170
139
  * @returns {Array} Array of finding objects.
@@ -176,17 +145,20 @@ function scanDirectory(projectRoot, targetFiles) {
176
145
  for (const fpath of targetFiles) {
177
146
  const absPath = path.isAbsolute(fpath) ? fpath : path.join(projectRoot, fpath);
178
147
  if (fs.existsSync(absPath) && fs.statSync(absPath).isFile()) {
179
- allFindings.push(...scanFile(absPath, projectRoot));
148
+ // FIX: Push individually instead of spread to avoid O()
149
+ const fileFindings = scanFile(absPath, projectRoot);
150
+ for (const f of fileFindings) allFindings.push(f);
180
151
  }
181
152
  }
182
153
  return allFindings;
183
154
  }
184
155
 
185
- const files = walkDir(projectRoot, SKIP_DIRS);
156
+ const files = walkDir(projectRoot, { extensions: SCAN_EXTENSIONS });
157
+
186
158
  for (const filepath of files) {
187
- const ext = path.extname(filepath);
188
- if (!SOURCE_EXTENSIONS.has(ext)) continue;
189
- allFindings.push(...scanFile(filepath, projectRoot));
159
+ // FIX: Push individually instead of spread to avoid O()
160
+ const fileFindings = scanFile(filepath, projectRoot);
161
+ for (const f of fileFindings) allFindings.push(f);
190
162
  }
191
163
 
192
164
  return allFindings;
@@ -223,12 +195,9 @@ function printFindings(findings, minSeverity) {
223
195
  }
224
196
 
225
197
 
226
- /**
227
- * Parse CLI arguments manually (no external dependencies).
228
- */
229
- function parseArgs(argv) {
198
+ function main() {
230
199
  const args = { path: null, severity: 'low', files: null };
231
- const raw = argv.slice(2);
200
+ const raw = process.argv.slice(2);
232
201
 
233
202
  for (let i = 0; i < raw.length; i++) {
234
203
  if (raw[i] === '--severity' && raw[i + 1]) {
@@ -242,12 +211,6 @@ function parseArgs(argv) {
242
211
  args.path = raw[i];
243
212
  }
244
213
  }
245
- return args;
246
- }
247
-
248
-
249
- function main() {
250
- const args = parseArgs(process.argv);
251
214
 
252
215
  if (!args.path) {
253
216
  console.error(`Usage: node security_scan.js <path> [--severity critical|high|medium|low] [--files ...]`);
@@ -260,20 +223,27 @@ function main() {
260
223
  process.exit(1);
261
224
  }
262
225
 
263
- console.log(`${BOLD}Tribunal — security_scan.js${RESET}`);
264
- console.log(`Project: ${projectRoot}`);
265
- console.log(`Severity filter: ${args.severity}+`);
226
+ console.log(banner('security_scan.js', {
227
+ Project: projectRoot,
228
+ Severity: `${args.severity}+`,
229
+ }));
266
230
 
231
+ const elapsed = timer();
267
232
  const findings = scanDirectory(projectRoot, args.files);
233
+ const scanMs = elapsed();
234
+
268
235
  const count = printFindings(findings, args.severity);
269
236
 
270
- // Summary
271
- console.log(`\n${BOLD}━━━ Security Scan Summary ━━━${RESET}`);
237
+ // ━━━ Summary ━━━
238
+ console.log(`\n${BOLD}${CYAN}━━━ Security Scan Summary ━━━${RESET}`);
239
+
272
240
  const bySeverity = {};
273
241
  for (const f of findings) {
274
242
  bySeverity[f.severity] = (bySeverity[f.severity] || 0) + 1;
275
243
  }
276
244
 
245
+ const uniqueFiles = new Set(findings.map(f => f.file)).size;
246
+
277
247
  for (const sev of ['critical', 'high', 'medium', 'low']) {
278
248
  const c = bySeverity[sev] || 0;
279
249
  if (c > 0) {
@@ -282,6 +252,8 @@ function main() {
282
252
  }
283
253
  }
284
254
 
255
+ console.log(`\n ${DIM}Scanned in ${formatMs(scanMs)} — ${findings.length} findings across ${uniqueFiles} file(s)${RESET}`);
256
+
285
257
  if (count === 0) {
286
258
  console.log(` ${GREEN}✅ No issues found — scan passed${RESET}`);
287
259
  } else {
@@ -290,6 +262,7 @@ function main() {
290
262
  console.log(`\n ${RED}${BOLD}⚠️ ${criticalHigh} critical/high issue(s) require immediate attention${RESET}`);
291
263
  }
292
264
  }
265
+ console.log();
293
266
 
294
267
  process.exit((bySeverity.critical || 0) > 0 ? 1 : 0);
295
268
  }