@mycadet/cli 0.13.0-dev.202610271937.2f71260 → 0.13.0-dev.202610290143.526d7ca

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.
Files changed (58) hide show
  1. package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/package.json +1 -1
  2. package/node_modules/@mycadet/avatar-manifest/package.json +1 -1
  3. package/node_modules/@mycadet/environments/package.json +1 -1
  4. package/node_modules/@mycadet/ipc-server-utils/package.json +1 -1
  5. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/avatar-manifest/package.json +1 -1
  6. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/package.json +1 -1
  7. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/package.json +1 -1
  8. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/shared/package.json +1 -1
  9. package/node_modules/@mycadet/local-mode/package.json +1 -1
  10. package/node_modules/@mycadet/local-mode/src/__tests__/environment.test.ts +1 -1
  11. package/node_modules/@mycadet/local-mode/src/__tests__/gateway-proxy.test.ts +40 -30
  12. package/node_modules/@mycadet/local-mode/src/__tests__/guardian-token-refresh.test.ts +5 -25
  13. package/node_modules/@mycadet/local-mode/src/__tests__/guardian-token.test.ts +40 -70
  14. package/node_modules/@mycadet/local-mode/src/__tests__/loopback-auth.test.ts +21 -15
  15. package/node_modules/@mycadet/local-mode/src/__tests__/pair.test.ts +100 -310
  16. package/node_modules/@mycadet/local-mode/src/__tests__/status.test.ts +24 -24
  17. package/node_modules/@mycadet/local-mode/src/__tests__/unpair.test.ts +17 -22
  18. package/node_modules/@mycadet/local-mode/src/avatar.test.ts +7 -6
  19. package/node_modules/@mycadet/local-mode/src/avatar.ts +1 -2
  20. package/node_modules/@mycadet/local-mode/src/config.ts +6 -6
  21. package/node_modules/@mycadet/local-mode/src/gateway-proxy.ts +4 -4
  22. package/node_modules/@mycadet/local-mode/src/guardian-token.ts +4 -7
  23. package/node_modules/@mycadet/local-mode/src/index.ts +0 -5
  24. package/node_modules/@mycadet/local-mode/src/lockfile-contract.test.ts +0 -28
  25. package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +4 -31
  26. package/node_modules/@mycadet/local-mode/src/lockfile-lock.test.ts +30 -19
  27. package/node_modules/@mycadet/local-mode/src/lockfile-lock.ts +4 -6
  28. package/node_modules/@mycadet/local-mode/src/lockfile.test.ts +49 -140
  29. package/node_modules/@mycadet/local-mode/src/lockfile.ts +32 -104
  30. package/node_modules/@mycadet/local-mode/src/pair.ts +32 -167
  31. package/node_modules/@mycadet/local-mode/src/status.ts +2 -4
  32. package/node_modules/@mycadet/local-mode/src/unpair.ts +69 -79
  33. package/node_modules/@mycadet/service-contracts/package.json +1 -1
  34. package/node_modules/@mycadet/shared/package.json +1 -1
  35. package/package.json +1 -1
  36. package/src/__tests__/app-command.test.ts +0 -21
  37. package/src/__tests__/app-tunnel-status.test.ts +1 -0
  38. package/src/__tests__/connect-import.test.ts +0 -41
  39. package/src/__tests__/guardian-token.test.ts +7 -22
  40. package/src/__tests__/nginx-ingress.test.ts +36 -14
  41. package/src/__tests__/tailscale.test.ts +28 -133
  42. package/src/__tests__/tunnel-stop.test.ts +12 -18
  43. package/src/__tests__/tunnel.test.ts +116 -293
  44. package/src/__tests__/upgrade-local.test.ts +3 -1
  45. package/src/__tests__/wake.test.ts +17 -30
  46. package/src/commands/connect/import.ts +20 -59
  47. package/src/commands/retire.ts +1 -4
  48. package/src/commands/tunnel.ts +13 -52
  49. package/src/lib/assistant-config.ts +2 -4
  50. package/src/lib/guardian-token.ts +4 -4
  51. package/src/lib/ingress-config.ts +3 -85
  52. package/src/lib/nginx-ingress.ts +7 -14
  53. package/src/lib/tunnel.ts +29 -132
  54. package/src/lib/tunnels/cloudflare.ts +5 -26
  55. package/src/lib/tunnels/ngrok.ts +17 -64
  56. package/src/lib/tunnels/process-lifecycle.ts +0 -2
  57. package/src/lib/tunnels/tailscale.ts +13 -114
  58. package/src/__tests__/ingress-config.test.ts +0 -184
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202610271937.2f71260",
3
+ "version": "0.13.0-dev.202610290143.526d7ca",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/avatar-manifest",
3
- "version": "0.13.0-dev.202610271937.2f71260",
3
+ "version": "0.13.0-dev.202610290143.526d7ca",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/environments",
3
- "version": "0.13.0-dev.202610271937.2f71260",
3
+ "version": "0.13.0-dev.202610290143.526d7ca",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/ipc-server-utils",
3
- "version": "0.13.0-dev.202610271937.2f71260",
3
+ "version": "0.13.0-dev.202610290143.526d7ca",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/avatar-manifest",
3
- "version": "0.13.0-dev.202610271937.2f71260",
3
+ "version": "0.13.0-dev.202610290143.526d7ca",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/environments",
3
- "version": "0.13.0-dev.202610271937.2f71260",
3
+ "version": "0.13.0-dev.202610290143.526d7ca",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202610271937.2f71260",
3
+ "version": "0.13.0-dev.202610290143.526d7ca",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/shared",
3
- "version": "0.13.0-dev.202610271937.2f71260",
3
+ "version": "0.13.0-dev.202610290143.526d7ca",
4
4
  "private": true,
