xclaude-cli 0.2.0 → 0.2.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 +2 -0
- package/dist/xclaude.js +102 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,9 +67,11 @@ xclaude's options (`--dir`, `--detach`, `--empty`) come right after the label, a
|
|
|
67
67
|
|
|
68
68
|
- **Shared by all accounts:** conversations and their checkpoints (`projects`, `file-history`), prompt history, task lists, plans, running-session info, personal skills, agents, commands, rules, output styles, hooks and plugins, and `~/.claude/CLAUDE.md`.
|
|
69
69
|
- **Per account:** the login, `.claude.json` (MCP servers, folder trust), `settings.json` (so plugins and the statusline can differ per account), keybindings, background sessions and caches. The MCP servers you added to `~/.claude.json` with `claude mcp add --scope user` still reach every account that takes `~/.claude`'s setup: each launch passes them with `--mcp-config`, and an account's own server of the same name wins (`xclaude <name> mcp list` shows only its own).
|
|
70
|
+
- **Logins:** each account signs in with its own login. A claude.ai login in your shell (`CLAUDE_CODE_OAUTH_TOKEN` from `claude setup-token`, and the variables that provision one) is left out of accounts: Claude Code would use it in place of every account's login, so one subscription ending would stop them all. `main` and plain `claude` still get it, and a token meant for one account can go in that account's `settings.json` `env`. `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, a cloud provider (`CLAUDE_CODE_USE_BEDROCK`, `_VERTEX`, `_FOUNDRY`) and `ANTHROPIC_PROFILE` come before an account's login too; they're passed on, each account's launch says so once, and `xclaude ls` names the credential in use in place of the email.
|
|
70
71
|
- **Asked once:** an account's first launch in a terminal (or `xclaude add`) shows what `~/.claude` would give it (settings, the plugins `~/.claude` has on, MCP servers) and asks whether it takes them. The answer is kept; `xclaude set <name> --inherit on|off` changes it. A launch without a terminal takes nothing until then and says once how to choose.
|
|
71
72
|
- **Taken from `~/.claude/settings.json`:** once the answer is yes, at every launch the account's `settings.json` takes what changed in `~/.claude/settings.json` since the last time: permission rules, hooks, auto mode and the rest, apart from login-bound settings (`env`, `apiKeyHelper` and the other credential helpers, `forceLoginMethod`, `forceLoginOrgUUID`) and `enabledPlugins`. What the account changed itself stays, so a rule it added or removed stays that way, and one you remove from `~/.claude/settings.json` goes from the accounts too. `~/.claude/settings.json` itself is never written. `xclaude set <name> --inherit off` stops it and takes back what the account took and hasn't changed; `--inherit reset` takes everything again.
|
|
72
73
|
- **Plugins:** a plugin installed under another login shows in an account's `/plugin` from its next launch: on when `~/.claude` has it on (in an account that takes `~/.claude`'s setup), off otherwise. Until you change such an entry, it follows `~/.claude` turning the plugin on or off; once you do, it's yours. Uninstalling a plugin removes it for every login. For the `~/.claude` login, turn on a plugin an account installed with `claude plugin enable <plugin>`.
|
|
74
|
+
- **Memory:** an account saves Claude's auto memory into `~/.claude/projects/<project>/memory/`, the folder plain `claude` uses, without asking, in auto mode as in any other. xclaude points Claude Code there with `CLAUDE_CODE_REMOTE_MEMORY_DIR`: from Claude Code 2.1.280 on, a save through the account's link would wait for your yes every time. Plan mode in an account still asks before it saves a plan file, and subagents with `memory: local` keep that memory in `~/.claude/projects/<project>/agent-memory-local/` instead of the project's `.claude/agent-memory-local/`.
|
|
73
75
|
|
|
74
76
|
Sharing works by linking each account's directories into `~/.claude`, which plain `claude` keeps using as before. Don't open the same conversation in two terminals at once. Scripts can read `XCLAUDE_ACCOUNT` to show the account, for example in a statusline.
|
|
75
77
|
|
package/dist/xclaude.js
CHANGED
|
@@ -310,7 +310,8 @@ var SWITCHES = {
|
|
|
310
310
|
spawnFallback: false,
|
|
311
311
|
linkIde: false,
|
|
312
312
|
normalizePaths: false,
|
|
313
|
-
keepSameEmailLogin: false
|
|
313
|
+
keepSameEmailLogin: false,
|
|
314
|
+
memoryInStore: true
|
|
314
315
|
};
|
|
315
316
|
function loadSwitches(env) {
|
|
316
317
|
const switches = { ...SWITCHES };
|
|
@@ -362,16 +363,29 @@ async function authStatus(claude, env) {
|
|
|
362
363
|
email: str(json.email),
|
|
363
364
|
orgId: str(json.orgId),
|
|
364
365
|
orgName: str(json.orgName),
|
|
366
|
+
method: str(json.authMethod),
|
|
365
367
|
error: null
|
|
366
368
|
};
|
|
367
369
|
} catch {
|
|
368
370
|
const why = (res.stderr || res.stdout).trim().split("\n")[0] || `exit code ${res.code}`;
|
|
369
|
-
return { loggedIn: false, email: null, orgId: null, orgName: null, error: why };
|
|
371
|
+
return { loggedIn: false, email: null, orgId: null, orgName: null, method: null, error: why };
|
|
370
372
|
}
|
|
371
373
|
}
|
|
374
|
+
var NOT_A_LOGIN = {
|
|
375
|
+
oauth_token: "a token",
|
|
376
|
+
api_key: "an API key",
|
|
377
|
+
api_key_helper: "apiKeyHelper",
|
|
378
|
+
third_party: "a cloud provider"
|
|
379
|
+
};
|
|
380
|
+
function otherCredential(s) {
|
|
381
|
+
if (s.error || !s.loggedIn || s.method === null) return null;
|
|
382
|
+
return NOT_A_LOGIN[s.method] ?? null;
|
|
383
|
+
}
|
|
372
384
|
function describeLogin(s) {
|
|
373
385
|
if (s.error) return `unknown (${s.error})`;
|
|
374
386
|
if (!s.loggedIn) return "not logged in";
|
|
387
|
+
const other = otherCredential(s);
|
|
388
|
+
if (other) return s.email ? `${other} (${s.email})` : other;
|
|
375
389
|
const who = s.email ?? "logged in";
|
|
376
390
|
return s.orgName ? `${who} (${s.orgName})` : who;
|
|
377
391
|
}
|
|
@@ -699,17 +713,66 @@ function stringOption(p, name) {
|
|
|
699
713
|
}
|
|
700
714
|
|
|
701
715
|
// src/launch/env.ts
|
|
716
|
+
function sharedMemoryDir(paths, table, switches) {
|
|
717
|
+
if (!switches.memoryInStore) return null;
|
|
718
|
+
return table.dirs.includes("projects") && table.dirs.includes("agent-memory") ? paths.store : null;
|
|
719
|
+
}
|
|
720
|
+
var LOGIN_VARS = [
|
|
721
|
+
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
722
|
+
"CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR",
|
|
723
|
+
"CLAUDE_CODE_OAUTH_REFRESH_TOKEN",
|
|
724
|
+
"CLAUDE_CODE_OAUTH_SCOPES"
|
|
725
|
+
];
|
|
726
|
+
var CREDENTIAL_VARS = [
|
|
727
|
+
"ANTHROPIC_API_KEY",
|
|
728
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
729
|
+
"CLAUDE_CODE_USE_BEDROCK",
|
|
730
|
+
"CLAUDE_CODE_USE_VERTEX",
|
|
731
|
+
"CLAUDE_CODE_USE_FOUNDRY",
|
|
732
|
+
"ANTHROPIC_PROFILE"
|
|
733
|
+
];
|
|
734
|
+
function setIn(env, names) {
|
|
735
|
+
return names.filter((name) => {
|
|
736
|
+
const value = env[name];
|
|
737
|
+
return value !== void 0 && value !== "" && !/^(0|false|no|off)$/i.test(value);
|
|
738
|
+
});
|
|
739
|
+
}
|
|
702
740
|
function buildEnv(base, identity) {
|
|
703
741
|
const env = {};
|
|
704
742
|
for (const [k, v] of Object.entries(base)) if (v !== void 0) env[k] = v;
|
|
705
|
-
if (identity.configDir)
|
|
706
|
-
|
|
743
|
+
if (identity.configDir) {
|
|
744
|
+
env.CLAUDE_CONFIG_DIR = identity.configDir;
|
|
745
|
+
for (const name of LOGIN_VARS) delete env[name];
|
|
746
|
+
if (identity.memoryDir && !env.CLAUDE_CODE_REMOTE_MEMORY_DIR) env.CLAUDE_CODE_REMOTE_MEMORY_DIR = identity.memoryDir;
|
|
747
|
+
} else {
|
|
748
|
+
delete env.CLAUDE_CONFIG_DIR;
|
|
749
|
+
if (identity.memoryDir && env.CLAUDE_CODE_REMOTE_MEMORY_DIR === identity.memoryDir) delete env.CLAUDE_CODE_REMOTE_MEMORY_DIR;
|
|
750
|
+
}
|
|
707
751
|
delete env.CLAUDE_SECURESTORAGE_CONFIG_DIR;
|
|
708
752
|
env.XCLAUDE_ACCOUNT = identity.name;
|
|
709
753
|
return env;
|
|
710
754
|
}
|
|
711
755
|
function identityEnv(ctx, name) {
|
|
712
|
-
return buildEnv(ctx.env, { name, configDir: name === MAIN ? null : accountDir(ctx.paths, name) });
|
|
756
|
+
return buildEnv(ctx.env, { name, configDir: name === MAIN ? null : accountDir(ctx.paths, name), memoryDir: null });
|
|
757
|
+
}
|
|
758
|
+
function joined(names) {
|
|
759
|
+
return names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names.join("");
|
|
760
|
+
}
|
|
761
|
+
function takeCredentialNotes(state, account, env) {
|
|
762
|
+
const told = new Set(state.credentialNoted[account] ?? []);
|
|
763
|
+
const dropped = setIn(env, LOGIN_VARS).filter((name) => !told.has(name));
|
|
764
|
+
const others = setIn(env, CREDENTIAL_VARS).filter((name) => !told.has(name));
|
|
765
|
+
const lines = [];
|
|
766
|
+
if (dropped.length) {
|
|
767
|
+
const [is, it] = dropped.length === 1 ? ["is", "it"] : ["are", "them"];
|
|
768
|
+
lines.push(`xclaude: ${account} signs in with its own login, so ${joined(dropped)} from your shell ${is} left out (plain claude still gets ${it})`);
|
|
769
|
+
}
|
|
770
|
+
if (others.length) {
|
|
771
|
+
const [is, it] = others.length === 1 ? ["is", "it"] : ["are", "them"];
|
|
772
|
+
lines.push(`xclaude: ${joined(others)} ${is} set in your shell, so Claude Code may use ${it} instead of ${account}'s own login (/status shows which)`);
|
|
773
|
+
}
|
|
774
|
+
if (lines.length) state.credentialNoted[account] = [...told, ...dropped, ...others].sort();
|
|
775
|
+
return lines;
|
|
713
776
|
}
|
|
714
777
|
|
|
715
778
|
// src/core/state.ts
|
|
@@ -722,7 +785,8 @@ function emptyState() {
|
|
|
722
785
|
seenUnknownEntries: {},
|
|
723
786
|
listedPlugins: {},
|
|
724
787
|
turnedOnPlugins: {},
|
|
725
|
-
inheritNoted: []
|
|
788
|
+
inheritNoted: [],
|
|
789
|
+
credentialNoted: {}
|
|
726
790
|
};
|
|
727
791
|
}
|
|
728
792
|
function isRecord(v) {
|
|
@@ -749,7 +813,7 @@ function loadState(paths) {
|
|
|
749
813
|
if (Array.isArray(entries)) state.seenUnknownEntries[name] = entries.filter((e) => typeof e === "string");
|
|
750
814
|
}
|
|
751
815
|
}
|
|
752
|
-
for (const key of ["listedPlugins", "turnedOnPlugins"]) {
|
|
816
|
+
for (const key of ["listedPlugins", "turnedOnPlugins", "credentialNoted"]) {
|
|
753
817
|
const lists = raw[key];
|
|
754
818
|
if (!isRecord(lists)) continue;
|
|
755
819
|
for (const [name, ids] of Object.entries(lists)) {
|
|
@@ -786,6 +850,7 @@ function forgetAccount(state, account) {
|
|
|
786
850
|
delete state.listedPlugins[account];
|
|
787
851
|
delete state.turnedOnPlugins[account];
|
|
788
852
|
state.inheritNoted = state.inheritNoted.filter((name) => name !== account);
|
|
853
|
+
delete state.credentialNoted[account];
|
|
789
854
|
}
|
|
790
855
|
|
|
791
856
|
// src/link/inherit.ts
|
|
@@ -2632,12 +2697,14 @@ async function addCommand(ctx, config, args) {
|
|
|
2632
2697
|
log(`xclaude: ${name} isn't logged in yet. Log in later with \`xclaude ${name} auth login\`, or /login inside \`xclaude ${name}\`.`);
|
|
2633
2698
|
return EXIT_OK;
|
|
2634
2699
|
}
|
|
2635
|
-
|
|
2700
|
+
const credential = otherCredential(status);
|
|
2701
|
+
if (credential) log(`xclaude: ${name} signs in with ${credential}, not a claude.ai login. Launch it with: xclaude ${name}`);
|
|
2702
|
+
else log(`xclaude: ${name} is logged in as ${describeLogin(status)}. Launch it with: xclaude ${name}`);
|
|
2636
2703
|
const others = identities(config).filter((n) => n !== name);
|
|
2637
2704
|
const theirs = await Promise.all(others.map((n) => authStatus(claude, identityEnv(ctx, n))));
|
|
2638
2705
|
others.forEach((other, i) => {
|
|
2639
2706
|
const s = theirs[i];
|
|
2640
|
-
if (s.loggedIn && s.email === status.email && s.orgId === status.orgId) {
|
|
2707
|
+
if (status.email && s.loggedIn && s.email === status.email && s.orgId === status.orgId) {
|
|
2641
2708
|
log(`xclaude: warning: ${name} and ${other} use the same login (${describeLogin(status)})`);
|
|
2642
2709
|
}
|
|
2643
2710
|
});
|
|
@@ -2909,6 +2976,7 @@ var STRIPPED_ENV = [
|
|
|
2909
2976
|
"XCLAUDE_ACCOUNT",
|
|
2910
2977
|
"CLAUDE_CODE_CHILD_SESSION",
|
|
2911
2978
|
"CLAUDE_SECURESTORAGE_CONFIG_DIR",
|
|
2979
|
+
"CLAUDE_CODE_REMOTE_MEMORY_DIR",
|
|
2912
2980
|
"CLAUDECODE",
|
|
2913
2981
|
"CLAUDE_CODE_SESSION_ID",
|
|
2914
2982
|
"CLAUDE_CODE_SESSION_ATTENDED",
|
|
@@ -3256,6 +3324,19 @@ ${s.orgId}`) ?? [], n]);
|
|
|
3256
3324
|
report.add("warn", `CLAUDE_CODE_EFFORT_LEVEL is set (${ctx.env.CLAUDE_CODE_EFFORT_LEVEL}); it overrides the effort level saved in every account's settings`);
|
|
3257
3325
|
envFindings++;
|
|
3258
3326
|
}
|
|
3327
|
+
const dropped = setIn(ctx.env, LOGIN_VARS);
|
|
3328
|
+
if (dropped.length) {
|
|
3329
|
+
const [is, it] = dropped.length === 1 ? ["is", "it"] : ["are", "them"];
|
|
3330
|
+
report.add("info", `${dropped.join(", ")} ${is} set: accounts don't get ${it}, so each signs in with its own login (plain claude still uses ${it})`);
|
|
3331
|
+
}
|
|
3332
|
+
const memory = ctx.env.CLAUDE_CODE_REMOTE_MEMORY_DIR;
|
|
3333
|
+
if (memory && memory !== ctx.paths.store) {
|
|
3334
|
+
report.add("info", `CLAUDE_CODE_REMOTE_MEMORY_DIR is set (${memory}): accounts keep it, so their memory goes there, as plain claude's does`);
|
|
3335
|
+
}
|
|
3336
|
+
for (const name of setIn(ctx.env, CREDENTIAL_VARS)) {
|
|
3337
|
+
report.add("warn", `${name} is set, so Claude Code may use it instead of each account's own login; unset it in your shell profile to stop that`);
|
|
3338
|
+
envFindings++;
|
|
3339
|
+
}
|
|
3259
3340
|
if (!envFindings) report.add("ok", "nothing that overrides accounts");
|
|
3260
3341
|
report.lines.push("");
|
|
3261
3342
|
const summary = report.errors || report.warnings ? `${report.errors} problem${report.errors === 1 ? "" : "s"}, ${report.warnings} warning${report.warnings === 1 ? "" : "s"}${report.errors && !p.values.fix ? ". Run `xclaude doctor --fix` to repair what can be repaired." : "."}` : "All good.";
|
|
@@ -3384,7 +3465,7 @@ function refreshInitFiles(paths, config, version) {
|
|
|
3384
3465
|
}
|
|
3385
3466
|
|
|
3386
3467
|
// package.json
|
|
3387
|
-
var package_default = { version: "0.2.
|
|
3468
|
+
var package_default = { version: "0.2.2" };
|
|
3388
3469
|
|
|
3389
3470
|
// src/version.ts
|
|
3390
3471
|
var VERSION = package_default.version;
|
|
@@ -3446,6 +3527,10 @@ has on and the MCP servers in ~/.claude.json. Its first launch in a terminal
|
|
|
3446
3527
|
asks; set <name> --inherit on|off changes the answer. A plugin installed under
|
|
3447
3528
|
another login shows in /plugin: on when the account takes ~/.claude's setup
|
|
3448
3529
|
and ~/.claude has it on, otherwise off.
|
|
3530
|
+
|
|
3531
|
+
Each account signs in with its own login: a CLAUDE_CODE_OAUTH_TOKEN in your
|
|
3532
|
+
shell is left out of accounts, and a launch says once when ANTHROPIC_API_KEY or
|
|
3533
|
+
another credential there may stand in for the account's login.
|
|
3449
3534
|
`;
|
|
3450
3535
|
var COMMAND_HELP = {
|
|
3451
3536
|
add: `Usage: xclaude add <name> [--model M] [--effort E] [--args "\u2026"]
|
|
@@ -3487,7 +3572,9 @@ confirmation.
|
|
|
3487
3572
|
|
|
3488
3573
|
Lists the accounts with their email, organization and login status, their
|
|
3489
3574
|
defaults, and each one's config dir (the CLAUDE_CONFIG_DIR to use elsewhere,
|
|
3490
|
-
e.g. in an editor's environment settings).
|
|
3575
|
+
e.g. in an editor's environment settings). When Claude Code signs an account
|
|
3576
|
+
in with something else, such as an ANTHROPIC_API_KEY in your shell, LOGIN
|
|
3577
|
+
names it.
|
|
3491
3578
|
`,
|
|
3492
3579
|
set: `Usage: xclaude set <name> [--model M] [--effort E] [--args "\u2026"]
|
|
3493
3580
|
[--unset model|effort|args] [--inherit on|off|reset]
|
|
@@ -4660,12 +4747,15 @@ async function launch(ctx, config, account, userArgs) {
|
|
|
4660
4747
|
const help = needsHelp(defaults, userArgs) ? loadHelp(claude, ctx.paths.cache, ctx.env) : null;
|
|
4661
4748
|
const mcp = isMain ? null : mcpForLaunch(ctx, settled, account, defaults, userArgs, help);
|
|
4662
4749
|
const args = [...mcp ? [`--mcp-config=${mcp}`] : [], ...buildArgs(defaults, userArgs, help)];
|
|
4663
|
-
const
|
|
4750
|
+
const memoryDir = sharedMemoryDir(ctx.paths, shareTable(settled, ctx.switches), ctx.switches);
|
|
4751
|
+
const env = buildEnv(ctx.env, { name: account, configDir: isMain ? null : accountDir(ctx.paths, account), memoryDir });
|
|
4664
4752
|
try {
|
|
4665
4753
|
updateState(ctx.paths, (state) => {
|
|
4666
4754
|
recordUse(state, ctx.cwd, account);
|
|
4667
4755
|
const configLabel = tildify(ctx.paths.config, ctx.paths.home);
|
|
4668
4756
|
for (const entry of takeNewUnknown(state, account, unknown)) ctx.io.err(`${unknownNotice(account, entry, configLabel)}
|
|
4757
|
+
`);
|
|
4758
|
+
if (!isMain) for (const line of takeCredentialNotes(state, account, ctx.env)) ctx.io.err(`${line}
|
|
4669
4759
|
`);
|
|
4670
4760
|
});
|
|
4671
4761
|
} catch {
|