@mycadet/cli 0.13.0-dev.202610312329.a740c1c → 0.13.0-dev.202611011818.51165c0

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 (167) hide show
  1. package/eslint.config.mjs +8 -0
  2. package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/package.json +1 -1
  3. package/node_modules/@mycadet/avatar-manifest/package.json +1 -1
  4. package/node_modules/@mycadet/environments/package.json +1 -1
  5. package/node_modules/@mycadet/ipc-server-utils/package.json +1 -1
  6. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/avatar-manifest/package.json +1 -1
  7. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/package.json +1 -1
  8. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/package.json +1 -1
  9. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/shared/eslint/no-re-exports.mjs +136 -0
  10. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/shared/eslint/no-re-exports.test.mjs +167 -0
  11. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/shared/package.json +7 -2
  12. package/node_modules/@mycadet/local-mode/package.json +1 -1
  13. package/node_modules/@mycadet/local-mode/src/__tests__/gateway-proxy.test.ts +0 -108
  14. package/node_modules/@mycadet/local-mode/src/__tests__/helpers/child-process-mock.ts +3 -0
  15. package/node_modules/@mycadet/local-mode/src/__tests__/helpers/lockfile-entry.ts +120 -0
  16. package/node_modules/@mycadet/local-mode/src/__tests__/operations-retire.test.ts +331 -0
  17. package/node_modules/@mycadet/local-mode/src/__tests__/operations-sleep.test.ts +470 -0
  18. package/{src/__tests__/retire-archive.test.ts → node_modules/@mycadet/local-mode/src/__tests__/remotes-local-archive.test.ts} +1 -1
  19. package/{src/__tests__/drain.test.ts → node_modules/@mycadet/local-mode/src/__tests__/remotes-local-drain.test.ts} +1 -1
  20. package/node_modules/@mycadet/local-mode/src/__tests__/remotes-local-retire.test.ts +424 -0
  21. package/node_modules/@mycadet/local-mode/src/cli-invocation.ts +1 -1
  22. package/node_modules/@mycadet/local-mode/src/cloud-auth.ts +194 -0
  23. package/node_modules/@mycadet/local-mode/src/config.ts +19 -12
  24. package/node_modules/@mycadet/local-mode/src/environment.ts +13 -0
  25. package/node_modules/@mycadet/local-mode/src/exec.ts +105 -0
  26. package/node_modules/@mycadet/local-mode/src/gateway-bearer.ts +2 -2
  27. package/node_modules/@mycadet/local-mode/src/gateway-proxy.ts +0 -61
  28. package/node_modules/@mycadet/local-mode/src/guardian-token.ts +37 -12
  29. package/node_modules/@mycadet/local-mode/src/index.ts +87 -7
  30. package/node_modules/@mycadet/local-mode/src/ingress.ts +229 -0
  31. package/node_modules/@mycadet/local-mode/src/lifecycle-reporter.ts +31 -0
  32. package/node_modules/@mycadet/local-mode/src/lockfile-contract.test.ts +151 -0
  33. package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +86 -0
  34. package/node_modules/@mycadet/local-mode/src/operations/lookup.ts +141 -0
  35. package/node_modules/@mycadet/local-mode/src/operations/retire.ts +93 -0
  36. package/node_modules/@mycadet/local-mode/src/operations/routes.ts +114 -0
  37. package/node_modules/@mycadet/local-mode/src/operations/sleep.ts +78 -0
  38. package/node_modules/@mycadet/local-mode/src/process.ts +357 -0
  39. package/{src/lib/retire-apple-container.ts → node_modules/@mycadet/local-mode/src/remotes/apple-container/retire.ts} +23 -18
  40. package/node_modules/@mycadet/local-mode/src/remotes/cloud/retire.ts +128 -0
  41. package/node_modules/@mycadet/local-mode/src/remotes/custom/retire.ts +44 -0
  42. package/node_modules/@mycadet/local-mode/src/remotes/docker/retire.ts +108 -0
  43. package/node_modules/@mycadet/local-mode/src/remotes/docker/sleep.ts +71 -0
  44. package/{src/lib/retire-archive.ts → node_modules/@mycadet/local-mode/src/remotes/local/archive.ts} +9 -3
  45. package/{src/lib → node_modules/@mycadet/local-mode/src/remotes/local}/drain.ts +1 -2
  46. package/node_modules/@mycadet/local-mode/src/remotes/local/instance.ts +38 -0
  47. package/{src/lib/retire-local.ts → node_modules/@mycadet/local-mode/src/remotes/local/retire.ts} +37 -12
  48. package/node_modules/@mycadet/local-mode/src/remotes/local/sleep.ts +253 -0
  49. package/node_modules/@mycadet/local-mode/src/util.ts +1 -1
  50. package/node_modules/@mycadet/local-mode/src/wake.ts +1 -1
  51. package/node_modules/@mycadet/service-contracts/package.json +1 -1
  52. package/node_modules/@mycadet/shared/eslint/no-re-exports.mjs +136 -0
  53. package/node_modules/@mycadet/shared/eslint/no-re-exports.test.mjs +167 -0
  54. package/node_modules/@mycadet/shared/package.json +7 -2
  55. package/package.json +2 -2
  56. package/src/__tests__/app-command.test.ts +8 -3
  57. package/src/__tests__/assistant-config.test.ts +26 -34
  58. package/src/__tests__/backup.test.ts +2 -2
  59. package/src/__tests__/cloud-client.test.ts +1 -2
  60. package/src/__tests__/connect-import.test.ts +3 -3
  61. package/src/__tests__/debug.test.ts +2 -2
  62. package/src/__tests__/gateway-token.test.ts +22 -19
  63. package/src/__tests__/guardian-token.test.ts +17 -20
  64. package/src/__tests__/helpers/guardian-token.ts +1 -1
  65. package/src/__tests__/helpers/lockfile-entry.ts +1 -11
  66. package/src/__tests__/host-teleport-docker.test.ts +2 -2
  67. package/src/__tests__/host-teleport.test.ts +27 -8
  68. package/src/__tests__/multi-local.test.ts +4 -2
  69. package/src/__tests__/nginx.test.ts +10 -13
  70. package/src/__tests__/pair.test.ts +53 -28
  71. package/src/__tests__/ps-cloud-status.test.ts +5 -4
  72. package/src/__tests__/restore.test.ts +0 -24
  73. package/src/__tests__/retire.test.ts +38 -221
  74. package/src/__tests__/root-backup-docker.test.ts +4 -7
  75. package/src/__tests__/root-backup.test.ts +4 -3
  76. package/src/__tests__/root-process-lockfile.test.ts +1 -1
  77. package/src/__tests__/root-restore-command.test.ts +2 -1
  78. package/src/__tests__/setup.test.ts +64 -25
  79. package/src/__tests__/sleep.test.ts +295 -330
  80. package/src/__tests__/statefulset.test.ts +1 -1
  81. package/src/__tests__/teleport-backup.test.ts +4 -4
  82. package/src/__tests__/tunnel-stop.test.ts +5 -5
  83. package/src/__tests__/tunnel.test.ts +64 -217
  84. package/src/__tests__/uninstall.test.ts +6 -1
  85. package/src/__tests__/upgrade-local.test.ts +15 -46
  86. package/src/__tests__/upgrade-replay-env.test.ts +19 -7
  87. package/src/__tests__/upgrade-root-recovery.test.ts +11 -20
  88. package/src/__tests__/use.test.ts +2 -4
  89. package/src/__tests__/wake.test.ts +31 -81
  90. package/src/__tests__/windows-lifecycle.test.ts +3 -4
  91. package/src/commands/app.ts +3 -4
  92. package/src/commands/backup.ts +1 -2
  93. package/src/commands/client.ts +9 -9
  94. package/src/commands/completions.ts +1 -1
  95. package/src/commands/connect.ts +1 -1
  96. package/src/commands/debug.ts +11 -13
  97. package/src/commands/devices.ts +9 -12
  98. package/src/commands/exec.ts +7 -3
  99. package/src/commands/gateway/token.ts +9 -18
  100. package/src/commands/gateway.ts +1 -1
  101. package/src/commands/hatch.ts +7 -6
  102. package/src/commands/login.ts +8 -8
  103. package/src/commands/logs.ts +6 -5
  104. package/src/commands/pair.ts +6 -6
  105. package/src/commands/ps.ts +11 -8
  106. package/src/commands/restart.ts +1 -1
  107. package/src/commands/restore.ts +11 -17
  108. package/src/commands/retire.ts +13 -253
  109. package/src/commands/setup.ts +2 -2
  110. package/src/commands/sleep.ts +71 -278
  111. package/src/commands/teleport.ts +1 -1
  112. package/src/commands/terminal.ts +9 -7
  113. package/src/commands/tunnel.ts +8 -127
  114. package/src/commands/uninstall.ts +6 -4
  115. package/src/commands/upgrade.ts +16 -34
  116. package/src/commands/use.ts +4 -4
  117. package/src/commands/wake.ts +3 -6
  118. package/src/components/DefaultMainScreen.tsx +2 -6
  119. package/src/lib/__tests__/cloud-client-signed-url.test.ts +1 -1
  120. package/src/lib/__tests__/docker.test.ts +2 -7
  121. package/src/lib/__tests__/lifecycle-reporter.test.ts +5 -31
  122. package/src/lib/assistant-client.ts +8 -8
  123. package/src/lib/assistant-config.ts +6 -126
  124. package/src/lib/cloud-client.ts +20 -211
  125. package/src/lib/cloud-login-poll.ts +1 -2
  126. package/src/lib/cloud-login.ts +7 -5
  127. package/src/lib/cloud-releases.ts +1 -2
  128. package/src/lib/guardian-token.ts +101 -71
  129. package/src/lib/hatch-next-steps.ts +1 -1
  130. package/src/lib/health-check.ts +7 -6
  131. package/src/lib/host-teleport.ts +30 -21
  132. package/src/lib/http-client.ts +1 -1
  133. package/src/lib/lifecycle-reporter.ts +9 -21
  134. package/src/lib/live-voice/connection.ts +7 -7
  135. package/src/lib/live-voice/tunnel.ts +3 -4
  136. package/src/lib/port-heal.ts +2 -2
  137. package/src/lib/process.ts +15 -328
  138. package/src/lib/remotes/cloud.ts +1 -1
  139. package/src/lib/remotes/docker.ts +14 -188
  140. package/src/lib/remotes/local.ts +23 -205
  141. package/src/lib/root-backup.ts +7 -19
  142. package/src/lib/servers/nginx.ts +17 -221
  143. package/src/lib/statefulset.ts +0 -3
  144. package/src/lib/sync-cloud-assistants.ts +4 -7
  145. package/src/lib/teleport-backup.ts +5 -5
  146. package/src/lib/terminal-client.ts +10 -7
  147. package/src/lib/terminal-session.ts +1 -1
  148. package/src/lib/tunnel.ts +12 -110
  149. package/src/lib/tunnels/cloudflare.ts +6 -10
  150. package/src/lib/tunnels/gateway-notify.ts +4 -2
  151. package/src/lib/tunnels/ngrok.ts +15 -60
  152. package/src/lib/tunnels/process-lifecycle.ts +1 -1
  153. package/src/lib/tunnels/tailscale.ts +3 -4
  154. package/src/lib/upgrade-lifecycle.ts +37 -34
  155. package/src/lib/workos-pkce.ts +1 -1
  156. package/node_modules/@mycadet/local-mode/src/__tests__/retire.test.ts +0 -89
  157. package/node_modules/@mycadet/local-mode/src/retire.ts +0 -88
  158. package/node_modules/@mycadet/local-mode/src/sleep.ts +0 -79
  159. package/src/__tests__/detached-process.test.ts +0 -152
  160. package/src/__tests__/retire-local.test.ts +0 -215
  161. package/src/__tests__/tunnel-holder-heal.test.ts +0 -119
  162. package/src/__tests__/tunnel-startup-summary.test.ts +0 -92
  163. package/src/lib/cli-name.ts +0 -14
  164. package/src/lib/desktop-progress.ts +0 -22
  165. package/src/lib/detached-process.ts +0 -83
  166. package/src/lib/ingress-config.ts +0 -6
  167. /package/{src/lib → node_modules/@mycadet/local-mode/src}/loopback-fetch.ts +0 -0
