@mycadet/cli 0.13.0-dev.202610200020.9f20440 → 0.13.0-dev.202610201855.522ff0d

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 (80) hide show
  1. package/node_modules/@mycadet/assistant-api/constants/personality-sliders.test.ts +0 -8
  2. package/node_modules/@mycadet/assistant-api/constants/personality-sliders.ts +5 -41
  3. package/node_modules/@mycadet/assistant-api/events/message-complete.ts +0 -5
  4. package/node_modules/@mycadet/assistant-api/index.ts +0 -2
  5. package/node_modules/@mycadet/assistant-api/responses/conversation-message.ts +0 -10
  6. package/node_modules/@mycadet/environments/src/seeds.ts +6 -2
  7. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/src/seeds.ts +6 -2
  8. package/node_modules/@mycadet/local-mode/src/config.ts +0 -2
  9. package/node_modules/@mycadet/local-mode/src/index.ts +1 -1
  10. package/node_modules/@mycadet/local-mode/src/lockfile-contract.test.ts +1 -22
  11. package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +26 -7
  12. package/node_modules/@mycadet/local-mode/src/util.ts +1 -20
  13. package/node_modules/@mycadet/shared/github-repository.ts +5 -0
  14. package/node_modules/@mycadet/shared/package.json +10 -0
  15. package/node_modules/@mycadet/shared/scripts/run-isolated-tests.ts +700 -0
  16. package/package.json +3 -2
  17. package/src/__tests__/app-command.test.ts +164 -0
  18. package/src/__tests__/client-web-config.test.ts +0 -1
  19. package/src/__tests__/cloud-releases.test.ts +1 -1
  20. package/src/__tests__/local-version.test.ts +16 -0
  21. package/src/__tests__/nginx-ingress.test.ts +248 -630
  22. package/src/__tests__/ps-cloud-status.test.ts +85 -11
  23. package/src/__tests__/root-process-lockfile.test.ts +29 -2
  24. package/src/__tests__/tunnel-holder-heal.test.ts +119 -0
  25. package/src/__tests__/tunnel-stop.test.ts +6 -13
  26. package/src/__tests__/tunnel.test.ts +50 -193
  27. package/src/__tests__/wake.test.ts +6 -38
  28. package/src/__tests__/web-dist.test.ts +267 -89
  29. package/src/commands/app.ts +113 -0
  30. package/src/commands/backup.ts +5 -4
  31. package/src/commands/clean.ts +2 -1
  32. package/src/commands/client.ts +5 -68
  33. package/src/commands/completions.ts +12 -1
  34. package/src/commands/connect.ts +2 -1
  35. package/src/commands/debug.ts +2 -1
  36. package/src/commands/exec.ts +7 -6
  37. package/src/commands/gateway/token.ts +2 -1
  38. package/src/commands/gateway.ts +2 -1
  39. package/src/commands/hatch.ts +74 -80
  40. package/src/commands/login.ts +7 -6
  41. package/src/commands/logs.ts +2 -1
  42. package/src/commands/ps.ts +136 -6
  43. package/src/commands/restart.ts +2 -1
  44. package/src/commands/restore.ts +10 -9
  45. package/src/commands/retire.ts +4 -3
  46. package/src/commands/setup.ts +5 -4
  47. package/src/commands/sleep.ts +3 -2
  48. package/src/commands/teleport.ts +2 -1
  49. package/src/commands/terminal.ts +7 -6
  50. package/src/commands/tunnel.ts +196 -242
  51. package/src/commands/uninstall.ts +2 -1
  52. package/src/commands/upgrade.ts +2 -1
  53. package/src/commands/use.ts +2 -1
  54. package/src/commands/wake.ts +3 -2
  55. package/src/index.ts +5 -4
  56. package/src/lib/__tests__/web-dist.test.ts +1 -27
  57. package/src/lib/assistant-config.ts +101 -37
  58. package/src/lib/cli-name.ts +14 -0
  59. package/src/lib/cloud-client.ts +2 -1
  60. package/src/lib/cloud-login-poll.ts +2 -1
  61. package/src/lib/cloud-releases.ts +1 -1
  62. package/src/lib/docker.ts +32 -21
  63. package/src/lib/hatch-local.ts +1 -3
  64. package/src/lib/hatch-next-steps.ts +1 -9
  65. package/src/lib/ingress-config.ts +0 -31
  66. package/src/lib/local-version.ts +25 -4
  67. package/src/lib/local.ts +34 -9
  68. package/src/lib/nginx-ingress.ts +143 -244
  69. package/src/lib/provider-secrets.ts +0 -5
  70. package/src/lib/statefulset.ts +0 -1
  71. package/src/lib/tunnel.ts +244 -43
  72. package/src/lib/tunnels/ngrok.ts +57 -9
  73. package/src/lib/tunnels/tailscale.ts +2 -1
  74. package/src/lib/web-dist.ts +134 -56
  75. package/src/__tests__/flags.test.ts +0 -318
  76. package/src/__tests__/shell-mode.test.ts +0 -83
  77. package/src/commands/flags.ts +0 -255
  78. package/src/lib/flag-args.test.ts +0 -84
  79. package/src/lib/flag-args.ts +0 -74
  80. package/src/lib/github-repository.ts +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/cli",
