tribunal-kit 4.4.1 → 4.4.2
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/history/architecture-graph.yaml +140 -0
- package/.agent/history/graph-cache.json +262 -0
- package/.agent/history/snapshots/bin__tribunal-kit.js.json +19 -0
- package/.agent/history/snapshots/eslint.config.js.json +9 -0
- package/.agent/history/snapshots/migrate_refs.js.json +11 -0
- package/.agent/history/snapshots/scripts__changelog.js.json +13 -0
- package/.agent/history/snapshots/scripts__sync-version.js.json +12 -0
- package/.agent/history/snapshots/scripts__validate-payload.js.json +12 -0
- package/.agent/history/snapshots/test__integration__bridges.test.js.json +14 -0
- package/.agent/history/snapshots/test__integration__init.test.js.json +14 -0
- package/.agent/history/snapshots/test__integration__routing.test.js.json +12 -0
- package/.agent/history/snapshots/test__integration__swarm_dispatcher.test.js.json +14 -0
- package/.agent/history/snapshots/test__integration__wave2.test.js.json +14 -0
- package/.agent/history/snapshots/test__unit__args.test.js.json +20 -0
- package/.agent/history/snapshots/test__unit__case_law_manager.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__context_broker.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__copyDir.test.js.json +23 -0
- package/.agent/history/snapshots/test__unit__graph_tools.test.js.json +12 -0
- package/.agent/history/snapshots/test__unit__inner_loop_validator.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__selfInstall.test.js.json +23 -0
- package/.agent/history/snapshots/test__unit__semver.test.js.json +20 -0
- package/.agent/history/snapshots/test__unit__swarm_dispatcher.test.js.json +12 -0
- package/.agent/scripts/_colors.js +170 -18
- package/.agent/scripts/_utils.js +244 -42
- package/.agent/scripts/bundle_analyzer.js +261 -290
- package/.agent/scripts/case_law_manager.js +1 -7
- package/.agent/scripts/checklist.js +278 -266
- package/.agent/scripts/colors.js +11 -17
- package/.agent/scripts/context_broker.js +1 -7
- package/.agent/scripts/dependency_analyzer.js +234 -272
- package/.agent/scripts/graph_builder.js +46 -18
- package/.agent/scripts/graph_visualizer.js +10 -4
- package/.agent/scripts/graph_zoom.js +6 -4
- package/.agent/scripts/inner_loop_validator.js +2 -8
- package/.agent/scripts/lint_runner.js +186 -187
- package/.agent/scripts/schema_validator.js +8 -25
- package/.agent/scripts/security_scan.js +276 -303
- package/.agent/scripts/session_manager.js +1 -7
- package/.agent/scripts/skill_evolution.js +1 -8
- package/.agent/scripts/skill_integrator.js +1 -7
- package/.agent/scripts/test_runner.js +186 -193
- package/.agent/scripts/utils.js +17 -32
- package/.agent/scripts/verify_all.js +248 -257
- package/package.json +1 -1
|
@@ -1,257 +1,248 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* verify_all.js — Full pre-deploy validation suite for the Tribunal Agent Kit.
|
|
4
|
-
*
|
|
5
|
-
* Runs comprehensive checks before any production deployment.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* node .agent/scripts/verify_all.js
|
|
9
|
-
* node .agent/scripts/verify_all.js --skip build,deps
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
const fs = require('fs');
|
|
15
|
-
const path = require('path');
|
|
16
|
-
const { execFileSync } = require('child_process');
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const noteStr = note ? `\n ${note}` : '';
|
|
40
|
-
console.log(` ${RED}❌ ${label}${RESET}${noteStr}`);
|
|
41
|
-
RESULTS.push({ label,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function
|
|
45
|
-
console.log(` ${YELLOW}⏭️ ${label} — ${reason}${RESET}`);
|
|
46
|
-
RESULTS.push({ label,
|
|
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
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
// ━━━ Exports for testing & programmatic use ━━━
|
|
253
|
-
module.exports = { verifyAll, scanSecrets, hasNpm };
|
|
254
|
-
|
|
255
|
-
if (require.main === module) {
|
|
256
|
-
main();
|
|
257
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* verify_all.js — Full pre-deploy validation suite for the Tribunal Agent Kit.
|
|
4
|
+
*
|
|
5
|
+
* Runs comprehensive checks before any production deployment.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* node .agent/scripts/verify_all.js
|
|
9
|
+
* node .agent/scripts/verify_all.js --skip build,deps
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const { execFileSync } = require('child_process');
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
RED, GREEN, YELLOW, BLUE, BOLD, DIM, CYAN, RESET,
|
|
20
|
+
banner, sectionHeader, summaryTable, timer, formatMs,
|
|
21
|
+
ok, fail, skip,
|
|
22
|
+
} = require('./_colors');
|
|
23
|
+
|
|
24
|
+
const { walkDir, hasNpm, SOURCE_EXTENSIONS } = require('./_utils');
|
|
25
|
+
|
|
26
|
+
// ── Results Tracking ────────────────────────────────────────────────────────
|
|
27
|
+
|
|
28
|
+
const RESULTS = [];
|
|
29
|
+
|
|
30
|
+
function trackOk(label, ms, note) {
|
|
31
|
+
const timing = ms != null ? `${DIM}(${formatMs(ms)})${RESET}` : '';
|
|
32
|
+
const noteStr = note ? ` ${DIM}${note}${RESET}` : '';
|
|
33
|
+
console.log(` ${GREEN}✅ ${label}${RESET} ${timing}${noteStr}`);
|
|
34
|
+
RESULTS.push({ name: label, status: 'pass', ms, note: note || '' });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function trackFail(label, ms, note) {
|
|
38
|
+
const timing = ms != null ? `${DIM}(${formatMs(ms)})${RESET}` : '';
|
|
39
|
+
const noteStr = note ? `\n ${note}` : '';
|
|
40
|
+
console.log(` ${RED}❌ ${label}${RESET} ${timing}${noteStr}`);
|
|
41
|
+
RESULTS.push({ name: label, status: 'fail', ms, note: note || '' });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function trackSkip(label, reason) {
|
|
45
|
+
console.log(` ${YELLOW}⏭️ ${label} — ${reason}${RESET}`);
|
|
46
|
+
RESULTS.push({ name: label, status: 'skip', note: `skipped: ${reason}` });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ── Command Runner ──────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Run a shell command and return true if it exits with code 0.
|
|
53
|
+
*/
|
|
54
|
+
function run(label, cmd, cwd) {
|
|
55
|
+
const elapsed = timer();
|
|
56
|
+
try {
|
|
57
|
+
const isWindows = process.platform === 'win32';
|
|
58
|
+
|
|
59
|
+
execFileSync(cmd[0], cmd.slice(1), {
|
|
60
|
+
cwd,
|
|
61
|
+
stdio: 'pipe',
|
|
62
|
+
timeout: 120000,
|
|
63
|
+
encoding: 'utf8',
|
|
64
|
+
shell: isWindows
|
|
65
|
+
});
|
|
66
|
+
trackOk(label, elapsed());
|
|
67
|
+
return true;
|
|
68
|
+
} catch (err) {
|
|
69
|
+
const ms = elapsed();
|
|
70
|
+
if (err.code === 'ENOENT') {
|
|
71
|
+
trackSkip(label, 'tool not installed — skipping');
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (err.killed) {
|
|
75
|
+
trackFail(label, ms, 'timed out after 120s');
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const output = ((err.stdout || '') + (err.stderr || '')).trim();
|
|
79
|
+
trackFail(label, ms, output ? output.slice(0, 500) : 'non-zero exit code');
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Scan source files for obviously hardcoded credentials.
|
|
87
|
+
* Uses shared walkDir from _utils.js to eliminate duplicated walker code.
|
|
88
|
+
*/
|
|
89
|
+
function scanSecrets(cwd) {
|
|
90
|
+
const elapsed = timer();
|
|
91
|
+
const patterns = ['password=', 'secret=', 'api_key=', 'private_key=', 'auth_token='];
|
|
92
|
+
const found = [];
|
|
93
|
+
|
|
94
|
+
const sourceExtensions = new Set(['.ts', '.tsx', '.js', '.jsx', '.py']);
|
|
95
|
+
const files = walkDir(cwd, { extensions: sourceExtensions });
|
|
96
|
+
|
|
97
|
+
for (const fullPath of files) {
|
|
98
|
+
let content;
|
|
99
|
+
try { content = fs.readFileSync(fullPath, 'utf8'); } catch { continue; }
|
|
100
|
+
|
|
101
|
+
const lines = content.split('\n');
|
|
102
|
+
for (let i = 0; i < lines.length; i++) {
|
|
103
|
+
const low = lines[i].toLowerCase().trim();
|
|
104
|
+
const hasPattern = patterns.some(p => low.includes(p));
|
|
105
|
+
if (hasPattern && !low.startsWith('#') && low.includes('=')) {
|
|
106
|
+
const rel = path.relative(cwd, fullPath);
|
|
107
|
+
found.push(`${rel}:${i + 1}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const ms = elapsed();
|
|
113
|
+
if (found.length > 0) {
|
|
114
|
+
trackFail('Secret scan', ms, found.slice(0, 5).join('\n '));
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
trackOk('Secret scan — no hardcoded credentials found', ms, `${files.length} files scanned`);
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Run all verification checks. Returns number of failures.
|
|
124
|
+
*/
|
|
125
|
+
function verifyAll(cwd, skipped) {
|
|
126
|
+
let failures = 0;
|
|
127
|
+
RESULTS.length = 0; // Reset for clean runs (prevents accumulation in tests)
|
|
128
|
+
const totalTimer = timer();
|
|
129
|
+
|
|
130
|
+
console.log(sectionHeader('Secret Scan', 1));
|
|
131
|
+
if (!skipped.includes('secrets')) {
|
|
132
|
+
if (!scanSecrets(cwd)) failures++;
|
|
133
|
+
} else {
|
|
134
|
+
trackSkip('Secret scan', 'skipped by flag');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
console.log(sectionHeader('TypeScript', 2));
|
|
138
|
+
if (!skipped.includes('typescript')) {
|
|
139
|
+
if (hasNpm(cwd)) {
|
|
140
|
+
if (!run('tsc --noEmit', ['npx', 'tsc', '--noEmit'], cwd)) failures++;
|
|
141
|
+
} else {
|
|
142
|
+
trackSkip('TypeScript', 'no package.json found in project');
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
trackSkip('TypeScript', 'skipped by flag');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
console.log(sectionHeader('ESLint', 3));
|
|
149
|
+
if (!skipped.includes('lint')) {
|
|
150
|
+
if (hasNpm(cwd)) {
|
|
151
|
+
if (!run('ESLint', ['npx', 'eslint', '.', '--max-warnings=0'], cwd)) failures++;
|
|
152
|
+
} else {
|
|
153
|
+
trackSkip('ESLint', 'no package.json found in project');
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
trackSkip('ESLint', 'skipped by flag');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
console.log(sectionHeader('Unit Tests', 4));
|
|
160
|
+
if (!skipped.includes('tests')) {
|
|
161
|
+
if (hasNpm(cwd)) {
|
|
162
|
+
if (!run('Test suite', ['npm', 'test', '--', '--passWithNoTests'], cwd)) failures++;
|
|
163
|
+
} else {
|
|
164
|
+
trackSkip('Tests', 'no package.json found in project');
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
trackSkip('Tests', 'skipped by flag');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
console.log(sectionHeader('Build', 5));
|
|
171
|
+
if (!skipped.includes('build')) {
|
|
172
|
+
if (hasNpm(cwd)) {
|
|
173
|
+
if (!run('npm run build', ['npm', 'run', 'build'], cwd)) failures++;
|
|
174
|
+
} else {
|
|
175
|
+
trackSkip('Build', 'no package.json found in project');
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
trackSkip('Build', 'skipped by flag');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
console.log(sectionHeader('Dependency Audit', 6));
|
|
182
|
+
if (!skipped.includes('deps')) {
|
|
183
|
+
if (hasNpm(cwd)) {
|
|
184
|
+
if (!run('npm audit', ['npm', 'audit', '--audit-level=high'], cwd)) failures++;
|
|
185
|
+
} else {
|
|
186
|
+
trackSkip('Dependency audit', 'no package.json found in project');
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
trackSkip('Dependency audit', 'skipped by flag');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ━━━ Summary Table ━━━
|
|
193
|
+
const totalMs = totalTimer();
|
|
194
|
+
console.log(`\n${BOLD}${CYAN}━━━ Verification Summary ━━━${RESET}`);
|
|
195
|
+
summaryTable(RESULTS);
|
|
196
|
+
|
|
197
|
+
const passCount = RESULTS.filter(r => r.status === 'pass').length;
|
|
198
|
+
const failCount = RESULTS.filter(r => r.status === 'fail').length;
|
|
199
|
+
const skipCount = RESULTS.filter(r => r.status === 'skip').length;
|
|
200
|
+
|
|
201
|
+
console.log(`\n ${DIM}Total: ${RESULTS.length} checks in ${formatMs(totalMs)}${RESET}`);
|
|
202
|
+
console.log(` ${GREEN}${passCount} passed${RESET} ${failCount > 0 ? `${RED}${failCount} failed${RESET} ` : ''}${skipCount > 0 ? `${YELLOW}${skipCount} skipped${RESET}` : ''}`);
|
|
203
|
+
|
|
204
|
+
console.log();
|
|
205
|
+
if (failures === 0) {
|
|
206
|
+
console.log(`${GREEN}${BOLD} ✔ All checks passed — safe to deploy.${RESET}`);
|
|
207
|
+
} else {
|
|
208
|
+
console.log(`${RED}${BOLD} ✖ ${failures} check(s) failed — fix before deploying.${RESET}`);
|
|
209
|
+
}
|
|
210
|
+
console.log();
|
|
211
|
+
|
|
212
|
+
return failures;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Parse CLI arguments manually (no external dependencies).
|
|
218
|
+
*/
|
|
219
|
+
function parseArgs(argv) {
|
|
220
|
+
const args = { skip: [] };
|
|
221
|
+
const raw = argv.slice(2);
|
|
222
|
+
|
|
223
|
+
for (let i = 0; i < raw.length; i++) {
|
|
224
|
+
if (raw[i] === '--skip' && raw[i + 1]) {
|
|
225
|
+
args.skip = raw[++i].split(',').map(s => s.trim().toLowerCase()).filter(Boolean);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return args;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
function main() {
|
|
233
|
+
const args = parseArgs(process.argv);
|
|
234
|
+
const cwd = process.cwd();
|
|
235
|
+
|
|
236
|
+
console.log(banner('verify_all.js', { Project: cwd }));
|
|
237
|
+
|
|
238
|
+
const failures = verifyAll(cwd, args.skip);
|
|
239
|
+
process.exit(failures > 0 ? 1 : 0);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
// ━━━ Exports for testing & programmatic use ━━━
|
|
244
|
+
module.exports = { verifyAll, scanSecrets, hasNpm };
|
|
245
|
+
|
|
246
|
+
if (require.main === module) {
|
|
247
|
+
main();
|
|
248
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tribunal-kit",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.2",
|
|
4
4
|
"description": "Anti-Hallucination AI Agent Kit — 40 specialist agents, 31 slash commands, 16 parallel Tribunal reviewers, Performance Swarm engine, and Supreme Court case law pipeline.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|