@use-aistack/cli 0.22.0 → 0.22.1

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
@@ -29,9 +29,9 @@ After a manual sync, the CLI offers auto-sync with three choices: Enable, Maybe
29
29
 
30
30
  #### Multiple Claude Code accounts
31
31
 
32
- Sync combines the local histories of your Claude Code profiles into one Claude Code reading. It discovers `~/.claude*` folders, `claude*` folders under `XDG_CONFIG_HOME` (default `~/.config`), nested `profiles/` and `accounts/` folders, and Claude Swap session profiles under `~/.claude-swap-backup` or `$XDG_DATA_HOME/claude-swap` (default `~/.local/share/claude-swap`). A profile contributes only its `projects/` transcripts. Discovery does not open credentials, and the published aggregates do not include account names.
32
+ Sync combines the local histories of your Claude Code profiles into one Claude Code reading. It discovers `~/.claude*` folders, `claude*` folders under `XDG_CONFIG_HOME` (default `~/.config`), nested `profiles/` and `accounts/` folders, Claude Swap session profiles under `~/.claude-swap-backup` or `$XDG_DATA_HOME/claude-swap` (default `~/.local/share/claude-swap`), cc-switch accounts under `~/.cc-switch/claude-accounts/*/config`, and CCS accounts. CCS keeps each account in `instances/<name>` and shared transcripts in `shared/context-groups/<group>` inside its own folder: `$CCS_DIR`, else `$CCS_HOME/.ccs`, else `~/.ccs`. A profile contributes only its `projects/` transcripts. Discovery does not open credentials, and the published aggregates do not include account names.
33
33
 
34
- `CLAUDE_CONFIG_DIR` can add custom locations as a comma-separated list. The default and discovered profiles still count when this variable is set, so running sync from an account-specific shell keeps the other accounts included. Linked transcript roots and copied records with the same Claude record UUID are counted once. A profile discovery error marks the reading as partial so previously published evidence is retained.
34
+ `CLAUDE_CONFIG_DIR` can add custom locations as a comma-separated list. The default and discovered profiles still count when this variable is set, so running sync from an account-specific shell keeps the other accounts included. A folder from `CLAUDE_CONFIG_DIR`, `CCS_DIR` or `CCS_HOME` that the names above do not reach, such as a shell alias that sets `CLAUDE_CONFIG_DIR=~/work/claude`, is remembered in `~/.config/aistack/harness-homes.json` the first time a sync sees it. Later syncs and auto-sync hooks from any shell read it too. The file stays on this machine. Linked transcript roots and copied records with the same Claude record UUID are counted once. A profile discovery error marks the reading as partial so previously published evidence is retained.
35
35
 
36
36
  #### Multiple accounts in other harnesses
37
37
 
@@ -107,7 +107,7 @@ npx @use-aistack/cli@latest sync --auto off # revoke
107
107
  npx @use-aistack/cli@latest sync --auto status # each folder's hook
