@mycadet/cli 0.13.0-dev.202610201855.522ff0d → 0.13.0-dev.202610211119.c9ac8c3

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.
@@ -2,29 +2,75 @@
2
2
  * Pins the environment-to-cloud-hub mapping in one place. Both consumers
3
3
  * (the Capacitor shell's `server.url` and the CLI remote-web edge's
4
4
  * `hubUrl`) read this helper, so this matrix is the single behavioral pin
5
- * for the served URLs. (The remote-web edge additionally folds local → dev
6
- * at its own site: clients served through a tunnel cannot reach the local
7
- * seed's loopback.)
5
+ * for the served URLs. The helper reads `VITE_ENVIRONMENT` and
6
+ * `CADET_ENVIRONMENT` itself — under bun `import.meta.env` surfaces the
7
+ * process env live, so these cases drive both by setting/restoring them.
8
+ * (The remote-web edge additionally folds local → dev at its own site:
9
+ * clients served through a tunnel cannot reach the local seed's loopback.)
8
10
  */
9
11
 
10
- import { describe, expect, test } from "bun:test";
12
+ import { readFileSync } from "node:fs";
13
+
14
+ import { afterEach, describe, expect, test } from "bun:test";
11
15
 
12
16
  import { cloudAssistantHubUrl, SEEDS } from "../index.js";
13
17
 
14
18
  describe("cloudAssistantHubUrl", () => {
15
- test("every known environment resolves to its own web origin", () => {
19
+ const original = {
20
+ vite: process.env.VITE_ENVIRONMENT,
21
+ cadet: process.env.CADET_ENVIRONMENT,
22
+ };
23
+
24
+ afterEach(() => {
25
+ for (const [key, value] of Object.entries(original)) {
26
+ if (value === undefined) delete process.env[key];
27
+ else process.env[key] = value;
28
+ }
29
+ });
30
+
31
+ test("VITE_ENVIRONMENT picks its own web origin (the build-time inlined var)", () => {
16
32
  for (const name of ["production", "staging", "dev", "test", "local"]) {
17
- expect(cloudAssistantHubUrl(name)).toBe(
18
- `${SEEDS[name].webUrl}/assistant`,
19
- );
33
+ process.env.VITE_ENVIRONMENT = name;
34
+ delete process.env.CADET_ENVIRONMENT;
35
+ expect(cloudAssistantHubUrl()).toBe(`${SEEDS[name].webUrl}/assistant`);
20
36
  }
21
37
  });
22
38
 
23
- test("unknown environments fall back to the dev SPA", () => {
24
- for (const name of ["unknown-env", undefined]) {
25
- expect(cloudAssistantHubUrl(name)).toBe(
26
- "https://dev.mycadet.ai/assistant",
27
- );
39
+ test("CADET_ENVIRONMENT picks its own web origin (the runtime var)", () => {
40
+ for (const name of ["production", "staging", "dev", "test", "local"]) {
41
+ process.env.CADET_ENVIRONMENT = name;
42
+ delete process.env.VITE_ENVIRONMENT;
43
+ expect(cloudAssistantHubUrl()).toBe(`${SEEDS[name].webUrl}/assistant`);
28
44
  }
29
45
  });
46
+
47
+ test("CADET_ENVIRONMENT wins when both are set (the runtime contract)", () => {
48
+ process.env.VITE_ENVIRONMENT = "production";
49
+ process.env.CADET_ENVIRONMENT = "staging";
50
+ expect(cloudAssistantHubUrl()).toBe(`${SEEDS.staging.webUrl}/assistant`);
51
+ });
52
+
53
+ test("unset and unknown environments fall back to the dev SPA", () => {
54
+ for (const set of [
55
+ () => {
56
+ delete process.env.VITE_ENVIRONMENT;
57
+ delete process.env.CADET_ENVIRONMENT;
58
+ },
59
+ () => {
60
+ delete process.env.CADET_ENVIRONMENT;
61
+ process.env.VITE_ENVIRONMENT = "unknown-env";
62
+ },
63
+ ]) {
64
+ set();
65
+ expect(cloudAssistantHubUrl()).toBe("https://dev.mycadet.ai/assistant");
66
+ }
67
+ });
68
+ });
69
+
70
+ test("seeds.ts stays loadable by Capacitor's single-file TS config loader", () => {
71
+ // The loader transpiles the file to CJS; an import-meta reference can't be
72
+ // transpiled and makes Node execute the CJS output as ESM (`exports is not
73
+ // defined`), which took down the iOS Capacitor sync in CI.
74
+ const src = readFileSync(new URL("../seeds.ts", import.meta.url), "utf8");
75
+ expect(src).not.toContain("import.meta");
30
76
  });
@@ -1,3 +1,7 @@
1
+ // Loaded standalone by Capacitor's single-file TS config loader — keep
2
+ // imports type-only and keep this file free of the import-meta meta-property:
3
+ // the loader transpiles this file to CJS, where that syntax is illegal and
4
+ // makes Node misroute the result as ESM.
1
5
  import type { EnvironmentDefinition, PortMap } from "./types.js";
2
6
 
3
7
  /**
@@ -24,30 +28,24 @@ function portBlock(base: number): PortMap {
24
28
  };
25
29
  }
26
30
 
27
- /**
28
- * Base URL of the cloud-hosted assistant SPA (the "hub") for a deployment
29
- * environment: always `${SEEDS[env].webUrl}/assistant`. The Capacitor boot
30
- * bundle stamps this into baked mobile builds as `handoffUrl`, and the CLI's
31
- * remote-web edge stamps it into the served config as `hubUrl`, so the
32
- * environment-to-hub mapping lives here exactly once. Unknown environment
33
- * names fall back to the dev SPA defensively.
34
- *
35
- * The `/assistant` suffix is deliberate: booting on the bare host lands on
36
- * the marketing page, whose CTA redirects to `mycadet.ai/assistant` and
37
- * bounces non-prod shells off their own host.
38
- *
39
- * NOTE: this module is loaded by Capacitor's single-file TS config loader
40
- * (via the `@mycadet/environments/seeds` subpath), which cannot follow the
41
- * package index's `.js`-suffixed runtime re-exports. Keep this file's
42
- * imports type-only so it stays loadable on its own.
43
- */
44
- export function cloudWebUrl(envName: string | undefined): string {
31
+ /** Web origin for the current environment (CADET_ENVIRONMENT or VITE_ENVIRONMENT; unknown falls back to dev). */
32
+ export function cloudWebUrl(): string {
33
+ // globalThis.process reads the same env under bun/node while staying
34
+ // crash-free in browser bundles (no bare `process` reference) — and free
35
+ // of import-meta syntax, which the Capacitor config loader can't transpile.
36
+ const env = (
37
+ globalThis as unknown as {
38
+ process?: { env?: Record<string, string | undefined> };
39
+ }
40
+ ).process?.env;
41
+ const envName = env?.CADET_ENVIRONMENT ?? env?.VITE_ENVIRONMENT;
45
42
  const seed = (envName && SEEDS[envName]) || SEEDS.dev;
46
43
  return seed.webUrl;
47
44
  }
48
45
 
49
- export function cloudAssistantHubUrl(envName: string | undefined): string {
50
- return `${cloudWebUrl(envName)}/assistant`;
46
+ /** The cloud assistant hub — booting at the bare host bounces non-prod shells. */
47
+ export function cloudAssistantHubUrl(): string {
48
+ return `${cloudWebUrl()}/assistant`;
51
49
  }
52
50
 
53
51
  /**
@@ -2,29 +2,75 @@
2
2
  * Pins the environment-to-cloud-hub mapping in one place. Both consumers
3
3
  * (the Capacitor shell's `server.url` and the CLI remote-web edge's
4
4
  * `hubUrl`) read this helper, so this matrix is the single behavioral pin
5
- * for the served URLs. (The remote-web edge additionally folds local → dev
6
- * at its own site: clients served through a tunnel cannot reach the local
7
- * seed's loopback.)
5
+ * for the served URLs. The helper reads `VITE_ENVIRONMENT` and
6
+ * `CADET_ENVIRONMENT` itself — under bun `import.meta.env` surfaces the
7
+ * process env live, so these cases drive both by setting/restoring them.
8
+ * (The remote-web edge additionally folds local → dev at its own site:
9
+ * clients served through a tunnel cannot reach the local seed's loopback.)
8
10
  */
9
11
 
10
- import { describe, expect, test } from "bun:test";
12
+ import { readFileSync } from "node:fs";
13
+
14
+ import { afterEach, describe, expect, test } from "bun:test";
11
15
 
12
16
  import { cloudAssistantHubUrl, SEEDS } from "../index.js";
13
17
 
14
18
  describe("cloudAssistantHubUrl", () => {
15
- test("every known environment resolves to its own web origin", () => {
19
+ const original = {
20
+ vite: process.env.VITE_ENVIRONMENT,
21
+ cadet: process.env.CADET_ENVIRONMENT,
22
+ };
23
+
24
+ afterEach(() => {
25
+ for (const [key, value] of Object.entries(original)) {
26
+ if (value === undefined) delete process.env[key];
27
+ else process.env[key] = value;
28
+ }
29
+ });
30
+
31
+ test("VITE_ENVIRONMENT picks its own web origin (the build-time inlined var)", () => {
16
32
  for (const name of ["production", "staging", "dev", "test", "local"]) {
17
- expect(cloudAssistantHubUrl(name)).toBe(
18
- `${SEEDS[name].webUrl}/assistant`,
19
- );
33
+ process.env.VITE_ENVIRONMENT = name;
34
+ delete process.env.CADET_ENVIRONMENT;
35
+ expect(cloudAssistantHubUrl()).toBe(`${SEEDS[name].webUrl}/assistant`);
20
36
  }
21
37
  });
22
38
 
23
- test("unknown environments fall back to the dev SPA", () => {
24
- for (const name of ["unknown-env", undefined]) {
25
- expect(cloudAssistantHubUrl(name)).toBe(
26
- "https://dev.mycadet.ai/assistant",
27
- );
39
+ test("CADET_ENVIRONMENT picks its own web origin (the runtime var)", () => {
40
+ for (const name of ["production", "staging", "dev", "test", "local"]) {
41
+ process.env.CADET_ENVIRONMENT = name;
42
+ delete process.env.VITE_ENVIRONMENT;
43
+ expect(cloudAssistantHubUrl()).toBe(`${SEEDS[name].webUrl}/assistant`);
28
44
  }
29
45
  });
46
+
47
+ test("CADET_ENVIRONMENT wins when both are set (the runtime contract)", () => {
48
+ process.env.VITE_ENVIRONMENT = "production";
49
+ process.env.CADET_ENVIRONMENT = "staging";
50
+ expect(cloudAssistantHubUrl()).toBe(`${SEEDS.staging.webUrl}/assistant`);
51
+ });
52
+
53
+ test("unset and unknown environments fall back to the dev SPA", () => {
54
+ for (const set of [
55
+ () => {
56
+ delete process.env.VITE_ENVIRONMENT;
57
+ delete process.env.CADET_ENVIRONMENT;
58
+ },
59
+ () => {
60
+ delete process.env.CADET_ENVIRONMENT;
61
+ process.env.VITE_ENVIRONMENT = "unknown-env";
62
+ },
63
+ ]) {
64
+ set();
65
+ expect(cloudAssistantHubUrl()).toBe("https://dev.mycadet.ai/assistant");
66
+ }
67
+ });
68
+ });
69
+
70
+ test("seeds.ts stays loadable by Capacitor's single-file TS config loader", () => {
71
+ // The loader transpiles the file to CJS; an import-meta reference can't be
72
+ // transpiled and makes Node execute the CJS output as ESM (`exports is not
73
+ // defined`), which took down the iOS Capacitor sync in CI.
74
+ const src = readFileSync(new URL("../seeds.ts", import.meta.url), "utf8");
75
+ expect(src).not.toContain("import.meta");
30
76
  });
@@ -1,3 +1,7 @@
1
+ // Loaded standalone by Capacitor's single-file TS config loader — keep
2
+ // imports type-only and keep this file free of the import-meta meta-property:
3
+ // the loader transpiles this file to CJS, where that syntax is illegal and
4
+ // makes Node misroute the result as ESM.
1
5
  import type { EnvironmentDefinition, PortMap } from "./types.js";
2
6
 
3
7
  /**
@@ -24,30 +28,24 @@ function portBlock(base: number): PortMap {
24
28
  };
25
29
  }
26
30
 
27
- /**
28
- * Base URL of the cloud-hosted assistant SPA (the "hub") for a deployment
29
- * environment: always `${SEEDS[env].webUrl}/assistant`. The Capacitor boot
30
- * bundle stamps this into baked mobile builds as `handoffUrl`, and the CLI's
31
- * remote-web edge stamps it into the served config as `hubUrl`, so the
32
- * environment-to-hub mapping lives here exactly once. Unknown environment
33
- * names fall back to the dev SPA defensively.
34
- *
35
- * The `/assistant` suffix is deliberate: booting on the bare host lands on
36
- * the marketing page, whose CTA redirects to `mycadet.ai/assistant` and
37
- * bounces non-prod shells off their own host.
38
- *
39
- * NOTE: this module is loaded by Capacitor's single-file TS config loader
40
- * (via the `@mycadet/environments/seeds` subpath), which cannot follow the
41
- * package index's `.js`-suffixed runtime re-exports. Keep this file's
42
- * imports type-only so it stays loadable on its own.
43
- */
44
- export function cloudWebUrl(envName: string | undefined): string {
31
+ /** Web origin for the current environment (CADET_ENVIRONMENT or VITE_ENVIRONMENT; unknown falls back to dev). */
32
+ export function cloudWebUrl(): string {
33
+ // globalThis.process reads the same env under bun/node while staying
34
+ // crash-free in browser bundles (no bare `process` reference) — and free
35
+ // of import-meta syntax, which the Capacitor config loader can't transpile.
36
+ const env = (
37
+ globalThis as unknown as {
38
+ process?: { env?: Record<string, string | undefined> };
39
+ }
40
+ ).process?.env;
41
+ const envName = env?.CADET_ENVIRONMENT ?? env?.VITE_ENVIRONMENT;
45
42
  const seed = (envName && SEEDS[envName]) || SEEDS.dev;
46
43
  return seed.webUrl;
47
44
  }
48
45
 
49
- export function cloudAssistantHubUrl(envName: string | undefined): string {
50
- return `${cloudWebUrl(envName)}/assistant`;
46
+ /** The cloud assistant hub — booting at the bare host bounces non-prod shells. */
47
+ export function cloudAssistantHubUrl(): string {
48
+ return `${cloudWebUrl()}/assistant`;
51
49
  }
52
50
 
53
51
  /**
@@ -5,6 +5,7 @@
5
5
  "exports": {
6
6
  ".": "./github-repository.ts",
7
7
  "./github-repository": "./github-repository.ts",
8
- "./scripts/run-isolated-tests": "./scripts/run-isolated-tests.ts"
8
+ "./scripts/run-isolated-tests": "./scripts/run-isolated-tests.ts",
9
+ "./version": "./version.ts"
9
10
  }
10
11
  }
@@ -1,5 +1,5 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { existsSync } from "node:fs";
2
+ import { existsSync, readFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
 
5
5
  /**
@@ -69,7 +69,7 @@ function headCommitTime(root: string): Date | null {
69
69
  return Number.isNaN(parsed.getTime()) ? null : parsed;
70
70
  }
71
71
 
72
- export function displayVersion(
72
+ export function stampedVersion(
73
73
  base: string,
74
74
  now: Date = new Date(),
75
75
  entryPath: string = import.meta.path,
@@ -85,3 +85,23 @@ export function displayVersion(
85
85
  const stamp = headCommitTime(root) ?? now;
86
86
  return `${base}-local.${utcStamp(stamp)}.${sha}`;
87
87
  }
88
+
89
+ /**
90
+ * The version the calling package reports: its own package.json version,
91
+ * stamped for local-environment source builds, plain otherwise — release
92
+ * versions are decided by the release pipeline, never the machine.
93
+ */
94
+ export function resolveVersion(packageRoot: string = process.cwd()): string {
95
+ let base = "";
96
+ try {
97
+ const pkg = JSON.parse(
98
+ readFileSync(join(packageRoot, "package.json"), "utf8"),
99
+ ) as { version?: string };
100
+ base = typeof pkg.version === "string" ? pkg.version : "";
101
+ } catch {
102
+ return "";
103
+ }
104
+ if (!base) return "";
105
+ if ((process.env.CADET_ENVIRONMENT || "local") !== "local") return base;
106
+ return stampedVersion(base, new Date(), import.meta.path);
107
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/cli",
3
- "version": "0.13.0-dev.202610201855.522ff0d",
3
+ "version": "0.13.0-dev.202610211119.c9ac8c3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/vargasjr-dev/mycadet-temp.git"
@@ -26,13 +26,13 @@ import {
26
26
  import { z } from "zod";
27
27
 
28
28
  import * as httpClient from "../lib/http-client.js";
29
- import * as localVersionModule from "../lib/local-version.js";
29
+ import * as versionModule from "@mycadet/shared/version";
30
30
  import type { AssistantEntry } from "../lib/assistant-config.js";
31
31
 
32
32
  const realChildProcess = { ...childProcess };
33
33
  const realFs = { ...fsModule };
34
34
  const realHttpClient = { ...httpClient };
35
- const realLocalVersion = { ...localVersionModule };
35
+ const realVersionModule = { ...versionModule };
36
36
 
37
37
  const execFileSyncMock = mock(childProcess.execFileSync);
38
38
  const spawnSyncMock = mock(childProcess.spawnSync);
@@ -78,12 +78,12 @@ mock.module("../lib/http-client.js", () => ({
78
78
  waitForDaemonReady: waitForDaemonReadyMock,
79
79
  }));
80
80
 
81
- // The edge stamps the CLI's own displayVersion as the served version — a
81
+ // The edge stamps the CLI's own stampedVersion as the served version — a
82
82
  // fixed value here keeps the fingerprint replicas below exact.
83
- const displayVersionMock = mock(() => "1.2.3");
83
+ const stampedVersionMock = mock(() => "1.2.3");
84
84
 
85
- mock.module("../lib/local-version.js", () => ({
86
- displayVersion: displayVersionMock,
85
+ mock.module("@mycadet/shared/version", () => ({
86
+ stampedVersion: stampedVersionMock,
87
87
  }));
88
88
 
89
89
  // Restore the real modules once this file finishes so the mocks do not leak
@@ -92,7 +92,7 @@ afterAll(() => {
92
92
  mock.module("node:child_process", () => realChildProcess);
93
93
  mock.module("node:fs", () => realFs);
94
94
  mock.module("../lib/http-client.js", () => realHttpClient);
95
- mock.module("../lib/local-version.js", () => realLocalVersion);
95
+ mock.module("@mycadet/shared/version", () => realVersionModule);
96
96
  });
97
97
 
98
98
  import {
@@ -151,8 +151,8 @@ afterEach(() => {
151
151
  existsSyncMock.mockImplementation(realFs.existsSync);
152
152
  readFileSyncMock.mockReset();
153
153
  readFileSyncMock.mockImplementation(realFs.readFileSync);
154
- displayVersionMock.mockReset();
155
- displayVersionMock.mockImplementation(() => "1.2.3");
154
+ stampedVersionMock.mockReset();
155
+ stampedVersionMock.mockImplementation(() => "1.2.3");
156
156
  waitForDaemonReadyMock.mockReset();
157
157
  waitForDaemonReadyMock.mockImplementation(async () => true);
158
158
  for (const dir of workspaces.splice(0)) {
@@ -35,7 +35,6 @@ describe("getBuilderManagedEnvKeys", () => {
35
35
  expect(always.has(key)).toBe(true);
36
36
  }
37
37
 
38
- expect(always.has("CADET_DISABLE_CLOUD")).toBe(false);
39
38
  expect(always.has("CADET_DEVICE_ID")).toBe(false);
40
39
  });
41
40
 
@@ -126,7 +125,7 @@ describe("buildServiceRunArgs extra env routing", () => {
126
125
  gatewayContainer: "test-gateway",
127
126
  network: "test-net",
128
127
  },
129
- extraGatewayEnv: { CADET_DISABLE_CLOUD: "1" },
128
+ extraGatewayEnv: { BAR: "1" },
130
129
  extraAssistantEnv: { FOO: "bar" },
131
130
  };
132
131
 
@@ -134,19 +133,19 @@ describe("buildServiceRunArgs extra env routing", () => {
134
133
 
135
134
  test("extraGatewayEnv lands only in gateway args", () => {
136
135
  const gatewayArgs = runArgs.gateway();
137
- expect(gatewayArgs).toContain("CADET_DISABLE_CLOUD=1");
136
+ expect(gatewayArgs).toContain("BAR=1");
138
137
  expect(gatewayArgs).not.toContain("FOO=bar");
139
138
  });
140
139
 
141
140
  test("extraAssistantEnv lands only in assistant args", () => {
142
141
  const assistantArgs = runArgs.assistant();
143
142
  expect(assistantArgs).toContain("FOO=bar");
144
- expect(assistantArgs).not.toContain("CADET_DISABLE_CLOUD=1");
143
+ expect(assistantArgs).not.toContain("BAR=1");
145
144
  });
146
145
 
147
146
  test("credential-executor args get neither extra env map", () => {
148
147
  const cesArgs = runArgs["credential-executor"]();
149
- expect(cesArgs).not.toContain("CADET_DISABLE_CLOUD=1");
148
+ expect(cesArgs).not.toContain("BAR=1");
150
149
  expect(cesArgs).not.toContain("FOO=bar");
151
150
  });
152
151
 
@@ -17,19 +17,19 @@ afterEach(() => {
17
17
  });
18
18
 
19
19
  describe("buildReplayEnv", () => {
20
- test("gateway: drops secrets, statics, and PATH; keeps flag overrides", () => {
20
+ test("gateway: drops secrets, statics, and PATH; keeps the rest", () => {
21
21
  const captured = {
22
22
  GUARDIAN_BOOTSTRAP_SECRET: "s1",
23
23
  CES_SERVICE_TOKEN: "s2",
24
24
  ACTOR_TOKEN_SIGNING_KEY: "s3",
25
25
  PATH: "/usr/bin",
26
26
  GATEWAY_PORT: "18080",
27
- CADET_DISABLE_CLOUD: "1",
27
+ CADET_TELEMETRY: "1",
28
28
  CADET_DEVICE_ID: "abc",
29
29
  };
30
30
 
31
31
  expect(buildReplayEnv(captured, "gateway")).toEqual({
32
- CADET_DISABLE_CLOUD: "1",
32
+ CADET_TELEMETRY: "1",
33
33
  CADET_DEVICE_ID: "abc",
34
34
  });
35
35
  });
@@ -118,9 +118,9 @@ describe("buildReplayState", () => {
118
118
  });
119
119
 
120
120
  test("backfills CADET_DEVICE_ID on gateway replay env when absent", () => {
121
- const state = buildReplayState({}, { CADET_DISABLE_CLOUD: "1" });
121
+ const state = buildReplayState({}, { CADET_TELEMETRY: "1" });
122
122
  expect(state.extraGatewayEnv).toEqual({
123
- CADET_DISABLE_CLOUD: "1",
123
+ CADET_TELEMETRY: "1",
124
124
  CADET_DEVICE_ID: "host-device-id",
125
125
  });
126
126
  });
@@ -1,22 +1,22 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { execSync } from "node:child_process";
3
3
 
4
- import { displayVersion } from "../lib/local-version.js";
4
+ import { stampedVersion } from "@mycadet/shared/version";
5
5
  import { environmentFromVersion } from "../lib/environments/resolve.js";
6
6
  import { isLocalVersion, parseVersion } from "../lib/version-compat.js";
7
7
 
8
- describe("displayVersion", () => {
8
+ describe("stampedVersion", () => {
9
9
  test("stamps source checkouts with a -local. postfix in the dev-release format", () => {
10
10
  // In the repo the CLI always runs as Bun-executed TypeScript with git
11
11
  // history, so the stamp applies. Format mirrors dev-release.yaml:
12
12
  // `<base>-local.<yyyymmddhhmm>.<shortsha>`.
13
- expect(displayVersion("0.13.0")).toMatch(
13
+ expect(stampedVersion("0.13.0")).toMatch(
14
14
  /^0\.13\.0-local\.\d{12}\.[0-9a-f]{7,}$/,
15
15
  );
16
16
  });
17
17
 
18
18
  test("stamped version parses as semver and denotes a local build", () => {
19
- const version = displayVersion("0.13.0");
19
+ const version = stampedVersion("0.13.0");
20
20
  expect(parseVersion(version)?.pre).toMatch(/^local\.\d{12}\.[0-9a-f]{7,}$/);
21
21
  expect(isLocalVersion(version)).toBe(true);
22
22
  });
@@ -25,13 +25,13 @@ describe("displayVersion", () => {
25
25
  // `cadet-local` pins CADET_ENVIRONMENT anyway, but the version stamp and
26
26
  // the environment mapping must agree so a source checkout is legible as
27
27
  // a local build no matter which signal is consulted.
28
- expect(environmentFromVersion(displayVersion("0.13.0"))).toBe("local");
28
+ expect(environmentFromVersion(stampedVersion("0.13.0"))).toBe("local");
29
29
  });
30
30
 
31
31
  test("non-source entries keep the plain package version", () => {
32
32
  // Compiled installs run from a non-.ts entry: no stamp, so the release
33
33
  // pipeline's version stays authoritative there.
34
- expect(displayVersion("0.13.0", new Date(), "/usr/local/bin/mycadet")).toBe(
34
+ expect(stampedVersion("0.13.0", new Date(), "/usr/local/bin/mycadet")).toBe(
35
35
  "0.13.0",
36
36
  );
37
37
  });
@@ -40,7 +40,7 @@ describe("displayVersion", () => {
40
40
  // The sha is what makes the stamp meaningful; a tarball checkout can't
41
41
  // produce one, so it keeps the plain version rather than a half-stamp.
42
42
  expect(
43
- displayVersion("0.13.0", new Date(), "/opt/src/cli/src/index.ts"),
43
+ stampedVersion("0.13.0", new Date(), "/opt/src/cli/src/index.ts"),
44
44
  ).toBe("0.13.0");
45
45
  });
46
46
 
@@ -56,6 +56,6 @@ describe("displayVersion", () => {
56
56
  .replace(/[-:T]/g, "")
57
57
  .slice(0, 12);
58
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}`);
59
+ expect(stampedVersion("0.13.0")).toBe(`0.13.0-local.${stamp}.${sha}`);
60
60
  });
61
61
  });
@@ -61,7 +61,7 @@ import {
61
61
  type CliInvocation,
62
62
  } from "@mycadet/local-mode";
63
63
  import { parseAssistantTargetArg } from "../lib/assistant-target-args.js";
64
- import { displayVersion } from "../lib/local-version.js";
64
+ import { stampedVersion } from "@mycadet/shared/version";
65
65
  import cliPkg from "../../package.json";
66
66
  import {
67
67
  fetchOrganizationId,
@@ -140,7 +140,6 @@ interface ParsedArgs {
140
140
  bearerToken?: string;
141
141
  /** Interface identifier sent as X-Cadet-Interface-Id on all requests. */
142
142
  interfaceId: SupportedInterface;
143
- disableCloud: boolean;
144
143
  /** Auto-open the web interface in the default browser (--interface web only). */
145
144
  openBrowser: boolean;
146
145
  /** Explicit web server port (--interface web only). Binds strictly — no scan. */
@@ -171,10 +170,6 @@ function readWorkspaceRoot(entry: AssistantEntry | null): string | undefined {
171
170
 
172
171
  // Exported for unit testing the arg/auth resolution without launching the TUI.
173
172
  export function parseArgs(): ParsedArgs {
174
- const disableCloudAmbient =
175
- process.env.CADET_DISABLE_CLOUD?.trim().toLowerCase();
176
- let disableCloud =
177
- disableCloudAmbient === "true" || disableCloudAmbient === "1";
178
173
  const args = process.argv.slice(3);
179
174
 
180
175
  const positionalName = parseAssistantTargetArg(args, [
@@ -198,8 +193,6 @@ export function parseArgs(): ParsedArgs {
198
193
  if (arg === "--help" || arg === "-h") {
199
194
  printUsage();
200
195
  process.exit(0);
201
- } else if (arg === "--disable-cloud") {
202
- disableCloud = true;
203
196
  } else if (arg === "--no-open") {
204
197
  openBrowserPref = false;
205
198
  } else if (arg === "--background") {
@@ -344,7 +337,6 @@ export function parseArgs(): ParsedArgs {
344
337
  cloudToken,
345
338
  bearerToken,
346
339
  interfaceId,
347
- disableCloud,
348
340
  openBrowser: openBrowserPref,
349
341
  webPort,
350
342
  background,
@@ -374,8 +366,6 @@ ${ANSI.bold}OPTIONS:${ANSI.reset}
374
366
  --background Run the web server as a background process
375
367
  (--interface web). Prints the URL, PID, and log
376
368
  path, then returns to the shell.
377
- --flag <key=value> Feature flag override (repeatable, kebab-case key)
378
- --disable-cloud Suppress all outbound platform API calls
379
369
  -h, --help Show this help message
380
370
 
381
371
  ${ANSI.bold}EXAMPLES:${ANSI.reset}
@@ -1288,7 +1278,6 @@ export function buildWebInterfaceConfig(opts: {
1288
1278
  }
1289
1279
 
1290
1280
  async function runWebInterface(
1291
- disableCloud: boolean,
1292
1281
  openInBrowser: boolean,
1293
1282
  webPort: number | undefined,
1294
1283
  ): Promise<void> {
@@ -1296,7 +1285,7 @@ async function runWebInterface(
1296
1285
  // (HMR, __local endpoints, gateway proxy).
1297
1286
  const webSourceDir = findWebSourceDir();
1298
1287
  if (webSourceDir) {
1299
- return runViteDevServer(webSourceDir, disableCloud, openInBrowser, webPort);
1288
+ return runViteDevServer(webSourceDir, openInBrowser, webPort);
1300
1289
  }
1301
1290
 
1302
1291
  const distDir = findWebDistDir();
@@ -1317,7 +1306,7 @@ async function runWebInterface(
1317
1306
  const configJson = safeJson(
1318
1307
  buildWebInterfaceConfig({
1319
1308
  cloudUrl,
1320
- version: displayVersion(cliPkg.version),
1309
+ version: stampedVersion(cliPkg.version),
1321
1310
  }),
1322
1311
  );
1323
1312
  const indexHtml = rawIndexHtml.replace(
@@ -1489,7 +1478,6 @@ async function runWebInterface(
1489
1478
 
1490
1479
  async function runViteDevServer(
1491
1480
  webSourceDir: string,
1492
- disableCloud: boolean,
1493
1481
  openInBrowser: boolean,
1494
1482
  webPort: number | undefined,
1495
1483
  ): Promise<void> {
@@ -1510,7 +1498,6 @@ async function runViteDevServer(
1510
1498
  windowsHide: true,
1511
1499
  env: {
1512
1500
  ...process.env,
1513
- ...(disableCloud ? { VITE_CADET_DISABLE_CLOUD: "true" } : {}),
1514
1501
  VITE_WEB_MODE: "full",
1515
1502
  API_PROXY_TARGET: cloudUrl,
1516
1503
  CADET_WEB_URL: getWebUrl(),
@@ -1595,22 +1582,17 @@ export const client = Object.assign(
1595
1582
  cloudToken,
1596
1583
  bearerToken,
1597
1584
  interfaceId,
1598
- disableCloud,
1599
1585
  openBrowser: openInBrowser,
1600
1586
  webPort,
1601
1587
  background,
1602
1588
  } = parseArgs();
1603
1589
 
1604
- if (disableCloud) {
1605
- process.env.CADET_DISABLE_CLOUD = "true";
1606
- }
1607
-
1608
1590
  if (interfaceId === WEB_INTERFACE_ID) {
1609
1591
  if (background) {
1610
1592
  await spawnBackgroundWebInterface(webPort);
1611
1593
  return;
1612
1594
  }
1613
- await runWebInterface(disableCloud, openInBrowser, webPort);
1595
+ await runWebInterface(openInBrowser, webPort);
1614
1596
  return;
1615
1597
  }
1616
1598
 
package/src/index.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  } from "@mycadet/local-mode";
10
10
 
11
11
  import { emitCliError } from "./lib/cli-error.js";
12
- import { displayVersion } from "./lib/local-version.js";
12
+ import { stampedVersion } from "@mycadet/shared/version";
13
13
 
14
14
  import cliPkg from "../package.json";
15
15
  import { backup } from "./commands/backup";
@@ -212,7 +212,7 @@ async function main() {
212
212
  process.argv = [...process.argv.slice(0, 2), ...filteredArgs];
213
213
 
214
214
  if (commandName === "--version" || commandName === "-v") {
215
- console.log(`@mycadet/cli v${displayVersion(cliPkg.version)}`);
215
+ console.log(`@mycadet/cli v${stampedVersion(cliPkg.version)}`);
216
216
  process.exit(0);
217
217
  }
218
218
 
package/src/lib/docker.ts CHANGED
@@ -293,7 +293,6 @@ export interface HatchDockerParams {
293
293
  watch?: boolean;
294
294
  /** Hatch-time config values (key → value). */
295
295
  configValues?: Record<string, string>;
296
- /** Extra env vars forwarded into the assistant container. */
297
296
  setupProviderCredentials?: boolean;
298
297
  /** Whole-installation state installed into stopped containers before startup. */
299
298
  initialArchive?: string;
@@ -158,7 +158,6 @@ export interface HatchLocalParams {
158
158
  watch?: boolean;
159
159
  /** Hatch-time config values (key → value). */
160
160
  configValues?: Record<string, string>;
161
- /** Extra env vars forwarded into the assistant process. */
162
161
  setupProviderCredentials?: boolean;
163
162
  /** Whole-installation state installed before the first service startup. */
164
163
  initialArchive?: string;
package/src/lib/local.ts CHANGED
@@ -1681,7 +1681,6 @@ export async function startLocalDaemon(
1681
1681
  "CADET_DEBUG",
1682
1682
  "CADET_DEV",
1683
1683
  "CADET_DESKTOP_APP",
1684
- "CADET_DISABLE_CLOUD",
1685
1684
  "CADET_MIGRATION_EXPORT_ALLOWED_HOSTS",
1686
1685
  "CADET_MIGRATION_IMPORT_ALLOWED_HOSTS",
1687
1686
  "CADET_WORKSPACE_DIR",
@@ -22,7 +22,7 @@ import { z } from "zod";
22
22
  import { cloudAssistantHubUrl } from "@mycadet/environments";
23
23
 
24
24
  import cliPkg from "../../package.json";
25
- import { displayVersion } from "./local-version.js";
25
+ import { stampedVersion } from "@mycadet/shared/version";
26
26
 
27
27
  import {
28
28
  clearAppProcessRecord,
@@ -33,7 +33,6 @@ import {
33
33
  type AssistantEntry,
34
34
  } from "./assistant-config.js";
35
35
  import type { RemoteHost } from "./constants.js";
36
- import { getCurrentEnvironment } from "./environments/resolve.js";
37
36
  import { waitForDaemonReady } from "./http-client.js";
38
37
  import {
39
38
  getDefaultWorkspaceDir,
@@ -1231,12 +1230,12 @@ export async function startRemoteWebIngress(opts: {
1231
1230
  }
1232
1231
  // The edge serves the CLI's own bundles, so the version it stamps answers
1233
1232
  // "which cadet is running this" — the CLI's own stamp, not the gateway
1234
- // runtime's. displayVersion is stable for a given checkout (the stamp's
1233
+ // runtime's. stampedVersion is stable for a given checkout (the stamp's
1235
1234
  // timestamp is the HEAD commit's), so the fingerprint below never drifts
1236
1235
  // between processes.
1237
- const version = displayVersion(cliPkg.version);
1236
+ const version = stampedVersion(cliPkg.version);
1238
1237
  const spaOptions = {
1239
- hubUrl: cloudAssistantHubUrl(getCurrentEnvironment().name),
1238
+ hubUrl: cloudAssistantHubUrl(),
1240
1239
  assistantName: opts.assistantName,
1241
1240
  assistantId: opts.assistantId,
1242
1241
  version,