package/eslint.config.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { defineConfig, globalIgnores } from "eslint/config";
2
2
  import tseslint from "typescript-eslint";
3
+ import { noReExports } from "@mycadet/shared/eslint/no-re-exports";
3
4
 
4
5
  const eslintConfig = defineConfig([
5
6
  ...tseslint.configs.recommended,
@@ -19,6 +20,13 @@ const eslintConfig = defineConfig([
19
20
  ],
20
21
  },
21
22
  },
23
+ {
24
+ // Re-export shims are outlawed: consumers import from the defining
25
+ // module, and only index files aggregate a public surface. Warning
26
+ // level with a pinned count — each PR chips away at the remainder.
27
+ plugins: { "@mycadet": { rules: { "no-re-exports": noReExports } } },
28
+ rules: { "@mycadet/no-re-exports": "error" },
29
+ },
22
30
  ]);
23
31
 
24
32
  export default eslintConfig;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202610312329.a740c1c",
3
+ "version": "0.13.0-dev.202611011818.51165c0",
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.202610312329.a740c1c",
3
+ "version": "0.13.0-dev.202611011818.51165c0",
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.202610312329.a740c1c",
3
+ "version": "0.13.0-dev.202611011818.51165c0",
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.202610312329.a740c1c",
3
+ "version": "0.13.0-dev.202611011818.51165c0",
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.202610312329.a740c1c",
3
+ "version": "0.13.0-dev.202611011818.51165c0",
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.202610312329.a740c1c",
3
+ "version": "0.13.0-dev.202611011818.51165c0",
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.202610312329.a740c1c",
3
+ "version": "0.13.0-dev.202611011818.51165c0",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,136 @@
1
+ // @ts-check
2
+ /**
3
+ * `no-re-exports` — outlaw re-exports of imports outside index files.
4
+ *
5
+ * A file that imports a binding only to export it again (`export { x } from
6
+ * "y"`, `export * from "y"`, or `import { x } from "y"` + `export { x }`) is
7
+ * a re-export shim: it hides the true dependency graph, gives the binding a
8
+ * second home that drifts from its defining module, and earns the same
9
+ * review comment every time — delete the re-export and update the consumers.
10
+ * This rule encodes that review.
11
+ *
12
+ * Index files (a file named `index.ts`/`index.js`/…) are the one exception:
13
+ * they are the package's public surface and may aggregate exports from the
14
+ * modules beside them. Everything else must make consumers import from the
15
+ * defining module directly.
16
+ *
17
+ * Flagged shapes:
18
+ * - `export { x } from "y"` and `export type { x } from "y"` (fused re-export)
19
+ * - `export * from "y"` and `export * as ns from "y"` (star re-export)
20
+ * - `import { x } from "y"` + `export { x }` / `export { x as z }` (shim form,
21
+ * including the type-only variants of both halves)
22
+ *
23
+ * Not flagged: `export const x = y` — it binds a NEW name this file owns
24
+ * (a wrapper, not a re-export); if that wrapper is redundant, that is a
25
+ * deletion to make in review, not a lint error here.
26
+ */
27
+
28
+ import { basename } from "node:path";
29
+
30
+ /** File extensions an index file may carry. */
31
+ const INDEX_EXTENSIONS = new Set([
32
+ ".ts",
33
+ ".tsx",
34
+ ".js",
35
+ ".jsx",
36
+ ".mjs",
37
+ ".cjs",
38
+ ".mts",
39
+ ".cts",
40
+ ]);
41
+
42
+ /**
43
+ * Whether the linted file is an index file, which may aggregate exports.
44
+ * `context.filename` is the absolute path; only the basename matters.
45
+ */
46
+ function isIndexFile(filename) {
47
+ const base = basename(filename);
48
+ const dot = base.lastIndexOf(".");
49
+ if (dot <= 0) return false;
50
+ return (
51
+ base.slice(0, dot) === "index" &&
52
+ INDEX_EXTENSIONS.has(base.slice(dot).toLowerCase())
53
+ );
54
+ }
55
+
56
+ /** The module string of an import/export source node, or a fallback. */
57
+ function moduleOf(node) {
58
+ return typeof node?.value === "string" ? node.value : "the defining module";
59
+ }
60
+
61
+ const rule = {
62
+ meta: {
63
+ type: "problem",
64
+ docs: {
65
+ description: "Outlaw re-exports of imports outside index files.",
66
+ },
67
+ schema: [],
68
+ messages: {
69
+ exportFrom:
70
+ "Re-exports are outlawed outside index files: update consumers to import from '{{module}}' directly and delete this re-export. If this file is meant to be a public surface, it should be an index file.",
71
+ exportStar:
72
+ "`export *` is outlawed outside index files: import from '{{module}}' directly, or make this file an index file whose exports are named explicitly.",
73
+ reExportedImport:
74
+ "'{{name}}' is an import re-exported back out — outside index files, consumers import from '{{module}}' directly. Export only what this file defines.",
75
+ },
76
+ },
77
+
78
+ create(context) {
79
+ if (isIndexFile(context.filename)) return {};
80
+
81
+ /** local binding name -> the module it was imported from. */
82
+ const importedBindings = new Map();
83
+
84
+ return {
85
+ // Imports are collected up front so a shim whose import trails its
86
+ // export (`export { x };` first — imports hoist at runtime) is still
87
+ // caught: visitors fire in source order, but the whole program is
88
+ // known before any export is judged. The `Program` visitor fires on
89
+ // entry, before any descendant statement is visited.
90
+ Program(program) {
91
+ for (const statement of program.body) {
92
+ if (
93
+ statement.type === "ImportDeclaration" &&
94
+ typeof statement.source?.value === "string"
95
+ ) {
96
+ for (const spec of statement.specifiers) {
97
+ importedBindings.set(spec.local.name, statement.source.value);
98
+ }
99
+ }
100
+ }
101
+ },
102
+
103
+ ExportAllDeclaration(node) {
104
+ context.report({
105
+ node,
106
+ messageId: "exportStar",
107
+ data: { module: moduleOf(node.source) },
108
+ });
109
+ },
110
+
111
+ ExportNamedDeclaration(node) {
112
+ if (node.source) {
113
+ context.report({
114
+ node,
115
+ messageId: "exportFrom",
116
+ data: { module: moduleOf(node.source) },
117
+ });
118
+ return;
119
+ }
120
+ for (const spec of node.specifiers) {
121
+ const module = importedBindings.get(spec.local.name);
122
+ if (module !== undefined) {
123
+ context.report({
124
+ node: spec,
125
+ messageId: "reExportedImport",
126
+ data: { name: spec.local.name, module },
127
+ });
128
+ }
129
+ }
130
+ },
131
+ };
132
+ },
133
+ };
134
+
135
+ export const noReExports = rule;
136
+ export default rule;
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Unit tests for the no-re-exports ESLint rule.
3
+ *
4
+ * Run with: `bun test packages/eslint-plugin/no-re-exports.test.mjs`
5
+ *
6
+ * A passing run prints "Ran 0 tests". That is a reporting artifact, not a
7
+ * skip: bun does not expose `describe` / `it` as globals to `.mjs`, so
8
+ * `RuleTester` falls back to its own inline runner and never registers with
9
+ * bun's reporter. The cases still execute, a wrong expectation still throws,
10
+ * and the process still exits non-zero. Verify by breaking a case on purpose.
11
+ */
12
+ import { RuleTester } from "eslint";
13
+ import tseslint from "typescript-eslint";
14
+
15
+ import { noReExports } from "./no-re-exports.mjs";
16
+
17
+ const ruleTester = new RuleTester({
18
+ languageOptions: {
19
+ parser: tseslint.parser,
20
+ ecmaVersion: "latest",
21
+ sourceType: "module",
22
+ },
23
+ });
24
+
25
+ ruleTester.run("no-re-exports", noReExports, {
26
+ valid: [
27
+ {
28
+ name: "a module exporting what it defines is fine",
29
+ code: [
30
+ 'import { helper } from "./helper.js";',
31
+ "",
32
+ "export function local() {",
33
+ " return helper();",
34
+ "}",
35
+ ].join("\n"),
36
+ },
37
+ {
38
+ name: "a bare export of a locally-defined binding is fine, even in a file that imports",
39
+ code: [
40
+ 'import { helper } from "./helper.js";',
41
+ "",
42
+ "const thing = helper();",
43
+ "",
44
+ "export { thing };",
45
+ ].join("\n"),
46
+ },
47
+ {
48
+ name: "a new const binding wrapping an import is a wrapper, not a re-export",
49
+ code: [
50
+ 'import { Client } from "./client.js";',
51
+ "",
52
+ "export const sharedClient = new Client();",
53
+ ].join("\n"),
54
+ },
55
+ {
56
+ name: "index files may aggregate fused re-exports",
57
+ code: [
58
+ 'export { alpha } from "./alpha.js";',
59
+ 'export type { Beta } from "./beta.js";',
60
+ ].join("\n"),
61
+ filename: "/repo/packages/some-pkg/src/index.ts",
62
+ },
63
+ {
64
+ name: "index files may aggregate star re-exports",
65
+ code: 'export * from "./alpha.js";',
66
+ filename: "/repo/packages/some-pkg/index.mjs",
67
+ },
68
+ {
69
+ name: "index files may re-export their imports",
70
+ code: [
71
+ 'import { alpha } from "./alpha.js";',
72
+ "",
73
+ "export { alpha };",
74
+ ].join("\n"),
75
+ filename: "/repo/packages/some-pkg/index.js",
76
+ },
77
+ {
78
+ name: "default exports of locally-defined things are fine",
79
+ code: [
80
+ 'import { helper } from "./helper.js";',
81
+ "",
82
+ "export default function local() {",
83
+ " return helper();",
84
+ "}",
85
+ ].join("\n"),
86
+ },
87
+ ],
88
+
89
+ invalid: [
90
+ {
91
+ name: "fused value re-export",
92
+ code: 'export { alpha } from "./alpha.js";',
93
+ errors: [{ messageId: "exportFrom" }],
94
+ },
95
+ {
96
+ name: "index exemption is basename-only: index-helper.ts is still an outlaw",
97
+ code: 'export { alpha } from "./alpha.js";',
98
+ filename: "/repo/packages/some-pkg/src/index-helper.ts",
99
+ errors: [{ messageId: "exportFrom" }],
100
+ },
101
+ {
102
+ name: "fused type re-export",
103
+ code: 'export type { Beta } from "./beta.js";',
104
+ errors: [{ messageId: "exportFrom" }],
105
+ },
106
+ {
107
+ name: "star re-export",
108
+ code: 'export * from "./alpha.js";',
109
+ errors: [{ messageId: "exportStar" }],
110
+ },
111
+ {
112
+ name: "star-as re-export",
113
+ code: 'export * as ns from "./alpha.js";',
114
+ errors: [{ messageId: "exportStar" }],
115
+ },
116
+ {
117
+ name: "shim form: import then bare export",
118
+ code: [
119
+ 'import { alpha } from "./alpha.js";',
120
+ "",
121
+ "export { alpha };",
122
+ ].join("\n"),
123
+ errors: [{ messageId: "reExportedImport" }],
124
+ },
125
+ {
126
+ name: "shim form under a new name",
127
+ code: [
128
+ 'import { alpha } from "./alpha.js";',
129
+ "",
130
+ "export { alpha as beta };",
131
+ ].join("\n"),
132
+ errors: [{ messageId: "reExportedImport" }],
133
+ },
134
+ {
135
+ name: "type-only shim form",
136
+ code: [
137
+ 'import type { Alpha } from "./alpha.js";',
138
+ "",
139
+ "export type { Alpha };",
140
+ ].join("\n"),
141
+ errors: [{ messageId: "reExportedImport" }],
142
+ },
143
+ {
144
+ name: "the import can trail the export (imports hoist)",
145
+ code: [
146
+ "export { alpha };",
147
+ "",
148
+ 'import { alpha } from "./alpha.js";',
149
+ ].join("\n"),
150
+ errors: [{ messageId: "reExportedImport" }],
151
+ },
152
+ {
153
+ name: "several shims in one file each report",
154
+ code: [
155
+ 'import { alpha, beta } from "./alpha.js";',
156
+ 'import { gamma } from "./gamma.js";',
157
+ "",
158
+ "export { alpha, beta, gamma };",
159
+ ].join("\n"),
160
+ errors: [
161
+ { messageId: "reExportedImport" },
162
+ { messageId: "reExportedImport" },
163
+ { messageId: "reExportedImport" },
164
+ ],
165
+ },
166
+ ],
167
+ });
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "@mycadet/shared",
3
- "version": "0.13.0-dev.202610312329.a740c1c",
3
+ "version": "0.13.0-dev.202611011818.51165c0",
4
4
  "private": true,
