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.
- 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/security-auditor.md +13 -0
- package/.agent/agents/ui-ux-auditor.md +7 -31
- package/.agent/history/memory/.memory.idx +766 -0
- package/.agent/history/memory/MEMORY.md +62 -0
- package/.agent/routing_index.json +694 -714
- package/.agent/rules/GEMINI.md +58 -8
- 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 +235 -0
- package/.agent/skills/thinking-protocol/SKILL.md +27 -0
- package/.agent/workflows/generate.md +1 -1
- package/.agent/workflows/tribunal-speed.md +1 -1
- package/README.md +53 -53
- package/bin/mcp-server.js +460 -175
- package/bin/tribunal-kit.js +1245 -987
- package/bin/wrapper.js +104 -74
- package/dist/cli.js +31 -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 +2 -2
- 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
package/scripts/benchmark.js
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* Tribunal-Kit Performance Benchmark
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* Measures and reports performance metrics for key operations.
|
|
6
6
|
* Run: node scripts/benchmark.js
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
const {
|
|
10
|
-
const path = require(
|
|
11
|
-
const fs = require(
|
|
12
|
-
const os = require(
|
|
9
|
+
const { spawnSync } = require("child_process");
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
const os = require("os");
|
|
13
13
|
|
|
14
14
|
// ANSI colors
|
|
15
15
|
const C = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
reset: "\x1b[0m",
|
|
17
|
+
bold: "\x1b[1m",
|
|
18
|
+
dim: "\x1b[2m",
|
|
19
|
+
red: "\x1b[91m",
|
|
20
|
+
green: "\x1b[92m",
|
|
21
|
+
yellow: "\x1b[93m",
|
|
22
|
+
cyan: "\x1b[96m",
|
|
23
|
+
white: "\x1b[97m",
|
|
24
|
+
gray: "\x1b[90m",
|
|
19
25
|
};
|
|
20
26
|
|
|
21
|
-
function c(color, text) {
|
|
22
|
-
|
|
27
|
+
function c(color, text) {
|
|
28
|
+
return `${C[color]}${text}${C.reset}`;
|
|
29
|
+
}
|
|
30
|
+
function bold(text) {
|
|
31
|
+
return `${C.bold}${text}${C.reset}`;
|
|
32
|
+
}
|
|
23
33
|
|
|
24
34
|
/**
|
|
25
35
|
* Time a command execution in milliseconds.
|
|
@@ -29,132 +39,159 @@ function bold(text) { return `${C.bold}${text}${C.reset}`; }
|
|
|
29
39
|
* @returns {{ label: string, avg: number, min: number, max: number, runs: number }}
|
|
30
40
|
*/
|
|
31
41
|
async function benchmark(label, fn, runs = 3) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const times = [];
|
|
43
|
+
for (let i = 0; i < runs; i++) {
|
|
44
|
+
const start = performance.now();
|
|
45
|
+
await fn();
|
|
46
|
+
const end = performance.now();
|
|
47
|
+
times.push(end - start);
|
|
48
|
+
}
|
|
49
|
+
const avg = times.reduce((a, b) => a + b, 0) / times.length;
|
|
50
|
+
const min = Math.min(...times);
|
|
51
|
+
const max = Math.max(...times);
|
|
52
|
+
return { label, avg, min, max, runs };
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
/**
|
|
46
56
|
* Time a shell command.
|
|
47
57
|
*/
|
|
48
58
|
function benchmarkCommand(label, command, runs = 3) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
return benchmark(
|
|
60
|
+
label,
|
|
61
|
+
() => {
|
|
62
|
+
spawnSync("node", command.split(" "), {
|
|
63
|
+
stdio: "pipe",
|
|
64
|
+
encoding: "utf8",
|
|
65
|
+
env: { ...process.env, TK_SKIP_UPDATE_CHECK: "1" },
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
runs,
|
|
69
|
+
);
|
|
56
70
|
}
|
|
57
71
|
|
|
58
72
|
async function main() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
73
|
+
console.log();
|
|
74
|
+
console.log(bold(` ⚡ Tribunal-Kit Performance Benchmark`));
|
|
75
|
+
console.log(c("gray", ` ─────────────────────────────────────────`));
|
|
76
|
+
console.log(c("gray", ` Platform: ${os.platform()} ${os.arch()}`));
|
|
77
|
+
console.log(c("gray", ` Node: ${process.version}`));
|
|
78
|
+
console.log(
|
|
79
|
+
c(
|
|
80
|
+
"gray",
|
|
81
|
+
` CPUs: ${os.cpus().length}x ${os.cpus()[0]?.model || "unknown"}`,
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
console.log(c("gray", ` ─────────────────────────────────────────`));
|
|
85
|
+
console.log();
|
|
86
|
+
|
|
87
|
+
const cliPath = path.resolve(__dirname, "../bin/wrapper.js");
|
|
88
|
+
const tempDir = path.join(os.tmpdir(), `tribunal-bench-${Date.now()}`);
|
|
89
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
90
|
+
|
|
91
|
+
const results = [];
|
|
92
|
+
|
|
93
|
+
// 1. Cold start (help)
|
|
94
|
+
console.log(c("cyan", " ▸ Benchmarking: CLI cold-start (--help)"));
|
|
95
|
+
const helpResult = await benchmarkCommand(
|
|
96
|
+
"CLI cold-start (--help)",
|
|
97
|
+
`${cliPath} --help`,
|
|
98
|
+
5,
|
|
99
|
+
);
|
|
100
|
+
results.push(helpResult);
|
|
101
|
+
|
|
102
|
+
// 2. Status check
|
|
103
|
+
console.log(c("cyan", " ▸ Benchmarking: tk status"));
|
|
104
|
+
const statusResult = await benchmarkCommand(
|
|
105
|
+
"Status check",
|
|
106
|
+
`${cliPath} status --quiet`,
|
|
107
|
+
5,
|
|
108
|
+
);
|
|
109
|
+
results.push(statusResult);
|
|
110
|
+
|
|
111
|
+
// 3. Init (dry-run)
|
|
112
|
+
console.log(c("cyan", " ▸ Benchmarking: tk init --dry-run"));
|
|
113
|
+
const initResult = await benchmarkCommand(
|
|
114
|
+
"Init (dry-run)",
|
|
115
|
+
`${cliPath} init --dry-run --quiet --skip-update-check --path=${tempDir}`,
|
|
116
|
+
3,
|
|
117
|
+
);
|
|
118
|
+
results.push(initResult);
|
|
119
|
+
|
|
120
|
+
// 4. Init (real, to temp dir)
|
|
121
|
+
console.log(c("cyan", " ▸ Benchmarking: tk init (real copy)"));
|
|
122
|
+
const initRealResult = await benchmark(
|
|
123
|
+
"Init (full copy)",
|
|
124
|
+
() => {
|
|
125
|
+
const runDir = path.join(tempDir, `run-${Date.now()}`);
|
|
126
|
+
fs.mkdirSync(runDir, { recursive: true });
|
|
127
|
+
spawnSync(
|
|
128
|
+
"node",
|
|
129
|
+
[cliPath, "init", "--quiet", "--skip-update-check", `--path=${runDir}`],
|
|
130
|
+
{
|
|
131
|
+
stdio: "pipe",
|
|
132
|
+
encoding: "utf8",
|
|
133
|
+
env: { ...process.env, TK_SKIP_UPDATE_CHECK: "1" },
|
|
115
134
|
},
|
|
116
|
-
|
|
135
|
+
);
|
|
136
|
+
// Cleanup
|
|
137
|
+
try {
|
|
138
|
+
fs.rmSync(runDir, { recursive: true, force: true });
|
|
139
|
+
} catch {}
|
|
140
|
+
},
|
|
141
|
+
3,
|
|
142
|
+
);
|
|
143
|
+
results.push(initRealResult);
|
|
144
|
+
|
|
145
|
+
// Print results table
|
|
146
|
+
console.log();
|
|
147
|
+
console.log(bold(` Results`));
|
|
148
|
+
console.log(
|
|
149
|
+
c("gray", ` ─────────────────────────────────────────────────────────`),
|
|
150
|
+
);
|
|
151
|
+
console.log(
|
|
152
|
+
` ${c("white", "Operation".padEnd(30))} ${c("white", "Avg (ms)".padStart(10))} ${c("white", "Min".padStart(8))} ${c("white", "Max".padStart(8))}`,
|
|
153
|
+
);
|
|
154
|
+
console.log(
|
|
155
|
+
c("gray", ` ─────────────────────────────────────────────────────────`),
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
for (const r of results) {
|
|
159
|
+
const avgColor = r.avg < 100 ? "green" : r.avg < 500 ? "yellow" : "red";
|
|
160
|
+
console.log(
|
|
161
|
+
` ${c("white", r.label.padEnd(30))} ${c(avgColor, String(Math.round(r.avg)).padStart(10))} ${c("gray", String(Math.round(r.min)).padStart(8))} ${c("gray", String(Math.round(r.max)).padStart(8))}`,
|
|
117
162
|
);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
})),
|
|
148
|
-
};
|
|
149
|
-
fs.writeFileSync(outputPath, JSON.stringify(outputData, null, 2));
|
|
150
|
-
console.log(c('green', ` ✔ Results saved to benchmark-results.json`));
|
|
151
|
-
|
|
152
|
-
// Cleanup temp
|
|
153
|
-
try { fs.rmSync(tempDir, { recursive: true, force: true }); } catch {}
|
|
154
|
-
console.log();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
console.log(
|
|
166
|
+
c("gray", ` ─────────────────────────────────────────────────────────`),
|
|
167
|
+
);
|
|
168
|
+
console.log();
|
|
169
|
+
|
|
170
|
+
// Write results to JSON for CI/comparison
|
|
171
|
+
const outputPath = path.resolve(__dirname, "../benchmark-results.json");
|
|
172
|
+
const outputData = {
|
|
173
|
+
timestamp: new Date().toISOString(),
|
|
174
|
+
platform: `${os.platform()}-${os.arch()}`,
|
|
175
|
+
node: process.version,
|
|
176
|
+
results: results.map((r) => ({
|
|
177
|
+
label: r.label,
|
|
178
|
+
avg_ms: Math.round(r.avg),
|
|
179
|
+
min_ms: Math.round(r.min),
|
|
180
|
+
max_ms: Math.round(r.max),
|
|
181
|
+
runs: r.runs,
|
|
182
|
+
})),
|
|
183
|
+
};
|
|
184
|
+
fs.writeFileSync(outputPath, JSON.stringify(outputData, null, 2));
|
|
185
|
+
console.log(c("green", ` ✔ Results saved to benchmark-results.json`));
|
|
186
|
+
|
|
187
|
+
// Cleanup temp
|
|
188
|
+
try {
|
|
189
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
190
|
+
} catch {}
|
|
191
|
+
console.log();
|
|
155
192
|
}
|
|
156
193
|
|
|
157
|
-
main().catch(err => {
|
|
158
|
-
|
|
159
|
-
|
|
194
|
+
main().catch((err) => {
|
|
195
|
+
console.error(`Benchmark failed: ${err.message}`);
|
|
196
|
+
process.exit(1);
|
|
160
197
|
});
|