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
@@ -1,197 +1,207 @@
1
- #!/usr/bin/env node
2
- /**
3
- * auto_preview.js — Start, stop, or check a local development server.
4
- *
5
- * Usage:
6
- * node .agent/scripts/auto_preview.js start
7
- * node .agent/scripts/auto_preview.js stop
8
- * node .agent/scripts/auto_preview.js status
9
- * node .agent/scripts/auto_preview.js restart
10
- */
11
-
12
- 'use strict';
13
-
14
- const fs = require('fs');
15
- const path = require('path');
16
- const { spawn } = require('child_process');
17
- const net = require('net');
18
-
19
- const PID_FILE = ".preview.pid";
20
- const DEFAULT_PORT = 3000;
21
- const TIMEOUT_SECONDS = 30;
22
-
23
- const { GREEN, RED, YELLOW, BOLD, RESET } = require('./colors.js');
24
-
25
- function findStartCommand() {
26
- const pkgPath = path.resolve("package.json");
27
- if (!fs.existsSync(pkgPath)) return { cmd: [], found: false };
28
-
29
- try {
30
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
31
- const scripts = pkg.scripts || {};
32
- if (scripts.dev) return { cmd: ["npm", "run", "dev"], found: true };
33
- if (scripts.start) return { cmd: ["npm", "run", "start"], found: true };
34
- } catch {
35
- // Ignore
36
- }
37
- return { cmd: [], found: false };
38
- }
39
-
40
- function getPortFromEnv() {
41
- const envPath = path.resolve(".env");
42
- if (fs.existsSync(envPath)) {
43
- try {
44
- const data = fs.readFileSync(envPath, 'utf8');
45
- for (const line of data.split('\n')) {
46
- if (line.trim().startsWith("PORT=")) {
47
- return parseInt(line.split("=")[1].trim(), 10);
48
- }
49
- }
50
- } catch {}
51
- }
52
- return DEFAULT_PORT;
53
- }
54
-
55
- function isPortOpen(port) {
56
- return new Promise(resolve => {
57
- const client = new net.Socket();
58
- client.setTimeout(1000);
59
- client.once('connect', () => {
60
- client.destroy();
61
- resolve(true);
62
- }).once('timeout', () => {
63
- client.destroy();
64
- resolve(false);
65
- }).once('error', () => {
66
- resolve(false);
67
- }).connect(port, 'localhost');
68
- });
69
- }
70
-
71
- function readPid() {
72
- if (fs.existsSync(PID_FILE)) {
73
- try {
74
- return parseInt(fs.readFileSync(PID_FILE, 'utf8').trim(), 10);
75
- } catch {}
76
- }
77
- return null;
78
- }
79
-
80
- function writePid(pid) {
81
- fs.writeFileSync(PID_FILE, String(pid), 'utf8');
82
- }
83
-
84
- function clearPid() {
85
- if (fs.existsSync(PID_FILE)) {
86
- fs.unlinkSync(PID_FILE);
87
- }
88
- }
89
-
90
- async function startServer() {
91
- const port = getPortFromEnv();
92
-
93
- if (await isPortOpen(port)) {
94
- console.log(`${YELLOW}⚠️ Port ${port} is already in use.${RESET}`);
95
- const pid = readPid();
96
- if (pid) console.log(` Known PID: ${pid}`);
97
- return;
98
- }
99
-
100
- const { cmd, found } = findStartCommand();
101
- if (!found) {
102
- console.log(`${RED}❌ No dev/start script found.${RESET}`);
103
- console.log(` This project has no package.json, or its package.json has no 'dev' or 'start' script.`);
104
- console.log(` Add a script to package.json, or start your server manually.`);
105
- return;
106
- }
107
-
108
- console.log(`${BOLD}Starting: ${cmd.join(' ')}${RESET}`);
109
- // Adjust command for windows (npm.cmd instead of npm)
110
- const executable = process.platform === 'win32' ? `${cmd[0]}.cmd` : cmd[0];
111
-
112
- const proc = spawn(executable, cmd.slice(1), {
113
- stdio: 'pipe',
114
- detached: true
115
- });
116
-
117
- // Ignore children stdout inside detached mode to let node exit
118
- proc.stdout.unref();
119
- proc.stderr.unref();
120
- proc.unref();
121
-
122
- writePid(proc.pid);
123
-
124
- process.stdout.write(`Waiting for port ${port}…`);
125
- for (let i = 0; i < TIMEOUT_SECONDS; i++) {
126
- if (await isPortOpen(port)) {
127
- console.log(`\n${GREEN}✅ Server started${RESET}`);
128
- console.log(` URL: http://localhost:${port}`);
129
- console.log(` PID: ${proc.pid}`);
130
- console.log(` Command: ${cmd.join(' ')}`);
131
- console.log(`\nStop with: node .agent/scripts/auto_preview.js stop`);
132
- return;
133
- }
134
- process.stdout.write(".");
135
- await new Promise(r => setTimeout(r, 1000));
136
- }
137
-
138
- console.log(`\n${RED}❌ Server did not start within ${TIMEOUT_SECONDS}s${RESET}`);
139
- try {
140
- process.kill(proc.pid, 'SIGTERM');
141
- } catch {}
142
- clearPid();
143
- }
144
-
145
- function stopServer() {
146
- const pid = readPid();
147
- if (!pid) {
148
- console.log(`${YELLOW}⚠️ No stored server PID found${RESET}`);
149
- return;
150
- }
151
- try {
152
- process.kill(pid, 'SIGTERM');
153
- console.log(`${GREEN}✅ Server stopped (PID ${pid})${RESET}`);
154
- } catch {
155
- console.log(`${YELLOW}Process ${pid} was not running${RESET}`);
156
- } finally {
157
- clearPid();
158
- }
159
- }
160
-
161
- async function showStatus() {
162
- const port = getPortFromEnv();
163
- const pid = readPid();
164
- if (await isPortOpen(port)) {
165
- console.log(`${GREEN}🟢 Running http://localhost:${port}${RESET}`);
166
- if (pid) console.log(` PID: ${pid}`);
167
- } else {
168
- console.log(`${RED}🔴 Not running on port ${port}${RESET}`);
169
- }
170
- }
171
-
172
- async function main() {
173
- const args = process.argv.slice(2);
174
- const actions = new Set(["start", "stop", "status", "restart"]);
175
-
176
- if (args.length < 1 || !actions.has(args[0])) {
177
- console.log(`Usage: node auto_preview.js [start|stop|status|restart]`);
178
- process.exit(1);
179
- }
180
-
181
- const action = args[0];
182
- if (action === "start") {
183
- await startServer();
184
- } else if (action === "stop") {
185
- stopServer();
186
- } else if (action === "status") {
187
- await showStatus();
188
- } else if (action === "restart") {
189
- stopServer();
190
- await new Promise(r => setTimeout(r, 1000));
191
- await startServer();
192
- }
193
- }
194
-
195
- if (require.main === module) {
196
- main();
197
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * auto_preview.js — Start, stop, or check a local development server.
4
+ *
5
+ * Usage:
6
+ * node .agent/scripts/auto_preview.js start
7
+ * node .agent/scripts/auto_preview.js stop
8
+ * node .agent/scripts/auto_preview.js status
9
+ * node .agent/scripts/auto_preview.js restart
10
+ */
11
+
12
+ "use strict";
13
+
14
+ const fs = require("fs");
15
+ const path = require("path");
16
+ const { spawn } = require("child_process");
17
+ const net = require("net");
18
+
19
+ const PID_FILE = ".preview.pid";
20
+ const DEFAULT_PORT = 3000;
21
+ const TIMEOUT_SECONDS = 30;
22
+
23
+ const { GREEN, RED, YELLOW, BOLD, RESET } = require("./colors.js");
24
+
25
+ function findStartCommand() {
26
+ const pkgPath = path.resolve("package.json");
27
+ if (!fs.existsSync(pkgPath)) return { cmd: [], found: false };
28
+
29
+ try {
30
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
31
+ const scripts = pkg.scripts || {};
32
+ if (scripts.dev) return { cmd: ["npm", "run", "dev"], found: true };
33
+ if (scripts.start) return { cmd: ["npm", "run", "start"], found: true };
34
+ } catch {
35
+ // Ignore
36
+ }
37
+ return { cmd: [], found: false };
38
+ }
39
+
40
+ function getPortFromEnv() {
41
+ const envPath = path.resolve(".env");
42
+ if (fs.existsSync(envPath)) {
43
+ try {
44
+ const data = fs.readFileSync(envPath, "utf8");
45
+ for (const line of data.split("\n")) {
46
+ if (line.trim().startsWith("PORT=")) {
47
+ return parseInt(line.split("=")[1].trim(), 10);
48
+ }
49
+ }
50
+ } catch {}
51
+ }
52
+ return DEFAULT_PORT;
53
+ }
54
+
55
+ function isPortOpen(port) {
56
+ return new Promise((resolve) => {
57
+ const client = new net.Socket();
58
+ client.setTimeout(1000);
59
+ client
60
+ .once("connect", () => {
61
+ client.destroy();
62
+ resolve(true);
63
+ })
64
+ .once("timeout", () => {
65
+ client.destroy();
66
+ resolve(false);
67
+ })
68
+ .once("error", () => {
69
+ resolve(false);
70
+ })
71
+ .connect(port, "localhost");
72
+ });
73
+ }
74
+
75
+ function readPid() {
76
+ if (fs.existsSync(PID_FILE)) {
77
+ try {
78
+ return parseInt(fs.readFileSync(PID_FILE, "utf8").trim(), 10);
79
+ } catch {}
80
+ }
81
+ return null;
82
+ }
83
+
84
+ function writePid(pid) {
85
+ fs.writeFileSync(PID_FILE, String(pid), "utf8");
86
+ }
87
+
88
+ function clearPid() {
89
+ if (fs.existsSync(PID_FILE)) {
90
+ fs.unlinkSync(PID_FILE);
91
+ }
92
+ }
93
+
94
+ async function startServer() {
95
+ const port = getPortFromEnv();
96
+
97
+ if (await isPortOpen(port)) {
98
+ console.log(`${YELLOW}⚠️ Port ${port} is already in use.${RESET}`);
99
+ const pid = readPid();
100
+ if (pid) console.log(` Known PID: ${pid}`);
101
+ return;
102
+ }
103
+
104
+ const { cmd, found } = findStartCommand();
105
+ if (!found) {
106
+ console.log(`${RED}❌ No dev/start script found.${RESET}`);
107
+ console.log(
108
+ ` This project has no package.json, or its package.json has no 'dev' or 'start' script.`,
109
+ );
110
+ console.log(
111
+ ` Add a script to package.json, or start your server manually.`,
112
+ );
113
+ return;
114
+ }
115
+
116
+ console.log(`${BOLD}Starting: ${cmd.join(" ")}${RESET}`);
117
+ // Adjust command for windows (npm.cmd instead of npm)
118
+ const executable = process.platform === "win32" ? `${cmd[0]}.cmd` : cmd[0];
119
+
120
+ const proc = spawn(executable, cmd.slice(1), {
121
+ stdio: "pipe",
122
+ detached: true,
123
+ });
124
+
125
+ // Ignore children stdout inside detached mode to let node exit
126
+ proc.stdout.unref();
127
+ proc.stderr.unref();
128
+ proc.unref();
129
+
130
+ writePid(proc.pid);
131
+
132
+ process.stdout.write(`Waiting for port ${port}…`);
133
+ for (let i = 0; i < TIMEOUT_SECONDS; i++) {
134
+ if (await isPortOpen(port)) {
135
+ console.log(`\n${GREEN}✅ Server started${RESET}`);
136
+ console.log(` URL: http://localhost:${port}`);
137
+ console.log(` PID: ${proc.pid}`);
138
+ console.log(` Command: ${cmd.join(" ")}`);
139
+ console.log(`\nStop with: node .agent/scripts/auto_preview.js stop`);
140
+ return;
141
+ }
142
+ process.stdout.write(".");
143
+ await new Promise((r) => setTimeout(r, 1000));
144
+ }
145
+
146
+ console.log(
147
+ `\n${RED}❌ Server did not start within ${TIMEOUT_SECONDS}s${RESET}`,
148
+ );
149
+ try {
150
+ process.kill(proc.pid, "SIGTERM");
151
+ } catch {}
152
+ clearPid();
153
+ }
154
+
155
+ function stopServer() {
156
+ const pid = readPid();
157
+ if (!pid) {
158
+ console.log(`${YELLOW}⚠️ No stored server PID found${RESET}`);
159
+ return;
160
+ }
161
+ try {
162
+ process.kill(pid, "SIGTERM");
163
+ console.log(`${GREEN}✅ Server stopped (PID ${pid})${RESET}`);
164
+ } catch {
165
+ console.log(`${YELLOW}Process ${pid} was not running${RESET}`);
166
+ } finally {
167
+ clearPid();
168
+ }
169
+ }
170
+
171
+ async function showStatus() {
172
+ const port = getPortFromEnv();
173
+ const pid = readPid();
174
+ if (await isPortOpen(port)) {
175
+ console.log(`${GREEN}🟢 Running — http://localhost:${port}${RESET}`);
176
+ if (pid) console.log(` PID: ${pid}`);
177
+ } else {
178
+ console.log(`${RED}🔴 Not running on port ${port}${RESET}`);
179
+ }
180
+ }
181
+
182
+ async function main() {
183
+ const args = process.argv.slice(2);
184
+ const actions = new Set(["start", "stop", "status", "restart"]);
185
+
186
+ if (args.length < 1 || !actions.has(args[0])) {
187
+ console.log(`Usage: node auto_preview.js [start|stop|status|restart]`);
188
+ process.exit(1);
189
+ }
190
+
191
+ const action = args[0];
192
+ if (action === "start") {
193
+ await startServer();
194
+ } else if (action === "stop") {
195
+ stopServer();
196
+ } else if (action === "status") {
197
+ await showStatus();
198
+ } else if (action === "restart") {
199
+ stopServer();
200
+ await new Promise((r) => setTimeout(r, 1000));
201
+ await startServer();
202
+ }
203
+ }
204
+
205
+ if (require.main === module) {
206
+ main();
207
+ }