stim 1.25.0 → 1.27.0

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 (182) hide show
  1. package/README.md +1 -1
  2. package/dist/{acquire-artifact-zA4S7RHE.mjs → acquire-artifact-BKN2Yuhg.mjs} +2 -2
  3. package/dist/{act-BbHS3oV8.mjs → act-ROviTF_t.mjs} +415 -118
  4. package/dist/{activity-BpjwrQXU.mjs → activity-Cd-ysFes.mjs} +6 -7
  5. package/dist/{agent-device-usage-output-Bnkerfod.mjs → agent-device-usage-output-C5nCKWp9.mjs} +5 -5
  6. package/dist/{android-CNZgRC-4.mjs → android--HBgpvpW.mjs} +5 -5
  7. package/dist/{android-BGwuK3Mc.mjs → android-Cd6w7_qw.mjs} +134 -57
  8. package/dist/{android-saBeB4lr.mjs → android-Deb9X3_Y.mjs} +37 -15
  9. package/dist/{android-Cjcj8MCw.mjs → android-DriNoAVy.mjs} +99 -47
  10. package/dist/{android-cas-BVqh2Zep.mjs → android-cas-D5e6ecUg.mjs} +4 -4
  11. package/dist/android-cas-compiler.mjs +1 -1
  12. package/dist/{android-project-CTYaETc0.d.mts → android-project-DUGMbq28.d.mts} +55 -1
  13. package/dist/api.d.mts +20 -7
  14. package/dist/api.mjs +42 -32
  15. package/dist/apk-signed-tail-BHQHx3Rm.mjs +142 -0
  16. package/dist/{artifact-Co8zixVx.mjs → artifact-0AGJYB9O.mjs} +28 -28
  17. package/dist/{artifact-DN8JNwqS.mjs → artifact-faemIZv5.mjs} +40 -30
  18. package/dist/{artifact-platform-CMRc0M_r.mjs → artifact-platform-BO2Uvk_A.mjs} +1 -1
  19. package/dist/{attempt-DW-mQqM7.mjs → attempt-ClyJlZPT.mjs} +4 -2
  20. package/dist/auto-placement-z-H5pJza.mjs +350 -0
  21. package/dist/{browser-web-CCgZsHmI.mjs → browser-web-slD8AvLp.mjs} +16 -17
  22. package/dist/{build-cache-CKCzxzxA.mjs → build-cache-gBJ-WKzA.mjs} +141 -37
  23. package/dist/{build-CAiw8Ezm.mjs → build-hS0QyFlQ.mjs} +38 -31
  24. package/dist/{build-plan-zCuHGlA8.mjs → build-plan-CBqYbzYM.mjs} +7 -6
  25. package/dist/{cache-manifest-BPXRONJz.mjs → cache-manifest-DEjqGGat.mjs} +1 -1
  26. package/dist/cache-manifest.mjs +1 -1
  27. package/dist/{budget-HyShrIpL.mjs → ccache-BWTze1Ls.mjs} +634 -1514
  28. package/dist/{cdp-BG3FJCCx.mjs → cdp-C3svvXiE.mjs} +1 -1
  29. package/dist/{chrome-BvV8ssI3.mjs → chrome-DyDWurWG.mjs} +1 -1
  30. package/dist/{cli-C4w607Pz.mjs → cli-ftXDLto1.mjs} +24 -23
  31. package/dist/cli.mjs +1 -1
  32. package/dist/{client-BQsmyp_-.mjs → client-xsdxrhWA.mjs} +77 -116
  33. package/dist/collector-run.d.mts +10 -9
  34. package/dist/collector-run.mjs +42 -27
  35. package/dist/{command-output-BBvS1H6v.mjs → command-output-Dj-WT4BP.mjs} +1 -1
  36. package/dist/{config-BZhXY15H.mjs → config-Cn94Jc0g.mjs} +343 -18
  37. package/dist/{launch-DscF1QfM.mjs → dependencies-BGokZ-Ng.mjs} +330 -279
  38. package/dist/{dependency-state-BwNCYG5Q.mjs → dependency-state-C3OtgG94.mjs} +14 -7
  39. package/dist/{detached-entry-KmieOKgN.mjs → detached-entry-BPlSaCwC.mjs} +1 -1
  40. package/dist/{dev-client-CHoXXZeg.mjs → dev-client-BMca82xo.mjs} +2 -2
  41. package/dist/{device-F5-4z9ef.mjs → device-BJm0irrq.mjs} +16 -16
  42. package/dist/{device-capacity-ZYaRALv5.mjs → device-capacity-6LP7QsaA.mjs} +103 -25
  43. package/dist/device-host-worker.mjs +19 -21
  44. package/dist/{device-ios-DkHBrmvH.mjs → device-ios-534c14fz.mjs} +288 -28
  45. package/dist/{device-lease-run-ogEeJ62K.mjs → device-lease-run-DwsGfjUN.mjs} +5 -5
  46. package/dist/{device-pool-BIg8MU8l.mjs → device-pool-BnQqvs6o.mjs} +3 -3
  47. package/dist/{device-B9FqTBYW.mjs → device-tM41-TUq.mjs} +25 -24
  48. package/dist/{doctor-A_Nr_fDe.mjs → doctor-Dbx1ZpD2.mjs} +1 -1
  49. package/dist/{doctor-k3P3PizH.mjs → doctor-DyqE9n1J.mjs} +28 -16
  50. package/dist/{doctor-Bm8TVpGn.mjs → doctor-F-3VUUyN.mjs} +128 -35
  51. package/dist/{doctor-fingerprint-zlujA1Gs.mjs → doctor-fingerprint-o7ZI9YLn.mjs} +9 -3
  52. package/dist/doctor-fingerprint.mjs +1 -1
  53. package/dist/{doctor-watchman-BovI1y3-.mjs → doctor-watchman-CxDbyrrt.mjs} +5 -5
  54. package/dist/{eas-build-CyDKNTBP.mjs → eas-build-CjNSWmjo.mjs} +4 -4
  55. package/dist/eas-fallback-9fqb46kW.mjs +87 -0
  56. package/dist/{eas-session-ledger-BMCA1gdO.mjs → eas-session-ledger-DrP4OuuM.mjs} +6 -6
  57. package/dist/{error-diagnostics-B1Mj_-7h.mjs → error-diagnostics-snej9k4j.mjs} +51 -25
  58. package/dist/{exec-VFRpu1iA.mjs → exec-aULwtNly.mjs} +57 -6
  59. package/dist/{gc-eaz403W6.mjs → gc-BRwAY3qT.mjs} +2 -2
  60. package/dist/{gc-B9jcnmIk.mjs → gc-CGZ1Yg88.mjs} +218 -72
  61. package/dist/{guide-DR0K0xW9.mjs → guide-_rfEh_zM.mjs} +839 -222
  62. package/dist/{hosted-android-Bvb2-ZxD.mjs → hosted-android-BMKzUNnY.mjs} +4 -4
  63. package/dist/{hosted-client-rsRqysJc.mjs → hosted-client-D7Pk_Oo1.mjs} +13 -9
  64. package/dist/{hosted-logs-CWKGYWNX.mjs → hosted-logs-B1gqQuva.mjs} +18 -12
  65. package/dist/hosted-logs-sync-Dg3qrZmV.mjs +195 -0
  66. package/dist/{hosted-macos-d0pv9Tth.mjs → hosted-macos-B9w4H8hc.mjs} +6 -6
  67. package/dist/{hosted-native-BxTizGU2.mjs → hosted-native-CdgaiuyP.mjs} +17 -17
  68. package/dist/{idle-shutdown-BIyfl0Zj.mjs → idle-shutdown-Cbvo5KEh.mjs} +21 -9
  69. package/dist/{ios-BRVM8b0P.mjs → ios-B5HlVMhQ.mjs} +138 -55
  70. package/dist/{ios-Dvt97HgQ.mjs → ios-Bk4mWbtS.mjs} +8 -8
  71. package/dist/{ios-ENC4sRPA.mjs → ios-CsRVik64.mjs} +7 -1
  72. package/dist/{ios-BQzvJlzw.mjs → ios-E26qSpkb.mjs} +94 -11
  73. package/dist/{ios-device-CKSvk0bu.mjs → ios-device-C_QkIf1Z.mjs} +3 -3
  74. package/dist/{ios-device-B6HK951C.mjs → ios-device-CiBA-er9.mjs} +1 -1
  75. package/dist/{ios-project-DCUDo06I.mjs → ios-project-D8Jcy_br.mjs} +22 -9
  76. package/dist/{ios-signing-4c_qXvQm.mjs → ios-signing-BJzvDPfU.mjs} +2 -2
  77. package/dist/{ios-state-CT9nV5SP.mjs → ios-state-BZ03NFgF.mjs} +1 -1
  78. package/dist/{js-swap-Z9HbC4cj.mjs → js-swap-Dg2a945i.mjs} +8 -7
  79. package/dist/{launch-D0lPvFFu.mjs → launch-CRyBeNsA.mjs} +53 -44
  80. package/dist/lightened-BCsdAGj_.mjs +171 -0
  81. package/dist/{logs-BsIRre8x.mjs → logs-CC_-ZzEE.mjs} +10 -174
  82. package/dist/{logs-Crs9y34Z.mjs → logs-aJQb-RDg.mjs} +112 -38
  83. package/dist/{macos-CcUlJPMu.mjs → macos-BGmTpnv9.mjs} +1 -1
  84. package/dist/{macos-D477nfzH.mjs → macos-DlCBhMw5.mjs} +73 -39
  85. package/dist/macos-run.mjs +1 -1
  86. package/dist/maintenance-run.mjs +30 -13
  87. package/dist/{metro-1pJgCX4U.mjs → metro-CvyD-xwe.mjs} +4 -4
  88. package/dist/{metro-gateway-Bp9gJQAN.mjs → metro-gateway-BnHdqMO_.mjs} +3 -4
  89. package/dist/{named-ports-BVbn8SvC.mjs → named-ports-BCyMWA6b.mjs} +3 -3
  90. package/dist/{native-android-BvMizJn1.mjs → native-android-DlpxCyOP.mjs} +17 -18
  91. package/dist/{native-gradle-artifact-inputs-BJscK4vN.mjs → native-gradle-artifact-inputs-C13qT7R_.mjs} +5 -5
  92. package/dist/{native-runtime-B9w_Qyz3.mjs → native-runtime-DqaIBO5w.mjs} +9 -9
  93. package/dist/{native-source-D-4Dh4JU.mjs → native-source-D1AzWiuP.mjs} +1 -1
  94. package/dist/{native-xcode-inputs-Cv4l-obn.mjs → native-xcode-inputs-B1W8SrxB.mjs} +3 -3
  95. package/dist/{native-xcode-ios-DGrg90hE.mjs → native-xcode-ios-QPP0Rm68.mjs} +17 -18
  96. package/dist/{ndjson-CgE_o3Dl.mjs → ndjson-Dy2W4vRa.mjs} +2 -2
  97. package/dist/offload-worker.d.mts +3 -1
  98. package/dist/offload-worker.mjs +34 -25
  99. package/dist/{operation-exec-CUZifp6Z.mjs → operation-exec-Dp4FuIGR.mjs} +1 -1
  100. package/dist/{ownership-jxxz-19m.mjs → ownership-Bx-0cku-.mjs} +3 -3
  101. package/dist/{page-CzEA_-5_.mjs → page-CQJlcj3x.mjs} +2 -2
  102. package/dist/{phone-reverses-CYb7RRAx.mjs → phone-reverses-C9yAaKEv.mjs} +18 -4
  103. package/dist/{placement-log-DjOXJRIH.mjs → placement-log-BXUbiZM6.mjs} +3 -3
  104. package/dist/{plan-placement-BqKgKHCi.mjs → plan-placement-UxnQjv5Z.mjs} +36 -10
  105. package/dist/{ports-DtS1Amb0.mjs → ports-uUrghqWN.mjs} +3 -3
  106. package/dist/prebuild-BDpToDgR.mjs +1246 -0
  107. package/dist/{project-BiC68mIp.mjs → project-DYj-HVx6.mjs} +17 -18
  108. package/dist/{pull-request-CbNlkFok.mjs → pull-request-BzLmzAIQ.mjs} +2 -2
  109. package/dist/pull-requests.mjs +1 -1
  110. package/dist/{react-native-android-DRYqoJc4.mjs → react-native-android-DDBccgJw.mjs} +56 -36
  111. package/dist/{react-native-build-CwZB-agu.mjs → react-native-build-DaK2IFyP.mjs} +9 -9
  112. package/dist/{react-native-doctor-BCrytK7h.mjs → react-native-doctor-B-Mw6DcR.mjs} +50 -9
  113. package/dist/{react-native-ios-Cr1buNFo.mjs → react-native-ios-DjYwUF9U.mjs} +45 -25
  114. package/dist/{recordings-BaoQ0t-J.mjs → recordings-C20iUZfp.mjs} +1 -1
  115. package/dist/{registration-CN6nlhcD.mjs → registration-BwCe64PH.mjs} +1 -1
  116. package/dist/{reload-Beftw2X3.mjs → reload-DJBeF_rC.mjs} +1 -1
  117. package/dist/{reload-FbSgMF8x.mjs → reload-fUdkH2_p.mjs} +16 -16
  118. package/dist/{remote-BuZj6AyU.mjs → remote-y6n99WMW.mjs} +22 -9
  119. package/dist/{result-CR2vk2cj.mjs → result-CTqBw2Te.mjs} +32 -21
  120. package/dist/{run-BtzE09Dl.mjs → run-DaCeNKRm.mjs} +3 -3
  121. package/dist/{selection-D5cxEl3t.mjs → selection-Bs8phwhN.mjs} +183 -62
  122. package/dist/{server-bare-CH9X0RLn.mjs → server-bare-BOh-iZEj.mjs} +2 -2
  123. package/dist/{server-command-CaBbDNU2.mjs → server-command-8CuA51Cv.mjs} +6 -6
  124. package/dist/{server-expo-Ck8EIidM.mjs → server-expo-ABQs2XFA.mjs} +4 -4
  125. package/dist/server-expo-Ba_Y21vB.mjs +2 -0
  126. package/dist/{settings-B5tCoq9N.mjs → settings-BDVI8Ivc.mjs} +331 -62
  127. package/dist/{settings-DzH9mGQZ.mjs → settings-CMHhQNwI.mjs} +24 -3
  128. package/dist/settings-payload-cm60Zhib.mjs +257 -0
  129. package/dist/settings-write-BdNRLlBn.mjs +185 -0
  130. package/dist/settings.schema.json +84 -39
  131. package/dist/{simslim-BjxszUAb.mjs → simslim-DCQwzoPy.mjs} +4 -3
  132. package/dist/{slot-launch-QeuJMlnJ.mjs → slot-launch-0l7RqSpr.mjs} +6 -6
  133. package/dist/{stage-D8xlRU2D.mjs → stage-F4cAfJGi.mjs} +2 -2
  134. package/dist/{start-C1JLjkNw.mjs → start-DcqnF9p8.mjs} +1 -1
  135. package/dist/{start-YMpNwLhh.mjs → start-DrPwER_2.mjs} +27 -23
  136. package/dist/{state-DMRNP7-4.mjs → state-BX1y5syV.mjs} +4 -5
  137. package/dist/{state-DPaM3u5K.mjs → state-CZxLyetD.mjs} +2 -3
  138. package/dist/{stats-CP7STzZw.mjs → stats-GxuCbles.mjs} +5 -5
  139. package/dist/{stats-report-n2U5plhk.mjs → stats-report-B86Cv7Uc.mjs} +1 -1
  140. package/dist/{status-Fect2w9R.mjs → status-7ULDEJ1e.mjs} +1 -1
  141. package/dist/{status-CRLiJ-O_.mjs → status-BfnK9pUd.mjs} +25 -26
  142. package/dist/{status-cNw6i0_t.mjs → status-Bj7ZYvvc.mjs} +1 -1
  143. package/dist/{status-watch-Bc2J4TZn.mjs → status-watch-BfabQn03.mjs} +5 -5
  144. package/dist/status-worker.mjs +1 -1
  145. package/dist/{stim-desktop-DS0mzR8U.mjs → stim-desktop-CbWo21kb.mjs} +2 -2
  146. package/dist/{stop-COP6PQqw.mjs → stop-CH79S3IZ.mjs} +5 -6
  147. package/dist/{stop-Db9Kh-UA.mjs → stop-D-EAr25B.mjs} +25 -22
  148. package/dist/{stop-Br7LKxBE.mjs → stop-x1Yu3He4.mjs} +2 -2
  149. package/dist/supervisor-run.d.mts +1 -0
  150. package/dist/supervisor-run.mjs +17 -18
  151. package/dist/{support-qKcbgmI5.mjs → support-Be0UeVZU.mjs} +10 -10
  152. package/dist/{support-Cxj9CmII.mjs → support-CNg_YsOk.mjs} +6 -6
  153. package/dist/{swiftpm-artifact-inputs-iY9fsmOc.mjs → swiftpm-artifact-inputs-uPqYvGBv.mjs} +4 -4
  154. package/dist/{swiftpm-macos-Bp_sn9P4.mjs → swiftpm-macos-Ch4YjY_A.mjs} +11 -12
  155. package/dist/toolchain-CbCG6C5Z.mjs +2413 -0
  156. package/dist/toolchain-JYAOquPg.mjs +2 -0
  157. package/dist/{trigger-CBMe2YLH.mjs → trigger-DMou-X7j.mjs} +3 -3
  158. package/dist/trigger-qp2ji5wE.mjs +2 -0
  159. package/dist/{warm-progress-BV3ZPmcY.mjs → warm-progress-C0RsbngN.mjs} +731 -728
  160. package/dist/{web-B4Yjyt1G.mjs → web-Cq_AQ4DK.mjs} +9 -10
  161. package/dist/web-Je6abcpz.mjs +2 -0
  162. package/dist/web-run.mjs +9 -9
  163. package/dist/windows-report.mjs +1 -1
  164. package/dist/{workspace-state-CPSp3mav.mjs → workspace-state-BjqdjnJR.mjs} +46 -8
  165. package/dist/{workspaces-C9w4aeXF.mjs → workspaces-DFbj07jp.mjs} +1801 -76
  166. package/dist/{worktree-CclFIe1Z.mjs → worktree-COAJ3-OD.mjs} +934 -511
  167. package/dist/{worktree-Ct9Gk3KL.mjs → worktree-JGUd_53L.mjs} +1 -1
  168. package/package.json +8 -8
  169. package/dist/ccache-h1FKhZeg.mjs +0 -143
  170. package/dist/created-devices-D2Aca-xu.mjs +0 -52
  171. package/dist/eas-fallback-gaZi-dJL.mjs +0 -381
  172. package/dist/hosted-ios-RtVcJH3u.mjs +0 -15
  173. package/dist/native-run-D5OJsGwA.mjs +0 -276
  174. package/dist/paths-DQtTgsBf.mjs +0 -42
  175. package/dist/prebuild-JUaqOLpc.mjs +0 -501
  176. package/dist/server-expo-C16Zf2k7.mjs +0 -2
  177. package/dist/settings-write-n0zwfohx.mjs +0 -360
  178. package/dist/toolchain-DB1aeqxO.mjs +0 -2
  179. package/dist/toolchain-VzLJzZ7O.mjs +0 -908
  180. package/dist/trigger-BLsHgAGR.mjs +0 -2
  181. package/dist/web-DS4UDWvf.mjs +0 -2
  182. package/dist/xcode-CiIIDnuD.mjs +0 -910
