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