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.
- package/.agent/ARCHITECTURE.md +6 -7
- package/.agent/agents/frontend-reviewer.md +13 -0
- package/.agent/agents/frontend-specialist.md +14 -0
- package/.agent/agents/logic-reviewer.md +11 -0
- package/.agent/agents/orchestrator.md +15 -0
- package/.agent/agents/project-planner.md +5 -0
- package/.agent/agents/security-auditor.md +13 -0
- package/.agent/agents/ui-ux-auditor.md +7 -31
- package/.agent/history/memory/.memory.idx +1693 -0
- package/.agent/history/memory/MEMORY.md +123 -0
- package/.agent/routing_index.json +694 -714
- package/.agent/rules/GEMINI.md +88 -13
- package/.agent/scripts/_colors.js +131 -89
- package/.agent/scripts/_utils.js +163 -128
- package/.agent/scripts/auto_preview.js +207 -197
- package/.agent/scripts/bundle_analyzer.js +227 -192
- package/.agent/scripts/case_law_manager.js +991 -689
- package/.agent/scripts/checklist.js +233 -190
- package/.agent/scripts/context_broker.js +930 -605
- package/.agent/scripts/dependency_analyzer.js +275 -184
- package/.agent/scripts/graph_builder.js +412 -341
- package/.agent/scripts/graph_visualizer.js +392 -390
- package/.agent/scripts/graph_zoom.js +198 -156
- package/.agent/scripts/inner_loop_validator.js +523 -445
- package/.agent/scripts/lint_runner.js +199 -157
- package/.agent/scripts/marathon_harness.js +819 -661
- package/.agent/scripts/minify_context.js +115 -100
- package/.agent/scripts/mutation_runner.js +321 -280
- package/.agent/scripts/prompt_compiler.js +62 -42
- package/.agent/scripts/schema_validator.js +373 -280
- package/.agent/scripts/security_scan.js +333 -190
- package/.agent/scripts/session_manager.js +306 -270
- package/.agent/scripts/skill_evolution.js +810 -637
- package/.agent/scripts/skill_integrator.js +327 -307
- package/.agent/scripts/strengthen_skills.js +203 -193
- package/.agent/scripts/swarm_dispatcher.js +558 -457
- package/.agent/scripts/test_runner.js +178 -152
- package/.agent/scripts/verify_all.js +200 -168
- package/.agent/skills/fabel-protocol/SKILL.md +271 -0
- package/.agent/skills/thinking-protocol/SKILL.md +27 -0
- package/.agent/workflows/generate.md +2 -1
- package/.agent/workflows/tribunal-full.md +4 -3
- package/.agent/workflows/tribunal-speed.md +1 -1
- package/README.md +184 -58
- package/bin/mcp-server.js +496 -173
- package/bin/tribunal-kit.js +1245 -987
- package/bin/wrapper.js +108 -74
- package/dist/cli.js +44 -0
- package/dist/commands/align.js +201 -0
- package/dist/commands/case.js +23 -0
- package/dist/commands/compile.js +84 -0
- package/dist/commands/init.js +42 -0
- package/dist/commands/learn.js +57 -0
- package/dist/commands/memory.js +456 -0
- package/package.json +22 -10
- package/scripts/benchmark.js +162 -125
- package/scripts/changelog.js +196 -168
- package/scripts/sync-version.js +94 -81
- 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
|
-
|
|
12
|
+
"use strict";
|
|
13
13
|
|
|
14
|
-
const fs = require(
|
|
15
|
-
const path = require(
|
|
16
|
-
const { spawnSync } = require(
|
|
14
|
+
const fs = require("fs");
|
|
15
|
+
const path = require("path");
|
|
16
|
+
const { spawnSync } = require("child_process");
|
|
17
17
|
|
|
18
18
|
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
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
|
-
|
|
135
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
182
|
+
cmd = ["npm", "test", "--", "--passWithNoTests"];
|
|
183
|
+
if (coverageFlag) cmd.push("--coverage");
|
|
184
|
+
if (fileArg) cmd.push(fileArg);
|
|
179
185
|
}
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
211
|
+
main();
|
|
186
212
|
}
|