@use-aistack/cli 0.23.1 → 0.23.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/README.md +8 -0
- package/dist/cursor-worker.js +48 -0
- package/dist/cursor-worker.js.map +1 -1
- package/dist/index.js +119 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20356,7 +20356,7 @@ var KNOWN_ROW_IDS = /* @__PURE__ */ new Set([
|
|
|
20356
20356
|
]);
|
|
20357
20357
|
|
|
20358
20358
|
// src/version.ts
|
|
20359
|
-
var CLI_VERSION = true ? "0.23.
|
|
20359
|
+
var CLI_VERSION = true ? "0.23.2" : "0.0.0-dev";
|
|
20360
20360
|
|
|
20361
20361
|
// src/api.ts
|
|
20362
20362
|
var BASE_URL = process.env.AISTACK_URL || "https://aistack.to";
|
|
@@ -26238,6 +26238,66 @@ function reconcile(local, api) {
|
|
|
26238
26238
|
return [...local.filter((c) => !grains.has(grain(c))), ...reported];
|
|
26239
26239
|
}
|
|
26240
26240
|
|
|
26241
|
+
// src/harness/cursor/keychain.ts
|
|
26242
|
+
import { execFile } from "node:child_process";
|
|
26243
|
+
import { createDecipheriv, pbkdf2Sync } from "node:crypto";
|
|
26244
|
+
var ENCRYPTED_PREFIX = "cursor-safe-storage:v1:";
|
|
26245
|
+
var KEYCHAIN_SERVICE = "Cursor Safe Storage";
|
|
26246
|
+
var runSecurity = (args) => new Promise((resolve3) => {
|
|
26247
|
+
execFile(
|
|
26248
|
+
"/usr/bin/security",
|
|
26249
|
+
args,
|
|
26250
|
+
{ timeout: 12e4, encoding: "utf8" },
|
|
26251
|
+
(error, stdout) => {
|
|
26252
|
+
const code2 = error?.code;
|
|
26253
|
+
resolve3({
|
|
26254
|
+
code: error ? typeof code2 === "number" ? code2 : -1 : 0,
|
|
26255
|
+
stdout: error ? "" : stdout
|
|
26256
|
+
});
|
|
26257
|
+
}
|
|
26258
|
+
);
|
|
26259
|
+
});
|
|
26260
|
+
function macKeychainReader(platform5 = process.platform, run = runSecurity) {
|
|
26261
|
+
let held;
|
|
26262
|
+
return () => {
|
|
26263
|
+
held ??= (async () => {
|
|
26264
|
+
if (platform5 !== "darwin") return { failure: "unsupported" };
|
|
26265
|
+
const { code: code2, stdout } = await run([
|
|
26266
|
+
"find-generic-password",
|
|
26267
|
+
"-w",
|
|
26268
|
+
"-s",
|
|
26269
|
+
KEYCHAIN_SERVICE
|
|
26270
|
+
]);
|
|
26271
|
+
if (code2 === 44) return { failure: "missing" };
|
|
26272
|
+
const password = stdout.replace(/\r?\n$/, "");
|
|
26273
|
+
if (code2 !== 0 || !password) return { failure: "denied" };
|
|
26274
|
+
return { password };
|
|
26275
|
+
})();
|
|
26276
|
+
return held;
|
|
26277
|
+
};
|
|
26278
|
+
}
|
|
26279
|
+
var cursorKeychain = macKeychainReader();
|
|
26280
|
+
var KEY_TAG = "v10";
|
|
26281
|
+
var SALT = "saltysalt";
|
|
26282
|
+
var MAC_ITERATIONS = 1003;
|
|
26283
|
+
var IV = Buffer.alloc(16, " ");
|
|
26284
|
+
function decryptCursorToken(stored, password, iterations = MAC_ITERATIONS) {
|
|
26285
|
+
if (!stored.startsWith(ENCRYPTED_PREFIX)) return null;
|
|
26286
|
+
const sealed = Buffer.from(stored.slice(ENCRYPTED_PREFIX.length), "base64");
|
|
26287
|
+
if (sealed.subarray(0, 3).toString("latin1") !== KEY_TAG) return null;
|
|
26288
|
+
const body = sealed.subarray(3);
|
|
26289
|
+
if (body.length === 0 || body.length % 16 !== 0) return null;
|
|
26290
|
+
try {
|
|
26291
|
+
const key2 = pbkdf2Sync(password, SALT, iterations, 16, "sha1");
|
|
26292
|
+
const decipher = createDecipheriv("aes-128-cbc", key2, IV);
|
|
26293
|
+
return Buffer.concat([decipher.update(body), decipher.final()]).toString(
|
|
26294
|
+
"utf8"
|
|
26295
|
+
);
|
|
26296
|
+
} catch {
|
|
26297
|
+
return null;
|
|
26298
|
+
}
|
|
26299
|
+
}
|
|
26300
|
+
|
|
26241
26301
|
// src/harness/cursor/local.ts
|
|
26242
26302
|
import { existsSync as existsSync10 } from "node:fs";
|
|
26243
26303
|
import { stat as stat7 } from "node:fs/promises";
|
|
@@ -27019,9 +27079,8 @@ function isPageByteLimit(error) {
|
|
|
27019
27079
|
}
|
|
27020
27080
|
|
|
27021
27081
|
// src/harness/cursor/account.ts
|
|
27022
|
-
var ENCRYPTED_PREFIX = "cursor-safe-storage:";
|
|
27023
27082
|
var digest = (value) => createHash7("sha256").update(value).digest("hex");
|
|
27024
|
-
async function
|
|
27083
|
+
async function storedToken(root) {
|
|
27025
27084
|
let value;
|
|
27026
27085
|
let db;
|
|
27027
27086
|
try {
|
|
@@ -27034,11 +27093,47 @@ async function existingAccount(root) {
|
|
|
27034
27093
|
} finally {
|
|
27035
27094
|
db?.close();
|
|
27036
27095
|
}
|
|
27037
|
-
|
|
27038
|
-
|
|
27096
|
+
return typeof value === "string" ? value.trim().replace(/^"|"$/g, "") : null;
|
|
27097
|
+
}
|
|
27098
|
+
var KEYCHAIN_NOTICE = [
|
|
27099
|
+
"Cursor keeps your sign-in encrypted in the macOS Keychain.",
|
|
27100
|
+
'To read your exact Cursor usage, aistack asks macOS for the "Cursor Safe Storage" key.',
|
|
27101
|
+
"Choose Always Allow so the prompt does not come back on every sync.",
|
|
27102
|
+
"If you deny it, Cursor tokens are estimated from message text.",
|
|
27103
|
+
"The key and your sign-in stay in memory and go only to cursor.com."
|
|
27104
|
+
].join("\n");
|
|
27105
|
+
async function keychainNotice(roots, platform5 = process.platform) {
|
|
27106
|
+
if (platform5 !== "darwin") return null;
|
|
27107
|
+
for (const root of roots)
|
|
27108
|
+
if ((await storedToken(root))?.startsWith(ENCRYPTED_PREFIX))
|
|
27109
|
+
return KEYCHAIN_NOTICE;
|
|
27110
|
+
return null;
|
|
27111
|
+
}
|
|
27112
|
+
async function existingAccount(root, options = {}) {
|
|
27113
|
+
const stored = await storedToken(root);
|
|
27114
|
+
if (stored === null) return null;
|
|
27115
|
+
let token = stored;
|
|
27039
27116
|
if (token.startsWith(ENCRYPTED_PREFIX)) {
|
|
27040
27117
|
trace("cursor account \xB7 sign-in is encrypted at rest", "warn");
|
|
27041
|
-
|
|
27118
|
+
const read3 = options.keychain ? await options.keychain() : void 0;
|
|
27119
|
+
if (!read3 || "failure" in read3 && read3.failure === "unsupported")
|
|
27120
|
+
return { problem: "encrypted" };
|
|
27121
|
+
if ("failure" in read3) {
|
|
27122
|
+
trace(`cursor account \xB7 keychain ${read3.failure}`, "warn");
|
|
27123
|
+
return {
|
|
27124
|
+
problem: read3.failure === "missing" ? "keychain-missing" : "keychain-denied"
|
|
27125
|
+
};
|
|
27126
|
+
}
|
|
27127
|
+
const opened = decryptCursorToken(token, read3.password);
|
|
27128
|
+
if (opened === null) {
|
|
27129
|
+
trace(
|
|
27130
|
+
"cursor account \xB7 keychain password did not open the sign-in",
|
|
27131
|
+
"warn"
|
|
27132
|
+
);
|
|
27133
|
+
return { problem: "undecryptable" };
|
|
27134
|
+
}
|
|
27135
|
+
trace("cursor account \xB7 opened the encrypted sign-in");
|
|
27136
|
+
token = opened.trim();
|
|
27042
27137
|
}
|
|
27043
27138
|
try {
|
|
27044
27139
|
const claims = asObj(
|
|
@@ -27569,6 +27664,9 @@ function projectHistory(options) {
|
|
|
27569
27664
|
var accountRefreshes = /* @__PURE__ */ new Map();
|
|
27570
27665
|
var ACCOUNT_PROBLEMS = {
|
|
27571
27666
|
encrypted: "Cursor keeps its sign-in encrypted in the system keychain",
|
|
27667
|
+
"keychain-denied": "Keychain access to Cursor Safe Storage was denied",
|
|
27668
|
+
"keychain-missing": "the Cursor Safe Storage item is missing from the Keychain",
|
|
27669
|
+
undecryptable: "the encrypted Cursor sign-in could not be decrypted",
|
|
27572
27670
|
unreadable: "the stored Cursor sign-in could not be read"
|
|
27573
27671
|
};
|
|
27574
27672
|
async function readFolder(root, options, now, onProgress) {
|
|
@@ -27587,7 +27685,10 @@ async function readFolder(root, options, now, onProgress) {
|
|
|
27587
27685
|
);
|
|
27588
27686
|
complete = false;
|
|
27589
27687
|
}
|
|
27590
|
-
const lookup = ids.size ? await (options.accountImpl ?? existingAccount)(
|
|
27688
|
+
const lookup = ids.size ? await (options.accountImpl ?? existingAccount)(
|
|
27689
|
+
root,
|
|
27690
|
+
options.keychain ? { keychain: options.keychainImpl ?? cursorKeychain } : {}
|
|
27691
|
+
) : null;
|
|
27591
27692
|
const account = lookup && "scope" in lookup ? lookup : null;
|
|
27592
27693
|
const refreshKey = JSON.stringify([root, storeRoot(), file]);
|
|
27593
27694
|
let refreshState = accountRefreshes.get(refreshKey);
|
|
@@ -31282,7 +31383,7 @@ function selectDaysToPublish(input) {
|
|
|
31282
31383
|
}
|
|
31283
31384
|
|
|
31284
31385
|
// src/workflow/git.ts
|
|
31285
|
-
import { execFile, execFileSync as execFileSync2 } from "node:child_process";
|
|
31386
|
+
import { execFile as execFile2, execFileSync as execFileSync2 } from "node:child_process";
|
|
31286
31387
|
import { existsSync as existsSync19 } from "node:fs";
|
|
31287
31388
|
import path19 from "node:path";
|
|
31288
31389
|
var TEST_FILE_RULE_VERSION = "test-files/v2";
|
|
@@ -31334,7 +31435,7 @@ var defaultRunner = (cwd, args, report) => {
|
|
|
31334
31435
|
}
|
|
31335
31436
|
};
|
|
31336
31437
|
var defaultAsyncRunner = (cwd, args, report) => new Promise((resolve3) => {
|
|
31337
|
-
|
|
31438
|
+
execFile2(
|
|
31338
31439
|
"git",
|
|
31339
31440
|
[...args],
|
|
31340
31441
|
{
|
|
@@ -32363,6 +32464,7 @@ async function stageSync(deps) {
|
|
|
32363
32464
|
const loadConfig = deps.loadConfigImpl ?? loadSyncConfig;
|
|
32364
32465
|
const adapters = deps.adaptersImpl ?? (() => HARNESS_ADAPTERS);
|
|
32365
32466
|
const windowDays = deps.windowDays ?? DEFAULT_WINDOW_DAYS;
|
|
32467
|
+
const keychain = deps.keychain === true ? { keychain: true } : {};
|
|
32366
32468
|
const resolveProjectWorkspaceId = deps.getProjectWorkspaceIdImpl ?? getProjectWorkspaceId;
|
|
32367
32469
|
const workspaceIds = /* @__PURE__ */ new Map();
|
|
32368
32470
|
const projectWorkspaceId = (directory) => {
|
|
@@ -32533,10 +32635,11 @@ async function stageSync(deps) {
|
|
|
32533
32635
|
`scan ${adapter.name} (recent and historical)`
|
|
32534
32636
|
);
|
|
32535
32637
|
[reading.recent, reading.history] = await adapter.scanWindows([
|
|
32536
|
-
{ sinceMs, publishWorkflow: false },
|
|
32638
|
+
{ sinceMs, publishWorkflow: false, ...keychain },
|
|
32537
32639
|
{
|
|
32538
32640
|
sinceMs: daysSinceMs,
|
|
32539
32641
|
publishWorkflow: config.publishWorkflow,
|
|
32642
|
+
...keychain,
|
|
32540
32643
|
onProgress: progress("recent usage and history")
|
|
32541
32644
|
}
|
|
32542
32645
|
]);
|
|
@@ -32551,6 +32654,7 @@ async function stageSync(deps) {
|
|
|
32551
32654
|
reading.recent = await adapter.scan({
|
|
32552
32655
|
sinceMs,
|
|
32553
32656
|
publishWorkflow: false,
|
|
32657
|
+
...keychain,
|
|
32554
32658
|
onProgress: progress("recent usage")
|
|
32555
32659
|
});
|
|
32556
32660
|
scanDone2(
|
|
@@ -32563,6 +32667,7 @@ async function stageSync(deps) {
|
|
|
32563
32667
|
reading.history = await adapter.scan({
|
|
32564
32668
|
sinceMs: daysSinceMs,
|
|
32565
32669
|
publishWorkflow: config.publishWorkflow,
|
|
32670
|
+
...keychain,
|
|
32566
32671
|
onProgress: progress("history")
|
|
32567
32672
|
});
|
|
32568
32673
|
scanDone(
|
|
@@ -33233,6 +33338,8 @@ async function syncCommand(options = {}) {
|
|
|
33233
33338
|
}
|
|
33234
33339
|
const destinationToken = token;
|
|
33235
33340
|
const destinationConfig = loaded;
|
|
33341
|
+
const notice = await discoverCursorRoots().then(({ homes }) => keychainNotice(homes)).catch(() => null);
|
|
33342
|
+
if (notice) p7.log.info(notice);
|
|
33236
33343
|
p7.log.step("Scanning local history");
|
|
33237
33344
|
const board = createBoard({
|
|
33238
33345
|
write: (text) => process.stdout.write(text),
|
|
@@ -33244,7 +33351,8 @@ async function syncCommand(options = {}) {
|
|
|
33244
33351
|
baseUrl: BASE_URL,
|
|
33245
33352
|
getTokenImpl: () => destinationToken,
|
|
33246
33353
|
loadConfigImpl: async () => destinationConfig,
|
|
33247
|
-
onEvent: board.handle
|
|
33354
|
+
onEvent: board.handle,
|
|
33355
|
+
keychain: true
|
|
33248
33356
|
});
|
|
33249
33357
|
} catch (e) {
|
|
33250
33358
|
traceError("sync scan", e);
|