tribunal-kit 4.4.4 → 4.5.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/scripts/swarm_dispatcher.js +107 -10
- package/.agent/skills/advanced-rag-pipelines/SKILL.md +53 -0
- package/.agent/skills/browser-native-ai/SKILL.md +58 -0
- package/.agent/skills/generative-ui-expert/SKILL.md +83 -0
- package/.agent/skills/harness-protocol/SKILL.md +23 -0
- package/.agent/skills/webgpu-performance/SKILL.md +73 -0
- package/README.md +17 -1
- package/bin/tribunal-kit.js +1152 -1119
- package/bin/wrapper.js +98 -0
- package/package.json +4 -3
- package/scripts/postinstall.js +127 -0
package/bin/wrapper.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Tribunal-Kit Core Wrapper
|
|
4
|
+
*
|
|
5
|
+
* This script routes commands to the ultra-fast Rust binary if available and supported.
|
|
6
|
+
* For legacy commands (or if the binary isn't available/compiled yet), it gracefully
|
|
7
|
+
* falls back to the original JavaScript implementation.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { spawnSync } = require('child_process');
|
|
13
|
+
const os = require('os');
|
|
14
|
+
|
|
15
|
+
// Commands that have been fully ported to Rust so far
|
|
16
|
+
const RUST_COMMANDS = new Set(['init', 'validate', 'status']);
|
|
17
|
+
|
|
18
|
+
// Determine the path to the compiled Rust binary
|
|
19
|
+
// In a full production release, this checks optionalDependencies in node_modules
|
|
20
|
+
// For development, it checks the local target/release folder
|
|
21
|
+
function getBinaryPath() {
|
|
22
|
+
const isWindows = os.platform() === 'win32';
|
|
23
|
+
const ext = isWindows ? '.exe' : '';
|
|
24
|
+
|
|
25
|
+
// First, check bin/ directory (postinstall downloaded binary)
|
|
26
|
+
const binPath = path.resolve(__dirname, `tribunal-core${ext}`);
|
|
27
|
+
if (fs.existsSync(binPath)) {
|
|
28
|
+
return binPath;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Second, try to find the binary compiled from crates/core/Cargo.toml
|
|
32
|
+
const devPath = path.resolve(__dirname, '..', 'target', 'release', `tribunal-core${ext}`);
|
|
33
|
+
if (fs.existsSync(devPath)) {
|
|
34
|
+
return devPath;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Third, try target/debug (if they ran `cargo build` instead of `--release`)
|
|
38
|
+
const debugPath = path.resolve(__dirname, '..', 'target', 'debug', `tribunal-core${ext}`);
|
|
39
|
+
if (fs.existsSync(debugPath)) {
|
|
40
|
+
return debugPath;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Production resolution (from optionalDependencies) would go here
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function runRustBinary(binPath, args) {
|
|
48
|
+
const result = spawnSync(binPath, args, {
|
|
49
|
+
stdio: 'inherit',
|
|
50
|
+
env: process.env
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (result.error) {
|
|
54
|
+
console.error(`\x1b[91m✖ Failed to execute Rust engine:\x1b[0m ${result.error.message}`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
process.exit(result.status || 0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function runLegacyFallback() {
|
|
62
|
+
// Graceful fallback to the original JS implementation
|
|
63
|
+
// We do this by modifying process.argv so it appears normal to the legacy script
|
|
64
|
+
require('./tribunal-kit.js');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function main() {
|
|
68
|
+
// Skip 'node' and 'wrapper.js'
|
|
69
|
+
const args = process.argv.slice(2);
|
|
70
|
+
|
|
71
|
+
// Extract the command (the first non-flag argument)
|
|
72
|
+
const command = args.find(a => !a.startsWith('-'));
|
|
73
|
+
|
|
74
|
+
if (command && RUST_COMMANDS.has(command)) {
|
|
75
|
+
const binPath = getBinaryPath();
|
|
76
|
+
|
|
77
|
+
if (binPath) {
|
|
78
|
+
// For the init command, Rust needs to know where the .agent template folder is.
|
|
79
|
+
if (command === 'init') {
|
|
80
|
+
const sourceDir = path.resolve(__dirname, '..', '.agent');
|
|
81
|
+
args.push('--source-dir', sourceDir);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Route to Rust engine
|
|
85
|
+
// console.log('\x1b[90m⚡ Executing via Rust Core Engine\x1b[0m');
|
|
86
|
+
runRustBinary(binPath, args);
|
|
87
|
+
return;
|
|
88
|
+
} else {
|
|
89
|
+
// Warn if Rust command was requested but binary is missing
|
|
90
|
+
console.warn('\x1b[93m⚠ Rust binary not found in target/. Falling back to JS engine.\x1b[0m');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Fall back to JS logic for un-ported commands (e.g. `learn`, `case`, `marathon`)
|
|
95
|
+
runLegacyFallback();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tribunal-kit",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Anti-Hallucination AI Agent Kit — 40 specialist agents, 32 slash commands, 16 parallel Tribunal reviewers, Performance Swarm engine, Supreme Court case law pipeline, and long-running agent harness.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"bin": {
|
|
45
|
-
"tribunal-kit": "bin/
|
|
46
|
-
"tk": "bin/
|
|
45
|
+
"tribunal-kit": "bin/wrapper.js",
|
|
46
|
+
"tk": "bin/wrapper.js"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"bin/",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"changelog:preview": "node scripts/changelog.js --preview",
|
|
66
66
|
"sync": "node scripts/sync-version.js",
|
|
67
67
|
"validate-payload": "node scripts/validate-payload.js",
|
|
68
|
+
"postinstall": "node scripts/postinstall.js",
|
|
68
69
|
"build": "echo 'No build step required for this project'"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* postinstall.js — Binary Download Script
|
|
4
|
+
*
|
|
5
|
+
* After `npm install`, this script downloads the pre-compiled Rust binary
|
|
6
|
+
* for the user's platform from the latest GitHub Release.
|
|
7
|
+
*
|
|
8
|
+
* If the download fails (offline, unsupported platform, etc.), it's a soft failure.
|
|
9
|
+
* The wrapper.js will detect the missing binary and fall back to the JS engine.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const https = require('https');
|
|
15
|
+
const os = require('os');
|
|
16
|
+
const crypto = require('crypto');
|
|
17
|
+
|
|
18
|
+
const PKG = require(path.resolve(__dirname, '..', 'package.json'));
|
|
19
|
+
const VERSION = PKG.version;
|
|
20
|
+
|
|
21
|
+
const BINARY_DIR = path.resolve(__dirname, '..', 'bin');
|
|
22
|
+
const REPO = 'Harmitx7/tribunal-kit';
|
|
23
|
+
|
|
24
|
+
function getPlatformBinary() {
|
|
25
|
+
const platform = os.platform();
|
|
26
|
+
const arch = os.arch();
|
|
27
|
+
|
|
28
|
+
const map = {
|
|
29
|
+
'win32-x64': 'tribunal-core-win-x64.exe',
|
|
30
|
+
'win32-arm64': 'tribunal-core-win-arm64.exe',
|
|
31
|
+
'darwin-x64': 'tribunal-core-darwin-x64',
|
|
32
|
+
'darwin-arm64': 'tribunal-core-darwin-arm64',
|
|
33
|
+
'linux-x64': 'tribunal-core-linux-x64',
|
|
34
|
+
'linux-arm64': 'tribunal-core-linux-arm64',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const key = `${platform}-${arch}`;
|
|
38
|
+
return map[key] || null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getLocalBinaryPath() {
|
|
42
|
+
const isWindows = os.platform() === 'win32';
|
|
43
|
+
return path.join(BINARY_DIR, `tribunal-core${isWindows ? '.exe' : ''}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function download(url) {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const request = https.get(url, { headers: { 'User-Agent': `tribunal-kit/${VERSION}` } }, (res) => {
|
|
49
|
+
// Handle redirects (GitHub sends 302 to the actual download URL)
|
|
50
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
51
|
+
download(res.headers.location).then(resolve).catch(reject);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (res.statusCode !== 200) {
|
|
56
|
+
reject(new Error(`HTTP ${res.statusCode}`));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const chunks = [];
|
|
61
|
+
res.on('data', (chunk) => chunks.push(chunk));
|
|
62
|
+
res.on('end', () => resolve(Buffer.concat(chunks)));
|
|
63
|
+
res.on('error', reject);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
request.on('error', reject);
|
|
67
|
+
request.setTimeout(30000, () => { request.destroy(); reject(new Error('Timeout')); });
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function main() {
|
|
72
|
+
const binaryName = getPlatformBinary();
|
|
73
|
+
|
|
74
|
+
if (!binaryName) {
|
|
75
|
+
console.log(`[tribunal-kit] No pre-built binary for ${os.platform()}-${os.arch()}. Using JS fallback.`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const localPath = getLocalBinaryPath();
|
|
80
|
+
|
|
81
|
+
// Skip if binary already exists (e.g. dev environment with cargo build)
|
|
82
|
+
if (fs.existsSync(localPath)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${binaryName}`;
|
|
87
|
+
const checksumsUrl = `https://github.com/${REPO}/releases/download/v${VERSION}/checksums.txt`;
|
|
88
|
+
|
|
89
|
+
console.log(`[tribunal-kit] Downloading native binary for ${os.platform()}-${os.arch()}...`);
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
// 1. Download checksums file
|
|
93
|
+
const checksumsData = await download(checksumsUrl);
|
|
94
|
+
const checksumsText = checksumsData.toString('utf-8');
|
|
95
|
+
|
|
96
|
+
// 2. Extract expected hash
|
|
97
|
+
const hashMatch = checksumsText.split('\n').find(line => line.includes(binaryName));
|
|
98
|
+
if (!hashMatch) {
|
|
99
|
+
throw new Error(`Checksum for ${binaryName} not found in checksums.txt`);
|
|
100
|
+
}
|
|
101
|
+
const expectedHash = hashMatch.split(' ')[0].trim();
|
|
102
|
+
|
|
103
|
+
// 3. Download binary
|
|
104
|
+
const data = await download(url);
|
|
105
|
+
|
|
106
|
+
// 4. Verify checksum
|
|
107
|
+
const actualHash = crypto.createHash('sha256').update(data).digest('hex');
|
|
108
|
+
if (actualHash !== expectedHash) {
|
|
109
|
+
throw new Error(`Checksum mismatch! Expected ${expectedHash}, got ${actualHash}. Potential tamper detected.`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 5. Write to disk
|
|
113
|
+
fs.writeFileSync(localPath, data);
|
|
114
|
+
|
|
115
|
+
// Make executable on Unix
|
|
116
|
+
if (os.platform() !== 'win32') {
|
|
117
|
+
fs.chmodSync(localPath, 0o755);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
console.log(`[tribunal-kit] Native binary installed and verified successfully.`);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
// Soft failure — wrapper.js will use the JS engine
|
|
123
|
+
console.log(`[tribunal-kit] Binary download skipped (${e.message}). Using JS fallback.`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
main();
|