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,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
+ }