git-colabor 0.3.0 → 0.3.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
@@ -158,7 +158,8 @@ Full threat model: [docs/SECURITY.md](../docs/SECURITY.md) in the extension repo
158
158
  | `GIT_COLABOR_AUDIT_FILE` | audit log path |
159
159
  | `GIT_COLABOR_MESSAGE_PATH` | commit template path |
160
160
  | `GIT_COLABOR_LOG_FILE` / `GIT_COLABOR_LOG_LEVEL` | CLI debug log |
161
- | `GIT_COLABOR_ASKPASS_SOCK` / `GIT_COLABOR_ASKPASS_TOKEN` | askpass bridge endpoint (set by the extension) |
161
+ | `GIT_COLABOR_GIT` | git executable to run (default: `git` from `PATH`; the extension points it at the git vscode.git runs) |
162
+ | `GIT_COLABOR_ASKPASS_SOCK` / `GIT_COLABOR_ASKPASS_TOKEN` | askpass bridge endpoint — UNIX socket, or a named pipe on Windows (set by the extension) |
162
163
 
163
164
  ## Library
164
165
 
package/dist/askpass.cjs CHANGED
@@ -49,6 +49,14 @@ function pidIsAlive(pid) {
49
49
  return e.code === "EPERM";
50
50
  }
51
51
  }
