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