@rigour-labs/core 4.0.4 → 4.0.5
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sidecar Binary Provider — runs inference via pre-compiled llama.cpp binary.
|
|
3
|
-
* Binary ships as @rigour/brain-{platform} optional npm dependency.
|
|
3
|
+
* Binary ships as @rigour-labs/brain-{platform} optional npm dependency.
|
|
4
4
|
* Falls back to PATH lookup for development/manual installs.
|
|
5
5
|
*/
|
|
6
6
|
import { execFile } from 'child_process';
|
|
@@ -13,11 +13,11 @@ import { ensureModel, isModelCached, getModelInfo } from './model-manager.js';
|
|
|
13
13
|
const execFileAsync = promisify(execFile);
|
|
14
14
|
/** Platform → npm package mapping */
|
|
15
15
|
const PLATFORM_PACKAGES = {
|
|
16
|
-
'darwin-arm64': '@rigour/brain-darwin-arm64',
|
|
17
|
-
'darwin-x64': '@rigour/brain-darwin-x64',
|
|
18
|
-
'linux-x64': '@rigour/brain-linux-x64',
|
|
19
|
-
'linux-arm64': '@rigour/brain-linux-arm64',
|
|
20
|
-
'win32-x64': '@rigour/brain-win-x64',
|
|
16
|
+
'darwin-arm64': '@rigour-labs/brain-darwin-arm64',
|
|
17
|
+
'darwin-x64': '@rigour-labs/brain-darwin-x64',
|
|
18
|
+
'linux-x64': '@rigour-labs/brain-linux-x64',
|
|
19
|
+
'linux-arm64': '@rigour-labs/brain-linux-arm64',
|
|
20
|
+
'win32-x64': '@rigour-labs/brain-win-x64',
|
|
21
21
|
};
|
|
22
22
|
export class SidecarProvider {
|
|
23
23
|
name = 'sidecar';
|
|
@@ -46,8 +46,9 @@ export class SidecarProvider {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
if (!this.binaryPath) {
|
|
49
|
-
onProgress?.('⚠ Inference engine not found. Install @rigour/brain-* or add llama-cli to PATH');
|
|
50
|
-
|
|
49
|
+
onProgress?.('⚠ Inference engine not found. Install @rigour-labs/brain-* or add llama-cli to PATH');
|
|
50
|
+
const installHint = packageName || `@rigour-labs/brain-${platformKey}`;
|
|
51
|
+
throw new Error(`Sidecar binary not found. Run: npm install ${installHint}`);
|
|
51
52
|
}
|
|
52
53
|
onProgress?.('✓ Inference engine ready');
|
|
53
54
|
// 2. Ensure model is downloaded
|
|
@@ -80,11 +81,14 @@ export class SidecarProvider {
|
|
|
80
81
|
args.push('--json');
|
|
81
82
|
}
|
|
82
83
|
try {
|
|
83
|
-
const
|
|
84
|
+
const execOptions = {
|
|
84
85
|
timeout: options?.timeout || 60000,
|
|
85
86
|
maxBuffer: 10 * 1024 * 1024, // 10MB
|
|
86
87
|
env: { ...process.env, LLAMA_LOG_DISABLE: '1' },
|
|
87
|
-
}
|
|
88
|
+
};
|
|
89
|
+
const { stdout } = process.platform === 'win32' && this.binaryPath.endsWith('.cmd')
|
|
90
|
+
? await execFileAsync('cmd.exe', ['/d', '/s', '/c', [this.binaryPath, ...args].map(quoteCmdArg).join(' ')], execOptions)
|
|
91
|
+
: await execFileAsync(this.binaryPath, args, execOptions);
|
|
88
92
|
// llama.cpp sometimes outputs to stderr for diagnostics — ignore
|
|
89
93
|
return stdout.trim();
|
|
90
94
|
}
|
|
@@ -105,7 +109,7 @@ export class SidecarProvider {
|
|
|
105
109
|
}
|
|
106
110
|
async resolveBinaryPath() {
|
|
107
111
|
const platformKey = this.getPlatformKey();
|
|
108
|
-
// Strategy 1: Check @rigour/brain-{platform} optional dependency
|
|
112
|
+
// Strategy 1: Check @rigour-labs/brain-{platform} optional dependency
|
|
109
113
|
const packageName = PLATFORM_PACKAGES[platformKey];
|
|
110
114
|
if (packageName) {
|
|
111
115
|
try {
|
|
@@ -113,9 +117,13 @@ export class SidecarProvider {
|
|
|
113
117
|
const pkgJsonPath = require.resolve(path.posix.join(packageName, 'package.json'));
|
|
114
118
|
const pkgDir = path.dirname(pkgJsonPath);
|
|
115
119
|
const resolvedBin = path.join(pkgDir, 'bin', 'rigour-brain');
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
const resolvedCandidates = os.platform() === 'win32'
|
|
121
|
+
? [resolvedBin + '.exe', resolvedBin + '.cmd', resolvedBin]
|
|
122
|
+
: [resolvedBin];
|
|
123
|
+
for (const resolvedBinPath of resolvedCandidates) {
|
|
124
|
+
if (await fs.pathExists(resolvedBinPath)) {
|
|
125
|
+
return resolvedBinPath;
|
|
126
|
+
}
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
catch {
|
|
@@ -134,9 +142,11 @@ export class SidecarProvider {
|
|
|
134
142
|
path.join(os.homedir(), '.npm-global', 'lib', 'node_modules', ...packageName.split('/'), 'bin', 'rigour-brain'),
|
|
135
143
|
];
|
|
136
144
|
for (const p of possiblePaths) {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
const candidates = os.platform() === 'win32' ? [p + '.exe', p + '.cmd', p] : [p];
|
|
146
|
+
for (const binPath of candidates) {
|
|
147
|
+
if (await fs.pathExists(binPath)) {
|
|
148
|
+
return binPath;
|
|
149
|
+
}
|
|
140
150
|
}
|
|
141
151
|
}
|
|
142
152
|
}
|
|
@@ -146,9 +156,13 @@ export class SidecarProvider {
|
|
|
146
156
|
}
|
|
147
157
|
// Strategy 2: Check ~/.rigour/bin/
|
|
148
158
|
const localBin = path.join(os.homedir(), '.rigour', 'bin', 'rigour-brain');
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
const localCandidates = os.platform() === 'win32'
|
|
160
|
+
? [localBin + '.exe', localBin + '.cmd', localBin]
|
|
161
|
+
: [localBin];
|
|
162
|
+
for (const localBinPath of localCandidates) {
|
|
163
|
+
if (await fs.pathExists(localBinPath)) {
|
|
164
|
+
return localBinPath;
|
|
165
|
+
}
|
|
152
166
|
}
|
|
153
167
|
// Strategy 3: Check PATH for llama-cli (llama.cpp CLI)
|
|
154
168
|
try {
|
|
@@ -193,3 +207,6 @@ export class SidecarProvider {
|
|
|
193
207
|
return true;
|
|
194
208
|
}
|
|
195
209
|
}
|
|
210
|
+
function quoteCmdArg(value) {
|
|
211
|
+
return `"${value.replace(/"/g, '\\"')}"`;
|
|
212
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rigour-labs/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "Deterministic quality gate engine for AI-generated code. AST analysis, drift detection, and Fix Packet generation across TypeScript, JavaScript, Python, Go, Ruby, and C#.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://rigour.run",
|
|
@@ -58,7 +58,12 @@
|
|
|
58
58
|
"@anthropic-ai/sdk": "^0.30.1",
|
|
59
59
|
"@xenova/transformers": "^2.17.2",
|
|
60
60
|
"better-sqlite3": "^11.0.0",
|
|
61
|
-
"openai": "^4.104.0"
|
|
61
|
+
"openai": "^4.104.0",
|
|
62
|
+
"@rigour-labs/brain-darwin-arm64": "4.0.5",
|
|
63
|
+
"@rigour-labs/brain-darwin-x64": "4.0.5",
|
|
64
|
+
"@rigour-labs/brain-linux-x64": "4.0.5",
|
|
65
|
+
"@rigour-labs/brain-linux-arm64": "4.0.5",
|
|
66
|
+
"@rigour-labs/brain-win-x64": "4.0.5"
|
|
62
67
|
},
|
|
63
68
|
"devDependencies": {
|
|
64
69
|
"@types/better-sqlite3": "^7.6.12",
|