3
- "version": "0.13.0-dev.202610200020.9f20440",
3
+ "version": "0.13.0-dev.202610201855.522ff0d",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/vargasjr-dev/mycadet-temp.git"
@@ -39,6 +39,7 @@
39
39
  "@mycadet/ipc-server-utils": "file:../packages/ipc-server-utils",
40
40
  "@mycadet/local-mode": "file:../packages/local-mode",
41
41
  "@mycadet/service-contracts": "file:../packages/service-contracts",
42
+ "@mycadet/shared": "file:../packages/shared",
42
43
  "chalk": "5.6.2",
43
44
  "ink": "6.8.0",
44
45
  "nanoid": "5.1.7",
@@ -55,10 +56,10 @@
55
56
  "@mycadet/environments",
56
57
  "@mycadet/ipc-server-utils",
57
58
  "@mycadet/local-mode",
59
+ "@mycadet/shared",
58
60
  "@mycadet/service-contracts"
59
61
  ],
60
62
  "devDependencies": {
61
- "@mycadet/shared": "0.0.1",
62
63
  "@types/bun": "1.3.11",
63
64
  "@types/qrcode-terminal": "0.12.2",
64
65
  "@types/react": "19.2.14",
@@ -0,0 +1,164 @@
1
+ import {
2
+ afterAll,
3
+ afterEach,
4
+ beforeEach,
5
+ describe,
6
+ expect,
7
+ mock,
8
+ test,
9
+ } from "bun:test";
10
+ import { mkdtempSync, rmSync } from "node:fs";
11
+ import { tmpdir } from "node:os";
12
+ import { join } from "node:path";
13
+
14
+ // ---------------------------------------------------------------------------
15
+ // Mocks — the app command's collaborators are process-boundary fakes; the
16
+ // real modules restore when this file finishes so nothing leaks into
17
+ // sibling suites in the same `bun test` run.
18
+ // ---------------------------------------------------------------------------
19
+
20
+ import * as tunnelLib from "../lib/tunnel.js";
21
+ import type { AssistantEntry } from "../lib/assistant-config.js";
22
+ import * as nginxIngress from "../lib/nginx-ingress.js";
23
+
24
+ const ensureNginxForEdgeMock = mock(tunnelLib.ensureNginxForEdge);
25
+ const resolveLocalTunnelTargetMock = mock(tunnelLib.resolveLocalTunnelTarget);
26
+
27
+ const ensureTunnelEdgeMock = mock(nginxIngress.ensureTunnelEdge);
28
+ const isIngressRunningMock = mock(nginxIngress.isIngressRunning);
29
+ const readIngressStateMock = mock(nginxIngress.readIngressState);
30
+ const stopIngressNginxMock = mock(nginxIngress.stopIngressNginx);
31
+
32
+ mock.module("../lib/tunnel.js", () => ({
33
+ ...tunnelLib,
34
+ ensureNginxForEdge: ensureNginxForEdgeMock,
35
+ resolveLocalTunnelTarget: resolveLocalTunnelTargetMock,
36
+ }));
37
+ mock.module("../lib/nginx-ingress.js", () => ({
38
+ ...nginxIngress,
39
+ ensureTunnelEdge: ensureTunnelEdgeMock,
40
+ isIngressRunning: isIngressRunningMock,
41
+ readIngressState: readIngressStateMock,
42
+ stopIngressNginx: stopIngressNginxMock,
43
+ }));
44
+
45
+ afterAll(() => {
46
+ mock.module("../lib/tunnel.js", () => tunnelLib);
47
+ mock.module("../lib/nginx-ingress.js", () => nginxIngress);
48
+ });
49
+
50
+ import { app } from "../commands/app.js";
51
+
52
+ // The default-workspace dir is real; the lockfile read inside the command's
53
+ // workspace sweep stays hermetic under a redirected lockfile dir.
54
+ const testDir = mkdtempSync(join(tmpdir(), "cli-app-command-test-"));
55
+ const originalLockfileDir = process.env.CADET_LOCKFILE_DIR;
56
+ process.env.CADET_LOCKFILE_DIR = testDir;
57
+
58
+ const originalArgv = process.argv;
59
+ let stdout: string[];
60
+ let originalLog: typeof console.log;
61
+
62
+ beforeEach(() => {
63
+ stdout = [];
64
+ originalLog = console.log;
65
+ console.log = (...args: unknown[]) => {
66
+ stdout.push(args.map((a) => String(a)).join(" "));
67
+ };
68
+ ensureNginxForEdgeMock.mockReset();
69
+ ensureNginxForEdgeMock.mockResolvedValue("nginx/1.26.3");
70
+ resolveLocalTunnelTargetMock.mockReset();
71
+ ensureTunnelEdgeMock.mockReset();
72
+ isIngressRunningMock.mockReset();
73
+ isIngressRunningMock.mockReturnValue(false);
74
+ readIngressStateMock.mockReset();
75
+ stopIngressNginxMock.mockReset();
76
+ stopIngressNginxMock.mockResolvedValue(true);
77
+ });
78
+
79
+ afterEach(() => {
80
+ console.log = originalLog;
81
+ process.argv = originalArgv;
82
+ });
83
+
84
+ afterAll(() => {
85
+ if (originalLockfileDir === undefined) {
86
+ delete process.env.CADET_LOCKFILE_DIR;
87
+ } else {
88
+ process.env.CADET_LOCKFILE_DIR = originalLockfileDir;
89
+ }
90
+ rmSync(testDir, { recursive: true, force: true });
91
+ });
92
+
93
+ const LOCAL_ENTRY: AssistantEntry = {
94
+ assistantId: "assistant-1",
95
+ runtimeUrl: "http://127.0.0.1:7830",
96
+ cloud: "local",
97
+ };
98
+
99
+ describe("cadet app", () => {
100
+ test("start brings the edge up for the resolved local assistant", async () => {
101
+ const workspaceDir = join(testDir, "workspace");
102
+ resolveLocalTunnelTargetMock.mockReturnValue({
103
+ entry: LOCAL_ENTRY,
104
+ gatewayPort: 7830,
105
+ workspaceDir,
106
+ });
107
+ ensureTunnelEdgeMock.mockResolvedValue({ port: 7841, started: true });
108
+ process.argv = ["bun", "cadet", "app", "start"];
109
+
110
+ await app();
111
+
112
+ expect(ensureNginxForEdgeMock).toHaveBeenCalled();
113
+ expect(ensureTunnelEdgeMock).toHaveBeenCalledWith({
114
+ assistantId: "assistant-1",
115
+ workspaceDir,
116
+ gatewayPort: 7830,
117
+ });
118
+ expect(stdout.join("\n")).toContain(
119
+ "Started the app edge on 127.0.0.1:7841",
120
+ );
121
+ });
122
+
123
+ test("start reports a reused edge and the stop command", async () => {
124
+ resolveLocalTunnelTargetMock.mockReturnValue({
125
+ entry: LOCAL_ENTRY,
126
+ gatewayPort: 7830,
127
+ workspaceDir: join(testDir, "workspace"),
128
+ } as never);
129
+ ensureTunnelEdgeMock.mockResolvedValue({ port: 7841, started: false });
130
+ process.argv = ["bun", "cadet", "app", "start"];
131
+
132
+ await app();
133
+
134
+ const output = stdout.join("\n");
135
+ expect(output).toContain("Reusing the app edge on 127.0.0.1:7841");
136
+ expect(output).toContain("cadet app stop");
137
+ });
138
+
139
+ test("stop takes the running edge down", async () => {
140
+ isIngressRunningMock.mockReturnValue(true);
141
+ readIngressStateMock.mockReturnValue({
142
+ listenPort: 7841,
143
+ gatewayPort: 7830,
144
+ });
145
+ process.argv = ["bun", "cadet", "app", "stop"];
146
+
147
+ await app();
148
+
149
+ expect(stopIngressNginxMock).toHaveBeenCalled();
150
+ expect(stdout.join("\n")).toContain(
151
+ "Stopped the app edge on 127.0.0.1:7841",
152
+ );
153
+ });
154
+
155
+ test("stop with nothing running says so", async () => {
156
+ isIngressRunningMock.mockReturnValue(false);
157
+ process.argv = ["bun", "cadet", "app", "stop"];
158
+
159
+ await app();
160
+
161
+ expect(stopIngressNginxMock).not.toHaveBeenCalled();
162
+ expect(stdout.join("\n")).toContain("No app edge is running.");
163
+ });
164
+ });
@@ -11,7 +11,6 @@ import { describe, expect, test } from "bun:test";
11
11
  import { buildWebInterfaceConfig } from "../commands/client.js";
12
12
 
13
13
  const BASE = {
14
- webUrl: "https://app.example.com",
15
14
  cloudUrl: "https://platform.example.com",
16
15
  version: "0.13.0-local.202610191920.58bcf38",
17
16
  };
@@ -13,7 +13,7 @@ import {
13
13
  isStagingVersion,
14
14
  } from "../lib/version-compat.js";
15
15
 
16
- import { CADET_GITHUB_REPOSITORY } from "../lib/github-repository.js";
16
+ import { CADET_GITHUB_REPOSITORY } from "@mycadet/shared";
17
17
 
18
18
  const originalFetch = globalThis.fetch;
19
19
 
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, test } from "bun:test";
2
+ import { execSync } from "node:child_process";
2
3
 
3
4
  import { displayVersion } from "../lib/local-version.js";
4
5
  import { environmentFromVersion } from "../lib/environments/resolve.js";
@@ -42,4 +43,19 @@ describe("displayVersion", () => {
42
43
  displayVersion("0.13.0", new Date(), "/opt/src/cli/src/index.ts"),
43
44
  ).toBe("0.13.0");
44
45
  });
46
+
47
+ test("the stamp's timestamp is the HEAD commit's, so a checkout stamps identically in every process", () => {
48
+ // The stamp rides the edge's served-config fingerprint: a wall-clock
49
+ // stamp would drift every CLI process and restart the edge on every
50
+ // invocation. The commit time moves exactly when the sha does.
51
+ const commitIso = execSync("git show -s --format=%cI HEAD")
52
+ .toString()
53
+ .trim();
54
+ const stamp = new Date(commitIso)
55
+ .toISOString()
56
+ .replace(/[-:T]/g, "")
57
+ .slice(0, 12);
58
+ const sha = execSync("git rev-parse --short=7 HEAD").toString().trim();
59
+ expect(displayVersion("0.13.0")).toBe(`0.13.0-local.${stamp}.${sha}`);
60
+ });
45
61
  });