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,156 +1,198 @@
1
- #!/usr/bin/env node
2
- /**
3
- * graph_zoom.js — Tribunal Kit Micro Zoomer
4
- * Provides an "X-Ray" structural view of a specific file for AI agents,
5
- * stripping out internal logic to save tokens and prevent context bloat.
6
- */
7
-
8
- 'use strict';
9
-
10
- const fs = require('fs');
11
- const path = require('path');
12
-
13
- const { RED, CYAN, RESET } = require('./_colors');
14
-
15
- function getFlag(name) {
16
- const idx = process.argv.indexOf(name);
17
- return (idx !== -1 && process.argv[idx + 1]) ? process.argv[idx + 1] : null;
18
- }
19
-
20
- const targetFile = getFlag('--focus');
21
-
22
- if (!targetFile) {
23
- console.error(`${RED}✖ Error: Provide a file to zoom into. Usage: node graph_zoom.js --focus <filepath>${RESET}`);
24
- process.exit(1);
25
- }
26
-
27
- const absolutePath = path.resolve(process.cwd(), targetFile);
28
-
29
- if (!fs.existsSync(absolutePath)) {
30
- console.error(`${RED}✖ Error: File not found at ${absolutePath}${RESET}`);
31
- process.exit(1);
32
- }
33
-
34
- function extractSkeleton(content) {
35
- const lines = content.split('\n');
36
- const skeleton = [];
37
-
38
- // State machine flags
39
- let inClass = false;
40
- let braceDepth = 0;
41
-
42
- // ── Regex Matchers ──
43
- const importRegex = /^import\s+.*$/;
44
- const requireRegex = /^(?:const|let|var)\s+.*require\(.*$/;
45
- const classRegex = /^(?:export\s+)?(?:default\s+)?class\s+(\w+)(?:\s+extends\s+[\w.]+)?/;
46
- const functionRegex = /^(?:export\s+)?(?:default\s+)?(?:async\s+)?function\s+(\w*)\s*\(([^)]*)\)/;
47
- const arrowFuncRegex = /^(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\(([^)]*)\)\s*=>/;
48
- // Heuristic for React Components (starts with Capital letter)
49
- const reactComponentRegex = /^(?:export\s+)?(?:const|let|var)\s+([A-Z]\w+)\s*=\s*(?:[^=;]+)?=>/;
50
- const typeInterfaceRegex = /^(?:export\s+)?(?:type|interface)\s+(\w+)/;
51
-
52
- for (let i = 0; i < lines.length; i++) {
53
- const line = lines[i];
54
- const trimmed = line.trim();
55
-
56
- if (!trimmed) continue;
57
-
58
- // Keep imports
59
- if (importRegex.test(trimmed) || requireRegex.test(trimmed)) {
60
- skeleton.push(line);
61
- continue;
62
- }
63
-
64
- // Keep types and interfaces
65
- if (typeInterfaceRegex.test(trimmed)) {
66
- skeleton.push(line + (trimmed.endsWith('{') ? ' /* ... */ }' : ''));
67
- continue;
68
- }
69
-
70
- // Keep classes
71
- const classMatch = classRegex.exec(trimmed);
72
- if (classMatch) {
73
- skeleton.push('\n' + line + (trimmed.endsWith('{') ? '' : ' {'));
74
- inClass = true;
75
- braceDepth = (trimmed.match(/\{/g) || []).length - (trimmed.match(/\}/g) || []).length;
76
- continue;
77
- }
78
-
79
- // Keep function signatures
80
- const funcMatch = functionRegex.exec(trimmed);
81
- if (funcMatch) {
82
- skeleton.push('\n' + line + (trimmed.endsWith('{') ? ' /* logic stripped */ }' : ' { /* logic stripped */ }'));
83
- continue;
84
- }
85
-
86
- // Keep arrow functions
87
- const arrowMatch = arrowFuncRegex.exec(trimmed);
88
- if (arrowMatch) {
89
- skeleton.push('\n' + line + (trimmed.endsWith('{') ? ' /* logic stripped */ }' : ' { /* logic stripped */ }'));
90
- continue;
91
- }
92
-
93
- // Keep React Components / Standard constants
94
- const reactMatch = reactComponentRegex.exec(trimmed);
95
- if (reactMatch && !arrowMatch) {
96
- skeleton.push('\n' + line + (trimmed.endsWith('{') ? ' /* logic stripped */ }' : ' { /* logic stripped */ }'));
97
- continue;
98
- }
99
-
100
- // Very basic tracking of class methods (indentation heuristic)
101
- if (inClass && (line.startsWith(' ') || line.startsWith('\t')) && trimmed.includes('(') && trimmed.includes(')') && !trimmed.startsWith('//')) {
102
- // Avoid pushing if it's just a deeply nested logic block
103
- if (!trimmed.startsWith('if') && !trimmed.startsWith('for') && !trimmed.startsWith('switch')) {
104
- skeleton.push(' ' + trimmed + ' { /* ... */ }');
105
- }
106
- }
107
-
108
- // Manage class brace depth to properly close the skeleton
109
- if (inClass) {
110
- braceDepth += (line.match(/\{/g) || []).length;
111
- braceDepth -= (line.match(/\}/g) || []).length;
112
- if (braceDepth <= 0) {
113
- skeleton.push('}\n');
114
- inClass = false;
115
- braceDepth = 0;
116
- }
117
- }
118
- }
119
-
120
- return skeleton.join('\n');
121
- }
122
-
123
- function main() {
124
- console.log(`${CYAN}✦ Zooming into: ${targetFile}${RESET}`);
125
-
126
- try {
127
- const content = fs.readFileSync(absolutePath, 'utf8');
128
-
129
- // Strip comments to make regex parsing easier
130
- const noComments = content.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
131
-
132
- let skeleton = extractSkeleton(noComments);
133
-
134
- // Fallback Logic: If the file produced practically no useful skeleton (e.g. pure data object or failed parsing)
135
- if (skeleton.trim().length < 20) {
136
- const lines = content.split('\n');
137
- skeleton = `// [WARNING: Parser yielded little structure. Falling back to truncated raw file]\n` +
138
- lines.slice(0, 100).join('\n') +
139
- (lines.length > 100 ? '\n\n... (truncated)' : '');
140
- }
141
-
142
- console.log('\n--- SKELETON START ---');
143
- console.log(skeleton);
144
- console.log('--- SKELETON END ---\n');
145
-
146
- } catch (e) {
147
- console.error(`${RED} Error parsing file: ${e.message}${RESET}`);
148
- // Fallback Logic: Return truncated raw on hard failure
149
- const rawContent = fs.readFileSync(absolutePath, 'utf8').split('\n').slice(0, 100).join('\n');
150
- console.log('\n--- RAW FILE FALLBACK (100 lines) ---');
151
- console.log(rawContent);
152
- console.log('-------------------------------------\n');
153
- }
154
- }
155
-
156
- main();
1
+ #!/usr/bin/env node
2
+ /**
3
+ * graph_zoom.js — Tribunal Kit Micro Zoomer
4
+ * Provides an "X-Ray" structural view of a specific file for AI agents,
5
+ * stripping out internal logic to save tokens and prevent context bloat.
6
+ */
7
+
8
+ "use strict";
9
+
10
+ const fs = require("fs");
11
+ const path = require("path");
12
+
13
+ const { RED, CYAN, RESET } = require("./_colors");
14
+
15
+ function getFlag(name) {
16
+ const idx = process.argv.indexOf(name);
17
+ return idx !== -1 && process.argv[idx + 1] ? process.argv[idx + 1] : null;
18
+ }
19
+
20
+ const targetFile = getFlag("--focus");
21
+
22
+ if (!targetFile) {
23
+ console.error(
24
+ `${RED}✖ Error: Provide a file to zoom into. Usage: node graph_zoom.js --focus <filepath>${RESET}`,
25
+ );
26
+ process.exit(1);
27
+ }
28
+
29
+ const absolutePath = path.resolve(process.cwd(), targetFile);
30
+
31
+ if (!fs.existsSync(absolutePath)) {
32
+ console.error(`${RED}✖ Error: File not found at ${absolutePath}${RESET}`);
33
+ process.exit(1);
34
+ }
35
+
36
+ function extractSkeleton(content) {
37
+ const lines = content.split("\n");
38
+ const skeleton = [];
39
+
40
+ // State machine flags
41
+ let inClass = false;
42
+ let braceDepth = 0;
43
+
44
+ // ── Regex Matchers ──
45
+ const importRegex = /^import\s+.*$/;
46
+ const requireRegex = /^(?:const|let|var)\s+.*require\(.*$/;
47
+ const classRegex =
48
+ /^(?:export\s+)?(?:default\s+)?class\s+(\w+)(?:\s+extends\s+[\w.]+)?/;
49
+ const functionRegex =
50
+ /^(?:export\s+)?(?:default\s+)?(?:async\s+)?function\s+(\w*)\s*\(([^)]*)\)/;
51
+ const arrowFuncRegex =
52
+ /^(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\(([^)]*)\)\s*=>/;
53
+ // Heuristic for React Components (starts with Capital letter)
54
+ const reactComponentRegex =
55
+ /^(?:export\s+)?(?:const|let|var)\s+([A-Z]\w+)\s*=\s*(?:[^=;]+)?=>/;
56
+ const typeInterfaceRegex = /^(?:export\s+)?(?:type|interface)\s+(\w+)/;
57
+
58
+ for (let i = 0; i < lines.length; i++) {
59
+ const line = lines[i];
60
+ const trimmed = line.trim();
61
+
62
+ if (!trimmed) continue;
63
+
64
+ // Keep imports
65
+ if (importRegex.test(trimmed) || requireRegex.test(trimmed)) {
66
+ skeleton.push(line);
67
+ continue;
68
+ }
69
+
70
+ // Keep types and interfaces
71
+ if (typeInterfaceRegex.test(trimmed)) {
72
+ skeleton.push(line + (trimmed.endsWith("{") ? " /* ... */ }" : ""));
73
+ continue;
74
+ }
75
+
76
+ // Keep classes
77
+ const classMatch = classRegex.exec(trimmed);
78
+ if (classMatch) {
79
+ skeleton.push("\n" + line + (trimmed.endsWith("{") ? "" : " {"));
80
+ inClass = true;
81
+ braceDepth =
82
+ (trimmed.match(/\{/g) || []).length -
83
+ (trimmed.match(/\}/g) || []).length;
84
+ continue;
85
+ }
86
+
87
+ // Keep function signatures
88
+ const funcMatch = functionRegex.exec(trimmed);
89
+ if (funcMatch) {
90
+ skeleton.push(
91
+ "\n" +
92
+ line +
93
+ (trimmed.endsWith("{")
94
+ ? " /* logic stripped */ }"
95
+ : " { /* logic stripped */ }"),
96
+ );
97
+ continue;
98
+ }
99
+
100
+ // Keep arrow functions
101
+ const arrowMatch = arrowFuncRegex.exec(trimmed);
102
+ if (arrowMatch) {
103
+ skeleton.push(
104
+ "\n" +
105
+ line +
106
+ (trimmed.endsWith("{")
107
+ ? " /* logic stripped */ }"
108
+ : " { /* logic stripped */ }"),
109
+ );
110
+ continue;
111
+ }
112
+
113
+ // Keep React Components / Standard constants
114
+ const reactMatch = reactComponentRegex.exec(trimmed);
115
+ if (reactMatch && !arrowMatch) {
116
+ skeleton.push(
117
+ "\n" +
118
+ line +
119
+ (trimmed.endsWith("{")
120
+ ? " /* logic stripped */ }"
121
+ : " { /* logic stripped */ }"),
122
+ );
123
+ continue;
124
+ }
125
+
126
+ // Very basic tracking of class methods (indentation heuristic)
127
+ if (
128
+ inClass &&
129
+ (line.startsWith(" ") || line.startsWith("\t")) &&
130
+ trimmed.includes("(") &&
131
+ trimmed.includes(")") &&
132
+ !trimmed.startsWith("//")
133
+ ) {
134
+ // Avoid pushing if it's just a deeply nested logic block
135
+ if (
136
+ !trimmed.startsWith("if") &&
137
+ !trimmed.startsWith("for") &&
138
+ !trimmed.startsWith("switch")
139
+ ) {
140
+ skeleton.push(" " + trimmed + " { /* ... */ }");
141
+ }
142
+ }
143
+
144
+ // Manage class brace depth to properly close the skeleton
145
+ if (inClass) {
146
+ braceDepth += (line.match(/\{/g) || []).length;
147
+ braceDepth -= (line.match(/\}/g) || []).length;
148
+ if (braceDepth <= 0) {
149
+ skeleton.push("}\n");
150
+ inClass = false;
151
+ braceDepth = 0;
152
+ }
153
+ }
154
+ }
155
+
156
+ return skeleton.join("\n");
157
+ }
158
+
159
+ function main() {
160
+ console.log(`${CYAN}✦ Zooming into: ${targetFile}${RESET}`);
161
+
162
+ try {
163
+ const content = fs.readFileSync(absolutePath, "utf8");
164
+
165
+ // Strip comments to make regex parsing easier
166
+ const noComments = content
167
+ .replace(/\/\*[\s\S]*?\*\//g, "")
168
+ .replace(/\/\/.*$/gm, "");
169
+
170
+ let skeleton = extractSkeleton(noComments);
171
+
172
+ // Fallback Logic: If the file produced practically no useful skeleton (e.g. pure data object or failed parsing)
173
+ if (skeleton.trim().length < 20) {
174
+ const lines = content.split("\n");
175
+ skeleton =
176
+ `// [WARNING: Parser yielded little structure. Falling back to truncated raw file]\n` +
177
+ lines.slice(0, 100).join("\n") +
178
+ (lines.length > 100 ? "\n\n... (truncated)" : "");
179
+ }
180
+
181
+ console.log("\n--- SKELETON START ---");
182
+ console.log(skeleton);
183
+ console.log("--- SKELETON END ---\n");
184
+ } catch (e) {
185
+ console.error(`${RED}✖ Error parsing file: ${e.message}${RESET}`);
186
+ // Fallback Logic: Return truncated raw on hard failure
187
+ const rawContent = fs
188
+ .readFileSync(absolutePath, "utf8")
189
+ .split("\n")
190
+ .slice(0, 100)
191
+ .join("\n");
192
+ console.log("\n--- RAW FILE FALLBACK (100 lines) ---");
193
+ console.log(rawContent);
194
+ console.log("-------------------------------------\n");
195
+ }
196
+ }
197
+
198
+ main();