@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 CHANGED
@@ -73,6 +73,14 @@ The list is stored in `~/.config/aistack/harness-homes.json`. A folder found thr
73
73
 
74
74
  Each folder keeps its own account lookup and cache. A chat that appears in two folders, for example after you copied a folder, counts once, from the copy with the most messages. A folder that can't be read marks the Cursor reading as partial, so previously published evidence is retained. Folder paths stay on this machine.
75
75
 
76
+ #### Cursor token counts and the macOS Keychain
77
+
78
+ Cursor's exact token counts come from your Cursor account's usage list on cursor.com. Sync signs in to it with the access token Cursor keeps in its `state.vscdb`, so you never sign in a second time. When that lookup fails, sync estimates tokens from message length and the gate says why, for example `account Cursor usage not read: the usage request failed (HTTP 401)`. Sync also marks the reading partial, so days already published with exact counts keep them.
79
+
80
+ Recent Cursor builds can store that token encrypted with a key from the system keychain. On macOS this is common. An interactive `npx @use-aistack/cli@latest sync` on a Mac then reads the key: it prints why first, and macOS asks whether `security` may use the "Cursor Safe Storage" item, and may ask for your login password. Choose Always Allow so the prompt does not come back on every sync. Sync decrypts the token the way Electron's safeStorage stores it (Chromium OSCrypt `v10`: AES-128-CBC with a key derived from the keychain password), keeps the key and the token in memory only, never on disk or in logs, and sends the token to cursor.com only.
81
+
82
+ Auto-sync and every other non-interactive run never ask the keychain. On a Mac with an encrypted Cursor sign-in, those runs mark the Cursor reading partial, so the exact days an interactive sync published stay as they are. If you deny the prompt or the item is missing, sync falls back to the estimate and names the reason in the gate. On Linux and Windows, sync does not read the keychain: an encrypted Cursor sign-in is named in the gate and the reading is marked partial.
83
+
76
84
  #### Several accounts of one harness
77
85
 
78
86
  When a harness keeps more than one account folder on this machine (two Claude Code profiles, a second Codex home, a second Cursor data folder), sync also records how each day's usage splits across those accounts: sessions, tokens by type, and tokens per model for each account. Each account is a random ID created on this machine and kept in `~/.config/aistack/accounts.json`. Folder paths, account names and emails stay on this machine. The split is stored for the stack owner, and no page shows it. A harness with one account sends no split. Antigravity keeps every signed-in account in one shared folder, so it always counts as one account.
@@ -19326,7 +19326,55 @@ import { gunzipSync, gzipSync } from "node:zlib";
19326
19326
 
19327
19327
  // src/harness/cursor/account.ts
19328
19328
  import { createHash } from "node:crypto";
19329
+
19330
+ // src/harness/cursor/keychain.ts
19331
+ import { execFile } from "node:child_process";
19332
+ var KEYCHAIN_SERVICE = "Cursor Safe Storage";
19333
+ var runSecurity = (args) => new Promise((resolve3) => {
19334
+ execFile(
19335
+ "/usr/bin/security",
19336
+ args,
19337
+ { timeout: 12e4, encoding: "utf8" },
19338
+ (error, stdout) => {
19339
+ const code = error?.code;
19340
+ resolve3({
19341
+ code: error ? typeof code === "number" ? code : -1 : 0,
19342
+ stdout: error ? "" : stdout
19343
+ });
19344
+ }
19345
+ );
19346
+ });
19347
+ function macKeychainReader(platform = process.platform, run = runSecurity) {
19348
+ let held;
19349
+ return () => {
19350
+ held ??= (async () => {
19351
+ if (platform !== "darwin") return { failure: "unsupported" };
19352
+ const { code, stdout } = await run([
19353
+ "find-generic-password",
19354
+ "-w",
19355
+ "-s",
19356
+ KEYCHAIN_SERVICE
19357
+ ]);
19358
+ if (code === 44) return { failure: "missing" };
19359
+ const password = stdout.replace(/\r?\n$/, "");
19360
+ if (code !== 0 || !password) return { failure: "denied" };
19361
+ return { password };
19362
+ })();
19363
+ return held;
19364
+ };
19365
+ }
19366
+ var cursorKeychain = macKeychainReader();
19367
+ var IV = Buffer.alloc(16, " ");
19368
+
19369
+ // src/harness/cursor/account.ts
19329
19370
  var digest = (value) => createHash("sha256").update(value).digest("hex");
19371
+ var KEYCHAIN_NOTICE = [
19372
+ "Cursor keeps your sign-in encrypted in the macOS Keychain.",
19373
+ 'To read your exact Cursor usage, aistack asks macOS for the "Cursor Safe Storage" key.',
19374
+ "Choose Always Allow so the prompt does not come back on every sync.",
19375
+ "If you deny it, Cursor tokens are estimated from message text.",
19376
+ "The key and your sign-in stay in memory and go only to cursor.com."
19377
+ ].join("\n");
19330
19378
 
19331
19379
  // src/harness/cursor/sessionCache.ts
19332
19380
  var SESSION_CACHE_FORMAT = 1;