tribunal-kit 5.7.0 → 5.8.1

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 (59) 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/project-planner.md +5 -0
  7. package/.agent/agents/security-auditor.md +13 -0
  8. package/.agent/agents/ui-ux-auditor.md +7 -31
  9. package/.agent/history/memory/.memory.idx +1693 -0
  10. package/.agent/history/memory/MEMORY.md +123 -0
  11. package/.agent/routing_index.json +694 -714
  12. package/.agent/rules/GEMINI.md +88 -13
  13. package/.agent/scripts/_colors.js +131 -89
  14. package/.agent/scripts/_utils.js +163 -128
  15. package/.agent/scripts/auto_preview.js +207 -197
  16. package/.agent/scripts/bundle_analyzer.js +227 -192
  17. package/.agent/scripts/case_law_manager.js +991 -689
  18. package/.agent/scripts/checklist.js +233 -190
  19. package/.agent/scripts/context_broker.js +930 -605
  20. package/.agent/scripts/dependency_analyzer.js +275 -184
  21. package/.agent/scripts/graph_builder.js +412 -341
  22. package/.agent/scripts/graph_visualizer.js +392 -390
  23. package/.agent/scripts/graph_zoom.js +198 -156
  24. package/.agent/scripts/inner_loop_validator.js +523 -445
  25. package/.agent/scripts/lint_runner.js +199 -157
  26. package/.agent/scripts/marathon_harness.js +819 -661
  27. package/.agent/scripts/minify_context.js +115 -100
  28. package/.agent/scripts/mutation_runner.js +321 -280
  29. package/.agent/scripts/prompt_compiler.js +62 -42
  30. package/.agent/scripts/schema_validator.js +373 -280
  31. package/.agent/scripts/security_scan.js +333 -190
  32. package/.agent/scripts/session_manager.js +306 -270
  33. package/.agent/scripts/skill_evolution.js +810 -637
  34. package/.agent/scripts/skill_integrator.js +327 -307
  35. package/.agent/scripts/strengthen_skills.js +203 -193
  36. package/.agent/scripts/swarm_dispatcher.js +558 -457
  37. package/.agent/scripts/test_runner.js +178 -152
  38. package/.agent/scripts/verify_all.js +200 -168
  39. package/.agent/skills/fabel-protocol/SKILL.md +271 -0
  40. package/.agent/skills/thinking-protocol/SKILL.md +27 -0
  41. package/.agent/workflows/generate.md +2 -1
  42. package/.agent/workflows/tribunal-full.md +4 -3
  43. package/.agent/workflows/tribunal-speed.md +1 -1
  44. package/README.md +184 -58
  45. package/bin/mcp-server.js +496 -173
  46. package/bin/tribunal-kit.js +1245 -987
  47. package/bin/wrapper.js +108 -74
  48. package/dist/cli.js +44 -0
  49. package/dist/commands/align.js +201 -0
  50. package/dist/commands/case.js +23 -0
  51. package/dist/commands/compile.js +84 -0
  52. package/dist/commands/init.js +42 -0
  53. package/dist/commands/learn.js +57 -0
  54. package/dist/commands/memory.js +456 -0
  55. package/package.json +22 -10
  56. package/scripts/benchmark.js +162 -125
  57. package/scripts/changelog.js +196 -168
  58. package/scripts/sync-version.js +94 -81
  59. package/scripts/validate-payload.js +85 -78
@@ -9,178 +9,204 @@
9
9
  * node .agent/scripts/test_runner.js . --file src/utils.test.ts
10
10
  */
11
11
 
12
- 'use strict';
12
+ "use strict";
13
13
 
14
- const fs = require('fs');
15
- const path = require('path');
16
- const { spawnSync } = require('child_process');
14
+ const fs = require("fs");
15
+ const path = require("path");
16
+ const { spawnSync } = require("child_process");
17
17
 
18
18
  const {
19
- RED, GREEN, YELLOW, BLUE, BOLD, DIM, CYAN, RESET,
20
- banner, sectionHeader, timer, formatMs,
21
- ok, fail, skip,
22
- } = require('./_colors');
23
-
24
- const { loadJson } = require('./_utils');
19
+ RED,
20
+ GREEN,
21
+ BOLD,
22
+ DIM,
23
+ CYAN,
24
+ RESET,
25
+ banner,
26
+ sectionHeader,
27
+ timer,
28
+ formatMs,
29
+ ok,
30
+ fail,
31
+ skip,
32
+ } = require("./_colors");
33
+
34
+ const { loadJson } = require("./_utils");
25
35
 