108
108
  ```
109
109
 
110
- **Every account gets its own hook.** If you run several accounts of one harness, each account keeps its own folder, and `on` writes the hook into every one of them. A session in any account then triggers the sync. The folders are the same ones a sync reads: every Claude Code profile (`~/.claude*`, `CLAUDE_CONFIG_DIR`, and profiles folders), every Codex home (`~/.codex*` and `CODEX_HOME`), and every Grok Build home (`~/.grok*` and `GROK_HOME`). The interactive sync adds the hook to an account folder that appears later. `off` removes the hook from every folder this machine wrote it into, including a folder that only an environment variable in another shell names. The CLI records those folders in `~/.config/aistack/settings.json`, which stays on this machine.
110
+ **Every account gets its own hook.** If you run several accounts of one harness, each account keeps its own folder, and `on` writes the hook into every one of them. A session in any account then triggers the sync. The folders are the same ones a sync reads: every Claude Code profile (`~/.claude*`, `CLAUDE_CONFIG_DIR`, remembered folders, profiles folders, and CCS and cc-switch accounts), every Codex home (`~/.codex*` and `CODEX_HOME`), and every Grok Build home (`~/.grok*` and `GROK_HOME`). The interactive sync adds the hook to an account folder that appears later. `off` removes the hook from every folder this machine wrote it into, including a folder that only an environment variable in another shell names. The CLI records those folders in `~/.config/aistack/settings.json`, which stays on this machine.
111
111
 
112
112
  The hook text is identical in every folder and across CLI versions. Codex pins each hook by its file and its exact text, so **every newly hooked Codex home needs a one-time approval**: open Codex with that account and run `/hooks`. The CLI names each home that still needs it when it writes the hook, and the interactive sync repeats the reminder until Codex trusts it.
113
113
 
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.22.0" : "0.0.0-dev";
20359
+ var CLI_VERSION = true ? "0.22.1" : "0.0.0-dev";
20360
20360
 
20361
20361
  // src/api.ts
20362
20362
  var BASE_URL = process.env.AISTACK_URL || "https://aistack.to";
@@ -24989,6 +24989,8 @@ function ingestTypedSkill(agg, rec, text) {
24989
24989
  import { readdir as readdir4, realpath as realpath3, stat as stat4 } from "node:fs/promises";
24990
24990
  import { homedir as homedir8 } from "node:os";
24991
24991
  import path4 from "node:path";
24992
+ var CLAUDE_HOMES_KEY = "claude";
24993
+ var CCS_HOMES_KEY = "ccs";
24992
24994
  async function discoverClaudeRoots() {
24993
24995
  const home = homedir8();
24994
24996
  const configHome = process.env.XDG_CONFIG_HOME || path4.join(home, ".config");
@@ -25010,41 +25012,76 @@ async function discoverClaudeRoots() {
25010
25012
  return [];
25011
25013
  }
25012
25014
  };
25013
- const configured = (process.env.CLAUDE_CONFIG_DIR ?? "").split(",").map((s) => s.trim()).filter(Boolean).map(
25014
- (dir) => path4.resolve(dir.startsWith("~/") ? path4.join(home, dir.slice(2)) : dir)
25015
- );
25016
- const profiles = /* @__PURE__ */ new Set([
25015
+ const ccsHome = process.env.CCS_HOME?.trim();
25016
+ const ccs = await discoverHomes({
25017
+ defaults: [path4.join(home, ".ccs")],
25018
+ configured: [process.env.CCS_DIR, ccsHome && path4.join(ccsHome, ".ccs")],
25019
+ remember: CCS_HOMES_KEY
25020
+ });
25021
+ if (!ccs.complete) complete = false;
25022
+ const contextGroups = /* @__PURE__ */ new Set();
25023
+ const managed = [];
25024
+ for (const dir of ccs.homes) {
25025
+ managed.push(...await children(path4.join(dir, "instances")));
25026
+ for (const group of await children(
25027
+ path4.join(dir, "shared", "context-groups")
25028
+ )) {
25029
+ contextGroups.add(group);
25030
+ managed.push(group);
25031
+ }
25032
+ }
25033
+ for (const account of await children(
25034
+ path4.join(home, ".cc-switch", "claude-accounts")
25035
+ ))
25036
+ managed.push(path4.join(account, "config"));
25037
+ for (const manager of [
25038
+ path4.join(home, ".claude-swap-backup"),
25039
+ path4.join(dataHome, "claude-swap")
25040
+ ]) {
25041
+ for (const collection of [manager, path4.join(manager, "sessions")])
25042
+ managed.push(...await children(collection));
25043
+ }
25044
+ const named = [
25017
25045
  path4.join(home, ".claude"),
25018
25046
  path4.join(configHome, "claude"),
25019
- ...configured,
25020
25047
  ...await children(home, ".claude"),
25021
- ...await children(configHome, "claude")
25022
- ]);
25048
+ ...await children(configHome, "claude"),
25049
+ ...managed
25050
+ ];
25051
+ const found = await discoverHomes({
25052
+ defaults: named,
25053
+ configured: (process.env.CLAUDE_CONFIG_DIR ?? "").split(","),
25054
+ remember: CLAUDE_HOMES_KEY
25055
+ });
25056
+ if (!found.complete) complete = false;
25057
+ const groups = /* @__PURE__ */ new Set();
25058
+ for (const group of contextGroups) {
25059
+ try {
25060
+ groups.add(await realpath3(group));
25061
+ } catch (error) {
25062
+ failed(error);
25063
+ }
25064
+ }
25065
+ const profiles = new Set(found.homes);
25023
25066
  for (const profile of [...profiles]) {
25024
25067
  for (const collection of ["profiles", "accounts"]) {
25025
25068
  for (const child of await children(path4.join(profile, collection)))
25026
25069
  profiles.add(child);
25027
25070
  }
25028
25071
  }
25029
- for (const manager of [
25030
- path4.join(home, ".claude-swap-backup"),
25031
- path4.join(dataHome, "claude-swap")
25032
- ]) {
25033
- for (const collection of [manager, path4.join(manager, "sessions")]) {
25034
- for (const child of await children(collection)) profiles.add(child);
25035
- }
25036
- }
25037
25072
  const roots = /* @__PURE__ */ new Set();
25073
+ const accounts = /* @__PURE__ */ new Set();
25038
25074
  for (const profile of profiles) {
25039
- const projects = path4.join(profile, "projects");
25040
25075
  try {
25041
- if ((await stat4(projects)).isDirectory())
25042
- roots.add(await realpath3(projects));
25076
+ const projects = await realpath3(path4.join(profile, "projects"));
25077
+ if (!(await stat4(projects)).isDirectory()) continue;
25078
+ roots.add(projects);
25079
+ if (!groups.has(profile)) accounts.add(await realpath3(profile));
25043
25080
  } catch (error) {
25044
25081
  failed(error);
25045
25082
  }
25046
25083
  }
25047
- return { roots: [...roots], complete };
25084
+ return { roots: [...roots], profiles: [...accounts], complete };
25048
25085
  }
25049
25086
 
25050
25087
  // src/harness/claude/scan.ts
@@ -29857,7 +29894,7 @@ import * as p7 from "@clack/prompts";
29857
29894
  // src/autosync/optin.ts
29858
29895
  import { existsSync as existsSync18 } from "node:fs";
29859
29896
  import { homedir as homedir27 } from "node:os";
29860
- import { dirname as dirname13, join as join20 } from "node:path";
29897
+ import { dirname as dirname12, join as join20 } from "node:path";
29861
29898
  import * as p6 from "@clack/prompts";
29862
29899
 
29863
29900
  // src/autosync/antigravityHook.ts
@@ -30369,7 +30406,7 @@ function grokAutoSyncHookInstalled(file = GROK_HOOK_FILE) {
30369
30406
  // src/autosync/homes.ts
30370
30407
  import { realpathSync as realpathSync4 } from "node:fs";
30371
30408
  import { homedir as homedir26 } from "node:os";
30372
- import { basename as basename5, dirname as dirname12, join as join19, relative as relative4, sep as sep3 } from "node:path";
30409
+ import { basename as basename5, join as join19, relative as relative4, sep as sep3 } from "node:path";
30373
30410
  var HOOK_HARNESSES = [
30374
30411
  "claude",
30375
30412
  "codex",
@@ -30400,8 +30437,8 @@ async function discoverHookHomes() {
30400
30437
  discoverGrokHomes()
30401
30438
  ]);
30402
30439
  return {
30403
- // A Claude Code profile is the folder that holds its `projects` folder.
30404
- claude: withDefault(join19(home, ".claude"), claude.roots.map(dirname12)),
30440
+ // Every Claude Code profile, remembered and CCS folders included.
30441
+ claude: withDefault(join19(home, ".claude"), claude.profiles),
30405
30442
  codex: withDefault(
30406
30443
  process.env.CODEX_HOME || join19(home, ".codex"),
30407
30444
  codex.homes
@@ -30733,7 +30770,7 @@ async function autoSyncStatus(deps = {}) {
30733
30770
  ]);
30734
30771
  }
30735
30772
  }
30736
- const cursorHome = dirname13(CURSOR_HOOK_FILE);
30773
+ const cursorHome = dirname12(CURSOR_HOOK_FILE);
30737
30774
  const cursorInstalled = (deps.cursorHookInstalledImpl ?? cursorAutoSyncHookInstalled)();
30738
30775
  if (cursorInstalled || existsSync18(cursorHome)) {
30739
30776
  rows.push([
@@ -30742,7 +30779,7 @@ async function autoSyncStatus(deps = {}) {
30742
30779
  cursorInstalled ? "hook installed" : "no hook"
30743
30780
  ]);
30744
30781
  }
30745
- const antigravityConfig = dirname13(antigravityHookFile());
30782
+ const antigravityConfig = dirname12(antigravityHookFile());
30746
30783
  const antigravityInstalled = (deps.antigravityHookInstalledImpl ?? antigravityAutoSyncHookInstalled)();
30747
30784
  if (antigravityInstalled || existsSync18(antigravityConfig)) {
30748
30785
  rows.push([
@@ -30832,7 +30869,7 @@ import {
30832
30869
  writeFileSync as writeFileSync11
30833
30870
  } from "node:fs";
30834
30871
  import { homedir as homedir29 } from "node:os";
30835
- import { dirname as dirname15, join as join21 } from "node:path";
30872
+ import { dirname as dirname14, join as join21 } from "node:path";
30836
30873
 
30837
30874
  // src/sync/stage.ts
30838
30875
  import { createHash as createHash11 } from "node:crypto";
@@ -32452,7 +32489,7 @@ import {
32452
32489
  statSync as statSync7,
32453
32490
  writeFileSync as writeFileSync10
32454
32491
  } from "node:fs";
32455
- import { dirname as dirname14 } from "node:path";
32492
+ import { dirname as dirname13 } from "node:path";
32456
32493
  var MUTEX_WAIT_MS = 2e3;
32457
32494
  var MUTEX_STALE_MS = 3e4;
32458
32495
  var code = (error) => error?.code;
@@ -32491,7 +32528,7 @@ function isHeld(file, now, windowMs) {
32491
32528
  return Date.now() - statSync7(file).mtimeMs < windowMs;
32492
32529
  }
32493
32530
  function reserveAttempt(file, now, windowMs) {
32494
- mkdirSync10(dirname14(file), { recursive: true });
32531
+ mkdirSync10(dirname13(file), { recursive: true });
32495
32532
  const mutex = `${file}.lock`;
32496
32533
  if (!acquire(mutex)) return false;
32497
32534
  try {
@@ -32511,7 +32548,7 @@ var SYNC_LOG_MAX_LINES = 200;
32511
32548
  var FIX_COMMAND = "npx @use-aistack/cli@latest sync";
32512
32549
  var REVOKED_RESULT = "off - auto-sync is switched off for this stack";
32513
32550
  function appendLogLine(file, line) {
32514
- mkdirSync11(dirname15(file), { recursive: true });
32551
+ mkdirSync11(dirname14(file), { recursive: true });
32515
32552
  appendFileSync(file, `${line}
32516
32553
  `);
32517
32554
  const lines2 = readFileSync21(file, "utf-8").split("\n").filter(Boolean);