5
5
  "exports": {
6
6
  ".": "./github-repository.ts",
7
7
  "./github-repository": "./github-repository.ts",
8
8
  "./providers/baseten": "./providers/baseten.ts",
9
9
  "./scripts/run-isolated-tests": "./scripts/run-isolated-tests.ts",
10
- "./version": "./version.ts"
10
+ "./version": "./version.ts",
11
+ "./eslint/no-re-exports": "./eslint/no-re-exports.mjs"
12
+ },
13
+ "devDependencies": {
14
+ "eslint": "10.1.0",
15
+ "typescript-eslint": "8.58.0"
11
16
  }
12
17
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/local-mode",
3
- "version": "0.13.0-dev.202610312329.a740c1c",
3
+ "version": "0.13.0-dev.202611011818.51165c0",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -12,7 +12,6 @@ import {
12
12
  authorizePairedForwardHeaders,
13
13
  parseAssistantGatewayUrl,
14
14
  readGatewayTargets,
15
- resolveAssistantRetireProxyDecision,
16
15
  resolveGatewayProxyTarget,
17
16
  sanitizePairedForwardHeaders,
18
17
  } from "../gateway-proxy";
@@ -429,110 +428,3 @@ describe("remote-forward header handling", () => {
429
428
  expect(headers.get("authorization")).toBe("Bearer host-token");
430
429
  });
