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.cjs CHANGED
@@ -2663,6 +2663,7 @@ function planFarm(params) {
2663
2663
  const entries = [];
2664
2664
  const materialised = [];
2665
2665
  const links = [];
2666
+ const dangling = [];
2666
2667
  const conditionalPatterns = [...params.flattened.rules.values()].filter((rule) => rule.when !== void 0).map((rule) => rule.canonicalPattern);
2667
2668
  const conditionalRuleCouldReach = (dir) => conditionalPatterns.some((pattern) => patternCouldReachUnder(pattern, dir));
2668
2669
  const subtreeDecision = (rel) => {
@@ -2695,7 +2696,10 @@ function planFarm(params) {
2695
2696
  return;
2696
2697
  }
2697
2698
  if (!fact.isDirectory) {
2698
- if (decision?.shared === true) {
2699
+ if (decision?.shared === true && fact.isDanglingSymlink) {
2700
+ entries.push({ kind: "omit", rel });
2701
+ dangling.push(rel);
2702
+ } else if (decision?.shared === true) {
2699
2703
  entries.push({ kind: "link", rel, target: linkTarget(rel) });
2700
2704
  links.push({ rel, target: linkTarget(rel) });
2701
2705
  } else {
@@ -2730,7 +2734,7 @@ function planFarm(params) {
2730
2734
  for (const rel of children.get("") ?? []) {
2731
2735
  visit(rel);
2732
2736
  }
2733
- return { entries, materialised, links };
2737
+ return { entries, materialised, links, dangling };
2734
2738
  }
2735
2739
  var import_node_path5;
2736
2740
  var init_plan = __esm({
@@ -2975,6 +2979,14 @@ function topLevelNames(facts) {
2975
2979
  function descendPolicyFor(cascade, home) {
2976
2980
  return descendPolicy(flattenLayers(assembleCascade(cascade).layers, { home }).rules.values());
2977
2981
  }
2982
+ function danglingDiagnostic(rel) {
2983
+ return {
2984
+ code: "SHARED_ENTRY_DANGLING",
2985
+ severity: "warning",
2986
+ 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.`,
2987
+ subject: rel
2988
+ };
2989
+ }
2978
2990
  function resolveDecisions(input) {
2979
2991
  const assembled = assembleCascade(input.cascade);
2980
2992
  const flattened = flattenLayers(assembled.layers, { home: input.facts.home });
@@ -2994,7 +3006,7 @@ function resolveDecisions(input) {
2994
3006
  classification,
2995
3007
  decisions: resolved.decisions,
2996
3008
  farm,
2997
- diagnostics: [...assembled.diagnostics, ...resolved.diagnostics]
3009
+ diagnostics: [...assembled.diagnostics, ...resolved.diagnostics, ...farm.dangling.map(danglingDiagnostic)]
2998
3010
  };
2999
3011
  }
3000
3012
  var init_pipeline = __esm({
@@ -3441,6 +3453,34 @@ function readFarmManifest(fs17, farmRoot) {
3441
3453
  const result = FarmManifestSchema.safeParse(parsed);
3442
3454
  return result.success ? result.data : void 0;
3443
3455
  }
3456
+ function danglingFarmLinks(fs17, farmRoot) {
3457
+ const manifest = readFarmManifest(fs17, farmRoot);
3458
+ const recorded = new Map((manifest?.links ?? []).map((link) => [link.rel, link.target]));
3459
+ const materialised = new Set(manifest?.materialised ?? []);
3460
+ const candidates = new Set(recorded.keys());
3461
+ const walk2 = (rel) => {
3462
+ const stat = fs17.lstat(import_node_path10.default.join(farmRoot, rel));
3463
+ if (stat?.kind === "symlink") {
3464
+ candidates.add(rel);
3465
+ } else if (stat?.kind === "dir" && materialised.has(rel)) {
3466
+ for (const name of fs17.readdir(import_node_path10.default.join(farmRoot, rel))) {
3467
+ walk2(`${rel}/${name}`);
3468
+ }
3469
+ }
3470
+ };
3471
+ for (const name of fs17.readdir(farmRoot)) {
3472
+ if (name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME) {
3473
+ walk2(name);
3474
+ }
3475
+ }
3476
+ return [...candidates].sort().filter((rel) => {
3477
+ const absolute = import_node_path10.default.join(farmRoot, rel);
3478
+ return fs17.lstat(absolute)?.kind === "symlink" && !fs17.resolves(absolute);
3479
+ }).map((rel) => {
3480
+ const target = recorded.get(rel);
3481
+ return target === void 0 ? { rel } : { rel, target };
3482
+ });
3483
+ }
3444
3484
  function buildEntryFacts(params) {
3445
3485
  const entries = /* @__PURE__ */ new Map();
3446
3486
  const visit = (rel) => {
@@ -3465,6 +3505,7 @@ function buildEntryFacts(params) {
3465
3505
  relPath: rel,
3466
3506
  isDirectory,
3467
3507
  isSymlink: stat.kind === "symlink",
3508
+ isDanglingSymlink: stat.kind === "symlink" && !params.fs.resolves(absolute),
3468
3509
  mtimeMs: stat.mtimeMs,
3469
3510
  latestMtimeMs,
3470
3511
  sizeBytes: stat.sizeBytes,
@@ -3827,6 +3868,7 @@ function resyncFarm(params) {
3827
3868
  farmRoot,
3828
3869
  noOp: true,
3829
3870
  manifest: previousManifest,
3871
+ previousManifest,
3830
3872
  resolved,
3831
3873
  adopted: outcome.adopted,
3832
3874
  recovery,
@@ -3849,6 +3891,7 @@ function resyncFarm(params) {
3849
3891
  farmRoot,
3850
3892
  noOp: false,
3851
3893
  manifest,
3894
+ ...previousManifest === void 0 ? {} : { previousManifest },
3852
3895
  resolved,
3853
3896
  adopted: outcome.adopted,
3854
3897
  recovery,
@@ -11072,15 +11115,15 @@ function pathDirectories(target, ports) {
11072
11115
  }
11073
11116
  return directories;
11074
11117
  }
11075
- function headroomDirectoryRefusal(directory, stat, uid, remedy) {
11118
+ function headroomDirectoryRefusal(directory, stat, uid, remedy2) {
11076
11119
  if (stat?.kind !== "dir") {
11077
11120
  return `the directory ${directory} on the allowlist file's path is ${stat === void 0 ? "missing" : "not a directory"}, so headroom refuses the file`;
11078
11121
  }
11079
11122
  if (stat.uid !== uid && stat.uid !== ROOT_UID) {
11080
- 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}` : ""}`;
11123
+ 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}` : ""}`;
11081
11124
  }
11082
11125
  if ((stat.mode & GROUP_OR_OTHER_WRITE_BITS) !== 0) {
11083
- 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}` : ""}`;
11126
+ 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}` : ""}`;
11084
11127
  }
11085
11128
  return void 0;
11086
11129
  }
@@ -11989,6 +12032,9 @@ var init_realPorts = __esm({
11989
12032
  const kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "dir" : "file";
11990
12033
  return { kind, mtimeMs: stat.mtimeMs, sizeBytes: stat.size };
11991
12034
  },
12035
+ resolves(filePath) {
12036
+ return import_node_fs6.default.statSync(filePath, { throwIfNoEntry: false }) !== void 0;
12037
+ },
11992
12038
  readdir(dirPath) {
11993
12039
  try {
11994
12040
  return import_node_fs6.default.readdirSync(dirPath);
@@ -14050,8 +14096,8 @@ var init_identityStore = __esm({
14050
14096
  init_identityRecords();
14051
14097
  init_launchRecords();
14052
14098
  IdentityNotFoundError = class extends CliError {
14053
- constructor(name, remedy = `Run \`agent-shim identity add ${name}\` first.`) {
14054
- super(`No identity named "${name}". ${remedy}`);
14099
+ constructor(name, remedy2 = `Run \`agent-shim identity add ${name}\` first.`) {
14100
+ super(`No identity named "${name}". ${remedy2}`);
14055
14101
  this.name = name;
14056
14102
  this.name = "IdentityNotFoundError";
14057
14103
  }
@@ -14109,7 +14155,7 @@ var init_package = __esm({
14109
14155
  "package.json"() {
14110
14156
  package_default = {
14111
14157
  name: "claude-use",
14112
- version: "14.3.1",
14158
+ version: "14.4.0",
14113
14159
  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.",
14114
14160
  license: "MIT",
14115
14161
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -20852,7 +20898,9 @@ var DIAGNOSTIC_CODES = [
20852
20898
  /** A previous launch was interrupted mid-swap and this launch completed or undid the half-finished work. */
20853
20899
  "FARM_SWAP_RECOVERED",
20854
20900
  /** 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. */
20855
- "FARM_PREVIOUS_RETAINED"
20901
+ "FARM_PREVIOUS_RETAINED",
20902
+ /** 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. */
20903
+ "SHARED_ENTRY_DANGLING"
20856
20904
  ];
20857
20905
  var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
20858
20906
 
@@ -21720,6 +21768,31 @@ function pushKeychainFindings(push, platform, run, identities, agentOf) {
21720
21768
  }
21721
21769
  }
21722
21770
 
21771
+ // src/doctorFarmLinks.ts
21772
+ function remedy(agent, name, rel) {
21773
+ if (agent === "codex") {
21774
+ return `Codex cannot write through it. A launch with \`agent-shim run --agent codex @${name}\` resyncs the farm and leaves the link out.`;
21775
+ }
21776
+ const lost = rel === "sessions" ? " (an interactive session's record under sessions/ is lost, so the session is missing from `claude agents`)" : "";
21777
+ 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.`;
21778
+ }
21779
+ function pushFarmLinkFindings(push, farms, agentOf) {
21780
+ let found = false;
21781
+ for (const farm of farms) {
21782
+ for (const link of farm.dangling) {
21783
+ found = true;
21784
+ const points = link.target === void 0 ? "" : ` to ${link.target}`;
21785
+ 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);
21786
+ }
21787
+ }
21788
+ if (!found) {
21789
+ push("farm-links", "pass", "Every identity's farm links lead somewhere.");
21790
+ }
21791
+ }
21792
+
21793
+ // src/doctorReport.ts
21794
+ init_farm();
21795
+
21723
21796
  // src/frontdoor/catalogueFailures.ts
21724
21797
  init_state();
21725
21798
  init_catalogueState();
@@ -22129,6 +22202,7 @@ var DOCTOR_SECTIONS = [
22129
22202
  "config-profile",
22130
22203
  "identity",
22131
22204
  "sign-in",
22205
+ "farm-links",
22132
22206
  "pool",
22133
22207
  "provider",
22134
22208
  "keychain",
@@ -22527,6 +22601,9 @@ function runDoctor(params) {
22527
22601
  push("provider", finding.level, finding.message, finding.alias);
22528
22602
  }
22529
22603
  pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
22604
+ if (params.farmLinks !== void 0) {
22605
+ pushFarmLinkFindings(push, params.farmLinks, validIdentityAgents);
22606
+ }
22530
22607
  if (params.directoryRules.raw === void 0) {
22531
22608
  push("directory-rules", "pass", "No directory-rules.json configured.");
22532
22609
  } else {
@@ -22676,73 +22753,6 @@ function runDoctor(params) {
22676
22753
  }
22677
22754
  return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
22678
22755
  }
22679
- var SECTION_TITLES = {
22680
- models: "Virtual models",
22681
- "ambient-credential": "Ambient-credential exposure",
22682
- "binary-discovery": "Claude Code binary discovery",
22683
- "claude-shim": "`claude` command shim",
22684
- "path-resolution": "PATH resolution",
22685
- "legacy-name": "Former `claude-use` name",
22686
- "config-profile": "Configuration profiles",
22687
- identity: "Identities",
22688
- "sign-in": "Sign-in",
22689
- pool: "Pools",
22690
- provider: "Providers",
22691
- keychain: "macOS Keychain",
22692
- "directory-rules": "Directory rules",
22693
- "global-config": "Global config",
22694
- headroom: "Headroom daemon",
22695
- frontdoor: "Front door",
22696
- "categories-local": "categories.local.json",
22697
- "active-identity": "Active identity"
22698
- };
22699
- var SECTION_ORDER = [
22700
- "ambient-credential",
22701
- "binary-discovery",
22702
- "claude-shim",
22703
- "path-resolution",
22704
- "config-profile",
22705
- "identity",
22706
- "sign-in",
22707
- "pool",
22708
- "provider",
22709
- "keychain",
22710
- "directory-rules",
22711
- "global-config",
22712
- "headroom",
22713
- "frontdoor",
22714
- "categories-local",
22715
- "active-identity"
22716
- ];
22717
- function severityPrefix(severity) {
22718
- switch (severity) {
22719
- case "pass":
22720
- return "[PASS]";
22721
- case "warn":
22722
- return "[WARN]";
22723
- case "fail":
22724
- return "[FAIL]";
22725
- default:
22726
- return severity;
22727
- }
22728
- }
22729
- function formatDoctorReport(report) {
22730
- const lines = [];
22731
- for (const section of SECTION_ORDER) {
22732
- const sectionFindings = report.findings.filter((finding) => finding.section === section);
22733
- if (sectionFindings.length === 0) {
22734
- continue;
22735
- }
22736
- lines.push("", `${SECTION_TITLES[section]}:`);
22737
- for (const finding of sectionFindings) {
22738
- const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
22739
- lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
22740
- }
22741
- }
22742
- const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
22743
- lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
22744
- return lines;
22745
- }
22746
22756
  function servingDoorListeners(paths) {
22747
22757
  const state = readFrontDoorState(realFarmFs, paths.frontdoorStateFile) ?? {};
22748
22758
  const alive = state.supervisorPid !== void 0 && realIsProcessRunning(state.supervisorPid);
@@ -22815,6 +22825,7 @@ function collectDoctorReport(params) {
22815
22825
  chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
22816
22826
  installedClaudeVersions: realInstalledClaudeVersions(),
22817
22827
  identities,
22828
+ farmLinks: identities.map(({ name, id, farmRoot }) => ({ name, id, dangling: danglingFarmLinks(realFarmFs, farmRoot) })),
22818
22829
  usageSnapshots,
22819
22830
  configProfiles,
22820
22831
  providers,
@@ -26841,6 +26852,81 @@ init_names();
26841
26852
  init_providersStore();
26842
26853
  init_poolStore();
26843
26854
  init_directoryRulesStore();
26855
+
26856
+ // src/doctorFormat.ts
26857
+ var SECTION_TITLES = {
26858
+ models: "Virtual models",
26859
+ "ambient-credential": "Ambient-credential exposure",
26860
+ "binary-discovery": "Claude Code binary discovery",
26861
+ "claude-shim": "`claude` command shim",
26862
+ "path-resolution": "PATH resolution",
26863
+ "legacy-name": "Former `claude-use` name",
26864
+ "config-profile": "Configuration profiles",
26865
+ identity: "Identities",
26866
+ "sign-in": "Sign-in",
26867
+ "farm-links": "Farm links",
26868
+ pool: "Pools",
26869
+ provider: "Providers",
26870
+ keychain: "macOS Keychain",
26871
+ "directory-rules": "Directory rules",
26872
+ "global-config": "Global config",
26873
+ headroom: "Headroom daemon",
26874
+ frontdoor: "Front door",
26875
+ "categories-local": "categories.local.json",
26876
+ "active-identity": "Active identity"
26877
+ };
26878
+ var SECTION_ORDER = [
26879
+ "ambient-credential",
26880
+ "binary-discovery",
26881
+ "claude-shim",
26882
+ "path-resolution",
26883
+ "legacy-name",
26884
+ "config-profile",
26885
+ "identity",
26886
+ "sign-in",
26887
+ "farm-links",
26888
+ "pool",
26889
+ "provider",
26890
+ "keychain",
26891
+ "directory-rules",
26892
+ "global-config",
26893
+ "models",
26894
+ "headroom",
26895
+ "frontdoor",
26896
+ "categories-local",
26897
+ "active-identity"
26898
+ ];
26899
+ function severityPrefix(severity) {
26900
+ switch (severity) {
26901
+ case "pass":
26902
+ return "[PASS]";
26903
+ case "warn":
26904
+ return "[WARN]";
26905
+ case "fail":
26906
+ return "[FAIL]";
26907
+ default:
26908
+ return severity;
26909
+ }
26910
+ }
26911
+ function formatDoctorReport(report) {
26912
+ const lines = [];
26913
+ for (const section of SECTION_ORDER) {
26914
+ const sectionFindings = report.findings.filter((finding) => finding.section === section);
26915
+ if (sectionFindings.length === 0) {
26916
+ continue;
26917
+ }
26918
+ lines.push("", `${SECTION_TITLES[section]}:`);
26919
+ for (const finding of sectionFindings) {
26920
+ const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
26921
+ lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
26922
+ }
26923
+ }
26924
+ const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
26925
+ lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
26926
+ return lines;
26927
+ }
26928
+
26929
+ // src/index.ts
26844
26930
  init_launcher();
26845
26931
  init_spawn();
26846
26932
  init_launchWiring();