claude-use 14.3.1 → 14.4.0

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.mjs CHANGED
@@ -2642,6 +2642,7 @@ function planFarm(params) {
2642
2642
  const entries = [];
2643
2643
  const materialised = [];
2644
2644
  const links = [];
2645
+ const dangling = [];
2645
2646
  const conditionalPatterns = [...params.flattened.rules.values()].filter((rule) => rule.when !== void 0).map((rule) => rule.canonicalPattern);
2646
2647
  const conditionalRuleCouldReach = (dir) => conditionalPatterns.some((pattern) => patternCouldReachUnder(pattern, dir));
2647
2648
  const subtreeDecision = (rel) => {
@@ -2674,7 +2675,10 @@ function planFarm(params) {
2674
2675
  return;
2675
2676
  }
2676
2677
  if (!fact.isDirectory) {
2677
- if (decision?.shared === true) {
2678
+ if (decision?.shared === true && fact.isDanglingSymlink) {
2679
+ entries.push({ kind: "omit", rel });
2680
+ dangling.push(rel);
2681
+ } else if (decision?.shared === true) {
2678
2682
  entries.push({ kind: "link", rel, target: linkTarget(rel) });
2679
2683
  links.push({ rel, target: linkTarget(rel) });
2680
2684
  } else {
@@ -2709,7 +2713,7 @@ function planFarm(params) {
2709
2713
  for (const rel of children.get("") ?? []) {
2710
2714
  visit(rel);
2711
2715
  }
2712
- return { entries, materialised, links };
2716
+ return { entries, materialised, links, dangling };
2713
2717
  }
2714
2718
  var init_plan = __esm({
2715
2719
  "src/resolve/plan.ts"() {
@@ -2951,6 +2955,14 @@ function topLevelNames(facts) {
2951
2955
  function descendPolicyFor(cascade, home) {
2952
2956
  return descendPolicy(flattenLayers(assembleCascade(cascade).layers, { home }).rules.values());
2953
2957
  }
2958
+ function danglingDiagnostic(rel) {
2959
+ return {
2960
+ code: "SHARED_ENTRY_DANGLING",
2961
+ severity: "warning",
2962
+ message: `"${rel}" is shared, but ~/.claude/${rel} is a symlink that leads nowhere, so the farm does not link it and this identity keeps its own copy. Once the symlink leads somewhere, the next launch, or \`agent-shim identity resync <identity>\` in this directory, links the entry.`,
2963
+ subject: rel
2964
+ };
2965
+ }
2954
2966
  function resolveDecisions(input) {
2955
2967
  const assembled = assembleCascade(input.cascade);
2956
2968
  const flattened = flattenLayers(assembled.layers, { home: input.facts.home });
@@ -2970,7 +2982,7 @@ function resolveDecisions(input) {
2970
2982
  classification,
2971
2983
  decisions: resolved.decisions,
2972
2984
  farm,
2973
- diagnostics: [...assembled.diagnostics, ...resolved.diagnostics]
2985
+ diagnostics: [...assembled.diagnostics, ...resolved.diagnostics, ...farm.dangling.map(danglingDiagnostic)]
2974
2986
  };
2975
2987
  }
2976
2988
  var init_pipeline = __esm({
@@ -3419,6 +3431,34 @@ function readFarmManifest(fs17, farmRoot) {
3419
3431
  const result = FarmManifestSchema.safeParse(parsed);
3420
3432
  return result.success ? result.data : void 0;
3421
3433
  }
3434
+ function danglingFarmLinks(fs17, farmRoot) {
3435
+ const manifest = readFarmManifest(fs17, farmRoot);
3436
+ const recorded = new Map((manifest?.links ?? []).map((link) => [link.rel, link.target]));
3437
+ const materialised = new Set(manifest?.materialised ?? []);
3438
+ const candidates = new Set(recorded.keys());
3439
+ const walk2 = (rel) => {
3440
+ const stat = fs17.lstat(path10.join(farmRoot, rel));
3441
+ if (stat?.kind === "symlink") {
3442
+ candidates.add(rel);
3443
+ } else if (stat?.kind === "dir" && materialised.has(rel)) {
3444
+ for (const name of fs17.readdir(path10.join(farmRoot, rel))) {
3445
+ walk2(`${rel}/${name}`);
3446
+ }
3447
+ }
3448
+ };
3449
+ for (const name of fs17.readdir(farmRoot)) {
3450
+ if (name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME) {
3451
+ walk2(name);
3452
+ }
3453
+ }
3454
+ return [...candidates].sort().filter((rel) => {
3455
+ const absolute = path10.join(farmRoot, rel);
3456
+ return fs17.lstat(absolute)?.kind === "symlink" && !fs17.resolves(absolute);
3457
+ }).map((rel) => {
3458
+ const target = recorded.get(rel);
3459
+ return target === void 0 ? { rel } : { rel, target };
3460
+ });
3461
+ }
3422
3462
  function buildEntryFacts(params) {
3423
3463
  const entries = /* @__PURE__ */ new Map();
3424
3464
  const visit = (rel) => {
@@ -3443,6 +3483,7 @@ function buildEntryFacts(params) {
3443
3483
  relPath: rel,
3444
3484
  isDirectory,
3445
3485
  isSymlink: stat.kind === "symlink",
3486
+ isDanglingSymlink: stat.kind === "symlink" && !params.fs.resolves(absolute),
3446
3487
  mtimeMs: stat.mtimeMs,
3447
3488
  latestMtimeMs,
3448
3489
  sizeBytes: stat.sizeBytes,
@@ -3805,6 +3846,7 @@ function resyncFarm(params) {
3805
3846
  farmRoot,
3806
3847
  noOp: true,
3807
3848
  manifest: previousManifest,
3849
+ previousManifest,
3808
3850
  resolved,
3809
3851
  adopted: outcome.adopted,
3810
3852
  recovery,
@@ -3827,6 +3869,7 @@ function resyncFarm(params) {
3827
3869
  farmRoot,
3828
3870
  noOp: false,
3829
3871
  manifest,
3872
+ ...previousManifest === void 0 ? {} : { previousManifest },
3830
3873
  resolved,
3831
3874
  adopted: outcome.adopted,
3832
3875
  recovery,
@@ -11046,15 +11089,15 @@ function pathDirectories(target, ports) {
11046
11089
  }
11047
11090
  return directories;
11048
11091
  }
11049
- function headroomDirectoryRefusal(directory, stat, uid, remedy) {
11092
+ function headroomDirectoryRefusal(directory, stat, uid, remedy2) {
11050
11093
  if (stat?.kind !== "dir") {
11051
11094
  return `the directory ${directory} on the allowlist file's path is ${stat === void 0 ? "missing" : "not a directory"}, so headroom refuses the file`;
11052
11095
  }
11053
11096
  if (stat.uid !== uid && stat.uid !== ROOT_UID) {
11054
- return `the directory ${directory} on the allowlist file's path is owned by uid ${String(stat.uid)}, not by this user (uid ${String(uid)}) or root, so headroom refuses the file${remedy ? `; ${MOVE_ROOT_REMEDY}` : ""}`;
11097
+ return `the directory ${directory} on the allowlist file's path is owned by uid ${String(stat.uid)}, not by this user (uid ${String(uid)}) or root, so headroom refuses the file${remedy2 ? `; ${MOVE_ROOT_REMEDY}` : ""}`;
11055
11098
  }
11056
11099
  if ((stat.mode & GROUP_OR_OTHER_WRITE_BITS) !== 0) {
11057
- return `the directory ${directory} on the allowlist file's path is writable by group or others (mode ${stat.mode.toString(OCTAL_RADIX2).padStart(MODE_DIGITS, "0")}), so headroom refuses the file${remedy ? `; ${stat.uid === uid && (stat.mode & STICKY_BIT) === 0 ? `run \`chmod go-w ${directory}\`` : MOVE_ROOT_REMEDY}` : ""}`;
11100
+ return `the directory ${directory} on the allowlist file's path is writable by group or others (mode ${stat.mode.toString(OCTAL_RADIX2).padStart(MODE_DIGITS, "0")}), so headroom refuses the file${remedy2 ? `; ${stat.uid === uid && (stat.mode & STICKY_BIT) === 0 ? `run \`chmod go-w ${directory}\`` : MOVE_ROOT_REMEDY}` : ""}`;
11058
11101
  }
11059
11102
  return void 0;
11060
11103
  }
@@ -11962,6 +12005,9 @@ var init_realPorts = __esm({
11962
12005
  const kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "dir" : "file";
11963
12006
  return { kind, mtimeMs: stat.mtimeMs, sizeBytes: stat.size };
11964
12007
  },
12008
+ resolves(filePath) {
12009
+ return fs6.statSync(filePath, { throwIfNoEntry: false }) !== void 0;
12010
+ },
11965
12011
  readdir(dirPath) {
11966
12012
  try {
11967
12013
  return fs6.readdirSync(dirPath);
@@ -14023,8 +14069,8 @@ var init_identityStore = __esm({
14023
14069
  init_identityRecords();
14024
14070
  init_launchRecords();
14025
14071
  IdentityNotFoundError = class extends CliError {
14026
- constructor(name, remedy = `Run \`agent-shim identity add ${name}\` first.`) {
14027
- super(`No identity named "${name}". ${remedy}`);
14072
+ constructor(name, remedy2 = `Run \`agent-shim identity add ${name}\` first.`) {
14073
+ super(`No identity named "${name}". ${remedy2}`);
14028
14074
  this.name = name;
14029
14075
  this.name = "IdentityNotFoundError";
14030
14076
  }
@@ -14082,7 +14128,7 @@ var init_package = __esm({
14082
14128
  "package.json"() {
14083
14129
  package_default = {
14084
14130
  name: "claude-use",
14085
- version: "14.3.1",
14131
+ version: "14.4.0",
14086
14132
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
14087
14133
  license: "MIT",
14088
14134
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -20401,7 +20447,9 @@ var DIAGNOSTIC_CODES = [
20401
20447
  /** A previous launch was interrupted mid-swap and this launch completed or undid the half-finished work. */
20402
20448
  "FARM_SWAP_RECOVERED",
20403
20449
  /** A superseded farm could not be discarded because it still held data the new farm has its own entry for, so it was left on disk for the user to look at. */
20404
- "FARM_PREVIOUS_RETAINED"
20450
+ "FARM_PREVIOUS_RETAINED",
20451
+ /** A shared `~/.claude` entry is a symlink that reaches nothing, so the farm does not link it and the identity keeps its own copy until the entry leads somewhere. */
20452
+ "SHARED_ENTRY_DANGLING"
20405
20453
  ];
20406
20454
  var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
20407
20455
 
@@ -21269,6 +21317,31 @@ function pushKeychainFindings(push, platform, run, identities, agentOf) {
21269
21317
  }
21270
21318
  }
21271
21319
 
21320
+ // src/doctorFarmLinks.ts
21321
+ function remedy(agent, name, rel) {
21322
+ if (agent === "codex") {
21323
+ return `Codex cannot write through it. A launch with \`agent-shim run --agent codex @${name}\` resyncs the farm and leaves the link out.`;
21324
+ }
21325
+ const lost = rel === "sessions" ? " (an interactive session's record under sessions/ is lost, so the session is missing from `claude agents`)" : "";
21326
+ return `Claude Code cannot write through it${lost}. A launch through agent-shim resyncs the farm and leaves the link out, but a session started with this directory as CLAUDE_CONFIG_DIR does not. Run \`agent-shim identity resync ${name}\` in the directory those sessions start in to bring the farm up to date without launching.`;
21327
+ }
21328
+ function pushFarmLinkFindings(push, farms, agentOf) {
21329
+ let found = false;
21330
+ for (const farm of farms) {
21331
+ for (const link of farm.dangling) {
21332
+ found = true;
21333
+ const points = link.target === void 0 ? "" : ` to ${link.target}`;
21334
+ push("farm-links", "warn", `identities/${farm.id}/${link.rel} is a farm link${points} that leads nowhere, so ${remedy(agentOf.get(farm.name) ?? "claude", farm.name, link.rel)}`, farm.name);
21335
+ }
21336
+ }
21337
+ if (!found) {
21338
+ push("farm-links", "pass", "Every identity's farm links lead somewhere.");
21339
+ }
21340
+ }
21341
+
21342
+ // src/doctorReport.ts
21343
+ init_farm();
21344
+
21272
21345
  // src/frontdoor/catalogueFailures.ts
21273
21346
  init_state();
21274
21347
  init_catalogueState();
@@ -21678,6 +21751,7 @@ var DOCTOR_SECTIONS = [
21678
21751
  "config-profile",
21679
21752
  "identity",
21680
21753
  "sign-in",
21754
+ "farm-links",
21681
21755
  "pool",
21682
21756
  "provider",
21683
21757
  "keychain",
@@ -22076,6 +22150,9 @@ function runDoctor(params) {
22076
22150
  push("provider", finding.level, finding.message, finding.alias);
22077
22151
  }
22078
22152
  pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
22153
+ if (params.farmLinks !== void 0) {
22154
+ pushFarmLinkFindings(push, params.farmLinks, validIdentityAgents);
22155
+ }
22079
22156
  if (params.directoryRules.raw === void 0) {
22080
22157
  push("directory-rules", "pass", "No directory-rules.json configured.");
22081
22158
  } else {
@@ -22225,73 +22302,6 @@ function runDoctor(params) {
22225
22302
  }
22226
22303
  return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
22227
22304
  }
22228
- var SECTION_TITLES = {
22229
- models: "Virtual models",
22230
- "ambient-credential": "Ambient-credential exposure",
22231
- "binary-discovery": "Claude Code binary discovery",
22232
- "claude-shim": "`claude` command shim",
22233
- "path-resolution": "PATH resolution",
22234
- "legacy-name": "Former `claude-use` name",
22235
- "config-profile": "Configuration profiles",
22236
- identity: "Identities",
22237
- "sign-in": "Sign-in",
22238
- pool: "Pools",
22239
- provider: "Providers",
22240
- keychain: "macOS Keychain",
22241
- "directory-rules": "Directory rules",
22242
- "global-config": "Global config",
22243
- headroom: "Headroom daemon",
22244
- frontdoor: "Front door",
22245
- "categories-local": "categories.local.json",
22246
- "active-identity": "Active identity"
22247
- };
22248
- var SECTION_ORDER = [
22249
- "ambient-credential",
22250
- "binary-discovery",
22251
- "claude-shim",
22252
- "path-resolution",
22253
- "config-profile",
22254
- "identity",
22255
- "sign-in",
22256
- "pool",
22257
- "provider",
22258
- "keychain",
22259
- "directory-rules",
22260
- "global-config",
22261
- "headroom",
22262
- "frontdoor",
22263
- "categories-local",
22264
- "active-identity"
22265
- ];
22266
- function severityPrefix(severity) {
22267
- switch (severity) {
22268
- case "pass":
22269
- return "[PASS]";
22270
- case "warn":
22271
- return "[WARN]";
22272
- case "fail":
22273
- return "[FAIL]";
22274
- default:
22275
- return severity;
22276
- }
22277
- }
22278
- function formatDoctorReport(report) {
22279
- const lines = [];
22280
- for (const section of SECTION_ORDER) {
22281
- const sectionFindings = report.findings.filter((finding) => finding.section === section);
22282
- if (sectionFindings.length === 0) {
22283
- continue;
22284
- }
22285
- lines.push("", `${SECTION_TITLES[section]}:`);
22286
- for (const finding of sectionFindings) {
22287
- const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
22288
- lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
22289
- }
22290
- }
22291
- const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
22292
- lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
22293
- return lines;
22294
- }
22295
22305
  function servingDoorListeners(paths) {
22296
22306
  const state = readFrontDoorState(realFarmFs, paths.frontdoorStateFile) ?? {};
22297
22307
  const alive = state.supervisorPid !== void 0 && realIsProcessRunning(state.supervisorPid);
@@ -22364,6 +22374,7 @@ function collectDoctorReport(params) {
22364
22374
  chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
22365
22375
  installedClaudeVersions: realInstalledClaudeVersions(),
22366
22376
  identities,
22377
+ farmLinks: identities.map(({ name, id, farmRoot }) => ({ name, id, dangling: danglingFarmLinks(realFarmFs, farmRoot) })),
22367
22378
  usageSnapshots,
22368
22379
  configProfiles,
22369
22380
  providers,
@@ -26390,6 +26401,81 @@ init_names();
26390
26401
  init_providersStore();
26391
26402
  init_poolStore();
26392
26403
  init_directoryRulesStore();
26404
+
26405
+ // src/doctorFormat.ts
26406
+ var SECTION_TITLES = {
26407
+ models: "Virtual models",
26408
+ "ambient-credential": "Ambient-credential exposure",
26409
+ "binary-discovery": "Claude Code binary discovery",
26410
+ "claude-shim": "`claude` command shim",
26411
+ "path-resolution": "PATH resolution",
26412
+ "legacy-name": "Former `claude-use` name",
26413
+ "config-profile": "Configuration profiles",
26414
+ identity: "Identities",
26415
+ "sign-in": "Sign-in",
26416
+ "farm-links": "Farm links",
26417
+ pool: "Pools",
26418
+ provider: "Providers",
26419
+ keychain: "macOS Keychain",
26420
+ "directory-rules": "Directory rules",
26421
+ "global-config": "Global config",
26422
+ headroom: "Headroom daemon",
26423
+ frontdoor: "Front door",
26424
+ "categories-local": "categories.local.json",
26425
+ "active-identity": "Active identity"
26426
+ };
26427
+ var SECTION_ORDER = [
26428
+ "ambient-credential",
26429
+ "binary-discovery",
26430
+ "claude-shim",
26431
+ "path-resolution",
26432
+ "legacy-name",
26433
+ "config-profile",
26434
+ "identity",
26435
+ "sign-in",
26436
+ "farm-links",
26437
+ "pool",
26438
+ "provider",
26439
+ "keychain",
26440
+ "directory-rules",
26441
+ "global-config",
26442
+ "models",
26443
+ "headroom",
26444
+ "frontdoor",
26445
+ "categories-local",
26446
+ "active-identity"
26447
+ ];
26448
+ function severityPrefix(severity) {
26449
+ switch (severity) {
26450
+ case "pass":
26451
+ return "[PASS]";
26452
+ case "warn":
26453
+ return "[WARN]";
26454
+ case "fail":
26455
+ return "[FAIL]";
26456
+ default:
26457
+ return severity;
26458
+ }
26459
+ }
26460
+ function formatDoctorReport(report) {
26461
+ const lines = [];
26462
+ for (const section of SECTION_ORDER) {
26463
+ const sectionFindings = report.findings.filter((finding) => finding.section === section);
26464
+ if (sectionFindings.length === 0) {
26465
+ continue;
26466
+ }
26467
+ lines.push("", `${SECTION_TITLES[section]}:`);
26468
+ for (const finding of sectionFindings) {
26469
+ const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
26470
+ lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
26471
+ }
26472
+ }
26473
+ const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
26474
+ lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
26475
+ return lines;
26476
+ }
26477
+
26478
+ // src/index.ts
26393
26479
  init_launcher();
26394
26480
  init_spawn();
26395
26481
  init_launchWiring();