tribunal-kit 4.6.1 → 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 +61 -47
- package/bin/mcp-server.js +476 -121
- package/bin/tribunal-kit.js +1245 -987
- package/bin/wrapper.js +104 -73
- package/dist/cli.js +265 -0
- package/dist/commands/case.js +71 -0
- package/dist/commands/compile.js +84 -0
- package/dist/commands/context.js +66 -0
- package/dist/commands/graph.js +38 -0
- package/dist/commands/hook.js +28 -0
- package/dist/commands/init.js +339 -0
- package/dist/commands/learn.js +117 -0
- package/dist/commands/marathon.js +45 -0
- package/dist/commands/memory.js +456 -0
- package/dist/commands/mutate.js +30 -0
- package/dist/commands/status.js +35 -0
- package/dist/commands/sync.js +25 -0
- package/dist/commands/uninstall.js +42 -0
- package/dist/commands/update.js +37 -0
- package/dist/mcp/server.js +142 -0
- package/dist/types.js +8 -0
- package/dist/utils/fs.js +96 -0
- package/dist/utils/hasher.js +142 -0
- package/dist/utils/helpers.js +68 -0
- package/dist/utils/logger.js +54 -0
- package/dist/utils/version.js +150 -0
- package/package.json +3 -2
- package/scripts/benchmark.js +197 -0
- package/scripts/changelog.js +196 -168
- package/scripts/sync-version.js +94 -81
- 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
|
-
|
|
9
|
-
|
|
10
|
-
const fs = require(
|
|
11
|
-
const path = require(
|
|
12
|
-
|
|
13
|
-
const { RED, CYAN, RESET } = require(
|
|
14
|
-
|
|
15
|
-
function getFlag(name) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const targetFile = getFlag(
|
|
21
|
-
|
|
22
|
-
if (!targetFile) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
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();
|