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,193 +1,186 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* test_runner.js — Standalone test runner for the Tribunal Agent Kit.
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* node .agent/scripts/test_runner.js .
|
|
7
|
-
* node .agent/scripts/test_runner.js . --coverage
|
|
8
|
-
* node .agent/scripts/test_runner.js . --watch
|
|
9
|
-
* node .agent/scripts/test_runner.js . --file src/utils.test.ts
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
const fs = require('fs');
|
|
15
|
-
const path = require('path');
|
|
16
|
-
const { spawnSync } = require('child_process');
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
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
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
cmd = ["
|
|
157
|
-
if (coverageFlag) cmd.push("--coverage");
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
passed
|
|
177
|
-
} else
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
process.exit(passed ? 0 : 1);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (require.main === module) {
|
|
192
|
-
main();
|
|
193
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* test_runner.js — Standalone test runner for the Tribunal Agent Kit.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node .agent/scripts/test_runner.js .
|
|
7
|
+
* node .agent/scripts/test_runner.js . --coverage
|
|
8
|
+
* node .agent/scripts/test_runner.js . --watch
|
|
9
|
+
* node .agent/scripts/test_runner.js . --file src/utils.test.ts
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const { spawnSync } = require('child_process');
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
RED, GREEN, YELLOW, BLUE, BOLD, DIM, CYAN, RESET,
|
|
20
|
+
banner, sectionHeader, timer, formatMs,
|
|
21
|
+
ok, fail, skip,
|
|
22
|
+
} = require('./_colors');
|
|
23
|
+
|
|
24
|
+
const { loadJson } = require('./_utils');
|
|
25
|
+
|
|
26
|
+
function runTests(label, cmd, cwd) {
|
|
27
|
+
const elapsed = timer();
|
|
28
|
+
try {
|
|
29
|
+
const executable = process.platform === 'win32' && (cmd[0] === 'npx' || cmd[0] === 'npm') ? `${cmd[0]}.cmd` : cmd[0];
|
|
30
|
+
const result = spawnSync(executable, cmd.slice(1), {
|
|
31
|
+
cwd,
|
|
32
|
+
encoding: 'utf8',
|
|
33
|
+
timeout: 300000, // 5m
|
|
34
|
+
shell: process.platform === 'win32'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const ms = elapsed();
|
|
38
|
+
|
|
39
|
+
if (result.error && !result.stdout && !result.stderr) {
|
|
40
|
+
console.log(` Error: ${result.error.message}`);
|
|
41
|
+
}
|
|
42
|
+
const out = result.stdout ? result.stdout.toString() : '';
|
|
43
|
+
const err = result.stderr ? result.stderr.toString() : '';
|
|
44
|
+
const output = (out + "\n" + err).trim();
|
|
45
|
+
if (output) {
|
|
46
|
+
for (const line of output.split("\n")) {
|
|
47
|
+
console.log(` ${line}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (result.status === 0) {
|
|
52
|
+
ok(`${label} — all tests passed ${DIM}(${formatMs(ms)})${RESET}`);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
fail(`${label} — test failures detected ${DIM}(${formatMs(ms)})${RESET}`);
|
|
57
|
+
return false;
|
|
58
|
+
} catch {
|
|
59
|
+
skip(`${label} — tool not installed`);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function detectTestFramework(projectRoot) {
|
|
65
|
+
const pkg = loadJson(path.join(projectRoot, "package.json"));
|
|
66
|
+
if (pkg) {
|
|
67
|
+
const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
|
|
68
|
+
const scripts = pkg.scripts || {};
|
|
69
|
+
|
|
70
|
+
if (deps.vitest) return "vitest";
|
|
71
|
+
if (deps.jest) return "jest";
|
|
72
|
+
if (deps.mocha) return "mocha";
|
|
73
|
+
if (scripts.test) return "npm-test";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (fs.existsSync(path.join(projectRoot, "pytest.ini")) ||
|
|
77
|
+
fs.existsSync(path.join(projectRoot, "pyproject.toml")) ||
|
|
78
|
+
fs.existsSync(path.join(projectRoot, "conftest.py"))) {
|
|
79
|
+
return "pytest";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Go
|
|
83
|
+
function hasGoTests(dir) {
|
|
84
|
+
let items;
|
|
85
|
+
try { items = fs.readdirSync(dir, { withFileTypes: true }); } catch { return false; }
|
|
86
|
+
for (const item of items) {
|
|
87
|
+
if (item.isDirectory() && !["node_modules", ".git"].includes(item.name)) {
|
|
88
|
+
if (hasGoTests(path.join(dir, item.name))) return true;
|
|
89
|
+
} else if (item.name.endsWith("_test.go")) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (hasGoTests(projectRoot)) return "go";
|
|
97
|
+
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function main() {
|
|
102
|
+
const args = process.argv.slice(2);
|
|
103
|
+
let targetPath = null;
|
|
104
|
+
let coverageFlag = false;
|
|
105
|
+
let watchFlag = false;
|
|
106
|
+
let fileArg = null;
|
|
107
|
+
|
|
108
|
+
let i = 0;
|
|
109
|
+
while (i < args.length) {
|
|
110
|
+
if (args[i] === '--coverage') coverageFlag = true;
|
|
111
|
+
else if (args[i] === '--watch') watchFlag = true;
|
|
112
|
+
else if (args[i] === '--file' && i + 1 < args.length) fileArg = args[++i];
|
|
113
|
+
else if (!targetPath && !args[i].startsWith('-')) targetPath = args[i];
|
|
114
|
+
i++;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!targetPath) {
|
|
118
|
+
console.log("Usage: node test_runner.js <path> [--coverage] [--watch] [--file <filepath>]");
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const projectRoot = path.resolve(targetPath);
|
|
123
|
+
if (!fs.existsSync(projectRoot) || !fs.statSync(projectRoot).isDirectory()) {
|
|
124
|
+
fail(`Directory not found: ${projectRoot}`);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const framework = detectTestFramework(projectRoot);
|
|
129
|
+
console.log(banner('test_runner.js', {
|
|
130
|
+
Project: projectRoot,
|
|
131
|
+
Framework: framework || 'none detected',
|
|
132
|
+
}));
|
|
133
|
+
|
|
134
|
+
if (!framework) {
|
|
135
|
+
skip("No test framework detected in this project");
|
|
136
|
+
process.exit(0);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
console.log(sectionHeader(`Running tests (${framework})`));
|
|
140
|
+
|
|
141
|
+
let cmd = [];
|
|
142
|
+
let passed = true;
|
|
143
|
+
|
|
144
|
+
if (["vitest", "jest", "mocha", "npm-test"].includes(framework)) {
|
|
145
|
+
if (framework === "vitest") {
|
|
146
|
+
cmd = ["npx", "vitest", "run"];
|
|
147
|
+
if (coverageFlag) cmd.push("--coverage");
|
|
148
|
+
if (watchFlag) cmd = ["npx", "vitest"];
|
|
149
|
+
if (fileArg) cmd.push(fileArg);
|
|
150
|
+
} else if (framework === "jest") {
|
|
151
|
+
cmd = ["npx", "jest"];
|
|
152
|
+
if (coverageFlag) cmd.push("--coverage");
|
|
153
|
+
if (watchFlag) cmd.push("--watch");
|
|
154
|
+
if (fileArg) cmd.push(fileArg);
|
|
155
|
+
} else {
|
|
156
|
+
cmd = ["npm", "test", "--", "--passWithNoTests"];
|
|
157
|
+
if (coverageFlag) cmd.push("--coverage");
|
|
158
|
+
if (fileArg) cmd.push(fileArg);
|
|
159
|
+
}
|
|
160
|
+
passed = runTests(framework, cmd, projectRoot);
|
|
161
|
+
} else if (framework === "pytest") {
|
|
162
|
+
cmd = ["python", "-m", "pytest", "-v"];
|
|
163
|
+
if (coverageFlag) cmd.push("--cov", "--cov-report=term-missing");
|
|
164
|
+
if (watchFlag) cmd = ["python", "-m", "pytest-watch", "--", "-v"];
|
|
165
|
+
if (fileArg) cmd.push(fileArg);
|
|
166
|
+
passed = runTests("pytest", cmd, projectRoot);
|
|
167
|
+
} else if (framework === "go") {
|
|
168
|
+
cmd = ["go", "test", "./...", "-v"];
|
|
169
|
+
if (coverageFlag) cmd.push("-cover");
|
|
170
|
+
if (fileArg) cmd = ["go", "test", "-v", "-run", fileArg];
|
|
171
|
+
passed = runTests("go test", cmd, projectRoot);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
console.log(`\n${BOLD}${CYAN}━━━ Test Summary ━━━${RESET}`);
|
|
175
|
+
if (passed) {
|
|
176
|
+
console.log(`\n${GREEN}${BOLD} ✔ Tests passed (${framework}).${RESET}\n`);
|
|
177
|
+
} else {
|
|
178
|
+
console.log(`\n${RED}${BOLD} ✖ Tests failed (${framework}).${RESET}\n`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
process.exit(passed ? 0 : 1);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (require.main === module) {
|
|
185
|
+
main();
|
|
186
|
+
}
|
package/.agent/scripts/utils.js
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* utils.js
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
current = path.dirname(current);
|
|
19
|
-
}
|
|
20
|
-
console.error("\x1b[91m✖ Error: '.agent' directory not found. Please run 'npx tribunal-kit init' first.\x1b[0m");
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function ensureUtf8Stdout() {
|
|
25
|
-
// In Node.js, process.stdout is typically already UTF-8 capable,
|
|
26
|
-
// but this exists for compatibility with legacy python workflows.
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
module.exports = {
|
|
30
|
-
findAgentDir,
|
|
31
|
-
ensureUtf8Stdout
|
|
32
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* utils.js — Backward-compatible re-export of _utils.js
|
|
3
|
+
* ══════════════════════════════════════════════════════
|
|
4
|
+
* All utilities are defined in _utils.js.
|
|
5
|
+
* This file re-exports them for scripts that import from './utils.js'.
|
|
6
|
+
*
|
|
7
|
+
* New scripts should import from './_utils' directly.
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const _utils = require('./_utils');
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
..._utils,
|
|
15
|
+
// Legacy export for compatibility
|
|
16
|
+
ensureUtf8Stdout: function() {},
|
|
17
|
+
};
|