@use-aistack/cli 0.20.2 → 0.20.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 +56 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3267,7 +3267,7 @@ var init_database = __esm({
|
|
|
3267
3267
|
});
|
|
3268
3268
|
|
|
3269
3269
|
// ../../node_modules/.pnpm/cursor-history@0.18.0_patch_hash=dbff0ea0e399ea9504168452170a23ee2b432a6dc6a69a20b49bf95ef139fa74/node_modules/cursor-history/dist/core/private-temp.js
|
|
3270
|
-
import { chmodSync, closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, mkdtempSync, openSync, readFileSync as readFileSync8, readlinkSync, readdirSync as readdirSync4, realpathSync, rmdirSync, statSync as statSync2, unlinkSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
3270
|
+
import { chmodSync as chmodSync2, closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, mkdtempSync, openSync, readFileSync as readFileSync8, readlinkSync, readdirSync as readdirSync4, realpathSync, rmdirSync, statSync as statSync2, unlinkSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
3271
3271
|
import { tmpdir } from "node:os";
|
|
3272
3272
|
import { basename as basename3, isAbsolute, join as join7, relative as relative2, resolve, sep } from "node:path";
|
|
3273
3273
|
import { performance as performance2 } from "node:perf_hooks";
|
|
@@ -3684,7 +3684,7 @@ function createPrivateTempWorkspace(options) {
|
|
|
3684
3684
|
try {
|
|
3685
3685
|
directoryPath = mkdtempSync(join7(parentPath, options.prefix));
|
|
3686
3686
|
if (IS_PERMISSION_AWARE_POSIX)
|
|
3687
|
-
|
|
3687
|
+
chmodSync2(directoryPath, 448);
|
|
3688
3688
|
const marker = createMarker();
|
|
3689
3689
|
const markerPath = join7(directoryPath, PRIVATE_TEMP_MARKER_FILENAME);
|
|
3690
3690
|
createExclusivePrivateFile(markerPath, `${JSON.stringify(marker)}
|
|
@@ -5760,7 +5760,7 @@ var init_session_id = __esm({
|
|
|
5760
5760
|
|
|
5761
5761
|
// ../../node_modules/.pnpm/cursor-history@0.18.0_patch_hash=dbff0ea0e399ea9504168452170a23ee2b432a6dc6a69a20b49bf95ef139fa74/node_modules/cursor-history/dist/core/backup.js
|
|
5762
5762
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
5763
|
-
import { chmodSync as
|
|
5763
|
+
import { chmodSync as chmodSync3, closeSync as closeSync3, constants as constants3, existsSync as existsSync7, copyFileSync, fchmodSync as fchmodSync3, fstatSync as fstatSync3, fsyncSync as fsyncSync2, lstatSync as lstatSync5, mkdirSync as mkdirSync2, openSync as openSync3, readFileSync as readFileSync9, readSync, readdirSync as readdirSync5, realpathSync as realpathSync2, statSync as statSync3, unlinkSync as unlinkSync4, writeSync } from "node:fs";
|
|
5764
5764
|
import { homedir as homedir10 } from "node:os";
|
|
5765
5765
|
import { basename as basename4, dirname as dirname4, isAbsolute as isAbsolute2, join as join8, relative as relative3, resolve as resolve2, sep as sep2 } from "node:path";
|
|
5766
5766
|
function backupDatabaseReadRequest(sqliteDriver, io, dbPath, logicalSessionId) {
|
|
@@ -6241,7 +6241,7 @@ async function createBackup(config) {
|
|
|
6241
6241
|
copyFileSync(dbFile.absolutePath, tempFilePath);
|
|
6242
6242
|
}
|
|
6243
6243
|
if (process.platform !== "win32")
|
|
6244
|
-
|
|
6244
|
+
chmodSync3(tempFilePath, 384);
|
|
6245
6245
|
if (dbFile.type === "global-db" || dbFile.type === "workspace-db") {
|
|
6246
6246
|
const databaseInventory = inspectComposerDatabase(tempFilePath, readOptions);
|
|
6247
6247
|
sessionCount += databaseInventory.sessionCount;
|
|
@@ -7725,7 +7725,7 @@ var init_content_evidence = __esm({
|
|
|
7725
7725
|
});
|
|
7726
7726
|
|
|
7727
7727
|
// ../../node_modules/.pnpm/cursor-history@0.18.0_patch_hash=dbff0ea0e399ea9504168452170a23ee2b432a6dc6a69a20b49bf95ef139fa74/node_modules/cursor-history/dist/core/store-stack/store-db.js
|
|
7728
|
-
import { chmodSync as
|
|
7728
|
+
import { chmodSync as chmodSync4, statSync as statSync4 } from "node:fs";
|
|
7729
7729
|
function databaseRequest(operation, required, forcedDriver, options, resourceClass = "store-database") {
|
|
7730
7730
|
return {
|
|
7731
7731
|
operation,
|
|
@@ -7781,7 +7781,7 @@ async function parseStoreDb(path16, options = {}) {
|
|
|
7781
7781
|
snapshotComplete = true;
|
|
7782
7782
|
throwIfAborted4(options.signal);
|
|
7783
7783
|
if (process.platform !== "win32")
|
|
7784
|
-
|
|
7784
|
+
chmodSync4(tmpPath, 384);
|
|
7785
7785
|
throwIfAborted4(options.signal);
|
|
7786
7786
|
db = await openDatabase(tmpPath, databaseRequest("read-session", STORE_READ_CAPABILITIES, options.sqliteDriver, options, "sqlite-snapshot"));
|
|
7787
7787
|
throwIfAborted4(options.signal);
|
|
@@ -18919,7 +18919,7 @@ function apiEquivalentCost(modelKey, t, atMs) {
|
|
|
18919
18919
|
}
|
|
18920
18920
|
|
|
18921
18921
|
// src/version.ts
|
|
18922
|
-
var CLI_VERSION = true ? "0.20.
|
|
18922
|
+
var CLI_VERSION = true ? "0.20.3" : "0.0.0-dev";
|
|
18923
18923
|
|
|
18924
18924
|
// src/api.ts
|
|
18925
18925
|
var BASE_URL = process.env.AISTACK_URL || "https://aistack.to";
|
|
@@ -19195,7 +19195,13 @@ function classify(files) {
|
|
|
19195
19195
|
|
|
19196
19196
|
// src/config.ts
|
|
19197
19197
|
import { randomBytes } from "node:crypto";
|
|
19198
|
-
import {
|
|
19198
|
+
import {
|
|
19199
|
+
chmodSync,
|
|
19200
|
+
existsSync,
|
|
19201
|
+
mkdirSync,
|
|
19202
|
+
readFileSync,
|
|
19203
|
+
writeFileSync
|
|
19204
|
+
} from "node:fs";
|
|
19199
19205
|
import { homedir } from "node:os";
|
|
19200
19206
|
import { dirname as dirname2, join } from "node:path";
|
|
19201
19207
|
var CONFIG_DIR = join(homedir(), ".config", "aistack");
|
|
@@ -19229,8 +19235,9 @@ function readCredentials(file) {
|
|
|
19229
19235
|
}
|
|
19230
19236
|
}
|
|
19231
19237
|
function writeCredentials(file, data) {
|
|
19232
|
-
mkdirSync(dirname2(file), { recursive: true });
|
|
19233
|
-
writeFileSync(file, JSON.stringify(data, null, 2));
|
|
19238
|
+
mkdirSync(dirname2(file), { recursive: true, mode: 448 });
|
|
19239
|
+
writeFileSync(file, JSON.stringify(data, null, 2), { mode: 384 });
|
|
19240
|
+
if (process.platform !== "win32") chmodSync(file, 384);
|
|
19234
19241
|
}
|
|
19235
19242
|
function getToken(serverUrl = BASE_URL, file = CREDENTIALS_FILE) {
|
|
19236
19243
|
const { data, legacy } = readCredentials(file);
|
|
@@ -22736,7 +22743,12 @@ function buildPayload(input) {
|
|
|
22736
22743
|
[...agg.projectDirs].map((directory) => projectWorkspaceId(directory))
|
|
22737
22744
|
)
|
|
22738
22745
|
].sort();
|
|
22739
|
-
if (projectKeys.length > 1e3
|
|
22746
|
+
if (projectKeys.length > 1e3) {
|
|
22747
|
+
throw new Error(
|
|
22748
|
+
"A harness snapshot can contain at most 1,000 project workspace identifiers"
|
|
22749
|
+
);
|
|
22750
|
+
}
|
|
22751
|
+
if (projectKeys.some((key2) => !/^[A-Za-z0-9_-]{22}$/.test(key2))) {
|
|
22740
22752
|
throw new Error(
|
|
22741
22753
|
"Project workspace identifiers must be 22-character base64url strings"
|
|
22742
22754
|
);
|
|
@@ -26830,11 +26842,13 @@ function ingestContribution(agg, row) {
|
|
|
26830
26842
|
agg.distinctResponses++;
|
|
26831
26843
|
agg.sessions.add(row.sessionId);
|
|
26832
26844
|
agg.activeDays.add(new Date(row.tsMs).toISOString().slice(0, 10));
|
|
26833
|
-
agg.projectDirs.add(row.projectDir);
|
|
26834
26845
|
agg.firstTs = agg.firstTs === null ? row.tsMs : Math.min(agg.firstTs, row.tsMs);
|
|
26835
26846
|
agg.lastTs = agg.lastTs === null ? row.tsMs : Math.max(agg.lastTs, row.tsMs);
|
|
26836
26847
|
noteSessionStart(agg, row.sessionId, row.tsMs);
|
|
26837
|
-
|
|
26848
|
+
if (row.projectDir !== void 0) {
|
|
26849
|
+
agg.projectDirs.add(row.projectDir);
|
|
26850
|
+
noteProjectDay(agg, row.projectDir, row.tsMs);
|
|
26851
|
+
}
|
|
26838
26852
|
for (const { model, counts: tokenCounts } of row.models) {
|
|
26839
26853
|
const key2 = normalizeModel(model);
|
|
26840
26854
|
addModelUsage(
|
|
@@ -27024,6 +27038,23 @@ async function stableRead(file, jsonl) {
|
|
|
27024
27038
|
trace("grok evidence incomplete \xB7 retries exhausted", "error");
|
|
27025
27039
|
return { complete: false };
|
|
27026
27040
|
}
|
|
27041
|
+
function absoluteCwd(value) {
|
|
27042
|
+
const cwd = asStr(value);
|
|
27043
|
+
return cwd && path11.isAbsolute(cwd) && !cwd.includes("\0") ? cwd : void 0;
|
|
27044
|
+
}
|
|
27045
|
+
async function workspaceCwd(workspacePath, entries) {
|
|
27046
|
+
try {
|
|
27047
|
+
const cwd = absoluteCwd(decodeURIComponent(path11.basename(workspacePath)));
|
|
27048
|
+
if (cwd !== void 0) return cwd;
|
|
27049
|
+
} catch {
|
|
27050
|
+
}
|
|
27051
|
+
if (entries.some((entry) => entry.name === ".cwd" && entry.isFile())) {
|
|
27052
|
+
const raw = await readFile4(path11.join(workspacePath, ".cwd"), "utf8").catch(
|
|
27053
|
+
() => void 0
|
|
27054
|
+
);
|
|
27055
|
+
return absoluteCwd(raw);
|
|
27056
|
+
}
|
|
27057
|
+
}
|
|
27027
27058
|
async function directories(root) {
|
|
27028
27059
|
try {
|
|
27029
27060
|
const workspaces = await readdir6(root, { withFileTypes: true });
|
|
@@ -27031,14 +27062,19 @@ async function directories(root) {
|
|
|
27031
27062
|
for (const workspace of workspaces) {
|
|
27032
27063
|
if (!workspace.isDirectory() || workspace.isSymbolicLink()) continue;
|
|
27033
27064
|
const workspacePath = path11.join(root, workspace.name);
|
|
27034
|
-
|
|
27065
|
+
const entries = await readdir6(workspacePath, {
|
|
27035
27066
|
withFileTypes: true
|
|
27036
|
-
})
|
|
27067
|
+
});
|
|
27068
|
+
const cwd = await workspaceCwd(workspacePath, entries);
|
|
27069
|
+
for (const session of entries) {
|
|
27037
27070
|
if (session.isDirectory() && !session.isSymbolicLink())
|
|
27038
|
-
out.push(path11.join(workspacePath, session.name));
|
|
27071
|
+
out.push({ dir: path11.join(workspacePath, session.name), cwd });
|
|
27039
27072
|
}
|
|
27040
27073
|
}
|
|
27041
|
-
return out.sort()
|
|
27074
|
+
return out.sort((a, b) => {
|
|
27075
|
+
if (a.dir === b.dir) return 0;
|
|
27076
|
+
return a.dir < b.dir ? -1 : 1;
|
|
27077
|
+
});
|
|
27042
27078
|
} catch (error) {
|
|
27043
27079
|
if (error.code !== "ENOENT")
|
|
27044
27080
|
traceError("grok session discovery", error);
|
|
@@ -27087,7 +27123,7 @@ async function scanWindows2(windows, opts = {}) {
|
|
|
27087
27123
|
complete = false;
|
|
27088
27124
|
continue;
|
|
27089
27125
|
}
|
|
27090
|
-
for (const dir of dirs) {
|
|
27126
|
+
for (const { dir, cwd } of dirs) {
|
|
27091
27127
|
let entries;
|
|
27092
27128
|
try {
|
|
27093
27129
|
entries = await readdir6(dir, { withFileTypes: true });
|
|
@@ -27101,7 +27137,7 @@ async function scanWindows2(windows, opts = {}) {
|
|
|
27101
27137
|
(e) => e.isFile() && (isGrokEvidenceFile(e.name) || e.name === "summary.json")
|
|
27102
27138
|
).map((e) => [e.name, path11.join(dir, e.name)])
|
|
27103
27139
|
);
|
|
27104
|
-
let projectDir =
|
|
27140
|
+
let projectDir = cwd;
|
|
27105
27141
|
let sessionFallback = path11.basename(dir);
|
|
27106
27142
|
let child = false;
|
|
27107
27143
|
let parentSession;
|
|
@@ -27115,7 +27151,7 @@ async function scanWindows2(windows, opts = {}) {
|
|
|
27115
27151
|
}
|
|
27116
27152
|
const value = asObj(read3.json);
|
|
27117
27153
|
const info = value && asObj(value.info);
|
|
27118
|
-
projectDir =
|
|
27154
|
+
projectDir = absoluteCwd(info?.cwd) ?? absoluteCwd(value?.cwd) ?? cwd;
|
|
27119
27155
|
sessionFallback = asStr(value?.sessionId) ?? sessionFallback;
|
|
27120
27156
|
parentSession = asStr(value?.parentSessionId) ?? asStr(value?.parent_session_id) ?? asStr(info?.parentSessionId) ?? asStr(info?.parent_session_id) ?? void 0;
|
|
27121
27157
|
child = parentSession !== void 0;
|