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
@@ -8,24 +8,46 @@
8
8
  * const { findAgentDir, walkDir, loadJson } = require('./_utils');
9
9
  */
10
10
 
11
- 'use strict';
11
+ "use strict";
12
12
 
13
- const fs = require('fs');
14
- const path = require('path');
15
- const { RED, RESET } = require('./_colors');
13
+ const fs = require("fs");
14
+ const path = require("path");
15
+ const { RED, RESET } = require("./_colors");
16
16
 
17
17
  // ── Default Skip Directories ────────────────────────────────────────────────
18
18
  const DEFAULT_SKIP_DIRS = new Set([
19
- 'node_modules', '.git', 'dist', 'build', '.next', '.agent',
20
- '__pycache__', '.venv', 'venv', 'coverage', '.turbo',
21
- '.svelte-kit', '.nuxt', '.output',
19
+ "node_modules",
20
+ ".git",
21
+ "dist",
22
+ "build",
23
+ ".next",
24
+ ".agent",
25
+ "__pycache__",
26
+ ".venv",
27
+ "venv",
28
+ "coverage",
29
+ ".turbo",
30
+ ".svelte-kit",
31
+ ".nuxt",
32
+ ".output",
22
33
  ]);
23
34
 
24
35
  // ── Default Source Extensions ───────────────────────────────────────────────
25
36
  const SOURCE_EXTENSIONS = new Set([
26
- '.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs',
27
- '.py', '.rs', '.go', '.java', '.cs', '.rb',
28
- '.vue', '.svelte',
37
+ ".ts",
38
+ ".tsx",
39
+ ".js",
40
+ ".jsx",
41
+ ".mjs",
42
+ ".cjs",
43
+ ".py",
44
+ ".rs",
45
+ ".go",
46
+ ".java",
47
+ ".cs",
48
+ ".rb",
49
+ ".vue",
50
+ ".svelte",
29
51
  ]);
30
52
 
31
53
  // ── Agent Directory Discovery ───────────────────────────────────────────────