@@ -0,0 +1,257 @@
1
+ import { _ as loadConfig$1, f as getConfigPath$1, h as getRepoSettings, m as getProjectSettings } from "./config-Cn94Jc0g.mjs";
2
+ import { a as killOnAbort, i as gitPath } from "./operation-exec-Dp4FuIGR.mjs";
3
+ import { K as removedMachineSettings, V as readCommittedSettings, st as unknownSettingKeys } from "./settings-BDVI8Ivc.mjs";
4
+ import { r as findCommandWorkspaceAsync } from "./project-DYj-HVx6.mjs";
5
+ import { i as stimDesktopInstalledAsync, n as settingDefault, r as stimDesktopInstalled } from "./stim-desktop-CbWo21kb.mjs";
6
+ import { join } from "node:path";
7
+ import { SETTINGS, SETTING_SCOPES, coerceSettingText, isJsonObject, replacementAdvice, settingDefinition, settingValueError } from "@stim-cli/core/state";
8
+ //#region src/workspace/settings-payload.ts
9
+ const MASK = "********";
10
+ const PRECEDENCE = [
11
+ "workspace",
12
+ "repo",
13
+ "committed",
14
+ "machine"
15
+ ];
16
+ var SettingsRefusal = class extends Error {
17
+ code;
18
+ remedy;
19
+ constructor(code, message, remedy) {
20
+ super(message);
21
+ this.code = code;
22
+ this.remedy = remedy;
23
+ }
24
+ };
25
+ /** Reads layers using exactly `env`; `signal` kills Git children. `resolvedProject` pins a mutation's readback target. */
26
+ async function readSettingsContext(cwd, env, note = () => {}, signal, resolvedProject) {
27
+ const repoRootOf = (dir) => gitPath(dir, ["--show-toplevel"], env, signal);
28
+ const projectPath = resolvedProject === void 0 ? await findCommandWorkspaceAsync(cwd, repoRootOf, note) : resolvedProject;
29
+ const start = projectPath ?? cwd;
30
+ const [common, root] = await Promise.all([gitPath(start, ["--path-format=absolute", "--git-common-dir"], env, signal), repoRootOf(start)]);
31
+ signal?.throwIfAborted();
32
+ const repoRoot = common ? root ?? projectPath : null;
33
+ const app = projectPath ?? repoRoot;
34
+ const repository = repoRoot ?? projectPath;
35
+ const committed = readCommittedSettings(app);
36
+ let installed;
37
+ return {
38
+ projectPath,
39
+ gitCommonDir: common,
40
+ repoRoot,
41
+ machine: loadConfig$1(),
42
+ workspace: projectPath ? getProjectSettings(projectPath) : {},
43
+ repo: common ? getRepoSettings(common) : {},
44
+ committed: {
45
+ app: committed,
46
+ repository: repository === app ? committed : readCommittedSettings(repository)
47
+ },
48
+ env,
49
+ desktopInstalled: () => installed ??= stimDesktopInstalled(process.platform, env)
50
+ };
51
+ }
52
+ function valueAt(settings, key) {
53
+ let node = settings;
54
+ for (const segment of key.split(".")) {
55
+ if (!isJsonObject(node)) return void 0;
56
+ node = node[segment];
57
+ }
58
+ return node;
59
+ }
60
+ function committedDirectory(context, setting) {
61
+ return setting?.committedAt === "repository" ? repositoryDirectory(context) : appDirectory(context);
62
+ }
63
+ function repositoryDirectory(context) {
64
+ return context.repoRoot ?? context.projectPath;
65
+ }
66
+ function appDirectory(context) {
67
+ return context.projectPath ?? context.repoRoot;
68
+ }
69
+ function layerFile(context, scope, setting) {
70
+ const machineFile = getConfigPath$1();
71
+ if (scope === "machine") return machineFile;
72
+ if (scope === "workspace") return context.projectPath ? `${machineFile} (projects["${context.projectPath}"].settings)` : null;
73
+ if (scope === "repo") return context.gitCommonDir ? `${machineFile} (repos["${context.gitCommonDir}"].settings)` : null;
74
+ const directory = committedDirectory(context, setting);
75
+ return directory ? join(directory, ".stim.json") : null;
76
+ }
77
+ function layerSettings(context, scope, setting) {
78
+ if (scope === "machine") return context.machine ?? {};
79
+ if (scope === "workspace") return context.workspace;
80
+ if (scope === "repo") return context.repo;
81
+ return setting?.committedAt === "repository" ? context.committed.repository : context.committed.app;
82
+ }
83
+ function masked(setting, value) {
84
+ return setting.sensitive && value !== void 0 && value !== null ? MASK : value;
85
+ }
86
+ function settingExample(setting) {
87
+ switch (setting.type.kind) {
88
+ case "boolean": return "false";
89
+ case "number": return String(setting.default ?? setting.type.minimum ?? 1);
90
+ case "strings": return `'["node_modules"]'`;
91
+ case "object": return `'{"key": "value"}'`;
92
+ case "choice": return setting.type.choices[0];
93
+ default: return "<value>";
94
+ }
95
+ }
96
+ function envSettingValue(setting, raw) {
97
+ const value = coerceSettingText(setting, raw);
98
+ const error = settingValueError(setting, value);
99
+ if (error) throw new SettingsRefusal("STIM_BAD_ARG", `Invalid ${setting.env} value ${JSON.stringify(raw)}. Expected ${error}.`, `Fix the environment variable, or unset it and run \`stim settings set ${setting.key} ${settingExample(setting)}\`.`);
100
+ return value;
101
+ }
102
+ /** The refusal `stim settings get` gives for an invalid environment override of `key`, or null when it is unset, blank or valid. */
103
+ function envSettingRefusal(key, env) {
104
+ const setting = settingDefinition(key);
105
+ const raw = setting?.env ? env[setting.env]?.trim() : void 0;
106
+ if (!setting || !raw) return null;
107
+ try {
108
+ envSettingValue(setting, raw);
109
+ return null;
110
+ } catch (error) {
111
+ if (error instanceof SettingsRefusal) return error;
112
+ throw error;
113
+ }
114
+ }
115
+ /** The refusal for an invalid configured value of a machine setting, or null when it is unset or valid. */
116
+ function configSettingRefusal(key, value) {
117
+ const setting = settingDefinition(key);
118
+ const checked = typeof value === "string" ? value.trim() : value;
119
+ const error = setting && checked !== void 0 && checked !== null ? settingValueError(setting, checked) : null;
120
+ if (!error) return null;
121
+ return new SettingsRefusal("STIM_BAD_ARG", `Invalid ${key} setting ${JSON.stringify(value)}. Expected ${error}.`, `Replace it with \`stim settings set ${key} <value>\`; \`stim guide settings\` lists the values it takes.`);
122
+ }
123
+ /** The refusal for an invalid `remote.build` that placement would read: the environment override first, else the configured value. */
124
+ function buildPreferenceRefusal(env, configured) {
125
+ const fromEnvironment = envSettingRefusal("remote.build", env);
126
+ if (fromEnvironment) return fromEnvironment;
127
+ return env.STIM_REMOTE_BUILD?.trim() ? null : configSettingRefusal("remote.build", configured);
128
+ }
129
+ function settingEntry(context, setting) {
130
+ const layers = {};
131
+ for (const scope of PRECEDENCE) {
132
+ if (!setting.scopes.includes(scope) || layerFile(context, scope, setting) === null) continue;
133
+ const value = valueAt(layerSettings(context, scope, setting), setting.key);
134
+ if (value !== void 0) layers[scope] = masked(setting, value);
135
+ }
136
+ const envValue = setting.env ? context.env[setting.env] : void 0;
137
+ const env = setting.env && envValue ? {
138
+ name: setting.env,
139
+ value: String(masked(setting, envValue))
140
+ } : void 0;
141
+ const scopedHome = !env && setting.scopedHomeValue !== void 0 && context.env.STIM_HOME;
142
+ const ci = !env && setting.ciValue !== void 0 && context.env.CI;
143
+ const winner = PRECEDENCE.find((scope) => scope in layers);
144
+ let value = null;
145
+ let origin = null;
146
+ let defaultReason = null;
147
+ if (env) {
148
+ value = masked(setting, envSettingValue(setting, envValue));
149
+ origin = "env";
150
+ } else if (scopedHome) {
151
+ value = setting.scopedHomeValue;
152
+ origin = "env";
153
+ } else if (ci) {
154
+ value = setting.ciValue;
155
+ origin = "env";
156
+ } else if (winner) {
157
+ value = layers[winner];
158
+ origin = winner;
159
+ } else if (setting.default !== void 0) {
160
+ const fallback = settingDefault(setting, context.desktopInstalled);
161
+ value = fallback.value;
162
+ origin = "default";
163
+ defaultReason = fallback.reason;
164
+ }
165
+ return {
166
+ key: setting.key,
167
+ value,
168
+ origin,
169
+ layers,
170
+ ...env ? { env } : scopedHome ? { env: {
171
+ name: "STIM_HOME",
172
+ value: context.env.STIM_HOME
173
+ } } : ci ? { env: {
174
+ name: "CI",
175
+ value: context.env.CI
176
+ } } : {},
177
+ ...setting.sensitive ? { sensitive: true } : {},
178
+ ...defaultReason ? { defaultReason } : {}
179
+ };
180
+ }
181
+ function unknownEntries(context) {
182
+ const sources = [
183
+ {
184
+ scope: "machine",
185
+ file: layerFile(context, "machine", null),
186
+ settings: {
187
+ optimizations: context.machine?.optimizations,
188
+ ...removedMachineSettings(context.machine)
189
+ }
190
+ },
191
+ {
192
+ scope: "workspace",
193
+ file: layerFile(context, "workspace", null),
194
+ settings: layerSettings(context, "workspace", null)
195
+ },
196
+ {
197
+ scope: "repo",
198
+ file: layerFile(context, "repo", null),
199
+ settings: layerSettings(context, "repo", null)
200
+ },
201
+ {
202
+ scope: "committed",
203
+ file: layerFile(context, "committed", null),
204
+ settings: layerSettings(context, "committed", null)
205
+ }
206
+ ];
207
+ const repository = repositoryDirectory(context);
208
+ if (repository && repository !== appDirectory(context)) sources.push({
209
+ scope: "committed",
210
+ file: join(repository, ".stim.json"),
211
+ settings: context.committed.repository
212
+ });
213
+ return sources.flatMap(({ scope, file, settings }) => file === null ? [] : unknownSettingKeys(settings).map((key) => {
214
+ const value = valueAt(settings, key);
215
+ const command = replacementAdvice(key, value)?.command;
216
+ const entry = {
217
+ key,
218
+ scope,
219
+ file,
220
+ value
221
+ };
222
+ return command ? Object.assign(entry, { replacement: command }) : entry;
223
+ }));
224
+ }
225
+ function settingsPayload(context) {
226
+ const files = {};
227
+ for (const scope of SETTING_SCOPES) {
228
+ const file = layerFile(context, scope, null);
229
+ if (file) files[scope] = file;
230
+ }
231
+ return {
232
+ project: context.projectPath,
233
+ files,
234
+ settings: SETTINGS.map((setting) => settingEntry(context, setting)),
235
+ unknown: unknownEntries(context)
236
+ };
237
+ }
238
+ /** Every setting with its effective value and layers; looks Stim Desktop up asynchronously, and only when a default depends on it. */
239
+ async function readSettingsPayload(context, signal) {
240
+ let asked = false;
241
+ const payload = settingsPayload({
242
+ ...context,
243
+ desktopInstalled: () => {
244
+ asked = true;
245
+ return false;
246
+ }
247
+ });
248
+ if (!asked) return payload;
249
+ const installed = await stimDesktopInstalledAsync(process.platform, context.env, killOnAbort(signal));
250
+ signal?.throwIfAborted();
251
+ return settingsPayload({
252
+ ...context,
253
+ desktopInstalled: () => installed
254
+ });
255
+ }
256
+ //#endregion
257
+ export { envSettingRefusal as a, readSettingsPayload as c, unknownEntries as d, configSettingRefusal as i, settingEntry as l, buildPreferenceRefusal as n, layerFile as o, committedDirectory as r, readSettingsContext as s, SettingsRefusal as t, settingExample as u };
@@ -0,0 +1,185 @@
1
+ import { u as withWorkspaceProcessLock } from "./exec-aULwtNly.mjs";
2
+ import { A as writeConfigSettingAsync, O as withConfigLockAsync$1, f as getConfigPath$1 } from "./config-Cn94Jc0g.mjs";
3
+ import { t as NO_PROJECT_REFUSAL } from "./project-DYj-HVx6.mjs";
4
+ import { i as stimDesktopInstalledAsync } from "./stim-desktop-CbWo21kb.mjs";
5
+ import { n as recordingLayers, t as deleteTurnedOffRecordings } from "./recordings-C20iUZfp.mjs";
6
+ import { d as unknownEntries, l as settingEntry, o as layerFile, r as committedDirectory, s as readSettingsContext, t as SettingsRefusal, u as settingExample } from "./settings-payload-cm60Zhib.mjs";
7
+ import { existsSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { configDir } from "@stim-cli/core";
10
+ import { REPLACED_SETTINGS, SETTING_SCOPES, coerceSettingText, isJsonObject, isSensitiveReference, replacementAdvice, settingDefinition, settingValueError } from "@stim-cli/core/state";
11
+ //#region src/workspace/settings-write.ts
12
+ function requireSetting(key, raw) {
13
+ const setting = settingDefinition(key);
14
+ if (setting) return setting;
15
+ const replaced = Object.hasOwn(REPLACED_SETTINGS, key) ? REPLACED_SETTINGS[key] : void 0;
16
+ if (replaced) {
17
+ const command = replacementAdvice(key, raw)?.command;
18
+ throw new SettingsRefusal("STIM_BAD_ARG", `${JSON.stringify(key)} was replaced by ${replaced.key} and is no longer read by Stim.`, `${command ? `Run \`${command}\`` : `Set ${replaced.key} (\`stim guide settings\` lists its values)`}, then run \`stim settings unset ${key}\` to remove the leftover key.`);
19
+ }
20
+ throw new SettingsRefusal("STIM_BAD_ARG", `${JSON.stringify(key)} is not a Stim setting.`, "Run `stim settings` to list every setting, or `stim guide settings` for what each one does.");
21
+ }
22
+ function parseScopeName(raw) {
23
+ if (!SETTING_SCOPES.includes(raw)) throw new SettingsRefusal("STIM_BAD_ARG", `--scope takes ${SETTING_SCOPES.join(", ")}, not ${JSON.stringify(raw)}.`, null);
24
+ return raw;
25
+ }
26
+ function readScope(raw, setting) {
27
+ if (raw === void 0) {
28
+ if (setting.scopes.length === 1) return setting.scopes[0];
29
+ throw new SettingsRefusal("STIM_BAD_ARG", `${setting.key} can live in more than one layer, so the command needs --scope.`, `Pass --scope ${setting.scopes.join("|")}.`);
30
+ }
31
+ const scope = parseScopeName(raw);
32
+ if (!setting.scopes.includes(scope)) throw new SettingsRefusal("STIM_BAD_ARG", `${setting.key} is not read from the ${scope} layer.`, `Pass --scope ${setting.scopes.join("|")}.`);
33
+ return scope;
34
+ }
35
+ function requireLayer(context, scope, setting) {
36
+ const file = layerFile(context, scope, setting);
37
+ if (file) return file;
38
+ if (scope === "repo") throw new SettingsRefusal("STIM_BAD_ARG", "The repo layer is keyed by a Git repository, and this directory is not inside one.", "Run this from inside the repository, or pick another --scope.");
39
+ throw new SettingsRefusal(NO_PROJECT_REFUSAL.code, NO_PROJECT_REFUSAL.message, NO_PROJECT_REFUSAL.remedy);
40
+ }
41
+ function parseSettingValue(setting, raw) {
42
+ const invalid = (expected) => new SettingsRefusal("STIM_BAD_ARG", `Invalid ${setting.key} value ${JSON.stringify(raw)}. Expected ${expected}.`, `For example: stim settings set ${setting.key} ${settingExample(setting)}${setting.scopes.length > 1 ? ` --scope ${setting.scopes[0]}` : ""}`);
43
+ const kind = setting.type.kind;
44
+ const value = coerceSettingText(setting, raw);
45
+ const error = settingValueError(setting, value);
46
+ if (error) throw invalid(kind === "strings" || kind === "object" ? `${error}, written as JSON` : error);
47
+ return value;
48
+ }
49
+ function committedTarget(context, setting) {
50
+ const directory = committedDirectory(context, setting);
51
+ if (!directory) throw new SettingsRefusal(NO_PROJECT_REFUSAL.code, NO_PROJECT_REFUSAL.message, NO_PROJECT_REFUSAL.remedy);
52
+ return join(directory, ".stim.json");
53
+ }
54
+ function writeCommitted(file, key, value, signal) {
55
+ return withConfigLockAsync$1(() => {
56
+ const exists = existsSync(file);
57
+ const text = exists ? readFileSync(file, "utf-8") : "";
58
+ let parsed = {};
59
+ if (exists && text.trim() !== "") try {
60
+ parsed = JSON.parse(text);
61
+ } catch (error) {
62
+ throw new SettingsRefusal("STIM_BAD_ARG", `${file} is not valid JSON: ${error.message}`, `Repair ${file}, then run the command again.`);
63
+ }
64
+ if (!isJsonObject(parsed)) throw new SettingsRefusal("STIM_BAD_ARG", `${file} is not a JSON object.`, `Repair ${file}, then run the command again.`);
65
+ const parts = key.split(".");
66
+ const chain = [parsed];
67
+ for (const part of parts.slice(0, -1)) {
68
+ const node = chain.at(-1);
69
+ if (!isJsonObject(node[part])) {
70
+ if (value === void 0) return false;
71
+ node[part] = {};
72
+ }
73
+ chain.push(node[part]);
74
+ }
75
+ const leaf = parts.at(-1);
76
+ const parent = chain.at(-1);
77
+ if (value === void 0) {
78
+ if (!(leaf in parent)) return false;
79
+ delete parent[leaf];
80
+ for (let index = chain.length - 1; index > 0; index--) {
81
+ if (Object.keys(chain[index]).length > 0) break;
82
+ delete chain[index - 1][parts[index - 1]];
83
+ }
84
+ } else parent[leaf] = value;
85
+ const indent = /\n([ \t]+)"/.exec(text)?.[1] ?? 2;
86
+ const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
87
+ writeFileSync(tmp, `${JSON.stringify(parsed, null, indent)}\n`);
88
+ try {
89
+ renameSync(tmp, file);
90
+ } catch (error) {
91
+ try {
92
+ unlinkSync(tmp);
93
+ } catch {}
94
+ throw error;
95
+ }
96
+ return true;
97
+ }, signal);
98
+ }
99
+ function writeSetting(context, setting, scope, value, signal) {
100
+ if (scope === "committed") return writeCommitted(committedTarget(context, setting), setting.key, value, signal);
101
+ if (scope === "machine") return writeConfigSettingAsync({ scope }, setting.key, value, signal);
102
+ if (scope === "workspace") return writeConfigSettingAsync({
103
+ scope,
104
+ projectPath: context.projectPath
105
+ }, setting.key, value, signal);
106
+ return writeConfigSettingAsync({
107
+ scope,
108
+ gitCommonDir: context.gitCommonDir
109
+ }, setting.key, value, signal);
110
+ }
111
+ /** Shares CLI set/unset validation and side effects; after commit, recording cleanup finishes despite cancellation. */
112
+ async function mutateSetting(request, { cwd, env, note = () => {}, signal, beforeWrite }) {
113
+ signal?.throwIfAborted();
114
+ const { key } = request;
115
+ const setting = requireSetting(key, request.action === "set" ? request.value : void 0);
116
+ const scope = readScope(request.scope, setting);
117
+ const value = request.action === "set" ? parseSettingValue(setting, request.value) : void 0;
118
+ if (setting.sensitive && scope === "committed" && value !== void 0 && !isSensitiveReference(value)) throw new SettingsRefusal("STIM_BAD_ARG", `${key} is sensitive, so a committed .stim.json takes only an env: or file: reference, never the secret.`, `Set the secret with --scope workspace or --scope repo, which store it in ${getConfigPath$1()}, readable only by you, or commit a reference such as env:MY_KEYSTORE_PASSWORD.`);
119
+ const context = await readSettingsContext(cwd, env, note, signal);
120
+ const file = requireLayer(context, scope, setting);
121
+ beforeWrite?.(context.projectPath);
122
+ const apply = async () => {
123
+ const recording = setting.key === "recording.enabled" ? recordingLayers() : null;
124
+ const changed = await writeSetting(context, setting, scope, value, signal);
125
+ const updated = await readSettingsContext(cwd, env, void 0, void 0, context.projectPath);
126
+ const recordingsDeleted = recording ? await deleteTurnedOffRecordings(recording) : void 0;
127
+ let entry = settingEntry({
128
+ ...updated,
129
+ desktopInstalled: () => false
130
+ }, setting);
131
+ if (entry.origin === "default" && setting.desktopDefault !== void 0) {
132
+ const installed = await stimDesktopInstalledAsync(process.platform, env);
133
+ entry = settingEntry({
134
+ ...updated,
135
+ desktopInstalled: () => installed
136
+ }, setting);
137
+ }
138
+ return {
139
+ key,
140
+ scope,
141
+ file,
142
+ changed,
143
+ setting: entry,
144
+ ...recordingsDeleted ? { recordingsDeleted } : {}
145
+ };
146
+ };
147
+ return key === "recording.enabled" ? withWorkspaceProcessLock(configDir(), "recording-settings", apply, {
148
+ external: true,
149
+ signal
150
+ }) : apply();
151
+ }
152
+ function configTarget(context, scope) {
153
+ if (scope === "workspace") return context.projectPath ? {
154
+ scope,
155
+ projectPath: context.projectPath
156
+ } : null;
157
+ if (scope === "repo") return context.gitCommonDir ? {
158
+ scope,
159
+ gitCommonDir: context.gitCommonDir
160
+ } : null;
161
+ return scope === "machine" ? { scope } : null;
162
+ }
163
+ /** Removes a key Stim no longer reads from every layer that has it, or from one with `scope`. */
164
+ async function unsetReplacedSetting(request, { cwd, env, note = () => {}, signal }) {
165
+ signal?.throwIfAborted();
166
+ const { key } = request;
167
+ const only = request.scope === void 0 ? void 0 : parseScopeName(request.scope);
168
+ const context = await readSettingsContext(cwd, env, note, signal);
169
+ const removed = [];
170
+ for (const entry of unknownEntries(context)) {
171
+ if (entry.key !== key || only && entry.scope !== only) continue;
172
+ const target = configTarget(context, entry.scope);
173
+ if (entry.scope === "committed" ? await writeCommitted(entry.file, key, void 0, signal) : target && await writeConfigSettingAsync(target, key, void 0, signal)) removed.push({
174
+ scope: entry.scope,
175
+ file: entry.file
176
+ });
177
+ }
178
+ return {
179
+ key,
180
+ replacedBy: REPLACED_SETTINGS[key]?.key ?? key,
181
+ removed
182
+ };
183
+ }
184
+ //#endregion
185
+ export { unsetReplacedSetting as i, readScope as n, requireSetting as r, mutateSetting as t };