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
@@ -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 { execSync, spawnSync } = require('child_process');
10
- const path = require('path');
11
- const fs = require('fs');
12
- const os = require('os');
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
- reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m',
17
- red: '\x1b[91m', green: '\x1b[92m', yellow: '\x1b[93m',
18
- cyan: '\x1b[96m', white: '\x1b[97m', gray: '\x1b[90m',
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) { return `${C[color]}${text}${C.reset}`; }
22
- function bold(text) { return `${C.bold}${text}${C.reset}`; }
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
- const times = [];
33
- for (let i = 0; i < runs; i++) {
34
- const start = performance.now();
35
- await fn();
36
- const end = performance.now();
37
- times.push(end - start);
38
- }
39
- const avg = times.reduce((a, b) => a + b, 0) / times.length;
40
- const min = Math.min(...times);
41
- const max = Math.max(...times);
42
- return { label, avg, min, max, runs };
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
- return benchmark(label, () => {
50
- spawnSync('node', command.split(' '), {
51
- stdio: 'pipe',
52
- encoding: 'utf8',
53
- env: { ...process.env, TK_SKIP_UPDATE_CHECK: '1' },
54
- });
55
- }, runs);
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
- console.log();
60
- console.log(bold(` ⚡ Tribunal-Kit Performance Benchmark`));
61
- console.log(c('gray', ` ─────────────────────────────────────────`));
62
- console.log(c('gray', ` Platform: ${os.platform()} ${os.arch()}`));
63
- console.log(c('gray', ` Node: ${process.version}`));
64
- console.log(c('gray', ` CPUs: ${os.cpus().length}x ${os.cpus()[0]?.model || 'unknown'}`));
65
- console.log(c('gray', ` ─────────────────────────────────────────`));
66
- console.log();
67
-
68
- const cliPath = path.resolve(__dirname, '../bin/wrapper.js');
69
- const tempDir = path.join(os.tmpdir(), `tribunal-bench-${Date.now()}`);
70
- fs.mkdirSync(tempDir, { recursive: true });
71
-
72
- const results = [];
73
-
74
- // 1. Cold start (help)
75
- console.log(c('cyan', ' ▸ Benchmarking: CLI cold-start (--help)'));
76
- const helpResult = await benchmarkCommand(
77
- 'CLI cold-start (--help)',
78
- `${cliPath} --help`,
79
- 5
80
- );
81
- results.push(helpResult);
82
-
83
- // 2. Status check
84
- console.log(c('cyan', ' ▸ Benchmarking: tk status'));
85
- const statusResult = await benchmarkCommand(
86
- 'Status check',
87
- `${cliPath} status --quiet`,
88
- 5
89
- );
90
- results.push(statusResult);
91
-
92
- // 3. Init (dry-run)
93
- console.log(c('cyan', ' ▸ Benchmarking: tk init --dry-run'));
94
- const initResult = await benchmarkCommand(
95
- 'Init (dry-run)',
96
- `${cliPath} init --dry-run --quiet --skip-update-check --path=${tempDir}`,
97
- 3
98
- );
99
- results.push(initResult);
100
-
101
- // 4. Init (real, to temp dir)
102
- console.log(c('cyan', ' ▸ Benchmarking: tk init (real copy)'));
103
- const initRealResult = await benchmark(
104
- 'Init (full copy)',
105
- () => {
106
- const runDir = path.join(tempDir, `run-${Date.now()}`);
107
- fs.mkdirSync(runDir, { recursive: true });
108
- spawnSync('node', [cliPath, 'init', '--quiet', '--skip-update-check', `--path=${runDir}`], {
109
- stdio: 'pipe',
110
- encoding: 'utf8',
111
- env: { ...process.env, TK_SKIP_UPDATE_CHECK: '1' },
112
- });
113
- // Cleanup
114
- try { fs.rmSync(runDir, { recursive: true, force: true }); } catch {}
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
- 3
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
- results.push(initRealResult);
119
-
120
- // Print results table
121
- console.log();
122
- console.log(bold(` Results`));
123
- console.log(c('gray', ` ─────────────────────────────────────────────────────────`));
124
- console.log(` ${c('white', 'Operation'.padEnd(30))} ${c('white', 'Avg (ms)'.padStart(10))} ${c('white', 'Min'.padStart(8))} ${c('white', 'Max'.padStart(8))}`);
125
- console.log(c('gray', ` ─────────────────────────────────────────────────────────`));
126
-
127
- for (const r of results) {
128
- const avgColor = r.avg < 100 ? 'green' : r.avg < 500 ? 'yellow' : 'red';
129
- console.log(` ${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))}`);
130
- }
131
-
132
- console.log(c('gray', ` ─────────────────────────────────────────────────────────`));
133
- console.log();
134
-
135
- // Write results to JSON for CI/comparison
136
- const outputPath = path.resolve(__dirname, '../benchmark-results.json');
137
- const outputData = {
138
- timestamp: new Date().toISOString(),
139
- platform: `${os.platform()}-${os.arch()}`,
140
- node: process.version,
141
- results: results.map(r => ({
142
- label: r.label,
143
- avg_ms: Math.round(r.avg),
144
- min_ms: Math.round(r.min),
145
- max_ms: Math.round(r.max),
146
- runs: r.runs,
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
- console.error(`Benchmark failed: ${err.message}`);
159
- process.exit(1);
194
+ main().catch((err) => {
195
+ console.error(`Benchmark failed: ${err.message}`);
196
+ process.exit(1);
160
197
  });