@@ -36,19 +58,21 @@ const SOURCE_EXTENSIONS = new Set([
36
58
  * @returns {string} Absolute path to the .agent directory.
37
59
  */
38
60
  function findAgentDir(startDir) {
39
- let current = path.resolve(startDir || process.cwd());
40
- const root = path.parse(current).root;
61
+ let current = path.resolve(startDir || process.cwd());
62
+ const root = path.parse(current).root;
41
63
 
42
- while (current !== root) {
43
- const candidate = path.join(current, '.agent');
44
- if (fs.existsSync(candidate) && fs.statSync(candidate).isDirectory()) {
45
- return candidate;
46
- }
47
- current = path.dirname(current);
64
+ while (current !== root) {
65
+ const candidate = path.join(current, ".agent");
66
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isDirectory()) {
67
+ return candidate;
48
68
  }
69
+ current = path.dirname(current);
70
+ }
49
71
 
50
- console.error(`${RED}✖ Error: '.agent' directory not found. Please run 'npx tribunal-kit init' first.${RESET}`);
51
- process.exit(1);
72
+ console.error(
73
+ `${RED}✖ Error: '.agent' directory not found. Please run 'npx tribunal-kit init' first.${RESET}`,
74
+ );
75
+ process.exit(1);
52
76
  }
53
77
 
54
78
  // ── Package.json Helpers ────────────────────────────────────────────────────
@@ -59,7 +83,7 @@ function findAgentDir(startDir) {
59
83
  * @returns {boolean}
60
84
  */
61
85
  function hasNpm(dir) {
62
- return fs.existsSync(path.join(dir, 'package.json'));
86
+ return fs.existsSync(path.join(dir, "package.json"));
63
87
  }
64
88
 
65
89
  /**
@@ -68,11 +92,11 @@ function hasNpm(dir) {
68
92
  * @returns {object|null}
69
93
  */
70
94
  function loadJson(filePath) {
71
- try {
72
- return JSON.parse(fs.readFileSync(filePath, 'utf8'));
73
- } catch {
74
- return null;
75
- }
95
+ try {
96
+ return JSON.parse(fs.readFileSync(filePath, "utf8"));
97
+ } catch {
98
+ return null;
99
+ }
76
100
  }
77
101
 
78
102
  // ── Filesystem Walking ──────────────────────────────────────────────────────
@@ -89,39 +113,39 @@ function loadJson(filePath) {
89
113
  * @returns {string[]} Array of absolute file paths.
90
114
  */
91
115
  function walkDir(dir, opts = {}) {
92
- const skipDirs = opts.skipDirs || DEFAULT_SKIP_DIRS;
93
- const extensions = opts.extensions || null;
94
- const filter = opts.filter || null;
95
- const results = [];
96
-
97
- function _walk(currentDir) {
98
- let entries;
99
- try {
100
- entries = fs.readdirSync(currentDir, { withFileTypes: true });
101
- } catch {
102
- return;
103
- }
116
+ const skipDirs = opts.skipDirs || DEFAULT_SKIP_DIRS;
117
+ const extensions = opts.extensions || null;
118
+ const filter = opts.filter || null;
119
+ const results = [];
104
120
 
105
- for (const entry of entries) {
106
- const fullPath = path.join(currentDir, entry.name);
107
-
108
- if (entry.isDirectory()) {
109
- if (!skipDirs.has(entry.name)) {
110
- _walk(fullPath);
111
- }
112
- } else if (entry.isFile()) {
113
- if (extensions) {
114
- const ext = path.extname(entry.name);
115
- if (!extensions.has(ext)) continue;
116
- }
117
- if (filter && !filter(fullPath)) continue;
118
- results.push(fullPath);
119
- }
121
+ function _walk(currentDir) {
122
+ let entries;
123
+ try {
124
+ entries = fs.readdirSync(currentDir, { withFileTypes: true });
125
+ } catch {
126
+ return;
127
+ }
128
+
129
+ for (const entry of entries) {
130
+ const fullPath = path.join(currentDir, entry.name);
131
+
132
+ if (entry.isDirectory()) {
133
+ if (!skipDirs.has(entry.name)) {
134
+ _walk(fullPath);
135
+ }
136
+ } else if (entry.isFile()) {
137
+ if (extensions) {
138
+ const ext = path.extname(entry.name);
139
+ if (!extensions.has(ext)) continue;
120
140
  }
141
+ if (filter && !filter(fullPath)) continue;
142
+ results.push(fullPath);
143
+ }
121
144
  }
145
+ }
122
146
 
123
- _walk(dir);
124
- return results;
147
+ _walk(dir);
148
+ return results;
125
149
  }
126
150
 
127
151
  /**
@@ -131,17 +155,22 @@ function walkDir(dir, opts = {}) {
131
155
  * @returns {number}
132
156
  */
133
157
  function countFiles(dir, skipDirs = DEFAULT_SKIP_DIRS) {
134
- let count = 0;
135
- function _count(d) {
136
- let entries;
137
- try { entries = fs.readdirSync(d, { withFileTypes: true }); } catch { return; }
138
- for (const e of entries) {
139
- if (e.isDirectory() && !skipDirs.has(e.name)) _count(path.join(d, e.name));
140
- else if (e.isFile()) count++;
141
- }
158
+ let count = 0;
159
+ function _count(d) {
160
+ let entries;
161
+ try {
162
+ entries = fs.readdirSync(d, { withFileTypes: true });
163
+ } catch {
164
+ return;
142
165
  }
143
- _count(dir);
144
- return count;
166
+ for (const e of entries) {
167
+ if (e.isDirectory() && !skipDirs.has(e.name))
168
+ _count(path.join(d, e.name));
169
+ else if (e.isFile()) count++;
170
+ }
171
+ }
172
+ _count(dir);
173
+ return count;
145
174
  }
146
175
 
147
176
  // ── CLI Argument Parsing ────────────────────────────────────────────────────
@@ -155,44 +184,44 @@ function countFiles(dir, skipDirs = DEFAULT_SKIP_DIRS) {
155
184
  * @returns {{ flags: object, positional: string[] }}
156
185
  */
157
186
  function parseArgs(argv, schema = {}) {
158
- const flags = {};
159
- const positional = [];
187
+ const flags = {};
188
+ const positional = [];
160
189
 
161
- // Set defaults
162
- for (const [key, def] of Object.entries(schema)) {
163
- flags[key] = def.default ?? (def.type === 'boolean' ? false : null);
164
- }
190
+ // Set defaults
191
+ for (const [key, def] of Object.entries(schema)) {
192
+ flags[key] = def.default ?? (def.type === "boolean" ? false : null);
193
+ }
165
194
 
166
- for (let i = 0; i < argv.length; i++) {
167
- const arg = argv[i];
195
+ for (let i = 0; i < argv.length; i++) {
196
+ const arg = argv[i];
168
197
 
169
- if (arg === '-h' || arg === '--help') {
170
- flags.help = true;
171
- continue;
172
- }
198
+ if (arg === "-h" || arg === "--help") {
199
+ flags.help = true;
200
+ continue;
201
+ }
173
202
 
174
- if (arg.startsWith('--')) {
175
- const flagName = arg.slice(2);
176
- const schemaDef = schema[flagName];
177
-
178
- if (schemaDef && schemaDef.type === 'boolean') {
179
- flags[flagName] = true;
180
- } else if (schemaDef && i + 1 < argv.length) {
181
- const val = argv[++i];
182
- flags[flagName] = schemaDef.type === 'number' ? Number(val) : val;
183
- } else {
184
- // Unknown flag, store as boolean
185
- flags[flagName] = true;
186
- }
187
- } else if (arg.startsWith('-') && arg.length === 2) {
188
- // Short flag — treat as boolean
189
- flags[arg.slice(1)] = true;
190
- } else {
191
- positional.push(arg);
192
- }
203
+ if (arg.startsWith("--")) {
204
+ const flagName = arg.slice(2);
205
+ const schemaDef = schema[flagName];
206
+
207
+ if (schemaDef && schemaDef.type === "boolean") {
208
+ flags[flagName] = true;
209
+ } else if (schemaDef && i + 1 < argv.length) {
210
+ const val = argv[++i];
211
+ flags[flagName] = schemaDef.type === "number" ? Number(val) : val;
212
+ } else {
213
+ // Unknown flag, store as boolean
214
+ flags[flagName] = true;
215
+ }
216
+ } else if (arg.startsWith("-") && arg.length === 2) {
217
+ // Short flag — treat as boolean
218
+ flags[arg.slice(1)] = true;
219
+ } else {
220
+ positional.push(arg);
193
221
  }
222
+ }
194
223
 
195
- return { flags, positional };
224
+ return { flags, positional };
196
225
  }
197
226
 
198
227
  // ── Command Runner ──────────────────────────────────────────────────────────
@@ -207,38 +236,44 @@ function parseArgs(argv, schema = {}) {
207
236
  * @returns {{ status: number, stdout: string, stderr: string, ok: boolean }}
208
237
  */
209
238
  function runCommand(cmd, args = [], opts = {}) {
210
- const { spawnSync } = require('child_process');
211
- const executable = process.platform === 'win32' && !cmd.endsWith('.cmd') && !cmd.includes(path.sep)
212
- ? `${cmd}.cmd`
213
- : cmd;
214
-
215
- const result = spawnSync(executable, args, {
216
- encoding: 'utf8',
217
- timeout: opts.timeout || 120000,
218
- cwd: opts.cwd || process.cwd(),
219
- shell: process.platform === 'win32',
220
- stdio: opts.stdio || 'pipe',
221
- ...opts,
222
- });
223
-
224
- return {
225
- status: result.status ?? 1,
226
- stdout: (result.stdout || '').toString(),
227
- stderr: (result.stderr || '').toString(),
228
- ok: result.status === 0,
229
- };
239
+ const { spawnSync } = require("child_process");
240
+ const executable =
241
+ process.platform === "win32" &&
242
+ !cmd.endsWith(".cmd") &&
243
+ !cmd.includes(path.sep)
244
+ ? `${cmd}.cmd`
245
+ : cmd;
246
+
247
+ const result = spawnSync(executable, args, {
248
+ encoding: "utf8",
249
+ timeout: opts.timeout || 120000,
250
+ cwd: opts.cwd || process.cwd(),
251
+ shell: process.platform === "win32",
252
+ stdio: opts.stdio || "pipe",
253
+ ...opts,
254
+ });
255
+
256
+ return {
257
+ status: result.status ?? 1,
258
+ stdout: (result.stdout || "").toString(),
259
+ stderr: (result.stderr || "").toString(),
260
+ ok: result.status === 0,
261
+ };
230
262
  }
231
263
 
232
264
  module.exports = {
233
- // Agent discovery
234
- findAgentDir,
235
- // Package.json
236
- hasNpm, loadJson,
237
- // Filesystem
238
- walkDir, countFiles,
239
- DEFAULT_SKIP_DIRS, SOURCE_EXTENSIONS,
240
- // CLI
241
- parseArgs,
242
- // Commands
243
- runCommand,
265
+ // Agent discovery
266
+ findAgentDir,
267
+ // Package.json
268
+ hasNpm,
269
+ loadJson,
270
+ // Filesystem
271
+ walkDir,
272
+ countFiles,
273
+ DEFAULT_SKIP_DIRS,
274
+ SOURCE_EXTENSIONS,
275
+ // CLI
276
+ parseArgs,
277
+ // Commands
278
+ runCommand,
244
279
  };