52
+ var SOCKET_NAME_RE = /^askpass-[\w.-]+\.sock$/;
53
+ var PIPE_RE = /^\\\\\.\\pipe\\git-colabor-askpass-[\w.-]+$/;
54
+ function askpassEndpointKind(dir, endpoint, platform = process.platform) {
55
+ if (typeof endpoint !== "string") return void 0;
56
+ if (platform === "win32" && PIPE_RE.test(endpoint)) return "pipe";
57
+ if (!SOCKET_NAME_RE.test(path.basename(endpoint))) return void 0;
58
+ return path.join(dir, path.basename(endpoint)) === endpoint ? "socket" : void 0;
59
+ }
52
60
  function discoverSessionBridges() {
53
61
  try {
54
62
  const dir = dataDir();
@@ -58,10 +66,10 @@ function discoverSessionBridges() {
58
66
  try {
59
67
  const parsed = JSON.parse(fs.readFileSync(path.join(dir, s.f), "utf8"));
60
68
  if (!parsed.socketPath || !parsed.token) continue;
61
- const ourSock = /^askpass-[\w.-]+\.sock$/.test(path.basename(parsed.socketPath)) && path.join(dir, path.basename(parsed.socketPath)) === parsed.socketPath;
62
- const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) || !ourSock || !fs.existsSync(parsed.socketPath);
69
+ const kind = askpassEndpointKind(dir, parsed.socketPath);
70
+ const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) || kind === void 0 || kind === "socket" && !fs.existsSync(parsed.socketPath);
63
71
  if (stale) {
64
- if (ourSock && fs.existsSync(parsed.socketPath)) {
72
+ if (kind === "socket" && fs.existsSync(parsed.socketPath)) {
65
73
  try {
66
74
  fs.rmSync(parsed.socketPath);
67
75
  } catch {
package/dist/cli.cjs CHANGED
@@ -353,9 +353,25 @@ var init_map = __esm({
353
353
  idOf = (name, email) => `${name.trim()} <${email.trim()}>`;
354
354
  }
355
355
  });
356
+ function gitCommand() {
357
+ return process.env.GIT_COLABOR_GIT?.trim() || "git";
358
+ }
359
+ function gitNotFound(cmd, e) {
360
+ return new AppError({
361
+ code: "GIT_NOT_FOUND",
362
+ message: `cannot start git ("${cmd}"): ${e.message}`,
363
+ exitCode: EXIT_CODES.RUNTIME,
364
+ hints: [
365
+ "install Git, or put its directory on PATH",
366
+ "VS Code extension: set the `git.path` setting to the git executable",
367
+ "standalone CLI: set GIT_COLABOR_GIT to the git executable"
368
+ ]
369
+ });
370
+ }
356
371
  function run(args, opts) {
357
372
  return new Promise((resolve4, reject) => {
358
- const child = child_process.spawn("git", args, {
373
+ const cmd = gitCommand();
374
+ const child = child_process.spawn(cmd, args, {
359
375
  cwd: opts.cwd,
360
376
  env: opts.env ? { ...process.env, ...opts.env } : process.env,
361
377
  stdio: ["ignore", "pipe", "pipe"]
@@ -368,7 +384,10 @@ function run(args, opts) {
368
384
  child.stderr.on("data", (d) => {
369
385
  stderr += d.toString("utf8");
370
386
  });
371
- child.on("error", reject);
387
+ child.on(
388
+ "error",
389
+ (e) => reject(e.code !== void 0 && CANNOT_START.has(e.code) ? gitNotFound(cmd, e) : e)
390
+ );
372
391
  child.on("close", (code) => {
373
392
  resolve4({ stdout, stderr, exitCode: code ?? 0 });
374
393
  });
@@ -405,9 +424,10 @@ async function runBin(cmd, args, opts = {}) {
405
424
  else child.stdin.end();
406
425
  });
407
426
  }
408
- var GitError;
427
+ var GitError, CANNOT_START;
409
428
  var init_exec = __esm({
410
429
  "src/core/git/exec.ts"() {
430
+ init_errors();
411
431
  GitError = class extends Error {
412
432
  cmd;
413
433
  exitCode;
@@ -420,6 +440,7 @@ var init_exec = __esm({
420
440
  this.stderr = stderr;
421
441
  }
422
442
  };
443
+ CANNOT_START = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "EPERM", "ENOTDIR"]);
423
444
  }
424
445
  });
425
446
 
@@ -1032,6 +1053,12 @@ function pidIsAlive(pid) {
1032
1053
  return e.code === "EPERM";
1033
1054
  }
1034
1055
  }
1056
+ function askpassEndpointKind(dir, endpoint, platform = process.platform) {
1057
+ if (typeof endpoint !== "string") return void 0;
1058
+ if (platform === "win32" && PIPE_RE.test(endpoint)) return "pipe";
1059
+ if (!SOCKET_NAME_RE.test(path.basename(endpoint))) return void 0;
1060
+ return path.join(dir, path.basename(endpoint)) === endpoint ? "socket" : void 0;
1061
+ }
1035
1062
  function discoverSessionBridges() {
1036
1063
  try {
1037
1064
  const dir = dataDir();
@@ -1041,10 +1068,10 @@ function discoverSessionBridges() {
1041
1068
  try {
1042
1069
  const parsed = JSON.parse(fs.readFileSync(path.join(dir, s.f), "utf8"));
1043
1070
  if (!parsed.socketPath || !parsed.token) continue;
1044
- const ourSock = /^askpass-[\w.-]+\.sock$/.test(path.basename(parsed.socketPath)) && path.join(dir, path.basename(parsed.socketPath)) === parsed.socketPath;
1045
- const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) || !ourSock || !fs.existsSync(parsed.socketPath);
1071
+ const kind = askpassEndpointKind(dir, parsed.socketPath);
1072
+ const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) || kind === void 0 || kind === "socket" && !fs.existsSync(parsed.socketPath);
1046
1073
  if (stale) {
1047
- if (ourSock && fs.existsSync(parsed.socketPath)) {
1074
+ if (kind === "socket" && fs.existsSync(parsed.socketPath)) {
1048
1075
  try {
1049
1076
  fs.rmSync(parsed.socketPath);
1050
1077
  } catch {
@@ -1068,9 +1095,12 @@ function discoverSessionBridges() {
1068
1095
  function discoverSessionBridge() {
1069
1096
  return discoverSessionBridges()[0];
1070
1097
  }
1098
+ var SOCKET_NAME_RE, PIPE_RE;
1071
1099
  var init_session_bridge = __esm({
1072
1100
  "src/core/secrets/session-bridge.ts"() {
1073
1101
  init_paths();
1102
+ SOCKET_NAME_RE = /^askpass-[\w.-]+\.sock$/;
1103
+ PIPE_RE = /^\\\\\.\\pipe\\git-colabor-askpass-[\w.-]+$/;
1074
1104
  }
1075
1105
  });
1076
1106
 
package/dist/index.cjs CHANGED
@@ -68,9 +68,83 @@ var init_formatter = __esm({
68
68
  init_types();
69
69
  }
70
70
  });
71
+
72
+ // src/core/errors.ts
73
+ function toErrorPayload(e) {
74
+ if (e instanceof exports.AppError) return e.toPayload();
75
+ const message = e instanceof Error ? e.message : String(e);
76
+ return { code: "INTERNAL", message, exitCode: exports.EXIT_CODES.RUNTIME };
77
+ }
78
+ exports.EXIT_CODES = void 0; exports.AppError = void 0; exports.Errors = void 0;
79
+ var init_errors = __esm({
80
+ "src/core/errors.ts"() {
81
+ exports.EXIT_CODES = {
82
+ OK: 0,
83
+ RUNTIME: 1,
84
+ USAGE: 2,
85
+ NOT_A_REPO: 3,
86
+ SECRET_UNAVAILABLE: 4,
87
+ NOT_FOUND: 5,
88
+ CONFLICT_BLOCKED: 6
89
+ };
90
+ exports.AppError = class extends Error {
91
+ code;
92
+ exitCode;
93
+ hints;
94
+ constructor(init) {
95
+ super(init.message);
96
+ this.name = "AppError";
97
+ this.code = init.code;
98
+ this.exitCode = init.exitCode ?? exports.EXIT_CODES.RUNTIME;
99
+ this.hints = init.hints;
100
+ }
101
+ toPayload() {
102
+ return { code: this.code, message: this.message, hints: this.hints, exitCode: this.exitCode };
103
+ }
104
+ };
105
+ exports.Errors = {
106
+ notARepo: (cwd) => new exports.AppError({
107
+ code: "NOT_A_REPO",
108
+ message: cwd ? `not a git repository: ${cwd}` : "not a git repository",
109
+ exitCode: exports.EXIT_CODES.NOT_A_REPO
110
+ }),
111
+ authorNotFound: (key) => new exports.AppError({
112
+ code: "AUTHOR_NOT_FOUND",
113
+ message: `Author with initials "${key}" not found in identities`,
114
+ exitCode: exports.EXIT_CODES.NOT_FOUND,
115
+ hints: [`Add it with: git colabor coauthor add ${key} "Full Name" email@example.com`]
116
+ }),
117
+ duplicateKey: (key) => new exports.AppError({
118
+ code: "DUPLICATE_KEY",
119
+ message: `Key "${key}" already exists`,
120
+ exitCode: exports.EXIT_CODES.NOT_FOUND,
121
+ hints: []
122
+ }),
123
+ invalidEmail: (email) => new exports.AppError({ code: "INVALID_EMAIL", message: `Invalid email: ${email}`, exitCode: exports.EXIT_CODES.USAGE }),
124
+ usage: (message, hints) => new exports.AppError({ code: "USAGE", message, exitCode: exports.EXIT_CODES.USAGE, hints }),
125
+ secretUnavailable: (message, hints) => new exports.AppError({ code: "SECRET_UNAVAILABLE", message, exitCode: exports.EXIT_CODES.SECRET_UNAVAILABLE, hints })
126
+ };
127
+ }
128
+ });
129
+ function gitCommand() {
130
+ return process.env.GIT_COLABOR_GIT?.trim() || "git";
131
+ }
132
+ function gitNotFound(cmd, e) {
133
+ return new exports.AppError({
134
+ code: "GIT_NOT_FOUND",
135
+ message: `cannot start git ("${cmd}"): ${e.message}`,
136
+ exitCode: exports.EXIT_CODES.RUNTIME,
137
+ hints: [
138
+ "install Git, or put its directory on PATH",
139
+ "VS Code extension: set the `git.path` setting to the git executable",
140
+ "standalone CLI: set GIT_COLABOR_GIT to the git executable"
141
+ ]
142
+ });
143
+ }
71
144
  function run(args, opts) {
72
145
  return new Promise((resolve4, reject) => {
73
- const child = child_process.spawn("git", args, {
146
+ const cmd = gitCommand();
147
+ const child = child_process.spawn(cmd, args, {
74
148
  cwd: opts.cwd,
75
149
  env: opts.env ? { ...process.env, ...opts.env } : process.env,
76
150
  stdio: ["ignore", "pipe", "pipe"]
@@ -83,7 +157,10 @@ function run(args, opts) {
83
157
  child.stderr.on("data", (d) => {
84
158
  stderr += d.toString("utf8");
85
159
  });
86
- child.on("error", reject);
160
+ child.on(
161
+ "error",
162
+ (e) => reject(e.code !== void 0 && CANNOT_START.has(e.code) ? gitNotFound(cmd, e) : e)
163
+ );
87
164
  child.on("close", (code) => {
88
165
  resolve4({ stdout, stderr, exitCode: code ?? 0 });
89
166
  });
@@ -120,9 +197,10 @@ async function runBin(cmd, args, opts = {}) {
120
197
  else child.stdin.end();
121
198
  });
122
199
  }
123
- exports.GitError = void 0;
200
+ exports.GitError = void 0; var CANNOT_START;
124
201
  var init_exec = __esm({
125
202
  "src/core/git/exec.ts"() {
203
+ init_errors();
126
204
  exports.GitError = class extends Error {
127
205
  cmd;
128
206
  exitCode;
@@ -135,6 +213,7 @@ var init_exec = __esm({
135
213
  this.stderr = stderr;
136
214
  }
137
215
  };
216
+ CANNOT_START = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "EPERM", "ENOTDIR"]);
138
217
  }
139
218
  });
140
219
 
@@ -636,60 +715,8 @@ function nowHeldBy(session, source) {
636
715
  // src/core/repo/status.ts
637
716
  init_rev();
638
717
 
639
- // src/core/errors.ts
640
- var EXIT_CODES = {
641
- OK: 0,
642
- RUNTIME: 1,
643
- USAGE: 2,
644
- NOT_A_REPO: 3,
645
- SECRET_UNAVAILABLE: 4,
646
- NOT_FOUND: 5,
647
- CONFLICT_BLOCKED: 6
648
- };
649
- var AppError = class extends Error {
650
- code;
651
- exitCode;
652
- hints;
653
- constructor(init) {
654
- super(init.message);
655
- this.name = "AppError";
656
- this.code = init.code;
657
- this.exitCode = init.exitCode ?? EXIT_CODES.RUNTIME;
658
- this.hints = init.hints;
659
- }
660
- toPayload() {
661
- return { code: this.code, message: this.message, hints: this.hints, exitCode: this.exitCode };
662
- }
663
- };
664
- var Errors = {
665
- notARepo: (cwd) => new AppError({
666
- code: "NOT_A_REPO",
667
- message: cwd ? `not a git repository: ${cwd}` : "not a git repository",
668
- exitCode: EXIT_CODES.NOT_A_REPO
669
- }),
670
- authorNotFound: (key) => new AppError({
671
- code: "AUTHOR_NOT_FOUND",
672
- message: `Author with initials "${key}" not found in identities`,
673
- exitCode: EXIT_CODES.NOT_FOUND,
674
- hints: [`Add it with: git colabor coauthor add ${key} "Full Name" email@example.com`]
675
- }),
676
- duplicateKey: (key) => new AppError({
677
- code: "DUPLICATE_KEY",
678
- message: `Key "${key}" already exists`,
679
- exitCode: EXIT_CODES.NOT_FOUND,
680
- hints: []
681
- }),
682
- invalidEmail: (email) => new AppError({ code: "INVALID_EMAIL", message: `Invalid email: ${email}`, exitCode: EXIT_CODES.USAGE }),
683
- usage: (message, hints) => new AppError({ code: "USAGE", message, exitCode: EXIT_CODES.USAGE, hints }),
684
- secretUnavailable: (message, hints) => new AppError({ code: "SECRET_UNAVAILABLE", message, exitCode: EXIT_CODES.SECRET_UNAVAILABLE, hints })
685
- };
686
- function toErrorPayload(e) {
687
- if (e instanceof AppError) return e.toPayload();
688
- const message = e instanceof Error ? e.message : String(e);
689
- return { code: "INTERNAL", message, exitCode: EXIT_CODES.RUNTIME };
690
- }
691
-
692
718
  // src/core/identity/map.ts
719
+ init_errors();
693
720
  var norm = (s) => s.trim().toLowerCase();
694
721
  var refOf = (i) => `${norm(i.name)} <${norm(i.email)}>`;
695
722
  var idOf = (name, email) => `${name.trim()} <${email.trim()}>`;
@@ -708,7 +735,7 @@ function resolveRow(map, ref) {
708
735
  if (/^\d+$/.test(ref.trim())) {
709
736
  const row = map.identities[Number(ref.trim()) - 1];
710
737
  if (row) return row;
711
- throw Errors.usage(
738
+ throw exports.Errors.usage(
712
739
  `identity index ${ref.trim()} out of range \u2014 the list has ${map.identities.length} entries (see \`git colabor identity ls\`)`
713
740
  );
714
741
  }
@@ -717,10 +744,10 @@ function resolveRow(map, ref) {
717
744
  if (byEmail.length === 1) return byEmail[0];
718
745
  if (byEmail.length > 1) {
719
746
  const list = byEmail.map((i) => `"${idOf(i.name, i.email)}"`).join(", ");
720
- throw Errors.usage(`email "${ref}" matches several identities \u2014 use the full form: ${list}`);
747
+ throw exports.Errors.usage(`email "${ref}" matches several identities \u2014 use the full form: ${list}`);
721
748
  }
722
749
  }
723
- throw Errors.usage(`identity "${ref}" not found`);
750
+ throw exports.Errors.usage(`identity "${ref}" not found`);
724
751
  }
725
752
  function foldRow(rows, raw) {
726
753
  let keyBindings = raw.keyBindings;
@@ -816,9 +843,9 @@ async function updateIdentity(ref, patch, opts = {}) {
816
843
  if (opts?.clearAlias) delete row.alias;
817
844
  const after = refOf(row);
818
845
  const aliasClash = patch.alias && map.identities.find((i) => i !== row && i.alias === patch.alias);
819
- if (aliasClash) throw Errors.usage(`alias "${patch.alias}" already belongs to ${idOf(aliasClash.name, aliasClash.email)}`);
846
+ if (aliasClash) throw exports.Errors.usage(`alias "${patch.alias}" already belongs to ${idOf(aliasClash.name, aliasClash.email)}`);
820
847
  const clash = map.identities.find((i) => i !== row && refOf(i) === after);
821
- if (clash) throw Errors.usage(`"${idOf(row.name, row.email)}" already exists`);
848
+ if (clash) throw exports.Errors.usage(`"${idOf(row.name, row.email)}" already exists`);
822
849
  if (map.defaultIdentity === before) map.defaultIdentity = after;
823
850
  await writeMap(map);
824
851
  return row;
@@ -912,17 +939,18 @@ function toBrief(a) {
912
939
 
913
940
  // src/core/identity/keys.ts
914
941
  init_exec();
942
+ init_errors();
915
943
  var FP_RE = /SHA256:[A-Za-z0-9+/=]+/;
916
944
  async function fingerprintOfFile(path) {
917
945
  const r = await runBin("ssh-keygen", ["-lf", path]);
918
946
  if (r.exitCode !== 0) {
919
- throw new AppError({
947
+ throw new exports.AppError({
920
948
  code: "KEY_READ_FAILED",
921
949
  message: `cannot read key fingerprint: ${r.stderr.trim() || "ssh-keygen failed"}`
922
950
  });
923
951
  }
924
952
  const m = r.stdout.match(FP_RE);
925
- if (!m) throw new AppError({ code: "KEY_READ_FAILED", message: `unparseable ssh-keygen output: ${r.stdout}` });
953
+ if (!m) throw new exports.AppError({ code: "KEY_READ_FAILED", message: `unparseable ssh-keygen output: ${r.stdout}` });
926
954
  return m[0];
927
955
  }
928
956
  async function isEncrypted(path) {
@@ -1089,10 +1117,12 @@ init_rev();
1089
1117
  // src/core/identity/sign.ts
1090
1118
  init_config();
1091
1119
  init_rev();
1120
+ init_errors();
1092
1121
 
1093
1122
  // src/core/identity/gpg.ts
1094
1123
  init_config();
1095
1124
  init_exec();
1125
+ init_errors();
1096
1126
  var UNUSABLE = /* @__PURE__ */ new Set(["i", "d", "r", "e", "n"]);
1097
1127
  function unescape(s) {
1098
1128
  return s.replace(/\\x([0-9a-fA-F]{2})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));
@@ -1148,7 +1178,7 @@ async function listSigningKeys(cwd, query) {
1148
1178
  try {
1149
1179
  r = await runBin(program, ["--batch", "--list-secret-keys", "--with-colons", ...query ? [query] : []], { cwd });
1150
1180
  } catch {
1151
- throw new AppError({
1181
+ throw new exports.AppError({
1152
1182
  code: "GPG_UNAVAILABLE",
1153
1183
  message: `cannot run "${program}"`,
1154
1184
  exitCode: 1,
@@ -1228,17 +1258,17 @@ async function disableSigning(cwd, scope = "local") {
1228
1258
  }
1229
1259
  }
1230
1260
  async function setCommitSigning(opts) {
1231
- if (!await insideWorkTree(opts.cwd)) throw Errors.notARepo(opts.cwd);
1261
+ if (!await insideWorkTree(opts.cwd)) throw exports.Errors.notARepo(opts.cwd);
1232
1262
  if (!opts.on) {
1233
1263
  await disableSigning(opts.cwd);
1234
1264
  if (opts.id) await setSignCommits(opts.id, false);
1235
1265
  await appendAudit({ action: "identity.sign", source: opts.source, identity: opts.id, repo: await safeTopLevel(opts.cwd), result: "ok", message: "signing off" });
1236
1266
  return { signing: false };
1237
1267
  }
1238
- if (!opts.id) throw Errors.usage("git colabor identity sign <id>");
1268
+ if (!opts.id) throw exports.Errors.usage("git colabor identity sign <id>");
1239
1269
  const identity = await getIdentity(opts.id);
1240
1270
  const cfg = await writeIdentitySigning(identity, opts.cwd, opts.askpassScriptPath);
1241
- if (!cfg) throw Errors.usage(`identity "${identity.name}" has no usable SSH or GPG key to sign with`);
1271
+ if (!cfg) throw exports.Errors.usage(`identity "${identity.name}" has no usable SSH or GPG key to sign with`);
1242
1272
  await setSignCommits(opts.id, true);
1243
1273
  await appendAudit({
1244
1274
  action: "identity.sign",
@@ -1280,6 +1310,14 @@ function pidIsAlive(pid) {
1280
1310
  return e.code === "EPERM";
1281
1311
  }
1282
1312
  }
1313
+ var SOCKET_NAME_RE = /^askpass-[\w.-]+\.sock$/;
1314
+ var PIPE_RE = /^\\\\\.\\pipe\\git-colabor-askpass-[\w.-]+$/;
1315
+ function askpassEndpointKind(dir, endpoint, platform = process.platform) {
1316
+ if (typeof endpoint !== "string") return void 0;
1317
+ if (platform === "win32" && PIPE_RE.test(endpoint)) return "pipe";
1318
+ if (!SOCKET_NAME_RE.test(path.basename(endpoint))) return void 0;
1319
+ return path.join(dir, path.basename(endpoint)) === endpoint ? "socket" : void 0;
1320
+ }
1283
1321
  function discoverSessionBridges() {
1284
1322
  try {
1285
1323
  const dir = dataDir();
@@ -1289,10 +1327,10 @@ function discoverSessionBridges() {
1289
1327
  try {
1290
1328
  const parsed = JSON.parse(fs.readFileSync(path.join(dir, s.f), "utf8"));
1291
1329
  if (!parsed.socketPath || !parsed.token) continue;
1292
- const ourSock = /^askpass-[\w.-]+\.sock$/.test(path.basename(parsed.socketPath)) && path.join(dir, path.basename(parsed.socketPath)) === parsed.socketPath;
1293
- const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) || !ourSock || !fs.existsSync(parsed.socketPath);
1330
+ const kind = askpassEndpointKind(dir, parsed.socketPath);
1331
+ const stale = parsed.pid !== void 0 && !pidIsAlive(parsed.pid) || kind === void 0 || kind === "socket" && !fs.existsSync(parsed.socketPath);
1294
1332
  if (stale) {
1295
- if (ourSock && fs.existsSync(parsed.socketPath)) {
1333
+ if (kind === "socket" && fs.existsSync(parsed.socketPath)) {
1296
1334
  try {
1297
1335
  fs.rmSync(parsed.socketPath);
1298
1336
  } catch {
@@ -1488,6 +1526,7 @@ async function resolveActive(cwd, opts = {}) {
1488
1526
  }
1489
1527
 
1490
1528
  // src/core/identity/logout.ts
1529
+ init_errors();
1491
1530
  async function safeTopLevel3(cwd) {
1492
1531
  try {
1493
1532
  return await topLevel(cwd);
@@ -1501,7 +1540,7 @@ async function logoutIdentity(opts) {
1501
1540
  if (!id) {
1502
1541
  const { identities } = await listIdentities();
1503
1542
  if (identities.length === 1) id = idOf(identities[0].name, identities[0].email);
1504
- else throw Errors.usage("no active identity \u2014 specify one: git colabor identity logout <id>");
1543
+ else throw exports.Errors.usage("no active identity \u2014 specify one: git colabor identity logout <id>");
1505
1544
  }
1506
1545
  const identity = await getIdentity(id);
1507
1546
  const binding = await getKeyBinding(id);
@@ -1571,6 +1610,9 @@ function askSocket(socketPath, token, fingerprint) {
1571
1610
  }, SOCKET_TIMEOUT_MS).unref?.();
1572
1611
  });
1573
1612
  }
1613
+
1614
+ // src/core/secrets/bridge.ts
1615
+ init_errors();
1574
1616
  async function resolvePassphrase(fingerprint, opts = {}) {
1575
1617
  if (opts.socketPath && opts.token) {
1576
1618
  const got = await askSocket(opts.socketPath, opts.token, fingerprint);
@@ -1579,7 +1621,7 @@ async function resolvePassphrase(fingerprint, opts = {}) {
1579
1621
  if (opts.interactive && process.stdin.isTTY) {
1580
1622
  return await promptPassphraseTty(`Passphrase for ${fingerprint}: `);
1581
1623
  }
1582
- throw Errors.secretUnavailable("no passphrase source available", [
1624
+ throw exports.Errors.secretUnavailable("no passphrase source available", [
1583
1625
  "run within the VS Code extension (provides the askpass bridge)",
1584
1626
  "load the key into ssh-agent first (ssh-add)",
1585
1627
  "import a passphraseless key"
@@ -1601,9 +1643,9 @@ async function promptPassphraseTty(prompt) {
1601
1643
  }
1602
1644
  }
1603
1645
 
1604
- exports.AppError = AppError;
1605
- exports.EXIT_CODES = EXIT_CODES;
1606
- exports.Errors = Errors;
1646
+ // src/index.ts
1647
+ init_errors();
1648
+
1607
1649
  exports.addConfigValue = addConfigValue;
1608
1650
  exports.addIdentity = addIdentity;
1609
1651
  exports.addRedactable = addRedactable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-colabor",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Git co-author + multi-identity + SSH key management CLI",
5
5
  "repository": {
6
6
  "type": "git",