@onebrain-ai/cli 2.0.3 → 2.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.
- package/dist/onebrain +174 -42
- package/package.json +1 -1
package/dist/onebrain
CHANGED
|
@@ -10210,9 +10210,9 @@ var init_register_hooks = __esm(() => {
|
|
|
10210
10210
|
};
|
|
10211
10211
|
HOOK_EVENTS = ["Stop", "PreCompact", "PostCompact", "SessionStart"];
|
|
10212
10212
|
PERMISSIONS_TO_ADD = [
|
|
10213
|
-
"Bash(onebrain
|
|
10214
|
-
"Bash(bun install -g @onebrain-ai/cli
|
|
10215
|
-
"Bash(npm install -g @onebrain-ai/cli
|
|
10213
|
+
"Bash(onebrain *)",
|
|
10214
|
+
"Bash(bun install -g @onebrain-ai/cli*)",
|
|
10215
|
+
"Bash(npm install -g @onebrain-ai/cli*)"
|
|
10216
10216
|
];
|
|
10217
10217
|
BUN_BIN = join4(homedir2(), ".bun", "bin");
|
|
10218
10218
|
NPM_GLOBAL_BIN = join4(homedir2(), ".npm-global", "bin");
|
|
@@ -10431,7 +10431,8 @@ async function checkQmdEmbeddings(config) {
|
|
|
10431
10431
|
};
|
|
10432
10432
|
}
|
|
10433
10433
|
try {
|
|
10434
|
-
const
|
|
10434
|
+
const qmdArgs = process.platform === "win32" ? ["powershell.exe", "-NoProfile", "-Command", "qmd status --json"] : ["qmd", "status", "--json"];
|
|
10435
|
+
const proc = Bun.spawn(qmdArgs, {
|
|
10435
10436
|
stdout: "pipe",
|
|
10436
10437
|
stderr: "pipe"
|
|
10437
10438
|
});
|
|
@@ -10742,7 +10743,7 @@ init_dist();
|
|
|
10742
10743
|
import { mkdir as mkdir3, readFile as readFile3, rename as rename3, stat as stat3, writeFile as writeFile3 } from "node:fs/promises";
|
|
10743
10744
|
import { homedir as homedir3 } from "node:os";
|
|
10744
10745
|
import { dirname as dirname3, join as join5 } from "node:path";
|
|
10745
|
-
var binaryVersion = "2.0.
|
|
10746
|
+
var binaryVersion = "2.0.5";
|
|
10746
10747
|
var STANDARD_FOLDERS = [
|
|
10747
10748
|
"00-inbox",
|
|
10748
10749
|
"01-projects",
|
|
@@ -11060,9 +11061,22 @@ async function fetchLatestVersion(fetchFn) {
|
|
|
11060
11061
|
}
|
|
11061
11062
|
return tagName;
|
|
11062
11063
|
}
|
|
11064
|
+
var _windowsShell;
|
|
11065
|
+
function windowsShell() {
|
|
11066
|
+
if (_windowsShell !== undefined)
|
|
11067
|
+
return _windowsShell;
|
|
11068
|
+
try {
|
|
11069
|
+
const r2 = Bun.spawnSync(["pwsh", "--version"], { stdout: "pipe", stderr: "pipe" });
|
|
11070
|
+
_windowsShell = r2.exitCode === 0 ? "pwsh" : "powershell.exe";
|
|
11071
|
+
} catch {
|
|
11072
|
+
_windowsShell = "powershell.exe";
|
|
11073
|
+
}
|
|
11074
|
+
return _windowsShell;
|
|
11075
|
+
}
|
|
11063
11076
|
async function defaultInstallBinary(version) {
|
|
11064
11077
|
const isWindows = process.platform === "win32";
|
|
11065
|
-
const
|
|
11078
|
+
const safeVersion = version.replace(/'/g, "''");
|
|
11079
|
+
const cmd = isWindows ? [windowsShell(), "-NoProfile", "-Command", `npm install -g '@onebrain-ai/cli@${safeVersion}'`] : ["bun", "install", "-g", `@onebrain-ai/cli@${version}`];
|
|
11066
11080
|
const proc = Bun.spawn(cmd, { stdout: "pipe", stderr: "pipe" });
|
|
11067
11081
|
const exitCode = await proc.exited;
|
|
11068
11082
|
if (exitCode !== 0) {
|
|
@@ -11072,7 +11086,9 @@ async function defaultInstallBinary(version) {
|
|
|
11072
11086
|
}
|
|
11073
11087
|
async function defaultValidateBinary() {
|
|
11074
11088
|
try {
|
|
11075
|
-
const
|
|
11089
|
+
const isWindows = process.platform === "win32";
|
|
11090
|
+
const cmd = isWindows ? [windowsShell(), "-NoProfile", "-Command", "onebrain --version"] : ["onebrain", "--version"];
|
|
11091
|
+
const proc = Bun.spawn(cmd, { stdout: "pipe", stderr: "pipe" });
|
|
11076
11092
|
const exitCode = await proc.exited;
|
|
11077
11093
|
if (exitCode !== 0)
|
|
11078
11094
|
return false;
|
|
@@ -11228,8 +11244,8 @@ async function updateCommand(opts = {}) {
|
|
|
11228
11244
|
}
|
|
11229
11245
|
|
|
11230
11246
|
// src/internal/checkpoint.ts
|
|
11231
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
11232
|
-
import { mkdir as mkdir4, writeFile as writeFile5 } from "node:fs/promises";
|
|
11247
|
+
import { readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
11248
|
+
import { mkdir as mkdir4, readdir as readdir2, writeFile as writeFile5 } from "node:fs/promises";
|
|
11233
11249
|
import { tmpdir as osTmpdir } from "node:os";
|
|
11234
11250
|
import { join as join7 } from "node:path";
|
|
11235
11251
|
var SKIP_WINDOW = 60;
|
|
@@ -11282,13 +11298,15 @@ function writeState(token, state, tmpDir = osTmpdir()) {
|
|
|
11282
11298
|
`);
|
|
11283
11299
|
}
|
|
11284
11300
|
}
|
|
11285
|
-
|
|
11301
|
+
var DEFAULT_LOGS_FOLDER = "07-logs";
|
|
11302
|
+
function loadVaultSettings(vaultRoot) {
|
|
11286
11303
|
try {
|
|
11287
11304
|
const vaultYml = join7(vaultRoot, "vault.yml");
|
|
11288
11305
|
const raw = readFileSync(vaultYml, "utf8");
|
|
11289
|
-
const checkpointBlock = raw.match(/^checkpoint:\s*\n((?:[ \t]+[^\n]+\n?)*)/m);
|
|
11290
11306
|
let messages = DEFAULT_MESSAGES_THRESHOLD;
|
|
11291
11307
|
let minutes = DEFAULT_MINUTES_THRESHOLD;
|
|
11308
|
+
let logsFolder = DEFAULT_LOGS_FOLDER;
|
|
11309
|
+
const checkpointBlock = raw.match(/^checkpoint:\s*\n((?:[ \t]+[^\n]+\n?)*)/m);
|
|
11292
11310
|
if (checkpointBlock?.[1]) {
|
|
11293
11311
|
const block = checkpointBlock[1];
|
|
11294
11312
|
const msgMatch = block.match(/messages:\s*(\d+)/);
|
|
@@ -11298,14 +11316,40 @@ function loadThresholds(vaultRoot) {
|
|
|
11298
11316
|
if (minMatch?.[1])
|
|
11299
11317
|
minutes = Number(minMatch[1]);
|
|
11300
11318
|
}
|
|
11301
|
-
|
|
11319
|
+
const foldersBlock = raw.match(/^folders:\s*\n((?:[ \t]+[^\n]+\n?)*)/m);
|
|
11320
|
+
if (foldersBlock?.[1]) {
|
|
11321
|
+
const logsMatch = foldersBlock[1].match(/logs:\s*['"]?([^'"\s]+)['"]?/);
|
|
11322
|
+
if (logsMatch?.[1])
|
|
11323
|
+
logsFolder = logsMatch[1];
|
|
11324
|
+
}
|
|
11325
|
+
return { messagesThreshold: messages, minutesThreshold: minutes, logsFolder };
|
|
11302
11326
|
} catch {
|
|
11303
11327
|
return {
|
|
11304
11328
|
messagesThreshold: DEFAULT_MESSAGES_THRESHOLD,
|
|
11305
|
-
minutesThreshold: DEFAULT_MINUTES_THRESHOLD
|
|
11329
|
+
minutesThreshold: DEFAULT_MINUTES_THRESHOLD,
|
|
11330
|
+
logsFolder: DEFAULT_LOGS_FOLDER
|
|
11306
11331
|
};
|
|
11307
11332
|
}
|
|
11308
11333
|
}
|
|
11334
|
+
function maxCheckpointNnSync(vaultRoot, date, token, logsFolder) {
|
|
11335
|
+
const yyyy = date.slice(0, 4);
|
|
11336
|
+
const mm = date.slice(5, 7);
|
|
11337
|
+
const dir = join7(vaultRoot, logsFolder, yyyy, mm);
|
|
11338
|
+
const prefix = `${date}-${token}-checkpoint-`;
|
|
11339
|
+
try {
|
|
11340
|
+
let max = 0;
|
|
11341
|
+
for (const f2 of readdirSync(dir)) {
|
|
11342
|
+
if (!f2.startsWith(prefix) || !f2.endsWith(".md"))
|
|
11343
|
+
continue;
|
|
11344
|
+
const m3 = f2.match(/-checkpoint-(\d{2})\.md$/);
|
|
11345
|
+
if (m3)
|
|
11346
|
+
max = Math.max(max, Number(m3[1]));
|
|
11347
|
+
}
|
|
11348
|
+
return max;
|
|
11349
|
+
} catch {
|
|
11350
|
+
return 0;
|
|
11351
|
+
}
|
|
11352
|
+
}
|
|
11309
11353
|
function formatDate(epochSeconds) {
|
|
11310
11354
|
const d2 = new Date(epochSeconds * 1000);
|
|
11311
11355
|
const yyyy = d2.getFullYear().toString();
|
|
@@ -11332,7 +11376,7 @@ function handleStop(token, vaultRoot, now = Math.floor(Date.now() / 1000), tmpDi
|
|
|
11332
11376
|
return;
|
|
11333
11377
|
}
|
|
11334
11378
|
state.count += 1;
|
|
11335
|
-
const { messagesThreshold, minutesThreshold } =
|
|
11379
|
+
const { messagesThreshold, minutesThreshold, logsFolder } = loadVaultSettings(vaultRoot);
|
|
11336
11380
|
const timeThreshold = minutesThreshold * 60;
|
|
11337
11381
|
const elapsed = state.last_ts === 0 ? 0 : now - state.last_ts;
|
|
11338
11382
|
const thresholdMet = state.count >= messagesThreshold || elapsed >= timeThreshold;
|
|
@@ -11344,12 +11388,13 @@ function handleStop(token, vaultRoot, now = Math.floor(Date.now() / 1000), tmpDi
|
|
|
11344
11388
|
writeState(token, { count: state.count, last_ts: state.last_ts, last_stop_nn: state.last_stop_nn }, tmpDir);
|
|
11345
11389
|
return;
|
|
11346
11390
|
}
|
|
11347
|
-
const nextNn = String(Number(state.last_stop_nn) + 1).padStart(2, "0");
|
|
11348
11391
|
const date = formatDate(now);
|
|
11392
|
+
const maxNn = maxCheckpointNnSync(vaultRoot, date, token, logsFolder);
|
|
11393
|
+
const nextNn = String(maxNn + 1).padStart(2, "0");
|
|
11394
|
+
const since = maxNn === 0 ? " since start" : ` since checkpoint-${String(maxNn).padStart(2, "0")}`;
|
|
11349
11395
|
const filename = `${date}-${token}-checkpoint-${nextNn}.md`;
|
|
11350
|
-
const since = state.last_stop_nn === "00" ? " since start" : ` since checkpoint-${state.last_stop_nn}`;
|
|
11351
11396
|
emitBlock(`${filename}${since}`);
|
|
11352
|
-
writeState(token, { count: 0, last_ts: now, last_stop_nn: nextNn }, tmpDir);
|
|
11397
|
+
writeState(token, { count: 0, last_ts: now, last_stop_nn: nextNn, pending_stub: state.pending_stub }, tmpDir);
|
|
11353
11398
|
}
|
|
11354
11399
|
var PRECOMPACT_STUB_TEMPLATE = (date, nn) => `---
|
|
11355
11400
|
tags: [checkpoint, session-log]
|
|
@@ -11388,10 +11433,11 @@ async function handlePrecompact(token, vaultRoot, now = Math.floor(Date.now() /
|
|
|
11388
11433
|
if (state.last_ts > 0 && now - state.last_ts < PRECOMPACT_RECENCY) {
|
|
11389
11434
|
return;
|
|
11390
11435
|
}
|
|
11391
|
-
|
|
11436
|
+
if (state.pending_stub) {
|
|
11437
|
+
return;
|
|
11438
|
+
}
|
|
11392
11439
|
const date = formatDate(now);
|
|
11393
|
-
|
|
11394
|
-
let logsFolder = "07-logs";
|
|
11440
|
+
let logsFolder = DEFAULT_LOGS_FOLDER;
|
|
11395
11441
|
try {
|
|
11396
11442
|
const config = await loadVaultConfig(vaultRoot);
|
|
11397
11443
|
logsFolder = config.folders.logs;
|
|
@@ -11399,6 +11445,16 @@ async function handlePrecompact(token, vaultRoot, now = Math.floor(Date.now() /
|
|
|
11399
11445
|
const yyyy = formatYYYY(now);
|
|
11400
11446
|
const mm = formatMM(now);
|
|
11401
11447
|
const stubDir = join7(vaultRoot, logsFolder, yyyy, mm);
|
|
11448
|
+
const existingFiles = await readdir2(stubDir).catch(() => []);
|
|
11449
|
+
const prefix = `${date}-${token}-checkpoint-`;
|
|
11450
|
+
const maxNn = existingFiles.reduce((max, f2) => {
|
|
11451
|
+
if (!f2.startsWith(prefix) || !f2.endsWith(".md"))
|
|
11452
|
+
return max;
|
|
11453
|
+
const m3 = f2.match(/-checkpoint-(\d{2})\.md$/);
|
|
11454
|
+
return m3 ? Math.max(max, Number(m3[1])) : max;
|
|
11455
|
+
}, 0);
|
|
11456
|
+
const stubNn = String(maxNn + 1).padStart(2, "0");
|
|
11457
|
+
const stubFilename = `${date}-${token}-checkpoint-${stubNn}.md`;
|
|
11402
11458
|
const stubPath = join7(stubDir, stubFilename);
|
|
11403
11459
|
try {
|
|
11404
11460
|
await mkdir4(stubDir, { recursive: true });
|
|
@@ -11415,15 +11471,79 @@ async function handlePrecompact(token, vaultRoot, now = Math.floor(Date.now() /
|
|
|
11415
11471
|
pending_stub: stubFilename
|
|
11416
11472
|
}, tmpDir);
|
|
11417
11473
|
}
|
|
11418
|
-
function handlePostcompact(token,
|
|
11474
|
+
function handlePostcompact(token, vaultRoot, now = Math.floor(Date.now() / 1000), tmpDir = osTmpdir()) {
|
|
11419
11475
|
const state = readState(token, tmpDir);
|
|
11420
11476
|
if (!state.pending_stub) {
|
|
11421
11477
|
writeState(token, { count: 0, last_ts: state.last_ts, last_stop_nn: state.last_stop_nn }, tmpDir);
|
|
11422
11478
|
return;
|
|
11423
11479
|
}
|
|
11424
|
-
const
|
|
11480
|
+
const stubNnMatch = state.pending_stub.match(/-checkpoint-(\d{2})\.md$/);
|
|
11481
|
+
const stubNn = stubNnMatch?.[1] ?? "01";
|
|
11482
|
+
const stubNnNum = Number(stubNn);
|
|
11483
|
+
const { logsFolder } = loadVaultSettings(vaultRoot);
|
|
11484
|
+
const date = state.pending_stub.slice(0, 10);
|
|
11485
|
+
const yyyy = date.slice(0, 4);
|
|
11486
|
+
const mm = date.slice(5, 7);
|
|
11487
|
+
const dir = join7(vaultRoot, logsFolder, yyyy, mm);
|
|
11488
|
+
const prefix = `${date}-${token}-checkpoint-`;
|
|
11489
|
+
let predecessorNn = 0;
|
|
11490
|
+
try {
|
|
11491
|
+
for (const f2 of readdirSync(dir)) {
|
|
11492
|
+
if (!f2.startsWith(prefix) || !f2.endsWith(".md"))
|
|
11493
|
+
continue;
|
|
11494
|
+
const m3 = f2.match(/-checkpoint-(\d{2})\.md$/);
|
|
11495
|
+
if (m3) {
|
|
11496
|
+
const nn = Number(m3[1]);
|
|
11497
|
+
if (nn < stubNnNum)
|
|
11498
|
+
predecessorNn = Math.max(predecessorNn, nn);
|
|
11499
|
+
}
|
|
11500
|
+
}
|
|
11501
|
+
} catch {}
|
|
11502
|
+
const since = predecessorNn === 0 ? " since start" : ` since checkpoint-${String(predecessorNn).padStart(2, "0")}`;
|
|
11425
11503
|
emitBlock(`fill-checkpoint: ${state.pending_stub}${since}`);
|
|
11426
|
-
writeState(token, { count: 0, last_ts:
|
|
11504
|
+
writeState(token, { count: 0, last_ts: now, last_stop_nn: stubNn }, tmpDir);
|
|
11505
|
+
}
|
|
11506
|
+
function postcompactFallback(token, vaultRoot, now = Math.floor(Date.now() / 1000), tmpDir = osTmpdir()) {
|
|
11507
|
+
const state = readState(token, tmpDir);
|
|
11508
|
+
if (state.pending_stub) {
|
|
11509
|
+
handlePostcompact(token, vaultRoot, now, tmpDir);
|
|
11510
|
+
return;
|
|
11511
|
+
}
|
|
11512
|
+
const { logsFolder } = loadVaultSettings(vaultRoot);
|
|
11513
|
+
const date = formatDate(now);
|
|
11514
|
+
const yyyy = date.slice(0, 4);
|
|
11515
|
+
const mm = date.slice(5, 7);
|
|
11516
|
+
const dir = join7(vaultRoot, logsFolder, yyyy, mm);
|
|
11517
|
+
const prefix = `${date}-${token}-checkpoint-`;
|
|
11518
|
+
const stubs = [];
|
|
11519
|
+
const allNns = [];
|
|
11520
|
+
try {
|
|
11521
|
+
for (const f2 of readdirSync(dir)) {
|
|
11522
|
+
if (!f2.startsWith(prefix) || !f2.endsWith(".md"))
|
|
11523
|
+
continue;
|
|
11524
|
+
const m3 = f2.match(/-checkpoint-(\d{2})\.md$/);
|
|
11525
|
+
if (!m3)
|
|
11526
|
+
continue;
|
|
11527
|
+
allNns.push(Number(m3[1]));
|
|
11528
|
+
const content = readFileSync(join7(dir, f2), "utf8");
|
|
11529
|
+
if (/^trigger:\s*precompact/m.test(content) && !/^merged:\s*true/m.test(content)) {
|
|
11530
|
+
stubs.push(f2);
|
|
11531
|
+
}
|
|
11532
|
+
}
|
|
11533
|
+
} catch {}
|
|
11534
|
+
if (stubs.length === 0) {
|
|
11535
|
+
writeState(token, { count: 0, last_ts: state.last_ts, last_stop_nn: state.last_stop_nn }, tmpDir);
|
|
11536
|
+
return;
|
|
11537
|
+
}
|
|
11538
|
+
stubs.sort();
|
|
11539
|
+
const stubFilename = stubs[stubs.length - 1];
|
|
11540
|
+
const stubNnMatch = stubFilename.match(/-checkpoint-(\d{2})\.md$/);
|
|
11541
|
+
const stubNn = stubNnMatch?.[1] ?? "01";
|
|
11542
|
+
const stubNnNum = Number(stubNn);
|
|
11543
|
+
const predecessorNn = allNns.filter((n) => n < stubNnNum).reduce((max, n) => Math.max(max, n), 0);
|
|
11544
|
+
const since = predecessorNn === 0 ? " since start" : ` since checkpoint-${String(predecessorNn).padStart(2, "0")}`;
|
|
11545
|
+
emitBlock(`fill-checkpoint: ${stubFilename}${since}`);
|
|
11546
|
+
writeState(token, { count: 0, last_ts: now, last_stop_nn: stubNn }, tmpDir);
|
|
11427
11547
|
}
|
|
11428
11548
|
async function checkpointCommand(mode, token, vaultRoot) {
|
|
11429
11549
|
try {
|
|
@@ -11435,7 +11555,7 @@ async function checkpointCommand(mode, token, vaultRoot) {
|
|
|
11435
11555
|
await handlePrecompact(token, vaultRoot);
|
|
11436
11556
|
break;
|
|
11437
11557
|
case "postcompact":
|
|
11438
|
-
|
|
11558
|
+
postcompactFallback(token, vaultRoot);
|
|
11439
11559
|
break;
|
|
11440
11560
|
case "reset":
|
|
11441
11561
|
handleReset(token);
|
|
@@ -11451,7 +11571,7 @@ async function checkpointCommand(mode, token, vaultRoot) {
|
|
|
11451
11571
|
}
|
|
11452
11572
|
|
|
11453
11573
|
// src/internal/migrate.ts
|
|
11454
|
-
import { readFile as readFile5, readdir as
|
|
11574
|
+
import { readFile as readFile5, readdir as readdir3, writeFile as writeFile6 } from "node:fs/promises";
|
|
11455
11575
|
import { join as join8 } from "node:path";
|
|
11456
11576
|
init_dist();
|
|
11457
11577
|
function parseFrontmatterWithRest(rawText) {
|
|
@@ -11480,7 +11600,7 @@ function parseFrontmatterWithRest(rawText) {
|
|
|
11480
11600
|
}
|
|
11481
11601
|
async function listMdFiles(dir) {
|
|
11482
11602
|
try {
|
|
11483
|
-
const entries = await
|
|
11603
|
+
const entries = await readdir3(dir);
|
|
11484
11604
|
return entries.filter((e2) => e2.endsWith(".md"));
|
|
11485
11605
|
} catch {
|
|
11486
11606
|
return [];
|
|
@@ -11492,7 +11612,7 @@ async function runBackfillRecapped(logsFolder) {
|
|
|
11492
11612
|
let skipped = 0;
|
|
11493
11613
|
let yearDirs = [];
|
|
11494
11614
|
try {
|
|
11495
|
-
yearDirs = await
|
|
11615
|
+
yearDirs = await readdir3(logsFolder);
|
|
11496
11616
|
} catch {
|
|
11497
11617
|
return { backfilled: 0, skipped: 0 };
|
|
11498
11618
|
}
|
|
@@ -11500,7 +11620,7 @@ async function runBackfillRecapped(logsFolder) {
|
|
|
11500
11620
|
const yearPath = join8(logsFolder, yearDir);
|
|
11501
11621
|
let monthDirs = [];
|
|
11502
11622
|
try {
|
|
11503
|
-
monthDirs = await
|
|
11623
|
+
monthDirs = await readdir3(yearPath);
|
|
11504
11624
|
} catch {
|
|
11505
11625
|
continue;
|
|
11506
11626
|
}
|
|
@@ -11563,7 +11683,7 @@ async function migrateCommand(migrationName) {
|
|
|
11563
11683
|
|
|
11564
11684
|
// src/internal/orphan-scan.ts
|
|
11565
11685
|
init_dist();
|
|
11566
|
-
import { readFile as readFile6, readdir as
|
|
11686
|
+
import { readFile as readFile6, readdir as readdir4 } from "node:fs/promises";
|
|
11567
11687
|
import { join as join9 } from "node:path";
|
|
11568
11688
|
function parseFrontmatter(rawText) {
|
|
11569
11689
|
const text = rawText.replace(/\r\n/g, `
|
|
@@ -11592,7 +11712,7 @@ function getMonthParts(now = new Date) {
|
|
|
11592
11712
|
}
|
|
11593
11713
|
async function listMdFiles2(dir) {
|
|
11594
11714
|
try {
|
|
11595
|
-
const entries = await
|
|
11715
|
+
const entries = await readdir4(dir);
|
|
11596
11716
|
return entries.filter((e2) => e2.endsWith(".md"));
|
|
11597
11717
|
} catch {
|
|
11598
11718
|
return [];
|
|
@@ -11670,6 +11790,13 @@ async function orphanScanCommand(logsFolder, sessionToken) {
|
|
|
11670
11790
|
}
|
|
11671
11791
|
|
|
11672
11792
|
// src/internal/qmd-reindex.ts
|
|
11793
|
+
function buildQmdSpawnArgs(collection, platform = process.platform) {
|
|
11794
|
+
if (platform === "win32") {
|
|
11795
|
+
const safe = collection.replace(/'/g, "''");
|
|
11796
|
+
return ["powershell.exe", "-NoProfile", "-Command", `qmd update -c '${safe}'`];
|
|
11797
|
+
}
|
|
11798
|
+
return ["qmd", "update", "-c", collection];
|
|
11799
|
+
}
|
|
11673
11800
|
async function qmdReindexCommand(vaultRoot) {
|
|
11674
11801
|
try {
|
|
11675
11802
|
const config = await loadVaultConfig(vaultRoot);
|
|
@@ -11677,7 +11804,7 @@ async function qmdReindexCommand(vaultRoot) {
|
|
|
11677
11804
|
if (!collection) {
|
|
11678
11805
|
return;
|
|
11679
11806
|
}
|
|
11680
|
-
const proc = Bun.spawn(
|
|
11807
|
+
const proc = Bun.spawn(buildQmdSpawnArgs(collection), {
|
|
11681
11808
|
detached: true,
|
|
11682
11809
|
stdin: "ignore",
|
|
11683
11810
|
stdout: "ignore",
|
|
@@ -11704,9 +11831,9 @@ var HOOK_COMMANDS2 = {
|
|
|
11704
11831
|
};
|
|
11705
11832
|
var HOOK_EVENTS2 = ["Stop", "PreCompact", "PostCompact", "SessionStart"];
|
|
11706
11833
|
var PERMISSIONS_TO_ADD2 = [
|
|
11707
|
-
"Bash(onebrain
|
|
11708
|
-
"Bash(bun install -g @onebrain-ai/cli
|
|
11709
|
-
"Bash(npm install -g @onebrain-ai/cli
|
|
11834
|
+
"Bash(onebrain *)",
|
|
11835
|
+
"Bash(bun install -g @onebrain-ai/cli*)",
|
|
11836
|
+
"Bash(npm install -g @onebrain-ai/cli*)"
|
|
11710
11837
|
];
|
|
11711
11838
|
var BUN_BIN2 = join10(homedir4(), ".bun", "bin");
|
|
11712
11839
|
var NPM_GLOBAL_BIN2 = join10(homedir4(), ".npm-global", "bin");
|
|
@@ -12060,7 +12187,8 @@ async function cleanStaleStateFile(token, tmpDir) {
|
|
|
12060
12187
|
}
|
|
12061
12188
|
async function queryQmdUnembedded() {
|
|
12062
12189
|
try {
|
|
12063
|
-
const
|
|
12190
|
+
const qmdArgs = process.platform === "win32" ? ["powershell.exe", "-NoProfile", "-Command", "qmd status --json"] : ["qmd", "status", "--json"];
|
|
12191
|
+
const proc = Bun.spawn(qmdArgs, {
|
|
12064
12192
|
stdout: "pipe",
|
|
12065
12193
|
stderr: "pipe"
|
|
12066
12194
|
});
|
|
@@ -12115,7 +12243,7 @@ import {
|
|
|
12115
12243
|
mkdir as mkdir6,
|
|
12116
12244
|
mkdtemp as mkdtemp2,
|
|
12117
12245
|
readFile as readFile8,
|
|
12118
|
-
readdir as
|
|
12246
|
+
readdir as readdir5,
|
|
12119
12247
|
rename as rename6,
|
|
12120
12248
|
rm as rm2,
|
|
12121
12249
|
stat as stat4,
|
|
@@ -12156,7 +12284,7 @@ async function extractTarball2(tarball, destDir) {
|
|
|
12156
12284
|
throw new Error(`tar extraction failed (exit ${exitCode}): ${errText.trim()}`);
|
|
12157
12285
|
}
|
|
12158
12286
|
await unlink3(tarPath);
|
|
12159
|
-
const entries = await
|
|
12287
|
+
const entries = await readdir5(destDir);
|
|
12160
12288
|
const topLevel = entries.find((e2) => e2 !== "bundle.tar.gz");
|
|
12161
12289
|
if (!topLevel) {
|
|
12162
12290
|
throw new Error("Extracted tarball contains no top-level directory");
|
|
@@ -12170,7 +12298,7 @@ async function listFilesRecursive2(dir) {
|
|
|
12170
12298
|
const current = queue.pop();
|
|
12171
12299
|
let entries;
|
|
12172
12300
|
try {
|
|
12173
|
-
entries = await
|
|
12301
|
+
entries = await readdir5(current);
|
|
12174
12302
|
} catch {
|
|
12175
12303
|
continue;
|
|
12176
12304
|
}
|
|
@@ -12395,7 +12523,7 @@ async function cleanPluginCache2(installedPluginsPath, installedPluginsCacheDir)
|
|
|
12395
12523
|
} catch {}
|
|
12396
12524
|
if (onebrainDirs.length === 0) {
|
|
12397
12525
|
try {
|
|
12398
|
-
const marketplaceDirs = await
|
|
12526
|
+
const marketplaceDirs = await readdir5(cacheDir);
|
|
12399
12527
|
for (const mp of marketplaceDirs) {
|
|
12400
12528
|
const candidate = join12(cacheDir, mp, "onebrain");
|
|
12401
12529
|
try {
|
|
@@ -12411,7 +12539,7 @@ async function cleanPluginCache2(installedPluginsPath, installedPluginsCacheDir)
|
|
|
12411
12539
|
for (const pluginDir of onebrainDirs) {
|
|
12412
12540
|
let versionDirs;
|
|
12413
12541
|
try {
|
|
12414
|
-
versionDirs = await
|
|
12542
|
+
versionDirs = await readdir5(pluginDir);
|
|
12415
12543
|
} catch {
|
|
12416
12544
|
continue;
|
|
12417
12545
|
}
|
|
@@ -12598,8 +12726,12 @@ async function vaultSyncCommand2(vaultRoot, opts = {}) {
|
|
|
12598
12726
|
}
|
|
12599
12727
|
|
|
12600
12728
|
// src/index.ts
|
|
12601
|
-
var VERSION = "2.0.
|
|
12602
|
-
var RELEASE_DATE = "2026-04-
|
|
12729
|
+
var VERSION = "2.0.5";
|
|
12730
|
+
var RELEASE_DATE = "2026-04-26";
|
|
12731
|
+
if (process.platform === "win32") {
|
|
12732
|
+
process.stdout.setDefaultEncoding("utf8");
|
|
12733
|
+
process.stderr.setDefaultEncoding("utf8");
|
|
12734
|
+
}
|
|
12603
12735
|
var VERSION_STRING = `OneBrain v${VERSION} \u2014 released ${RELEASE_DATE}`;
|
|
12604
12736
|
if (process.argv.slice(2).length === 0) {
|
|
12605
12737
|
console.log(VERSION_STRING);
|