26
36
  function runTests(label, cmd, cwd) {
27
- const elapsed = timer();
28
- try {
29
- const executable = process.platform === 'win32' && (cmd[0] === 'npx' || cmd[0] === 'npm') ? `${cmd[0]}.cmd` : cmd[0];
30
- const result = spawnSync(executable, cmd.slice(1), {
31
- cwd,
32
- encoding: 'utf8',
33
- timeout: 300000, // 5m
34
- shell: process.platform === 'win32'
35
- });
36
-
37
- const ms = elapsed();
38
-
39
- if (result.error && !result.stdout && !result.stderr) {
40
- console.log(` Error: ${result.error.message}`);
41
- }
42
- const out = result.stdout ? result.stdout.toString() : '';
43
- const err = result.stderr ? result.stderr.toString() : '';
44
- const output = (out + "\n" + err).trim();
45
- if (output) {
46
- for (const line of output.split("\n")) {
47
- console.log(` ${line}`);
48
- }
49
- }
50
-
51
- if (result.status === 0) {
52
- ok(`${label} — all tests passed ${DIM}(${formatMs(ms)})${RESET}`);
53
- return true;
54
- }
55
-
56
- fail(`${label} — test failures detected ${DIM}(${formatMs(ms)})${RESET}`);
57
- return false;
58
- } catch {
59
- skip(`${label} — tool not installed`);
60
- return true;
61
- }
62
- }
63
-
64
- function detectTestFramework(projectRoot) {
65
- const pkg = loadJson(path.join(projectRoot, "package.json"));
66
- if (pkg) {
67
- const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
68
- const scripts = pkg.scripts || {};
69
-
70
- if (deps.vitest) return "vitest";
71
- if (deps.jest) return "jest";
72
- if (deps.mocha) return "mocha";
73
- if (scripts.test) return "npm-test";
37
+ const elapsed = timer();
38
+ try {
39
+ const executable =
40
+ process.platform === "win32" && (cmd[0] === "npx" || cmd[0] === "npm")
41
+ ? `${cmd[0]}.cmd`
42
+ : cmd[0];
43
+ const result = spawnSync(executable, cmd.slice(1), {
44
+ cwd,
45
+ encoding: "utf8",
46
+ timeout: 300000, // 5m
47
+ shell: process.platform === "win32",
48
+ });
49
+
50
+ const ms = elapsed();
51
+
52
+ if (result.error && !result.stdout && !result.stderr) {
53
+ console.log(` Error: ${result.error.message}`);
74
54
  }
75
-
76
- if (fs.existsSync(path.join(projectRoot, "pytest.ini")) ||
77
- fs.existsSync(path.join(projectRoot, "pyproject.toml")) ||
78
- fs.existsSync(path.join(projectRoot, "conftest.py"))) {
79
- return "pytest";
55
+ const out = result.stdout ? result.stdout.toString() : "";
56
+ const err = result.stderr ? result.stderr.toString() : "";
57
+ const output = (out + "\n" + err).trim();
58
+ if (output) {
59
+ for (const line of output.split("\n")) {
60
+ console.log(` ${line}`);
61
+ }
80
62
  }
81
63
 
82
- // Go
83
- function hasGoTests(dir) {
84
- let items;
85
- try { items = fs.readdirSync(dir, { withFileTypes: true }); } catch { return false; }
86
- for (const item of items) {
87
- if (item.isDirectory() && !["node_modules", ".git"].includes(item.name)) {
88
- if (hasGoTests(path.join(dir, item.name))) return true;
89
- } else if (item.name.endsWith("_test.go")) {
90
- return true;
91
- }
92
- }
93
- return false;
64
+ if (result.status === 0) {
65
+ ok(`${label} — all tests passed ${DIM}(${formatMs(ms)})${RESET}`);
66
+ return true;
94
67
  }
95
68
 
96
- if (hasGoTests(projectRoot)) return "go";
97
-
98
- return null;
69
+ fail(`${label} — test failures detected ${DIM}(${formatMs(ms)})${RESET}`);
70
+ return false;
71
+ } catch {
72
+ skip(`${label} — tool not installed`);
73
+ return true;
74
+ }
99
75
  }
100
76
 
101
- function main() {
102
- const args = process.argv.slice(2);
103
- let targetPath = null;
104
- let coverageFlag = false;
105
- let watchFlag = false;
106
- let fileArg = null;
107
-
108
- let i = 0;
109
- while (i < args.length) {
110
- if (args[i] === '--coverage') coverageFlag = true;
111
- else if (args[i] === '--watch') watchFlag = true;
112
- else if (args[i] === '--file' && i + 1 < args.length) fileArg = args[++i];
113
- else if (!targetPath && !args[i].startsWith('-')) targetPath = args[i];
114
- i++;
115
- }
116
-
117
- if (!targetPath) {
118
- console.log("Usage: node test_runner.js <path> [--coverage] [--watch] [--file <filepath>]");
119
- process.exit(1);
77
+ function detectTestFramework(projectRoot) {
78
+ const pkg = loadJson(path.join(projectRoot, "package.json"));
79
+ if (pkg) {
80
+ const deps = {
81
+ ...(pkg.dependencies || {}),
82
+ ...(pkg.devDependencies || {}),
83
+ };
84
+ const scripts = pkg.scripts || {};
85
+
86
+ if (deps.vitest) return "vitest";
87
+ if (deps.jest) return "jest";
88
+ if (deps.mocha) return "mocha";
89
+ if (scripts.test) return "npm-test";
90
+ }
91
+
92
+ if (
93
+ fs.existsSync(path.join(projectRoot, "pytest.ini")) ||
94
+ fs.existsSync(path.join(projectRoot, "pyproject.toml")) ||
95
+ fs.existsSync(path.join(projectRoot, "conftest.py"))
96
+ ) {
97
+ return "pytest";
98
+ }
99
+
100
+ // Go
101
+ function hasGoTests(dir) {
102
+ let items;
103
+ try {
104
+ items = fs.readdirSync(dir, { withFileTypes: true });
105
+ } catch {
106
+ return false;
120
107
  }
121
-
122
- const projectRoot = path.resolve(targetPath);
123
- if (!fs.existsSync(projectRoot) || !fs.statSync(projectRoot).isDirectory()) {
124
- fail(`Directory not found: ${projectRoot}`);
125
- process.exit(1);
108
+ for (const item of items) {
109
+ if (item.isDirectory() && !["node_modules", ".git"].includes(item.name)) {
110
+ if (hasGoTests(path.join(dir, item.name))) return true;
111
+ } else if (item.name.endsWith("_test.go")) {
112
+ return true;
113
+ }
126
114
  }
115
+ return false;
116
+ }
127
117
 
128
- const framework = detectTestFramework(projectRoot);
129
- console.log(banner('test_runner.js', {
130
- Project: projectRoot,
131
- Framework: framework || 'none detected',
132
- }));
118
+ if (hasGoTests(projectRoot)) return "go";
133
119
 
134
- if (!framework) {
135
- skip("No test framework detected in this project");
136
- process.exit(0);
137
- }
138
-
139
- console.log(sectionHeader(`Running tests (${framework})`));
140
-
141
- let cmd = [];
142
- let passed = true;
143
-
144
- if (["vitest", "jest", "mocha", "npm-test"].includes(framework)) {
145
- if (framework === "vitest") {
146
- cmd = ["npx", "vitest", "run"];
147
- if (coverageFlag) cmd.push("--coverage");
148
- if (watchFlag) cmd = ["npx", "vitest"];
149
- if (fileArg) cmd.push(fileArg);
150
- } else if (framework === "jest") {
151
- cmd = ["npx", "jest"];
152
- if (coverageFlag) cmd.push("--coverage");
153
- if (watchFlag) cmd.push("--watch");
154
- if (fileArg) cmd.push(fileArg);
155
- } else {
156
- cmd = ["npm", "test", "--", "--passWithNoTests"];
157
- if (coverageFlag) cmd.push("--coverage");
158
- if (fileArg) cmd.push(fileArg);
159
- }
160
- passed = runTests(framework, cmd, projectRoot);
161
- } else if (framework === "pytest") {
162
- cmd = ["python", "-m", "pytest", "-v"];
163
- if (coverageFlag) cmd.push("--cov", "--cov-report=term-missing");
164
- if (watchFlag) cmd = ["python", "-m", "pytest-watch", "--", "-v"];
165
- if (fileArg) cmd.push(fileArg);
166
- passed = runTests("pytest", cmd, projectRoot);
167
- } else if (framework === "go") {
168
- cmd = ["go", "test", "./...", "-v"];
169
- if (coverageFlag) cmd.push("-cover");
170
- if (fileArg) cmd = ["go", "test", "-v", "-run", fileArg];
171
- passed = runTests("go test", cmd, projectRoot);
172
- }
120
+ return null;
121
+ }
173
122
 
174
- console.log(`\n${BOLD}${CYAN}━━━ Test Summary ━━━${RESET}`);
175
- if (passed) {
176
- console.log(`\n${GREEN}${BOLD} Tests passed (${framework}).${RESET}\n`);
123
+ function main() {
124
+ const args = process.argv.slice(2);
125
+ let targetPath = null;
126
+ let coverageFlag = false;
127
+ let watchFlag = false;
128
+ let fileArg = null;
129
+
130
+ let i = 0;
131
+ while (i < args.length) {
132
+ if (args[i] === "--coverage") coverageFlag = true;
133
+ else if (args[i] === "--watch") watchFlag = true;
134
+ else if (args[i] === "--file" && i + 1 < args.length) fileArg = args[++i];
135
+ else if (!targetPath && !args[i].startsWith("-")) targetPath = args[i];
136
+ i++;
137
+ }
138
+
139
+ if (!targetPath) {
140
+ console.log(
141
+ "Usage: node test_runner.js <path> [--coverage] [--watch] [--file <filepath>]",
142
+ );
143
+ process.exit(1);
144
+ }
145
+
146
+ const projectRoot = path.resolve(targetPath);
147
+ if (!fs.existsSync(projectRoot) || !fs.statSync(projectRoot).isDirectory()) {
148
+ fail(`Directory not found: ${projectRoot}`);
149
+ process.exit(1);
150
+ }
151
+
152
+ const framework = detectTestFramework(projectRoot);
153
+ console.log(
154
+ banner("test_runner.js", {
155
+ Project: projectRoot,
156
+ Framework: framework || "none detected",
157
+ }),
158
+ );
159
+
160
+ if (!framework) {
161
+ skip("No test framework detected in this project");
162
+ process.exit(0);
163
+ }
164
+
165
+ console.log(sectionHeader(`Running tests (${framework})`));
166
+
167
+ let cmd = [];
168
+ let passed = true;
169
+
170
+ if (["vitest", "jest", "mocha", "npm-test"].includes(framework)) {
171
+ if (framework === "vitest") {
172
+ cmd = ["npx", "vitest", "run"];
173
+ if (coverageFlag) cmd.push("--coverage");
174
+ if (watchFlag) cmd = ["npx", "vitest"];
175
+ if (fileArg) cmd.push(fileArg);
176
+ } else if (framework === "jest") {
177
+ cmd = ["npx", "jest"];
178
+ if (coverageFlag) cmd.push("--coverage");
179
+ if (watchFlag) cmd.push("--watch");
180
+ if (fileArg) cmd.push(fileArg);
177
181
  } else {
178
- console.log(`\n${RED}${BOLD} ✖ Tests failed (${framework}).${RESET}\n`);
182
+ cmd = ["npm", "test", "--", "--passWithNoTests"];
183
+ if (coverageFlag) cmd.push("--coverage");
184
+ if (fileArg) cmd.push(fileArg);
179
185
  }
180
-
181
- process.exit(passed ? 0 : 1);
186
+ passed = runTests(framework, cmd, projectRoot);
187
+ } else if (framework === "pytest") {
188
+ cmd = ["python", "-m", "pytest", "-v"];
189
+ if (coverageFlag) cmd.push("--cov", "--cov-report=term-missing");
190
+ if (watchFlag) cmd = ["python", "-m", "pytest-watch", "--", "-v"];
191
+ if (fileArg) cmd.push(fileArg);
192
+ passed = runTests("pytest", cmd, projectRoot);
193
+ } else if (framework === "go") {
194
+ cmd = ["go", "test", "./...", "-v"];
195
+ if (coverageFlag) cmd.push("-cover");
196
+ if (fileArg) cmd = ["go", "test", "-v", "-run", fileArg];
197
+ passed = runTests("go test", cmd, projectRoot);
198
+ }
199
+
200
+ console.log(`\n${BOLD}${CYAN}━━━ Test Summary ━━━${RESET}`);
201
+ if (passed) {
202
+ console.log(`\n${GREEN}${BOLD} ✔ Tests passed (${framework}).${RESET}\n`);
203
+ } else {
204
+ console.log(`\n${RED}${BOLD} ✖ Tests failed (${framework}).${RESET}\n`);
205
+ }
206
+
207
+ process.exit(passed ? 0 : 1);
182
208
  }
183
209
 
184
210
  if (require.main === module) {
185
- main();
211
+ main();
186
212
  }