@nuucognition/flint-cli 0.5.6-dev.2 → 0.5.6-dev.3
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/dist/index.js +74 -11
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -8303,7 +8303,7 @@ import { existsSync as existsSync6 } from "fs";
|
|
|
8303
8303
|
import { join as join32 } from "path";
|
|
8304
8304
|
import { homedir as homedir5 } from "os";
|
|
8305
8305
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
8306
|
-
import { existsSync as existsSync52, readFileSync as readFileSync4 } from "fs";
|
|
8306
|
+
import { appendFileSync, existsSync as existsSync52, mkdirSync as mkdirSync22, readFileSync as readFileSync4 } from "fs";
|
|
8307
8307
|
import { dirname as dirname3, join as join22 } from "path";
|
|
8308
8308
|
import { readdirSync as readdirSync2, readFileSync as readFileSync5 } from "fs";
|
|
8309
8309
|
import { existsSync as existsSync7 } from "fs";
|
|
@@ -10215,29 +10215,63 @@ var JsonSessionWatcher = class {
|
|
|
10215
10215
|
function createJsonSessionWatcher(transcriptPath, mapper, options) {
|
|
10216
10216
|
return new JsonSessionWatcher(transcriptPath, mapper, options);
|
|
10217
10217
|
}
|
|
10218
|
+
function debugLog(message) {
|
|
10219
|
+
if (process.platform !== "win32") return;
|
|
10220
|
+
try {
|
|
10221
|
+
const root = process.env.FLINT_ROOT || process.cwd();
|
|
10222
|
+
const logDir = join22(root, ".flint");
|
|
10223
|
+
mkdirSync22(logDir, { recursive: true });
|
|
10224
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
10225
|
+
appendFileSync(join22(logDir, "orbh-debug.log"), `[${ts}] ${message}
|
|
10226
|
+
`);
|
|
10227
|
+
} catch {
|
|
10228
|
+
}
|
|
10229
|
+
}
|
|
10218
10230
|
function isCommandOnPath(name) {
|
|
10219
10231
|
const cmd = process.platform === "win32" ? "where" : "which";
|
|
10220
|
-
|
|
10232
|
+
const result = spawnSync3(cmd, [name], { stdio: "ignore" });
|
|
10233
|
+
debugLog(`isCommandOnPath(${name}): ${cmd} \u2192 exit ${result.status}`);
|
|
10234
|
+
return result.status === 0;
|
|
10221
10235
|
}
|
|
10222
10236
|
function resolveCommand(name) {
|
|
10223
10237
|
if (process.platform !== "win32") return { cmd: name, prependArgs: [] };
|
|
10238
|
+
debugLog(`resolveCommand(${name}): starting`);
|
|
10224
10239
|
const where = spawnSync3("where", [name], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] });
|
|
10240
|
+
debugLog(`resolveCommand(${name}): where exit=${where.status}, stdout=${JSON.stringify(where.stdout ?? "")}`);
|
|
10225
10241
|
const firstLine = (where.stdout ?? "").trim().split(/\r?\n/)[0]?.trim();
|
|
10226
|
-
if (where.status !== 0 || !firstLine)
|
|
10242
|
+
if (where.status !== 0 || !firstLine) {
|
|
10243
|
+
debugLog(`resolveCommand(${name}): where failed \u2014 returning bare name`);
|
|
10244
|
+
return { cmd: name, prependArgs: [] };
|
|
10245
|
+
}
|
|
10227
10246
|
const resolved = firstLine;
|
|
10228
|
-
|
|
10247
|
+
debugLog(`resolveCommand(${name}): resolved path = ${resolved}`);
|
|
10248
|
+
if (!resolved.toLowerCase().endsWith(".cmd")) {
|
|
10249
|
+
debugLog(`resolveCommand(${name}): not .cmd \u2014 using resolved path directly`);
|
|
10250
|
+
return { cmd: resolved, prependArgs: [] };
|
|
10251
|
+
}
|
|
10229
10252
|
try {
|
|
10230
10253
|
const content = readFileSync4(resolved, "utf-8");
|
|
10254
|
+
debugLog(`resolveCommand(${name}): .cmd content (${content.length} chars):
|
|
10255
|
+
${content}`);
|
|
10231
10256
|
const matches = [...content.matchAll(/%(?:~dp0|dp0%)\\([^"%\r\n]+\.m?[jc]?[jt]s)/gi)];
|
|
10257
|
+
debugLog(`resolveCommand(${name}): regex matches = ${JSON.stringify(matches.map((m) => m[0]))}`);
|
|
10232
10258
|
const last = matches.length > 0 ? matches[matches.length - 1] : void 0;
|
|
10233
10259
|
if (last && last[1]) {
|
|
10234
10260
|
const scriptPath = join22(dirname3(resolved), last[1]);
|
|
10235
|
-
|
|
10236
|
-
|
|
10261
|
+
const scriptExists = existsSync52(scriptPath);
|
|
10262
|
+
debugLog(`resolveCommand(${name}): script path = ${scriptPath}, exists = ${scriptExists}`);
|
|
10263
|
+
if (scriptExists) {
|
|
10264
|
+
const result = { cmd: process.execPath, prependArgs: [scriptPath] };
|
|
10265
|
+
debugLog(`resolveCommand(${name}): SUCCESS \u2192 ${result.cmd} ${result.prependArgs.join(" ")}`);
|
|
10266
|
+
return result;
|
|
10237
10267
|
}
|
|
10268
|
+
} else {
|
|
10269
|
+
debugLog(`resolveCommand(${name}): no regex match found in .cmd content`);
|
|
10238
10270
|
}
|
|
10239
|
-
} catch {
|
|
10271
|
+
} catch (err) {
|
|
10272
|
+
debugLog(`resolveCommand(${name}): error parsing .cmd: ${err}`);
|
|
10240
10273
|
}
|
|
10274
|
+
debugLog(`resolveCommand(${name}): FALLBACK \u2192 using resolved path ${resolved}`);
|
|
10241
10275
|
return { cmd: resolved, prependArgs: [] };
|
|
10242
10276
|
}
|
|
10243
10277
|
function buildTranscriptPath(cwd, nativeSessionId) {
|
|
@@ -17892,7 +17926,7 @@ function formatTokenSummary(usage) {
|
|
|
17892
17926
|
}
|
|
17893
17927
|
var DETACHED_ORB_MONITOR = String.raw`
|
|
17894
17928
|
const { spawn, spawnSync } = require('node:child_process');
|
|
17895
|
-
const { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, renameSync } = require('node:fs');
|
|
17929
|
+
const { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, renameSync } = require('node:fs');
|
|
17896
17930
|
const { basename, dirname, join } = require('node:path');
|
|
17897
17931
|
const { homedir } = require('node:os');
|
|
17898
17932
|
|
|
@@ -17901,6 +17935,17 @@ if (!configJson) process.exit(1);
|
|
|
17901
17935
|
|
|
17902
17936
|
const { sessionPath, cwd, command, args } = JSON.parse(configJson);
|
|
17903
17937
|
|
|
17938
|
+
function debugLog(msg) {
|
|
17939
|
+
if (process.platform !== 'win32') return;
|
|
17940
|
+
try {
|
|
17941
|
+
const logDir = join(cwd, '.flint');
|
|
17942
|
+
mkdirSync(logDir, { recursive: true });
|
|
17943
|
+
appendFileSync(join(logDir, 'orbh-debug.log'), '[' + new Date().toISOString() + '] [monitor] ' + msg + '\n');
|
|
17944
|
+
} catch {}
|
|
17945
|
+
}
|
|
17946
|
+
|
|
17947
|
+
debugLog('Monitor started. command=' + command + ', args=' + JSON.stringify(args).slice(0, 200));
|
|
17948
|
+
|
|
17904
17949
|
function readSession() {
|
|
17905
17950
|
try { return JSON.parse(readFileSync(sessionPath, 'utf-8')); }
|
|
17906
17951
|
catch { return null; }
|
|
@@ -17943,32 +17988,49 @@ function notify(title, message) {
|
|
|
17943
17988
|
let spawnCmd = command;
|
|
17944
17989
|
let spawnArgs = args;
|
|
17945
17990
|
if (process.platform === 'win32') {
|
|
17991
|
+
debugLog('Resolving command: ' + command);
|
|
17946
17992
|
const where = spawnSync('where', [command], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
17993
|
+
debugLog('where exit=' + where.status + ', stdout=' + JSON.stringify((where.stdout || '').trim()));
|
|
17947
17994
|
if (where.status === 0 && where.stdout) {
|
|
17948
17995
|
const resolved = where.stdout.trim().split(/\r?\n/)[0].trim();
|
|
17996
|
+
debugLog('Resolved path: ' + resolved);
|
|
17949
17997
|
if (resolved.toLowerCase().endsWith('.cmd')) {
|
|
17950
17998
|
try {
|
|
17951
17999
|
const content = readFileSync(resolved, 'utf-8');
|
|
18000
|
+
debugLog('.cmd content (' + content.length + ' chars):\n' + content);
|
|
17952
18001
|
const matches = [...content.matchAll(/%(?:~dp0|dp0%)\\([^"%\r\n]+\.m?[jc]?[jt]s)/gi)];
|
|
18002
|
+
debugLog('Regex matches: ' + JSON.stringify(matches.map(m => m[0])));
|
|
17953
18003
|
if (matches.length > 0) {
|
|
17954
18004
|
const scriptPath = join(dirname(resolved), matches[matches.length - 1][1]);
|
|
17955
|
-
|
|
18005
|
+
const scriptExists = existsSync(scriptPath);
|
|
18006
|
+
debugLog('Script path: ' + scriptPath + ', exists: ' + scriptExists);
|
|
18007
|
+
if (scriptExists) {
|
|
17956
18008
|
spawnCmd = process.execPath;
|
|
17957
18009
|
spawnArgs = [scriptPath, ...args];
|
|
17958
18010
|
}
|
|
18011
|
+
} else {
|
|
18012
|
+
debugLog('No regex matches in .cmd content');
|
|
17959
18013
|
}
|
|
17960
|
-
} catch {
|
|
18014
|
+
} catch (e) {
|
|
18015
|
+
debugLog('Error parsing .cmd: ' + e);
|
|
18016
|
+
}
|
|
17961
18017
|
} else {
|
|
17962
18018
|
spawnCmd = resolved;
|
|
17963
18019
|
}
|
|
18020
|
+
} else {
|
|
18021
|
+
debugLog('where failed — using bare command name');
|
|
17964
18022
|
}
|
|
17965
18023
|
}
|
|
18024
|
+
debugLog('Final spawn: cmd=' + spawnCmd + ', args[0..2]=' + JSON.stringify(spawnArgs.slice(0, 3)));
|
|
17966
18025
|
const child = spawn(spawnCmd, spawnArgs, { cwd, stdio: ['ignore', 'ignore', 'pipe'] });
|
|
17967
18026
|
|
|
17968
18027
|
let stderr = '';
|
|
17969
18028
|
child.stderr?.on('data', (chunk) => { stderr += chunk.toString(); });
|
|
17970
18029
|
|
|
17971
|
-
|
|
18030
|
+
debugLog('Spawn initiated, pid=' + (child.pid || 'none'));
|
|
18031
|
+
|
|
18032
|
+
child.on('error', (err) => {
|
|
18033
|
+
debugLog('Spawn ERROR: ' + err.message + ' (code=' + err.code + ')');
|
|
17972
18034
|
const s = readSession();
|
|
17973
18035
|
if (s) {
|
|
17974
18036
|
s.status = 'failed';
|
|
@@ -18095,6 +18157,7 @@ if (command === 'gemini') {
|
|
|
18095
18157
|
}
|
|
18096
18158
|
|
|
18097
18159
|
child.on('exit', (code) => {
|
|
18160
|
+
debugLog('Child exited with code=' + code + ', stderr=' + (stderr || '(empty)').slice(0, 500));
|
|
18098
18161
|
const s = readSession();
|
|
18099
18162
|
if (!s) { process.exit(typeof code === 'number' ? code : 1); return; }
|
|
18100
18163
|
const desc = (s.title || s.description || s.prompt || '').slice(0, 60);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuucognition/flint-cli",
|
|
3
|
-
"version": "0.5.6-dev.
|
|
3
|
+
"version": "0.5.6-dev.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Flint cognitive workspace CLI",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"tsup": "^8.3.5",
|
|
37
37
|
"tsx": "^4.19.2",
|
|
38
38
|
"typescript": "^5.9.2",
|
|
39
|
-
"@nuucognition/
|
|
39
|
+
"@nuucognition/flint": "0.1.0",
|
|
40
40
|
"@nuucognition/flint-server": "0.0.1",
|
|
41
|
-
"@nuucognition/
|
|
41
|
+
"@nuucognition/orbh": "0.0.1-dev.0",
|
|
42
|
+
"@nuucognition/eslint-config": "0.0.0",
|
|
42
43
|
"@nuucognition/typescript-config": "0.0.0",
|
|
43
|
-
"@nuucognition/flint": "0.1.0"
|
|
44
|
-
"@nuucognition/orbh": "0.0.1-dev.0"
|
|
44
|
+
"@nuucognition/flint-migrations": "0.1.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"predev": "turbo build --filter=@nuucognition/flint-cli^...",
|