431
430
  });
432
-
433
- describe("resolveAssistantRetireProxyDecision", () => {
434
- const noLockfile = () => null as never;
435
- const withEntries =
436
- (...entries: unknown[]) =>
437
- () => ({ assistants: entries });
438
-
439
- const localEntry = { assistantId: "asst-local", cloud: "local", port: 7830 };
440
- const dockerEntry = {
441
- assistantId: "asst-docker",
442
- cloud: "docker",
443
- port: 7831,
444
- };
445
- const appleEntry = {
446
- assistantId: "asst-apple",
447
- cloud: "apple-container",
448
- mgmtSocket: "/tmp/mgmt.sock",
449
- };
450
- const cloudEntry = {
451
- assistantId: "asst-cloud",
452
- cloud: "cloud",
453
- };
454
- const pairedEntry = {
455
- assistantId: "asst-paired",
456
- cloud: "custom",
457
- runtimeUrl: "https://gw.example.com",
458
- };
459
-
460
- test("non-DELETE methods pass without consulting the lockfile", () => {
461
- expect(
462
- resolveAssistantRetireProxyDecision(
463
- "/v1/assistants/asst-local/retire/",
464
- "POST",
465
- withEntries(localEntry),
466
- ),
467
- ).toEqual({ kind: "pass" });
468
- // The thunk is never called for a bail, so null proves the point.
469
- expect(
470
- resolveAssistantRetireProxyDecision(
471
- "/v1/assistants/asst-local/retire/",
472
- "GET",
473
- noLockfile,
474
- ),
475
- ).toEqual({ kind: "pass" });
476
- });
477
-
478
- test("non-retire paths pass without consulting the lockfile", () => {
479
- expect(
480
- resolveAssistantRetireProxyDecision(
481
- "/v1/assistants/asst-local/conversations",
482
- "DELETE",
483
- noLockfile,
484
- ),
485
- ).toEqual({ kind: "pass" });
486
- });
487
-
488
- test("a host-retirable entry resolves to retireLocal", () => {
489
- expect(
490
- resolveAssistantRetireProxyDecision(
491
- "/v1/assistants/asst-local/retire/",
492
- "DELETE",
493
- withEntries(localEntry),
494
- ),
495
- ).toEqual({ kind: "retireLocal", assistantId: "asst-local" });
496
- expect(
497
- resolveAssistantRetireProxyDecision(
498
- "/v1/assistants/asst-docker/retire/",
499
- "DELETE",
500
- withEntries(dockerEntry),
501
- ),
502
- ).toEqual({ kind: "retireLocal", assistantId: "asst-docker" });
503
- expect(
504
- resolveAssistantRetireProxyDecision(
505
- "/v1/assistants/asst-apple/retire/",
506
- "DELETE",
507
- withEntries(appleEntry),
508
- ),
509
- ).toEqual({ kind: "retireLocal", assistantId: "asst-apple" });
510
- });
511
-
512
- test("cloud and paired entries pass through to the endpoint's forward", () => {
513
- expect(
514
- resolveAssistantRetireProxyDecision(
515
- "/v1/assistants/asst-cloud/retire/",
516
- "DELETE",
517
- withEntries(cloudEntry),
518
- ),
519
- ).toEqual({ kind: "pass" });
520
- expect(
521
- resolveAssistantRetireProxyDecision(
522
- "/v1/assistants/asst-paired/retire/",
523
- "DELETE",
524
- withEntries(pairedEntry),
525
- ),
526
- ).toEqual({ kind: "pass" });
527
- });
528
-
529
- test("an id the lockfile does not know passes", () => {
530
- expect(
531
- resolveAssistantRetireProxyDecision(
532
- "/v1/assistants/ghost/retire/",
533
- "DELETE",
534
- withEntries(localEntry),
535
- ),
536
- ).toEqual({ kind: "pass" });
537
- });
538
- });
@@ -9,6 +9,9 @@ export class FakeChild extends EventEmitter {
9
9
  stdout = new EventEmitter();
10
10
  stderr = new EventEmitter();
11
11
  kill = mock(() => true);
12
+ // Detached spawns (the retire archive's background tar) unref the child so
13
+ // the parent can exit first.
14
+ unref = mock(() => {});
12
15
  }
