@nuucognition/flint-cli 0.5.6-dev.1 → 0.5.6-dev.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/dist/index.js +142 -95
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -403,9 +403,9 @@ var require_brace_expansion = __commonJS({
|
|
|
403
403
|
|
|
404
404
|
// src/index.ts
|
|
405
405
|
import { Command as Command38 } from "commander";
|
|
406
|
-
import { readFileSync as
|
|
406
|
+
import { readFileSync as readFileSync12, existsSync as existsSync16, cpSync, mkdirSync as mkdirSync5, readdirSync as readdirSync8 } from "fs";
|
|
407
407
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
408
|
-
import { dirname as
|
|
408
|
+
import { dirname as dirname5, join as join20 } from "path";
|
|
409
409
|
import { homedir as homedir11 } from "os";
|
|
410
410
|
import pc43 from "picocolors";
|
|
411
411
|
|
|
@@ -5851,10 +5851,10 @@ function sendNotification(title, message) {
|
|
|
5851
5851
|
}
|
|
5852
5852
|
}
|
|
5853
5853
|
|
|
5854
|
-
const
|
|
5854
|
+
const agentCmd = resolveCommand('claude');
|
|
5855
|
+
const child = spawn(agentCmd.cmd, [...agentCmd.prependArgs, ...claudeArgs], {
|
|
5855
5856
|
cwd: flintPath,
|
|
5856
5857
|
stdio: ['ignore', 'ignore', 'pipe'],
|
|
5857
|
-
shell: process.platform === 'win32',
|
|
5858
5858
|
});
|
|
5859
5859
|
|
|
5860
5860
|
let stderr = '';
|
|
@@ -8299,24 +8299,26 @@ import { randomUUID as randomUUID2 } from "crypto";
|
|
|
8299
8299
|
import { existsSync as existsSync22, readFileSync as readFileSync22 } from "fs";
|
|
8300
8300
|
import { closeSync, existsSync as existsSync32, openSync, readSync, statSync, unwatchFile, watch, watchFile } from "fs";
|
|
8301
8301
|
import { existsSync as existsSync42, readFileSync as readFileSync3, unwatchFile as unwatchFile2, watch as watch2, watchFile as watchFile2 } from "fs";
|
|
8302
|
-
import { existsSync as existsSync52 } from "fs";
|
|
8303
|
-
import { join as join22 } from "path";
|
|
8304
|
-
import { homedir as homedir5 } from "os";
|
|
8305
|
-
import { spawnSync as spawnSync3 } from "child_process";
|
|
8306
|
-
import { readdirSync as readdirSync2, readFileSync as readFileSync4 } from "fs";
|
|
8307
8302
|
import { existsSync as existsSync6 } from "fs";
|
|
8308
8303
|
import { join as join32 } from "path";
|
|
8304
|
+
import { homedir as homedir5 } from "os";
|
|
8305
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
8306
|
+
import { existsSync as existsSync52, readFileSync as readFileSync4 } from "fs";
|
|
8307
|
+
import { dirname as dirname3, join as join22 } from "path";
|
|
8308
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync5 } from "fs";
|
|
8309
|
+
import { existsSync as existsSync7 } from "fs";
|
|
8310
|
+
import { join as join42 } from "path";
|
|
8309
8311
|
import { homedir as homedir22 } from "os";
|
|
8310
|
-
import { existsSync as
|
|
8311
|
-
import { basename as basename4, join as
|
|
8312
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3, readFileSync as readFileSync6, statSync as statSync2 } from "fs";
|
|
8313
|
+
import { basename as basename4, join as join52 } from "path";
|
|
8312
8314
|
import { homedir as homedir32 } from "os";
|
|
8313
|
-
import { existsSync as
|
|
8315
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4, readFileSync as readFileSync7, statSync as statSync3 } from "fs";
|
|
8314
8316
|
import { spawnSync as spawnSync22 } from "child_process";
|
|
8315
8317
|
import { homedir as homedir42 } from "os";
|
|
8316
|
-
import { basename as basename22, join as
|
|
8318
|
+
import { basename as basename22, join as join62 } from "path";
|
|
8317
8319
|
import { spawn as spawn4, spawnSync as spawnSync32 } from "child_process";
|
|
8318
|
-
import { existsSync as
|
|
8319
|
-
import { join as
|
|
8320
|
+
import { existsSync as existsSync10, readdirSync as readdirSync5, readFileSync as readFileSync8 } from "fs";
|
|
8321
|
+
import { join as join72 } from "path";
|
|
8320
8322
|
import { homedir as homedir52 } from "os";
|
|
8321
8323
|
var RUN_TRANSITIONS = {
|
|
8322
8324
|
running: ["completed", "failed", "cancelled", "suspended"],
|
|
@@ -10217,10 +10219,30 @@ function isCommandOnPath(name) {
|
|
|
10217
10219
|
const cmd = process.platform === "win32" ? "where" : "which";
|
|
10218
10220
|
return spawnSync3(cmd, [name], { stdio: "ignore" }).status === 0;
|
|
10219
10221
|
}
|
|
10220
|
-
|
|
10222
|
+
function resolveCommand(name) {
|
|
10223
|
+
if (process.platform !== "win32") return { cmd: name, prependArgs: [] };
|
|
10224
|
+
const where = spawnSync3("where", [name], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] });
|
|
10225
|
+
const firstLine = (where.stdout ?? "").trim().split(/\r?\n/)[0]?.trim();
|
|
10226
|
+
if (where.status !== 0 || !firstLine) return { cmd: name, prependArgs: [] };
|
|
10227
|
+
const resolved = firstLine;
|
|
10228
|
+
if (!resolved.toLowerCase().endsWith(".cmd")) return { cmd: resolved, prependArgs: [] };
|
|
10229
|
+
try {
|
|
10230
|
+
const content = readFileSync4(resolved, "utf-8");
|
|
10231
|
+
const matches = [...content.matchAll(/%(?:~dp0|dp0%)\\([^"%\r\n]+\.m?[jc]?[jt]s)/gi)];
|
|
10232
|
+
const last = matches.length > 0 ? matches[matches.length - 1] : void 0;
|
|
10233
|
+
if (last && last[1]) {
|
|
10234
|
+
const scriptPath = join22(dirname3(resolved), last[1]);
|
|
10235
|
+
if (existsSync52(scriptPath)) {
|
|
10236
|
+
return { cmd: process.execPath, prependArgs: [scriptPath] };
|
|
10237
|
+
}
|
|
10238
|
+
}
|
|
10239
|
+
} catch {
|
|
10240
|
+
}
|
|
10241
|
+
return { cmd: resolved, prependArgs: [] };
|
|
10242
|
+
}
|
|
10221
10243
|
function buildTranscriptPath(cwd, nativeSessionId) {
|
|
10222
10244
|
const sanitized = cwd.replace(/[^a-zA-Z0-9\-_]/g, "-");
|
|
10223
|
-
return
|
|
10245
|
+
return join32(homedir5(), ".claude", "projects", sanitized, `${nativeSessionId}.jsonl`);
|
|
10224
10246
|
}
|
|
10225
10247
|
function createClaudeHarness() {
|
|
10226
10248
|
return {
|
|
@@ -10268,7 +10290,7 @@ function createClaudeHarness() {
|
|
|
10268
10290
|
},
|
|
10269
10291
|
resolveTranscriptPath(nativeSessionId, cwd) {
|
|
10270
10292
|
const candidate = buildTranscriptPath(cwd, nativeSessionId);
|
|
10271
|
-
if (
|
|
10293
|
+
if (existsSync6(candidate)) {
|
|
10272
10294
|
return candidate;
|
|
10273
10295
|
}
|
|
10274
10296
|
return null;
|
|
@@ -10288,7 +10310,7 @@ function createClaudeHarness() {
|
|
|
10288
10310
|
};
|
|
10289
10311
|
}
|
|
10290
10312
|
function listDateDirectories(root) {
|
|
10291
|
-
if (!
|
|
10313
|
+
if (!existsSync7(root)) {
|
|
10292
10314
|
return [];
|
|
10293
10315
|
}
|
|
10294
10316
|
const directories = [];
|
|
@@ -10296,15 +10318,15 @@ function listDateDirectories(root) {
|
|
|
10296
10318
|
if (!year.isDirectory()) {
|
|
10297
10319
|
continue;
|
|
10298
10320
|
}
|
|
10299
|
-
const yearPath =
|
|
10321
|
+
const yearPath = join42(root, year.name);
|
|
10300
10322
|
for (const month of readdirSync2(yearPath, { withFileTypes: true })) {
|
|
10301
10323
|
if (!month.isDirectory()) {
|
|
10302
10324
|
continue;
|
|
10303
10325
|
}
|
|
10304
|
-
const monthPath =
|
|
10326
|
+
const monthPath = join42(yearPath, month.name);
|
|
10305
10327
|
for (const day of readdirSync2(monthPath, { withFileTypes: true })) {
|
|
10306
10328
|
if (day.isDirectory()) {
|
|
10307
|
-
directories.push(
|
|
10329
|
+
directories.push(join42(monthPath, day.name));
|
|
10308
10330
|
}
|
|
10309
10331
|
}
|
|
10310
10332
|
}
|
|
@@ -10312,11 +10334,11 @@ function listDateDirectories(root) {
|
|
|
10312
10334
|
return directories.sort((left, right) => right.localeCompare(left));
|
|
10313
10335
|
}
|
|
10314
10336
|
function resolveCodexSessionIndex(root, nativeSessionId) {
|
|
10315
|
-
const indexPath =
|
|
10316
|
-
if (!
|
|
10337
|
+
const indexPath = join42(root, "session_index.jsonl");
|
|
10338
|
+
if (!existsSync7(indexPath)) {
|
|
10317
10339
|
return null;
|
|
10318
10340
|
}
|
|
10319
|
-
const lines =
|
|
10341
|
+
const lines = readFileSync5(indexPath, "utf-8").split("\n");
|
|
10320
10342
|
for (const line of lines) {
|
|
10321
10343
|
const trimmed = line.trim();
|
|
10322
10344
|
if (trimmed.length === 0) {
|
|
@@ -10368,7 +10390,7 @@ function createCodexHarness() {
|
|
|
10368
10390
|
return args;
|
|
10369
10391
|
},
|
|
10370
10392
|
resolveTranscriptPath(nativeSessionId) {
|
|
10371
|
-
const sessionsRoot =
|
|
10393
|
+
const sessionsRoot = join42(homedir22(), ".codex", "sessions");
|
|
10372
10394
|
const indexedPath = resolveCodexSessionIndex(sessionsRoot, nativeSessionId);
|
|
10373
10395
|
if (indexedPath) {
|
|
10374
10396
|
return indexedPath;
|
|
@@ -10376,7 +10398,7 @@ function createCodexHarness() {
|
|
|
10376
10398
|
for (const directory of listDateDirectories(sessionsRoot)) {
|
|
10377
10399
|
for (const entry of readdirSync2(directory)) {
|
|
10378
10400
|
if (entry.includes(nativeSessionId) && entry.endsWith(".jsonl")) {
|
|
10379
|
-
return
|
|
10401
|
+
return join42(directory, entry);
|
|
10380
10402
|
}
|
|
10381
10403
|
}
|
|
10382
10404
|
}
|
|
@@ -10402,13 +10424,13 @@ function sanitizeFactoryCwd(cwd) {
|
|
|
10402
10424
|
return cwd.replace(/[\\/]/g, "-");
|
|
10403
10425
|
}
|
|
10404
10426
|
function buildScopedTranscriptPath(cwd, nativeSessionId) {
|
|
10405
|
-
return
|
|
10427
|
+
return join52(homedir32(), ".factory", "sessions", sanitizeFactoryCwd(cwd), `${nativeSessionId}.jsonl`);
|
|
10406
10428
|
}
|
|
10407
10429
|
function buildLegacyTranscriptPath(nativeSessionId) {
|
|
10408
|
-
return
|
|
10430
|
+
return join52(homedir32(), ".factory", "sessions", `${nativeSessionId}.jsonl`);
|
|
10409
10431
|
}
|
|
10410
10432
|
function getDroidSessionsRoot() {
|
|
10411
|
-
return
|
|
10433
|
+
return join52(homedir32(), ".factory", "sessions");
|
|
10412
10434
|
}
|
|
10413
10435
|
function parseStartedAtMs(startedAt) {
|
|
10414
10436
|
if (typeof startedAt === "number" && Number.isFinite(startedAt)) {
|
|
@@ -10433,7 +10455,7 @@ function isTranscriptRecentEnough(transcriptPath, startedAt) {
|
|
|
10433
10455
|
}
|
|
10434
10456
|
function readDroidSessionId(transcriptPath) {
|
|
10435
10457
|
try {
|
|
10436
|
-
const firstLine =
|
|
10458
|
+
const firstLine = readFileSync6(transcriptPath, "utf-8").split(/\r?\n/, 1)[0]?.trim();
|
|
10437
10459
|
if (!firstLine) {
|
|
10438
10460
|
return basename4(transcriptPath, ".jsonl");
|
|
10439
10461
|
}
|
|
@@ -10446,10 +10468,10 @@ function readDroidSessionId(transcriptPath) {
|
|
|
10446
10468
|
return basename4(transcriptPath, ".jsonl");
|
|
10447
10469
|
}
|
|
10448
10470
|
function listDroidTranscriptPaths(cwd) {
|
|
10449
|
-
const candidateDirs = [
|
|
10471
|
+
const candidateDirs = [join52(getDroidSessionsRoot(), sanitizeFactoryCwd(cwd)), getDroidSessionsRoot()];
|
|
10450
10472
|
const transcriptPaths = /* @__PURE__ */ new Map();
|
|
10451
10473
|
for (const directory of candidateDirs) {
|
|
10452
|
-
if (!
|
|
10474
|
+
if (!existsSync8(directory)) {
|
|
10453
10475
|
continue;
|
|
10454
10476
|
}
|
|
10455
10477
|
try {
|
|
@@ -10457,7 +10479,7 @@ function listDroidTranscriptPaths(cwd) {
|
|
|
10457
10479
|
if (!entry.isFile() || !entry.name.endsWith(".jsonl")) {
|
|
10458
10480
|
continue;
|
|
10459
10481
|
}
|
|
10460
|
-
const transcriptPath =
|
|
10482
|
+
const transcriptPath = join52(directory, entry.name);
|
|
10461
10483
|
transcriptPaths.set(transcriptPath, statSync2(transcriptPath).mtimeMs);
|
|
10462
10484
|
}
|
|
10463
10485
|
} catch {
|
|
@@ -10473,7 +10495,7 @@ function discoverDroidNativeSessionByOrbhSessionId(cwd, orbhSessionId, options)
|
|
|
10473
10495
|
continue;
|
|
10474
10496
|
}
|
|
10475
10497
|
try {
|
|
10476
|
-
const content =
|
|
10498
|
+
const content = readFileSync6(transcriptPath, "utf-8");
|
|
10477
10499
|
if (!content.includes(orbhSessionId)) {
|
|
10478
10500
|
continue;
|
|
10479
10501
|
}
|
|
@@ -10536,11 +10558,11 @@ function createDroidHarness() {
|
|
|
10536
10558
|
},
|
|
10537
10559
|
resolveTranscriptPath(nativeSessionId, cwd) {
|
|
10538
10560
|
const scopedPath = buildScopedTranscriptPath(cwd, nativeSessionId);
|
|
10539
|
-
if (
|
|
10561
|
+
if (existsSync8(scopedPath)) {
|
|
10540
10562
|
return scopedPath;
|
|
10541
10563
|
}
|
|
10542
10564
|
const legacyPath = buildLegacyTranscriptPath(nativeSessionId);
|
|
10543
|
-
if (
|
|
10565
|
+
if (existsSync8(legacyPath)) {
|
|
10544
10566
|
return legacyPath;
|
|
10545
10567
|
}
|
|
10546
10568
|
return scopedPath;
|
|
@@ -10566,24 +10588,24 @@ function slugifyProjectName(name) {
|
|
|
10566
10588
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
10567
10589
|
}
|
|
10568
10590
|
function getGeminiTmpRoot() {
|
|
10569
|
-
return
|
|
10591
|
+
return join62(homedir42(), ".gemini", "tmp");
|
|
10570
10592
|
}
|
|
10571
10593
|
function getProjectSlug(cwd) {
|
|
10572
10594
|
return slugifyProjectName(basename22(cwd));
|
|
10573
10595
|
}
|
|
10574
10596
|
function getGeminiChatsDir(cwd) {
|
|
10575
|
-
return
|
|
10597
|
+
return join62(getGeminiTmpRoot(), getProjectSlug(cwd), "chats");
|
|
10576
10598
|
}
|
|
10577
10599
|
function listGeminiTranscriptPaths(cwd) {
|
|
10578
10600
|
const chatsDir = getGeminiChatsDir(cwd);
|
|
10579
|
-
if (!
|
|
10601
|
+
if (!existsSync9(chatsDir)) {
|
|
10580
10602
|
return [];
|
|
10581
10603
|
}
|
|
10582
|
-
return readdirSync4(chatsDir).filter((entry) => entry.startsWith("session-") && entry.endsWith(".json")).map((entry) =>
|
|
10604
|
+
return readdirSync4(chatsDir).filter((entry) => entry.startsWith("session-") && entry.endsWith(".json")).map((entry) => join62(chatsDir, entry)).sort((left, right) => right.localeCompare(left));
|
|
10583
10605
|
}
|
|
10584
10606
|
function readGeminiSessionId(transcriptPath) {
|
|
10585
10607
|
try {
|
|
10586
|
-
const parsed = JSON.parse(
|
|
10608
|
+
const parsed = JSON.parse(readFileSync7(transcriptPath, "utf-8"));
|
|
10587
10609
|
return typeof parsed.sessionId === "string" ? parsed.sessionId : null;
|
|
10588
10610
|
} catch {
|
|
10589
10611
|
return null;
|
|
@@ -10661,7 +10683,7 @@ function discoverGeminiNativeSessionByOrbhSessionId(cwd, orbhSessionId, options)
|
|
|
10661
10683
|
continue;
|
|
10662
10684
|
}
|
|
10663
10685
|
try {
|
|
10664
|
-
const content =
|
|
10686
|
+
const content = readFileSync7(transcriptPath, "utf-8");
|
|
10665
10687
|
if (!content.includes(orbhSessionId)) {
|
|
10666
10688
|
continue;
|
|
10667
10689
|
}
|
|
@@ -10778,7 +10800,7 @@ function buildHarnessSpawnEnv(cwd, sessionId, baseEnv = process.env) {
|
|
|
10778
10800
|
delete env.CODEX_THREAD_ID;
|
|
10779
10801
|
delete env.CODEX_CI;
|
|
10780
10802
|
delete env.CODEX_SESSION_ID;
|
|
10781
|
-
const localBin =
|
|
10803
|
+
const localBin = join72(homedir52(), ".local", "bin");
|
|
10782
10804
|
if (env.PATH && !env.PATH.startsWith(localBin)) {
|
|
10783
10805
|
env.PATH = `${localBin}:${env.PATH}`;
|
|
10784
10806
|
}
|
|
@@ -10810,8 +10832,8 @@ function sendNotification2(session, exitCode) {
|
|
|
10810
10832
|
}
|
|
10811
10833
|
}
|
|
10812
10834
|
function listRecentCodexRollouts() {
|
|
10813
|
-
const sessionsRoot =
|
|
10814
|
-
if (!
|
|
10835
|
+
const sessionsRoot = join72(homedir52(), ".codex", "sessions");
|
|
10836
|
+
if (!existsSync10(sessionsRoot)) {
|
|
10815
10837
|
return [];
|
|
10816
10838
|
}
|
|
10817
10839
|
const paths = [];
|
|
@@ -10819,20 +10841,20 @@ function listRecentCodexRollouts() {
|
|
|
10819
10841
|
if (!year.isDirectory()) {
|
|
10820
10842
|
continue;
|
|
10821
10843
|
}
|
|
10822
|
-
const yearPath =
|
|
10844
|
+
const yearPath = join72(sessionsRoot, year.name);
|
|
10823
10845
|
for (const month of readdirSync5(yearPath, { withFileTypes: true })) {
|
|
10824
10846
|
if (!month.isDirectory()) {
|
|
10825
10847
|
continue;
|
|
10826
10848
|
}
|
|
10827
|
-
const monthPath =
|
|
10849
|
+
const monthPath = join72(yearPath, month.name);
|
|
10828
10850
|
for (const day of readdirSync5(monthPath, { withFileTypes: true })) {
|
|
10829
10851
|
if (!day.isDirectory()) {
|
|
10830
10852
|
continue;
|
|
10831
10853
|
}
|
|
10832
|
-
const dayPath =
|
|
10854
|
+
const dayPath = join72(monthPath, day.name);
|
|
10833
10855
|
for (const fileName of readdirSync5(dayPath)) {
|
|
10834
10856
|
if (fileName.startsWith("rollout-") && fileName.endsWith(".jsonl")) {
|
|
10835
|
-
paths.push(
|
|
10857
|
+
paths.push(join72(dayPath, fileName));
|
|
10836
10858
|
}
|
|
10837
10859
|
}
|
|
10838
10860
|
}
|
|
@@ -10844,7 +10866,7 @@ function listCodexNativeSessionCandidates(cwd) {
|
|
|
10844
10866
|
const candidates = [];
|
|
10845
10867
|
for (const rolloutPath of listRecentCodexRollouts()) {
|
|
10846
10868
|
try {
|
|
10847
|
-
const [firstLine] =
|
|
10869
|
+
const [firstLine] = readFileSync8(rolloutPath, "utf-8").split("\n");
|
|
10848
10870
|
if (!firstLine) {
|
|
10849
10871
|
continue;
|
|
10850
10872
|
}
|
|
@@ -10897,13 +10919,13 @@ async function spawnHarnessProcess(options) {
|
|
|
10897
10919
|
const run = addRun2(session, { nativeSessionId });
|
|
10898
10920
|
session.status = "queued";
|
|
10899
10921
|
writeSession(options.sessionsDir, session);
|
|
10900
|
-
const
|
|
10901
|
-
const
|
|
10922
|
+
const commandName = options.command ?? harness.name;
|
|
10923
|
+
const resolved = resolveCommand(commandName);
|
|
10924
|
+
const child = spawn4(resolved.cmd, [...resolved.prependArgs, ...harness.buildSpawnArgs(options.config)], {
|
|
10902
10925
|
cwd: options.cwd,
|
|
10903
10926
|
detached: true,
|
|
10904
10927
|
stdio: ["ignore", "ignore", "pipe"],
|
|
10905
|
-
env: buildHarnessSpawnEnv(options.cwd, options.sessionId)
|
|
10906
|
-
shell: process.platform === "win32"
|
|
10928
|
+
env: buildHarnessSpawnEnv(options.cwd, options.sessionId)
|
|
10907
10929
|
});
|
|
10908
10930
|
let stderr = "";
|
|
10909
10931
|
child.stderr?.on("data", (chunk) => {
|
|
@@ -12544,7 +12566,7 @@ minimatch.unescape = unescape;
|
|
|
12544
12566
|
|
|
12545
12567
|
// ../../packages/flint-server/dist/index.js
|
|
12546
12568
|
import { parse as parseYaml } from "yaml";
|
|
12547
|
-
import { existsSync as
|
|
12569
|
+
import { existsSync as existsSync11, watch as watch3 } from "fs";
|
|
12548
12570
|
import { stat as stat22 } from "fs/promises";
|
|
12549
12571
|
import path22 from "path";
|
|
12550
12572
|
import { mkdir as mkdir5, readFile as readFile22, writeFile as writeFile3 } from "fs/promises";
|
|
@@ -13145,7 +13167,7 @@ function createResilientWatcher({
|
|
|
13145
13167
|
if (closed) {
|
|
13146
13168
|
return;
|
|
13147
13169
|
}
|
|
13148
|
-
if (!
|
|
13170
|
+
if (!existsSync11(targetPath)) {
|
|
13149
13171
|
scheduleRestart();
|
|
13150
13172
|
return;
|
|
13151
13173
|
}
|
|
@@ -14084,12 +14106,12 @@ function registerOrbhRoutes(app, ctx, options) {
|
|
|
14084
14106
|
prompt: prompt6,
|
|
14085
14107
|
extraArgs: session.runtime === "claude" ? ["--chrome"] : []
|
|
14086
14108
|
});
|
|
14087
|
-
const
|
|
14109
|
+
const resolved = resolveCommand(harness.name);
|
|
14110
|
+
const child = spawn22(resolved.cmd, [...resolved.prependArgs, ...args], {
|
|
14088
14111
|
cwd: ctx.flintPath,
|
|
14089
14112
|
detached: true,
|
|
14090
14113
|
stdio: ["ignore", "ignore", "pipe"],
|
|
14091
|
-
env: buildHarnessSpawnEnv(ctx.flintPath, session.id)
|
|
14092
|
-
shell: process.platform === "win32"
|
|
14114
|
+
env: buildHarnessSpawnEnv(ctx.flintPath, session.id)
|
|
14093
14115
|
});
|
|
14094
14116
|
let stderr = "";
|
|
14095
14117
|
child.stderr?.on("data", (chunk) => {
|
|
@@ -16050,7 +16072,7 @@ import { Command as Command24 } from "commander";
|
|
|
16050
16072
|
import pc29 from "picocolors";
|
|
16051
16073
|
import { spawn as spawn7, execSync as execSync3 } from "child_process";
|
|
16052
16074
|
import { createInterface as createInterface5 } from "readline";
|
|
16053
|
-
import { existsSync as
|
|
16075
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync3, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "fs";
|
|
16054
16076
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
16055
16077
|
import { join as join14 } from "path";
|
|
16056
16078
|
|
|
@@ -16255,7 +16277,7 @@ function exportOrbhSessionTranscript(session, flintPath) {
|
|
|
16255
16277
|
}
|
|
16256
16278
|
let content;
|
|
16257
16279
|
try {
|
|
16258
|
-
content =
|
|
16280
|
+
content = readFileSync9(transcriptPath, "utf-8");
|
|
16259
16281
|
} catch {
|
|
16260
16282
|
console.log(pc29.dim("Could not read transcript file."));
|
|
16261
16283
|
return;
|
|
@@ -16284,10 +16306,10 @@ var CLIENT_INFO = {
|
|
|
16284
16306
|
};
|
|
16285
16307
|
async function bootstrapCodexSession(cwd, initPrompt) {
|
|
16286
16308
|
return new Promise((resolve12, reject) => {
|
|
16287
|
-
const
|
|
16309
|
+
const codexCmd = resolveCommand("codex");
|
|
16310
|
+
const proc = spawn7(codexCmd.cmd, [...codexCmd.prependArgs, "app-server"], {
|
|
16288
16311
|
stdio: ["pipe", "pipe", "pipe"],
|
|
16289
|
-
cwd
|
|
16290
|
-
shell: process.platform === "win32"
|
|
16312
|
+
cwd
|
|
16291
16313
|
});
|
|
16292
16314
|
const rl = createInterface5({ input: proc.stdout });
|
|
16293
16315
|
const send = (msg) => proc.stdin.write(`${JSON.stringify(msg)}
|
|
@@ -16305,7 +16327,7 @@ async function bootstrapCodexSession(cwd, initPrompt) {
|
|
|
16305
16327
|
let pollInterval = null;
|
|
16306
16328
|
const startPolling = () => {
|
|
16307
16329
|
pollInterval = setInterval(() => {
|
|
16308
|
-
if (sessionPath &&
|
|
16330
|
+
if (sessionPath && existsSync12(sessionPath)) {
|
|
16309
16331
|
if (pollInterval) clearInterval(pollInterval);
|
|
16310
16332
|
send({ method: "turn/interrupt", id: 4, params: { threadId } });
|
|
16311
16333
|
setTimeout(() => {
|
|
@@ -16370,10 +16392,10 @@ codeCommand.command("claude").description("Open Claude Code TUI").option("-p, --
|
|
|
16370
16392
|
sessionId = randomUUID4();
|
|
16371
16393
|
args.push("--session-id", sessionId, await buildClaudeInitPrompt(sessionId));
|
|
16372
16394
|
}
|
|
16373
|
-
const
|
|
16395
|
+
const claudeCmd = resolveCommand("claude");
|
|
16396
|
+
const child = spawn7(claudeCmd.cmd, [...claudeCmd.prependArgs, ...args], {
|
|
16374
16397
|
cwd: flintPath,
|
|
16375
|
-
stdio: "inherit"
|
|
16376
|
-
shell: process.platform === "win32"
|
|
16398
|
+
stdio: "inherit"
|
|
16377
16399
|
});
|
|
16378
16400
|
child.on("error", (err) => {
|
|
16379
16401
|
if (err.code === "ENOENT") {
|
|
@@ -16440,15 +16462,16 @@ codeCommand.command("codex").description("Open Codex TUI with session tracking")
|
|
|
16440
16462
|
console.log(pc29.green(`Session ID: ${threadId}`));
|
|
16441
16463
|
console.log("");
|
|
16442
16464
|
const resumePrompt = options.continue ? `continuing session ${threadId}` : `your session id is ${threadId}`;
|
|
16443
|
-
const
|
|
16465
|
+
const codexResumeCmd = resolveCommand("codex");
|
|
16466
|
+
const child = spawn7(codexResumeCmd.cmd, [
|
|
16467
|
+
...codexResumeCmd.prependArgs,
|
|
16444
16468
|
"resume",
|
|
16445
16469
|
threadId,
|
|
16446
16470
|
"--dangerously-bypass-approvals-and-sandbox",
|
|
16447
16471
|
resumePrompt
|
|
16448
16472
|
], {
|
|
16449
16473
|
cwd: flintPath,
|
|
16450
|
-
stdio: "inherit"
|
|
16451
|
-
shell: process.platform === "win32"
|
|
16474
|
+
stdio: "inherit"
|
|
16452
16475
|
});
|
|
16453
16476
|
child.on("error", (err) => {
|
|
16454
16477
|
console.error(pc29.red(`Error: ${err.message}`));
|
|
@@ -16539,11 +16562,11 @@ codeCommand.command("gemini").description("Open Gemini CLI with Orbh session tra
|
|
|
16539
16562
|
writeSession(sessionsDir, fresh);
|
|
16540
16563
|
});
|
|
16541
16564
|
}
|
|
16542
|
-
const
|
|
16565
|
+
const geminiCmd = resolveCommand("gemini");
|
|
16566
|
+
const child = spawn7(geminiCmd.cmd, [...geminiCmd.prependArgs, ...args], {
|
|
16543
16567
|
cwd: flintPath,
|
|
16544
16568
|
stdio: "inherit",
|
|
16545
|
-
env: { ...process.env, ORBH_SESSION_ID: session.id }
|
|
16546
|
-
shell: process.platform === "win32"
|
|
16569
|
+
env: { ...process.env, ORBH_SESSION_ID: session.id }
|
|
16547
16570
|
});
|
|
16548
16571
|
if (child.pid) {
|
|
16549
16572
|
updateCurrentRun2(session, { pid: child.pid });
|
|
@@ -16604,7 +16627,7 @@ codeCommand.command("gemini").description("Open Gemini CLI with Orbh session tra
|
|
|
16604
16627
|
// src/commands/helper.ts
|
|
16605
16628
|
import { Command as Command25 } from "commander";
|
|
16606
16629
|
import pc30 from "picocolors";
|
|
16607
|
-
import { readdirSync as readdirSync6, existsSync as
|
|
16630
|
+
import { readdirSync as readdirSync6, existsSync as existsSync13, statSync as statSync4 } from "fs";
|
|
16608
16631
|
import { join as join15, basename as basename5 } from "path";
|
|
16609
16632
|
function extractNumberFromFile(filename, typeName) {
|
|
16610
16633
|
const regex = new RegExp(`^\\(${typeName}\\)\\s+(\\d+)`, "i");
|
|
@@ -16613,7 +16636,7 @@ function extractNumberFromFile(filename, typeName) {
|
|
|
16613
16636
|
}
|
|
16614
16637
|
function collectFilesRecursively(dirPath) {
|
|
16615
16638
|
const files = [];
|
|
16616
|
-
if (!
|
|
16639
|
+
if (!existsSync13(dirPath)) {
|
|
16617
16640
|
return files;
|
|
16618
16641
|
}
|
|
16619
16642
|
const entries = readdirSync6(dirPath);
|
|
@@ -16634,7 +16657,7 @@ function collectFilesRecursively(dirPath) {
|
|
|
16634
16657
|
}
|
|
16635
16658
|
function getNextNumber(flintPath, typeName) {
|
|
16636
16659
|
const meshDir = join15(flintPath, "Mesh");
|
|
16637
|
-
if (!
|
|
16660
|
+
if (!existsSync13(meshDir)) {
|
|
16638
16661
|
return 1;
|
|
16639
16662
|
}
|
|
16640
16663
|
const allFiles = collectFilesRecursively(meshDir);
|
|
@@ -16752,7 +16775,7 @@ var featuresCommand = createFeaturesCommand({
|
|
|
16752
16775
|
import { Command as Command27 } from "commander";
|
|
16753
16776
|
import pc32 from "picocolors";
|
|
16754
16777
|
var VALID_TYPES = ["codebase", "flint"];
|
|
16755
|
-
var
|
|
16778
|
+
var resolveCommand2 = new Command27("resolve").description("Resolve a reference to its local path").argument("<type>", "Reference type: codebase, flint, or source").argument("<name>", 'Name of the reference to resolve (or "FlintName/ExportName" for sources)').option("-p, --path <dir>", "Path to flint (default: auto-detect)").option("--json", "Output as JSON").action(async (type, name, options) => {
|
|
16756
16779
|
try {
|
|
16757
16780
|
const flintPath = options.path || await findFlintRoot(process.cwd());
|
|
16758
16781
|
if (!flintPath) {
|
|
@@ -16917,17 +16940,17 @@ function prompt5(message) {
|
|
|
16917
16940
|
// src/commands/update.ts
|
|
16918
16941
|
import { Command as Command29 } from "commander";
|
|
16919
16942
|
import pc34 from "picocolors";
|
|
16920
|
-
import { readFileSync as
|
|
16921
|
-
import { dirname as
|
|
16943
|
+
import { readFileSync as readFileSync10, existsSync as existsSync14 } from "fs";
|
|
16944
|
+
import { dirname as dirname4, join as join16 } from "path";
|
|
16922
16945
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
16923
16946
|
import { execSync as execSync4 } from "child_process";
|
|
16924
16947
|
import https from "https";
|
|
16925
|
-
var __dirname2 =
|
|
16948
|
+
var __dirname2 = dirname4(fileURLToPath3(import.meta.url));
|
|
16926
16949
|
function readPkgVersion() {
|
|
16927
16950
|
for (const rel of ["../..", ".."]) {
|
|
16928
16951
|
const p = join16(__dirname2, rel, "package.json");
|
|
16929
|
-
if (
|
|
16930
|
-
return JSON.parse(
|
|
16952
|
+
if (existsSync14(p)) {
|
|
16953
|
+
return JSON.parse(readFileSync10(p, "utf-8")).version;
|
|
16931
16954
|
}
|
|
16932
16955
|
}
|
|
16933
16956
|
throw new Error("Could not determine current version");
|
|
@@ -17803,7 +17826,7 @@ var tinderboxCommand = new Command35("tinderbox").description("Orchestrate opera
|
|
|
17803
17826
|
import { Command as Command36 } from "commander";
|
|
17804
17827
|
import pc41 from "picocolors";
|
|
17805
17828
|
import { spawn as spawn8, spawnSync as spawnSync4, execSync as execSync5 } from "child_process";
|
|
17806
|
-
import { existsSync as
|
|
17829
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync4, readFileSync as readFileSync11, readdirSync as readdirSync7, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
17807
17830
|
import { join as join18 } from "path";
|
|
17808
17831
|
import { homedir as homedir10 } from "os";
|
|
17809
17832
|
import { createInterface as createInterface7 } from "readline";
|
|
@@ -17847,7 +17870,7 @@ function readTranscriptEntries(session, flintPath) {
|
|
|
17847
17870
|
const transcriptPath = harness.resolveTranscriptPath(nativeId, flintPath);
|
|
17848
17871
|
if (!transcriptPath) return null;
|
|
17849
17872
|
try {
|
|
17850
|
-
const content =
|
|
17873
|
+
const content = readFileSync11(transcriptPath, "utf-8");
|
|
17851
17874
|
return harness.parseTranscript(content, { transcriptPath });
|
|
17852
17875
|
} catch {
|
|
17853
17876
|
return null;
|
|
@@ -17916,7 +17939,31 @@ function notify(title, message) {
|
|
|
17916
17939
|
} catch {}
|
|
17917
17940
|
}
|
|
17918
17941
|
|
|
17919
|
-
|
|
17942
|
+
// On Windows, resolve .cmd shims to the underlying node script
|
|
17943
|
+
let spawnCmd = command;
|
|
17944
|
+
let spawnArgs = args;
|
|
17945
|
+
if (process.platform === 'win32') {
|
|
17946
|
+
const where = spawnSync('where', [command], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
17947
|
+
if (where.status === 0 && where.stdout) {
|
|
17948
|
+
const resolved = where.stdout.trim().split(/\r?\n/)[0].trim();
|
|
17949
|
+
if (resolved.toLowerCase().endsWith('.cmd')) {
|
|
17950
|
+
try {
|
|
17951
|
+
const content = readFileSync(resolved, 'utf-8');
|
|
17952
|
+
const matches = [...content.matchAll(/%(?:~dp0|dp0%)\\([^"%\r\n]+\.m?[jc]?[jt]s)/gi)];
|
|
17953
|
+
if (matches.length > 0) {
|
|
17954
|
+
const scriptPath = join(dirname(resolved), matches[matches.length - 1][1]);
|
|
17955
|
+
if (existsSync(scriptPath)) {
|
|
17956
|
+
spawnCmd = process.execPath;
|
|
17957
|
+
spawnArgs = [scriptPath, ...args];
|
|
17958
|
+
}
|
|
17959
|
+
}
|
|
17960
|
+
} catch {}
|
|
17961
|
+
} else {
|
|
17962
|
+
spawnCmd = resolved;
|
|
17963
|
+
}
|
|
17964
|
+
}
|
|
17965
|
+
}
|
|
17966
|
+
const child = spawn(spawnCmd, spawnArgs, { cwd, stdio: ['ignore', 'ignore', 'pipe'] });
|
|
17920
17967
|
|
|
17921
17968
|
let stderr = '';
|
|
17922
17969
|
child.stderr?.on('data', (chunk) => { stderr += chunk.toString(); });
|
|
@@ -18216,7 +18263,7 @@ function exportSessionTranscript(session, flintPath) {
|
|
|
18216
18263
|
}
|
|
18217
18264
|
let content;
|
|
18218
18265
|
try {
|
|
18219
|
-
content =
|
|
18266
|
+
content = readFileSync11(transcriptPath, "utf-8");
|
|
18220
18267
|
} catch {
|
|
18221
18268
|
console.log(pc41.dim("Could not read transcript file."));
|
|
18222
18269
|
return;
|
|
@@ -19118,11 +19165,11 @@ orbCommand.command("watch").description("Stream a live session transcript to the
|
|
|
19118
19165
|
console.log(`${pc41.bold("Watching")} ${pc41.cyan(shortId2(session.id))} ${pc41.dim("\xB7")} ${session.runtime}${watchTitle} ${pc41.dim("\xB7")} ${statusIcon2(session.status)} ${session.status}${watchMeta}`);
|
|
19119
19166
|
console.log(pc41.dim(transcriptPath));
|
|
19120
19167
|
console.log("");
|
|
19121
|
-
if (!
|
|
19168
|
+
if (!existsSync15(transcriptPath)) {
|
|
19122
19169
|
process.stdout.write(pc41.dim("Waiting for transcript..."));
|
|
19123
19170
|
await new Promise((resolve12, reject) => {
|
|
19124
19171
|
const poll = setInterval(() => {
|
|
19125
|
-
if (
|
|
19172
|
+
if (existsSync15(transcriptPath)) {
|
|
19126
19173
|
clearInterval(poll);
|
|
19127
19174
|
process.stdout.write("\r\x1B[2K");
|
|
19128
19175
|
resolve12();
|
|
@@ -19541,15 +19588,15 @@ var steelCommand = new Command37("steel").description("Manage Steel UI state (.s
|
|
|
19541
19588
|
);
|
|
19542
19589
|
|
|
19543
19590
|
// src/index.ts
|
|
19544
|
-
var __dirname3 =
|
|
19545
|
-
var pkg = JSON.parse(
|
|
19591
|
+
var __dirname3 = dirname5(fileURLToPath4(import.meta.url));
|
|
19592
|
+
var pkg = JSON.parse(readFileSync12(join20(__dirname3, "..", "package.json"), "utf-8"));
|
|
19546
19593
|
var runtime = resolveRuntimeSync({ cliname: "flint" });
|
|
19547
19594
|
var devAvailable = runtime.mode === "dev";
|
|
19548
19595
|
var newDir = getConfigDir("flint");
|
|
19549
19596
|
var oldDir = join20(homedir11(), ".flint");
|
|
19550
19597
|
var intermediateDir = join20(homedir11(), ".nuucognition", ".flint");
|
|
19551
19598
|
function migrateDir(sourceDir, label) {
|
|
19552
|
-
if (!
|
|
19599
|
+
if (!existsSync16(sourceDir)) return false;
|
|
19553
19600
|
try {
|
|
19554
19601
|
const entries = readdirSync8(sourceDir);
|
|
19555
19602
|
const filesToMigrate = entries.filter((e) => !e.startsWith(".DS_Store"));
|
|
@@ -19559,7 +19606,7 @@ function migrateDir(sourceDir, label) {
|
|
|
19559
19606
|
for (const entry of filesToMigrate) {
|
|
19560
19607
|
const src = join20(sourceDir, entry);
|
|
19561
19608
|
const dest = join20(newDir, entry);
|
|
19562
|
-
if (!
|
|
19609
|
+
if (!existsSync16(dest)) {
|
|
19563
19610
|
cpSync(src, dest, { recursive: true });
|
|
19564
19611
|
migrated++;
|
|
19565
19612
|
}
|
|
@@ -19627,7 +19674,7 @@ var COMMAND_MAP = [
|
|
|
19627
19674
|
{ featureId: "reference", command: referenceCommand },
|
|
19628
19675
|
{ featureId: "export", command: exportCommand },
|
|
19629
19676
|
{ featureId: "obsidian", command: obsidianCommand },
|
|
19630
|
-
{ featureId: "resolve", command:
|
|
19677
|
+
{ featureId: "resolve", command: resolveCommand2 },
|
|
19631
19678
|
{ featureId: "fulfill", command: fulfillCommand },
|
|
19632
19679
|
{ featureId: "update", command: updateCommand },
|
|
19633
19680
|
{ featureId: "send", command: sendCommand },
|
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.2",
|
|
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/eslint-config": "0.0.0",
|
|
39
40
|
"@nuucognition/flint-server": "0.0.1",
|
|
40
|
-
"@nuucognition/flint": "0.1.0",
|
|
41
41
|
"@nuucognition/flint-migrations": "0.1.0",
|
|
42
42
|
"@nuucognition/typescript-config": "0.0.0",
|
|
43
|
-
"@nuucognition/
|
|
44
|
-
"@nuucognition/
|
|
43
|
+
"@nuucognition/flint": "0.1.0",
|
|
44
|
+
"@nuucognition/orbh": "0.0.1-dev.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"predev": "turbo build --filter=@nuucognition/flint-cli^...",
|