5
5
  "exports": {
6
6
  ".": "./github-repository.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/local-mode",
3
- "version": "0.13.0-dev.202610271937.2f71260",
3
+ "version": "0.13.0-dev.202610290143.526d7ca",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -217,7 +217,7 @@ describe("Windows path resolution", () => {
217
217
  expect(() => resolveInstanceDir(assistantId)).toThrow(
218
218
  "Invalid assistant ID",
219
219
  );
220
- expect(() => guardianTokenPath("C:\\Cadet", assistantId)).toThrow(
220
+ expect(() => guardianTokenPath(assistantId)).toThrow(
221
221
  "Invalid assistant ID",
222
222
  );
223
223
  }
@@ -312,28 +312,41 @@ describe("gatewayTargetsFromLockfile", () => {
312
312
  });
313
313
 
314
314
  describe("readGatewayTargets", () => {
315
- test("reads the id-keyed target map from disk", () => {
315
+ // The reader resolves its path from the environment; a per-test XDG home
316
+ // points it at the fixture's cadet dir.
317
+ const withAmbientLockfile = (
318
+ write: (lockfilePath: string) => void,
319
+ ): string => {
316
320
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), "gateway-proxy-"));
317
- const lockfile = path.join(dir, "lockfile.json");
318
- fs.writeFileSync(
319
- lockfile,
320
- JSON.stringify({
321
- assistants: [
322
- {
323
- assistantId: "abc-123",
324
- cloud: "local",
325
- resources: { gatewayPort: 8080, daemonPort: 8501 },
326
- },
327
- {
328
- assistantId: "def-456",
329
- cloud: "custom",
330
- ipAddress: "gw.example.com",
331
- port: 443,
332
- },
333
- ],
334
- }),
321
+ process.env.XDG_CONFIG_HOME = dir;
322
+ const lockfilePath = path.join(dir, "cadet", "lockfile.json");
323
+ fs.mkdirSync(path.dirname(lockfilePath), { recursive: true });
324
+ write(lockfilePath);
325
+ return dir;
326
+ };
327
+
328
+ test("reads the id-keyed target map from disk", () => {
329
+ const dir = withAmbientLockfile((lockfilePath) =>
330
+ fs.writeFileSync(
331
+ lockfilePath,
332
+ JSON.stringify({
333
+ assistants: [
334
+ {
335
+ assistantId: "abc-123",
336
+ cloud: "local",
337
+ resources: { gatewayPort: 8080, daemonPort: 8501 },
338
+ },
339
+ {
340
+ assistantId: "def-456",
341
+ cloud: "custom",
342
+ ipAddress: "gw.example.com",
343
+ port: 443,
344
+ },
345
+ ],
346
+ }),
347
+ ),
335
348
  );
336
- expect(readGatewayTargets(lockfile)).toEqual(
349
+ expect(readGatewayTargets()).toEqual(
337
350
  targets({
338
351
  "abc-123": loopback(8080),
339
352
  "def-456": remote("https://gw.example.com"),
@@ -343,21 +356,18 @@ describe("readGatewayTargets", () => {
343
356
  });
344
357
 
345
358
  test("an empty lockfile yields an empty map", () => {
346
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "gateway-proxy-"));
347
- const lockfile = path.join(dir, "first.json");
348
- fs.writeFileSync(lockfile, JSON.stringify({ assistants: [] }));
349
- expect(readGatewayTargets(lockfile)).toEqual(new Map());
359
+ const dir = withAmbientLockfile((lockfilePath) =>
360
+ fs.writeFileSync(lockfilePath, JSON.stringify({ assistants: [] })),
361
+ );
362
+ expect(readGatewayTargets()).toEqual(new Map());
350
363
  fs.rmSync(dir, { recursive: true, force: true });
351
364
  });
352
365
 
353
366
  test("an unreadable or absent lockfile yields an empty map", () => {
354
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "gateway-proxy-"));
355
- const unreadable = path.join(dir, "unreadable.json");
356
- fs.writeFileSync(unreadable, "{ not json");
357
- expect(readGatewayTargets(unreadable)).toEqual(new Map());
358
- expect(readGatewayTargets(path.join(dir, "absent.json"))).toEqual(
359
- new Map(),
367
+ const dir = withAmbientLockfile((lockfilePath) =>
368
+ fs.writeFileSync(lockfilePath, "{ not json"),
360
369
  );
370
+ expect(readGatewayTargets()).toEqual(new Map());
361
371
  fs.rmSync(dir, { recursive: true, force: true });
362
372
  });
363
373
  });
@@ -64,7 +64,7 @@ describe("getGuardianAccessToken refresh spawn", () => {
64
64
 
65
65
  beforeEach(() => {
66
66
  configDir = fs.mkdtempSync(path.join(os.tmpdir(), "guardian-refresh-"));
67
- saveGuardianToken(configDir, "asst-1", makeTokenData({}));
67
+ saveGuardianToken("asst-1", makeTokenData({}));
68
68
  });
69
69
 
70
70
  afterEach(() => {
@@ -72,12 +72,7 @@ describe("getGuardianAccessToken refresh spawn", () => {
72
72
  });
73
73
 
74
74
  test("a labeled CLI 503 is an unreachable gateway, not a spent token", async () => {
75
- const pending = getGuardianAccessToken(
76
- "asst-1",
77
- configDir,
78
- invocation,
79
- true,
80
- );
75
+ const pending = getGuardianAccessToken("asst-1", invocation, true);
81
76
  await tick();
82
77
  lastChild.stderr.emit(
83
78
  "data",
@@ -95,12 +90,7 @@ describe("getGuardianAccessToken refresh spawn", () => {
95
90
  });
96
91
 
97
92
  test("a labeled CLI 401 is a spent credential", async () => {
98
- const pending = getGuardianAccessToken(
99
- "asst-1",
100
- configDir,
101
- invocation,
102
- true,
103
- );
93
+ const pending = getGuardianAccessToken("asst-1", invocation, true);
104
94
  await tick();
105
95
  lastChild.stderr.emit(
106
96
  "data",
@@ -118,12 +108,7 @@ describe("getGuardianAccessToken refresh spawn", () => {
118
108
  });
119
109
 
120
110
  test("a labeled CLI 403 is a local confidentiality refusal, not a spent credential", async () => {
121
- const pending = getGuardianAccessToken(
122
- "asst-1",
123
- configDir,
124
- invocation,
125
- true,
126
- );
111
+ const pending = getGuardianAccessToken("asst-1", invocation, true);
127
112
  await tick();
128
113
  lastChild.stderr.emit(
129
114
  "data",
@@ -141,12 +126,7 @@ describe("getGuardianAccessToken refresh spawn", () => {
141
126
  });
142
127
 
143
128
  test("an unlabeled non-zero CLI exit is a 503, not a 401", async () => {
144
- const pending = getGuardianAccessToken(
145
- "asst-1",
146
- configDir,
147
- invocation,
148
- true,
149
- );
129
+ const pending = getGuardianAccessToken("asst-1", invocation, true);
150
130
  await tick();
151
131
  lastChild.stderr.emit(
152
132
  "data",
@@ -41,30 +41,38 @@ describe("getGuardianAccessToken", () => {
41
41
  let configDir: string;
42
42
 
43
43
  beforeEach(() => {
44
- configDir = fs.mkdtempSync(path.join(os.tmpdir(), "guardian-token-test-"));
44
+ // The token paths resolve from the environment: XDG config home plus the
45
+ // production environment dir, so the fixture points XDG at the tmp home
46
+ // and reads back through the same ambient resolution.
47
+ const home = fs.mkdtempSync(path.join(os.tmpdir(), "guardian-token-test-"));
48
+ process.env.XDG_CONFIG_HOME = home;
49
+ configDir = path.join(home, "cadet");
45
50
  });
46
51
 
47
52
  afterEach(() => {
48
- fs.rmSync(configDir, { recursive: true, force: true });
53
+ Reflect.deleteProperty(process.env, "XDG_CONFIG_HOME");
54
+ fs.rmSync(path.dirname(configDir), { recursive: true, force: true });
49
55
  });
50
56
 
51
57
  test("returns the stored token while the access token is fresh", async () => {
52
- saveGuardianToken(configDir, "asst-1", makeTokenData({}));
58
+ saveGuardianToken("asst-1", makeTokenData({}));
53
59
 
54
- expect(
55
- await getGuardianAccessToken("asst-1", configDir, invocation, true),
56
- ).toEqual({ ok: true, accessToken: "access" });
60
+ expect(await getGuardianAccessToken("asst-1", invocation, true)).toEqual({
61
+ ok: true,
62
+ accessToken: "access",
63
+ });
57
64
  });
58
65
 
59
66
  test("returns a structured 404 when no token file exists", async () => {
60
- expect(
61
- await getGuardianAccessToken("missing", configDir, invocation, true),
62
- ).toEqual({ ok: false, status: 404, error: "Guardian token not found" });
67
+ expect(await getGuardianAccessToken("missing", invocation, true)).toEqual({
68
+ ok: false,
69
+ status: 404,
70
+ error: "Guardian token not found",
71
+ });
63
72
  });
64
73
 
65
74
  test("expired refresh token yields hatch/wake guidance by default", async () => {
66
75
  saveGuardianToken(
67
- configDir,
68
76
  "asst-1",
69
77
  makeTokenData({
70
78
  accessTokenExpiresAt: PAST,
@@ -72,12 +80,7 @@ describe("getGuardianAccessToken", () => {
72
80
  }),
73
81
  );
74
82
 
75
- const result = await getGuardianAccessToken(
76
- "asst-1",
77
- configDir,
78
- invocation,
79
- true,
80
- );
83
+ const result = await getGuardianAccessToken("asst-1", invocation, true);
81
84
 
82
85
  expect(result).toEqual({
83
86
  ok: false,
@@ -88,7 +91,6 @@ describe("getGuardianAccessToken", () => {
88
91
 
89
92
  test("expired refresh token yields re-pair guidance for a paired entry", async () => {
90
93
  saveGuardianToken(
91
- configDir,
92
94
  "asst-1",
93
95
  makeTokenData({
94
96
  accessTokenExpiresAt: PAST,
@@ -96,16 +98,10 @@ describe("getGuardianAccessToken", () => {
96
98
  }),
97
99
  );
98
100
 
99
- const result = await getGuardianAccessToken(
100
- "asst-1",
101
- configDir,
102
- invocation,
103
- true,
104
- {
105
- paired: true,
106
- pairedGatewayUrl: "https://gateway.example.com",
107
- },
108
- );
101
+ const result = await getGuardianAccessToken("asst-1", invocation, true, {
102
+ paired: true,
103
+ pairedGatewayUrl: "https://gateway.example.com",
104
+ });
109
105
 
110
106
  expect(result).toEqual({
111
107
  ok: false,
@@ -117,7 +113,6 @@ describe("getGuardianAccessToken", () => {
117
113
 
118
114
  test("an explicit paired: false keeps the hatch/wake guidance", async () => {
119
115
  saveGuardianToken(
120
- configDir,
121
116
  "asst-1",
122
117
  makeTokenData({
123
118
  accessTokenExpiresAt: PAST,
@@ -125,13 +120,9 @@ describe("getGuardianAccessToken", () => {
125
120
  }),
126
121
  );
127
122
 
128
- const result = await getGuardianAccessToken(
129
- "asst-1",
130
- configDir,
131
- invocation,
132
- true,
133
- { paired: false },
134
- );
123
+ const result = await getGuardianAccessToken("asst-1", invocation, true, {
124
+ paired: false,
125
+ });
135
126
 
136
127
  expect(result.ok).toBe(false);
137
128
  if (result.ok) {
@@ -142,62 +133,41 @@ describe("getGuardianAccessToken", () => {
142
133
 
143
134
  test("returns a paired token only for its stored gateway target", async () => {
144
135
  saveGuardianToken(
145
- configDir,
146
136
  "paired-1",
147
137
  makeTokenData({ pairedGatewayUrl: "https://gateway.example.com" }),
148
138
  );
149
139
 
150
- expect(
151
- await getGuardianAccessToken("paired-1", configDir, invocation, true),
152
- ).toEqual({
140
+ expect(await getGuardianAccessToken("paired-1", invocation, true)).toEqual({
153
141
  ok: false,
154
142
  status: 403,
155
143
  error: PAIRED_GUARDIAN_TOKEN_HOST_ONLY_ERROR,
156
144
  });
157
145
  expect(
158
- await getGuardianAccessToken(
159
- "paired-1",
160
- configDir,
161
- invocation,
162
- true,
163
- {
164
- paired: true,
165
- pairedGatewayUrl: "https://attacker.example.com",
166
- },
167
- ),
146
+ await getGuardianAccessToken("paired-1", invocation, true, {
147
+ paired: true,
148
+ pairedGatewayUrl: "https://attacker.example.com",
149
+ }),
168
150
  ).toEqual({
169
151
  ok: false,
170
152
  status: 403,
171
153
  error: PAIRED_GUARDIAN_TARGET_MISMATCH_ERROR,
172
154
  });
173
155
  expect(
174
- await getGuardianAccessToken(
175
- "paired-1",
176
- configDir,
177
- invocation,
178
- true,
179
- {
180
- paired: true,
181
- pairedGatewayUrl: "https://gateway.example.com",
182
- },
183
- ),
156
+ await getGuardianAccessToken("paired-1", invocation, true, {
157
+ paired: true,
158
+ pairedGatewayUrl: "https://gateway.example.com",
159
+ }),
184
160
  ).toEqual({ ok: true, accessToken: "access" });
185
161
  });
186
162
 
187
163
  test("binds a legacy paired token before returning it", async () => {
188
- saveGuardianToken(configDir, "paired-1", makeTokenData({}));
164
+ saveGuardianToken("paired-1", makeTokenData({}));
189
165
 
190
166
  expect(
191
- await getGuardianAccessToken(
192
- "paired-1",
193
- configDir,
194
- invocation,
195
- true,
196
- {
197
- paired: true,
198
- pairedGatewayUrl: "https://gateway.example.com",
199
- },
200
- ),
167
+ await getGuardianAccessToken("paired-1", invocation, true, {
168
+ paired: true,
169
+ pairedGatewayUrl: "https://gateway.example.com",
170
+ }),
201
171
  ).toEqual({ ok: true, accessToken: "access" });
202
172
 
203
173
  const stored = JSON.parse(
@@ -105,59 +105,65 @@ describe("isActiveAssistant", () => {
105
105
 
106
106
  test("returns true for the active assistant", () => {
107
107
  const dir = makeTempDir();
108
- const lockfilePath = path.join(dir, "lockfile.json");
108
+ process.env.XDG_CONFIG_HOME = dir;
109
+ fs.mkdirSync(path.join(dir, "cadet"), { recursive: true });
109
110
  fs.writeFileSync(
110
- lockfilePath,
111
+ path.join(dir, "cadet", "lockfile.json"),
111
112
  JSON.stringify({
112
113
  assistants: [{ assistantId: "active" }, { assistantId: "inactive" }],
113
114
  activeAssistant: "active",
114
115
  }),
115
116
  );
116
- expect(isActiveAssistant(lockfilePath, "active")).toBe(true);
117
+ expect(isActiveAssistant("active")).toBe(true);
117
118
  });
118
119
 
119
120
  test("returns true for the sole assistant when activeAssistant is empty", () => {
120
121
  const dir = makeTempDir();
121
- const lockfilePath = path.join(dir, "lockfile.json");
122
+ process.env.XDG_CONFIG_HOME = dir;
123
+ fs.mkdirSync(path.join(dir, "cadet"), { recursive: true });
122
124
  fs.writeFileSync(
123
- lockfilePath,
125
+ path.join(dir, "cadet", "lockfile.json"),
124
126
  JSON.stringify({
125
127
  assistants: [{ assistantId: "only" }],
126
128
  activeAssistant: null,
127
129
  }),
128
130
  );
129
- expect(isActiveAssistant(lockfilePath, "only")).toBe(true);
131
+ expect(isActiveAssistant("only")).toBe(true);
130
132
  });
131
133
 
132
134
  test("returns true for the sole assistant when activeAssistant is stale", () => {
133
135
  const dir = makeTempDir();
134
- const lockfilePath = path.join(dir, "lockfile.json");
136
+ process.env.XDG_CONFIG_HOME = dir;
137
+ fs.mkdirSync(path.join(dir, "cadet"), { recursive: true });
135
138
  fs.writeFileSync(
136
- lockfilePath,
139
+ path.join(dir, "cadet", "lockfile.json"),
137
140
  JSON.stringify({
138
141
  assistants: [{ assistantId: "only" }],
139
142
  activeAssistant: "missing",
140
143
  }),
141
144
  );
142
- expect(isActiveAssistant(lockfilePath, "only")).toBe(true);
145
+ expect(isActiveAssistant("only")).toBe(true);
143
146
  });
144
147
 
145
148
  test("returns false for a non-active assistant", () => {
146
149
  const dir = makeTempDir();
147
- const lockfilePath = path.join(dir, "lockfile.json");
150
+ process.env.XDG_CONFIG_HOME = dir;
151
+ fs.mkdirSync(path.join(dir, "cadet"), { recursive: true });
148
152
  fs.writeFileSync(
149
- lockfilePath,
153
+ path.join(dir, "cadet", "lockfile.json"),
150
154
  JSON.stringify({
151
155
  assistants: [{ assistantId: "active" }, { assistantId: "inactive" }],
152
156
  activeAssistant: "active",
153
157
  }),
154
158
  );
155
- expect(isActiveAssistant(lockfilePath, "inactive")).toBe(false);
159
+ expect(isActiveAssistant("inactive")).toBe(false);
156
160
  });
157
161
 
158
162
  test("returns false when lockfile does not exist", () => {
159
- expect(isActiveAssistant("/nonexistent/lockfile.json", "any")).toBe(
160
- false,
161
- );
163
+ expect(isActiveAssistant("any")).toBe(false);
164
+ });
165
+
166
+ afterEach(() => {
167
+ Reflect.deleteProperty(process.env, "XDG_CONFIG_HOME");
162
168
  });
163
169
  });