13
16
 
14
17
  /** Any stand-in for `spawn`; each suite records the arguments it asserts on. */
@@ -0,0 +1,120 @@
1
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname } from "node:path";
3
+
4
+ import {
5
+ LockfileAssistantSchema,
6
+ type LocalAssistant,
7
+ type LockfileAssistant,
8
+ type Remote,
9
+ } from "../../lockfile-contract";
10
+
11
+ import { resolveLockfilePath } from "../../config";
12
+
13
+ /**
14
+ * The canonical lockfile-entry fixture — one `makeEntry` for every suite.
15
+ * Writes the entry straight into the lockfile the suite has pointed the
16
+ * process at (via `XDG_CONFIG_HOME`) and returns void: suites that need the
17
+ * object read it back with `readEntry`. The entry parses through
18
+ * `LockfileAssistantSchema` so the shape is always the contract's.
19
+ */
20
+ export type EntryOverrides = {
21
+ assistantId?: string;
22
+ name?: string;
23
+ cloud?: Remote;
24
+ instanceDir?: string;
25
+ watcherPid?: number;
26
+ containerInfo?: Record<string, unknown>;
27
+ mgmtSocket?: string;
28
+ cloudAssistantId?: string;
29
+ cloudBaseUrl?: string;
30
+ cloudOrganizationId?: string;
31
+ ipAddress?: string;
32
+ port?: number;
33
+ daemonPort?: number;
34
+ cesPort?: number;
35
+ sandboxUrl?: string;
36
+ hatchedAt?: string;
37
+ onboardedAt?: string;
38
+ };
39
+
40
+ /** The placement a fresh local fixture carries. */
41
+ export const BASE_PLACEMENT = {
42
+ instanceDir: "/tmp/cadet-test-instance",
43
+ daemonPort: 7801,
44
+ port: 7831,
45
+ cesPort: 7790,
46
+ };
47
+
48
+ function readLockfileRaw(): Record<string, unknown> {
49
+ try {
50
+ const raw = JSON.parse(readFileSync(resolveLockfilePath(), "utf-8")) as {
51
+ assistants?: unknown[];
52
+ };
53
+ return raw ?? {};
54
+ } catch {
55
+ return {};
56
+ }
57
+ }
58
+
59
+ function readAssistants(): unknown[] {
60
+ const raw = readLockfileRaw().assistants;
61
+ return Array.isArray(raw) ? raw : [];
62
+ }
63
+
64
+ export function makeEntry(overrides: EntryOverrides = {}): void {
65
+ const entry = LockfileAssistantSchema.parse({
66
+ assistantId: "assistant-1",
67
+ cloud: "local",
68
+ ...BASE_PLACEMENT,
69
+ ...overrides,
70
+ });
71
+ const assistants = readAssistants();
72
+ const index = assistants.findIndex(
73
+ (a) =>
74
+ typeof a === "object" &&
75
+ a !== null &&
76
+ "assistantId" in a &&
77
+ a.assistantId === entry.assistantId,
78
+ );
79
+ if (index >= 0) {
80
+ assistants[index] = entry;
81
+ } else {
82
+ assistants.push(entry);
83
+ }
84
+ const path = resolveLockfilePath();
85
+ mkdirSync(dirname(path), { recursive: true });
86
+ writeFileSync(
87
+ path,
88
+ JSON.stringify({ ...readLockfileRaw(), assistants }, null, 2),
89
+ );
90
+ }
91
+
92
+ /** The entry `makeEntry` wrote, parsed back through the contract. */
93
+ export function readEntry(
94
+ assistantId = "assistant-1",
95
+ ): LockfileAssistant | undefined {
96
+ const assistants = readAssistants();
97
+ const found = assistants.find(
98
+ (a) =>
99
+ typeof a === "object" &&
100
+ a !== null &&
101
+ "assistantId" in a &&
102
+ a.assistantId === assistantId,
103
+ );
104
+ return found === undefined ? undefined : LockfileAssistantSchema.parse(found);
105
+ }
106
+
107
+ /**
108
+ * `readEntry` for the canonical local fixture — narrows the union so the
109
+ * suites can assert on the runtime fields directly. Throws when the entry
110
+ * on disk is not a local assistant.
111
+ */
112
+ export function readLocalEntry(assistantId = "assistant-1"): LocalAssistant {
113
+ const entry = readEntry(assistantId);
114
+ if (!entry || entry.cloud !== "local") {
115
+ throw new Error(
116
+ `expected a local test entry '${assistantId}', found ${entry?.cloud ?? "nothing"}`,
117
+ );
118
+ }
119
+ return entry;
120
+ }