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.
- 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 +53 -53
- package/bin/mcp-server.js +460 -175
- package/bin/tribunal-kit.js +1245 -987
- package/bin/wrapper.js +104 -74
- package/dist/cli.js +31 -0
- package/dist/commands/case.js +23 -0
- package/dist/commands/compile.js +84 -0
- package/dist/commands/init.js +42 -0
- package/dist/commands/learn.js +57 -0
- package/dist/commands/memory.js +456 -0
- package/package.json +2 -2
- package/scripts/benchmark.js +162 -125
- package/scripts/changelog.js +196 -168
- package/scripts/sync-version.js +94 -81
- package/scripts/validate-payload.js +85 -78
package/.agent/scripts/_utils.js
CHANGED
|
@@ -8,24 +8,46 @@
|
|
|
8
8
|
* const { findAgentDir, walkDir, loadJson } = require('./_utils');
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
"use strict";
|
|
12
12
|
|
|
13
|
-
const fs
|
|
14
|
-
const path = require(
|
|
15
|
-
const { RED, RESET } = require(
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const { RED, RESET } = require("./_colors");
|
|
16
16
|
|
|
17
17
|
// ── Default Skip Directories ────────────────────────────────────────────────
|
|
18
18
|
const DEFAULT_SKIP_DIRS = new Set([
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
"node_modules",
|
|
20
|
+
".git",
|
|
21
|
+
"dist",
|
|
22
|
+
"build",
|
|
23
|
+
".next",
|
|
24
|
+
".agent",
|
|
25
|
+
"__pycache__",
|
|
26
|
+
".venv",
|
|
27
|
+
"venv",
|
|
28
|
+
"coverage",
|
|
29
|
+
".turbo",
|
|
30
|
+
".svelte-kit",
|
|
31
|
+
".nuxt",
|
|
32
|
+
".output",
|
|
22
33
|
]);
|
|
23
34
|
|
|
24
35
|
// ── Default Source Extensions ───────────────────────────────────────────────
|
|
25
36
|
const SOURCE_EXTENSIONS = new Set([
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
".ts",
|
|
38
|
+
".tsx",
|
|
39
|
+
".js",
|
|
40
|
+
".jsx",
|
|
41
|
+
".mjs",
|
|
42
|
+
".cjs",
|
|
43
|
+
".py",
|
|
44
|
+
".rs",
|
|
45
|
+
".go",
|
|
46
|
+
".java",
|
|
47
|
+
".cs",
|
|
48
|
+
".rb",
|
|
49
|
+
".vue",
|
|
50
|
+
".svelte",
|
|
29
51
|
]);
|
|
30
52
|
|
|
31
53
|
// ── Agent Directory Discovery ───────────────────────────────────────────────
|
|
@@ -36,19 +58,21 @@ const SOURCE_EXTENSIONS = new Set([
|
|
|
36
58
|
* @returns {string} Absolute path to the .agent directory.
|
|
37
59
|
*/
|
|
38
60
|
function findAgentDir(startDir) {
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
let current = path.resolve(startDir || process.cwd());
|
|
62
|
+
const root = path.parse(current).root;
|
|
41
63
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
current = path.dirname(current);
|
|
64
|
+
while (current !== root) {
|
|
65
|
+
const candidate = path.join(current, ".agent");
|
|
66
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isDirectory()) {
|
|
67
|
+
return candidate;
|
|
48
68
|
}
|
|
69
|
+
current = path.dirname(current);
|
|
70
|
+
}
|
|
49
71
|
|
|
50
|
-
|
|
51
|
-
|
|
72
|
+
console.error(
|
|
73
|
+
`${RED}✖ Error: '.agent' directory not found. Please run 'npx tribunal-kit init' first.${RESET}`,
|
|
74
|
+
);
|
|
75
|
+
process.exit(1);
|
|
52
76
|
}
|
|
53
77
|
|
|
54
78
|
// ── Package.json Helpers ────────────────────────────────────────────────────
|
|
@@ -59,7 +83,7 @@ function findAgentDir(startDir) {
|
|
|
59
83
|
* @returns {boolean}
|
|
60
84
|
*/
|
|
61
85
|
function hasNpm(dir) {
|
|
62
|
-
|
|
86
|
+
return fs.existsSync(path.join(dir, "package.json"));
|
|
63
87
|
}
|
|
64
88
|
|
|
65
89
|
/**
|
|
@@ -68,11 +92,11 @@ function hasNpm(dir) {
|
|
|
68
92
|
* @returns {object|null}
|
|
69
93
|
*/
|
|
70
94
|
function loadJson(filePath) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
95
|
+
try {
|
|
96
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
97
|
+
} catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
76
100
|
}
|
|
77
101
|
|
|
78
102
|
// ── Filesystem Walking ──────────────────────────────────────────────────────
|
|
@@ -89,39 +113,39 @@ function loadJson(filePath) {
|
|
|
89
113
|
* @returns {string[]} Array of absolute file paths.
|
|
90
114
|
*/
|
|
91
115
|
function walkDir(dir, opts = {}) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
function _walk(currentDir) {
|
|
98
|
-
let entries;
|
|
99
|
-
try {
|
|
100
|
-
entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
101
|
-
} catch {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
116
|
+
const skipDirs = opts.skipDirs || DEFAULT_SKIP_DIRS;
|
|
117
|
+
const extensions = opts.extensions || null;
|
|
118
|
+
const filter = opts.filter || null;
|
|
119
|
+
const results = [];
|
|
104
120
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
function _walk(currentDir) {
|
|
122
|
+
let entries;
|
|
123
|
+
try {
|
|
124
|
+
entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
125
|
+
} catch {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for (const entry of entries) {
|
|
130
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
131
|
+
|
|
132
|
+
if (entry.isDirectory()) {
|
|
133
|
+
if (!skipDirs.has(entry.name)) {
|
|
134
|
+
_walk(fullPath);
|
|
135
|
+
}
|
|
136
|
+
} else if (entry.isFile()) {
|
|
137
|
+
if (extensions) {
|
|
138
|
+
const ext = path.extname(entry.name);
|
|
139
|
+
if (!extensions.has(ext)) continue;
|
|
120
140
|
}
|
|
141
|
+
if (filter && !filter(fullPath)) continue;
|
|
142
|
+
results.push(fullPath);
|
|
143
|
+
}
|
|
121
144
|
}
|
|
145
|
+
}
|
|
122
146
|
|
|
123
|
-
|
|
124
|
-
|
|
147
|
+
_walk(dir);
|
|
148
|
+
return results;
|
|
125
149
|
}
|
|
126
150
|
|
|
127
151
|
/**
|
|
@@ -131,17 +155,22 @@ function walkDir(dir, opts = {}) {
|
|
|
131
155
|
* @returns {number}
|
|
132
156
|
*/
|
|
133
157
|
function countFiles(dir, skipDirs = DEFAULT_SKIP_DIRS) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
158
|
+
let count = 0;
|
|
159
|
+
function _count(d) {
|
|
160
|
+
let entries;
|
|
161
|
+
try {
|
|
162
|
+
entries = fs.readdirSync(d, { withFileTypes: true });
|
|
163
|
+
} catch {
|
|
164
|
+
return;
|
|
142
165
|
}
|
|
143
|
-
|
|
144
|
-
|
|
166
|
+
for (const e of entries) {
|
|
167
|
+
if (e.isDirectory() && !skipDirs.has(e.name))
|
|
168
|
+
_count(path.join(d, e.name));
|
|
169
|
+
else if (e.isFile()) count++;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
_count(dir);
|
|
173
|
+
return count;
|
|
145
174
|
}
|
|
146
175
|
|
|
147
176
|
// ── CLI Argument Parsing ────────────────────────────────────────────────────
|
|
@@ -155,44 +184,44 @@ function countFiles(dir, skipDirs = DEFAULT_SKIP_DIRS) {
|
|
|
155
184
|
* @returns {{ flags: object, positional: string[] }}
|
|
156
185
|
*/
|
|
157
186
|
function parseArgs(argv, schema = {}) {
|
|
158
|
-
|
|
159
|
-
|
|
187
|
+
const flags = {};
|
|
188
|
+
const positional = [];
|
|
160
189
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
190
|
+
// Set defaults
|
|
191
|
+
for (const [key, def] of Object.entries(schema)) {
|
|
192
|
+
flags[key] = def.default ?? (def.type === "boolean" ? false : null);
|
|
193
|
+
}
|
|
165
194
|
|
|
166
|
-
|
|
167
|
-
|
|
195
|
+
for (let i = 0; i < argv.length; i++) {
|
|
196
|
+
const arg = argv[i];
|
|
168
197
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
198
|
+
if (arg === "-h" || arg === "--help") {
|
|
199
|
+
flags.help = true;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
173
202
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
203
|
+
if (arg.startsWith("--")) {
|
|
204
|
+
const flagName = arg.slice(2);
|
|
205
|
+
const schemaDef = schema[flagName];
|
|
206
|
+
|
|
207
|
+
if (schemaDef && schemaDef.type === "boolean") {
|
|
208
|
+
flags[flagName] = true;
|
|
209
|
+
} else if (schemaDef && i + 1 < argv.length) {
|
|
210
|
+
const val = argv[++i];
|
|
211
|
+
flags[flagName] = schemaDef.type === "number" ? Number(val) : val;
|
|
212
|
+
} else {
|
|
213
|
+
// Unknown flag, store as boolean
|
|
214
|
+
flags[flagName] = true;
|
|
215
|
+
}
|
|
216
|
+
} else if (arg.startsWith("-") && arg.length === 2) {
|
|
217
|
+
// Short flag — treat as boolean
|
|
218
|
+
flags[arg.slice(1)] = true;
|
|
219
|
+
} else {
|
|
220
|
+
positional.push(arg);
|
|
193
221
|
}
|
|
222
|
+
}
|
|
194
223
|
|
|
195
|
-
|
|
224
|
+
return { flags, positional };
|
|
196
225
|
}
|
|
197
226
|
|
|
198
227
|
// ── Command Runner ──────────────────────────────────────────────────────────
|
|
@@ -207,38 +236,44 @@ function parseArgs(argv, schema = {}) {
|
|
|
207
236
|
* @returns {{ status: number, stdout: string, stderr: string, ok: boolean }}
|
|
208
237
|
*/
|
|
209
238
|
function runCommand(cmd, args = [], opts = {}) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
239
|
+
const { spawnSync } = require("child_process");
|
|
240
|
+
const executable =
|
|
241
|
+
process.platform === "win32" &&
|
|
242
|
+
!cmd.endsWith(".cmd") &&
|
|
243
|
+
!cmd.includes(path.sep)
|
|
244
|
+
? `${cmd}.cmd`
|
|
245
|
+
: cmd;
|
|
246
|
+
|
|
247
|
+
const result = spawnSync(executable, args, {
|
|
248
|
+
encoding: "utf8",
|
|
249
|
+
timeout: opts.timeout || 120000,
|
|
250
|
+
cwd: opts.cwd || process.cwd(),
|
|
251
|
+
shell: process.platform === "win32",
|
|
252
|
+
stdio: opts.stdio || "pipe",
|
|
253
|
+
...opts,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
status: result.status ?? 1,
|
|
258
|
+
stdout: (result.stdout || "").toString(),
|
|
259
|
+
stderr: (result.stderr || "").toString(),
|
|
260
|
+
ok: result.status === 0,
|
|
261
|
+
};
|
|
230
262
|
}
|
|
231
263
|
|
|
232
264
|
module.exports = {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
265
|
+
// Agent discovery
|
|
266
|
+
findAgentDir,
|
|
267
|
+
// Package.json
|
|
268
|
+
hasNpm,
|
|
269
|
+
loadJson,
|
|
270
|
+
// Filesystem
|
|
271
|
+
walkDir,
|
|
272
|
+
countFiles,
|
|
273
|
+
DEFAULT_SKIP_DIRS,
|
|
274
|
+
SOURCE_EXTENSIONS,
|
|
275
|
+
// CLI
|
|
276
|
+
parseArgs,
|
|
277
|
+
// Commands
|
|
278
|
+
runCommand,
|
|
244
279
|
};
|