@detergent-software/atk 9.4.0-dev.9 → 9.4.1-dev.1

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 (212) hide show
  1. package/CHANGELOG.md +401 -0
  2. package/README.md +7 -2
  3. package/build/command-manifest.json +33 -7
  4. package/build/commands/_app.d.ts.map +1 -1
  5. package/build/commands/_app.js +4 -2
  6. package/build/commands/_app.js.map +1 -1
  7. package/build/commands/audit.d.ts.map +1 -1
  8. package/build/commands/audit.js +7 -4
  9. package/build/commands/audit.js.map +1 -1
  10. package/build/commands/diff.d.ts.map +1 -1
  11. package/build/commands/diff.js +10 -10
  12. package/build/commands/diff.js.map +1 -1
  13. package/build/commands/doctor.d.ts.map +1 -1
  14. package/build/commands/doctor.js +1 -1
  15. package/build/commands/doctor.js.map +1 -1
  16. package/build/commands/info.d.ts.map +1 -1
  17. package/build/commands/info.js +16 -14
  18. package/build/commands/info.js.map +1 -1
  19. package/build/commands/init.d.ts.map +1 -1
  20. package/build/commands/init.js +1 -1
  21. package/build/commands/init.js.map +1 -1
  22. package/build/commands/install.d.ts.map +1 -1
  23. package/build/commands/install.js +161 -90
  24. package/build/commands/install.js.map +1 -1
  25. package/build/commands/move.d.ts.map +1 -1
  26. package/build/commands/move.js +5 -4
  27. package/build/commands/move.js.map +1 -1
  28. package/build/commands/outdated.js +1 -1
  29. package/build/commands/outdated.js.map +1 -1
  30. package/build/commands/sync.d.ts.map +1 -1
  31. package/build/commands/sync.js +6 -4
  32. package/build/commands/sync.js.map +1 -1
  33. package/build/commands/update.d.ts +1 -1
  34. package/build/commands/update.d.ts.map +1 -1
  35. package/build/commands/update.js +1 -1
  36. package/build/commands/update.js.map +1 -1
  37. package/build/commands/upgrade.d.ts +16 -0
  38. package/build/commands/upgrade.d.ts.map +1 -0
  39. package/build/commands/upgrade.js +64 -0
  40. package/build/commands/upgrade.js.map +1 -0
  41. package/build/commands/why.d.ts.map +1 -1
  42. package/build/commands/why.js +28 -7
  43. package/build/commands/why.js.map +1 -1
  44. package/build/components/DiffView.d.ts +3 -1
  45. package/build/components/DiffView.d.ts.map +1 -1
  46. package/build/components/DiffView.js +18 -4
  47. package/build/components/DiffView.js.map +1 -1
  48. package/build/components/EnabledEntriesHint.d.ts +14 -0
  49. package/build/components/EnabledEntriesHint.d.ts.map +1 -0
  50. package/build/components/EnabledEntriesHint.js +13 -0
  51. package/build/components/EnabledEntriesHint.js.map +1 -0
  52. package/build/components/InitSuccess.d.ts.map +1 -1
  53. package/build/components/InitSuccess.js +4 -1
  54. package/build/components/InitSuccess.js.map +1 -1
  55. package/build/components/InstallSummary.d.ts +7 -2
  56. package/build/components/InstallSummary.d.ts.map +1 -1
  57. package/build/components/InstallSummary.js +3 -1
  58. package/build/components/InstallSummary.js.map +1 -1
  59. package/build/components/LeftoverFilesHint.d.ts +21 -0
  60. package/build/components/LeftoverFilesHint.d.ts.map +1 -0
  61. package/build/components/LeftoverFilesHint.js +13 -0
  62. package/build/components/LeftoverFilesHint.js.map +1 -0
  63. package/build/components/PreferredScopeWarning.d.ts +4 -3
  64. package/build/components/PreferredScopeWarning.d.ts.map +1 -1
  65. package/build/components/PreferredScopeWarning.js +5 -2
  66. package/build/components/PreferredScopeWarning.js.map +1 -1
  67. package/build/components/index.d.ts +2 -0
  68. package/build/components/index.d.ts.map +1 -1
  69. package/build/components/index.js +2 -0
  70. package/build/components/index.js.map +1 -1
  71. package/build/hooks/useInitState.d.ts +9 -1
  72. package/build/hooks/useInitState.d.ts.map +1 -1
  73. package/build/hooks/useInitState.js +52 -10
  74. package/build/hooks/useInitState.js.map +1 -1
  75. package/build/hooks/useListActions.d.ts.map +1 -1
  76. package/build/hooks/useListActions.js +4 -1
  77. package/build/hooks/useListActions.js.map +1 -1
  78. package/build/hooks/useUninstallState.d.ts.map +1 -1
  79. package/build/hooks/useUninstallState.js +46 -23
  80. package/build/hooks/useUninstallState.js.map +1 -1
  81. package/build/lib/adapter.d.ts +14 -9
  82. package/build/lib/adapter.d.ts.map +1 -1
  83. package/build/lib/adapter.js +46 -8
  84. package/build/lib/adapter.js.map +1 -1
  85. package/build/lib/api-client.d.ts.map +1 -1
  86. package/build/lib/api-client.js +2 -1
  87. package/build/lib/api-client.js.map +1 -1
  88. package/build/lib/asset-tools.d.ts +8 -0
  89. package/build/lib/asset-tools.d.ts.map +1 -1
  90. package/build/lib/asset-tools.js +14 -0
  91. package/build/lib/asset-tools.js.map +1 -1
  92. package/build/lib/completion/candidates.d.ts.map +1 -1
  93. package/build/lib/completion/candidates.js +21 -8
  94. package/build/lib/completion/candidates.js.map +1 -1
  95. package/build/lib/config-entries.d.ts +3 -3
  96. package/build/lib/config-entries.d.ts.map +1 -1
  97. package/build/lib/config-entries.js +16 -6
  98. package/build/lib/config-entries.js.map +1 -1
  99. package/build/lib/config-lock.d.ts +2 -1
  100. package/build/lib/config-lock.d.ts.map +1 -1
  101. package/build/lib/config-lock.js +10 -2
  102. package/build/lib/config-lock.js.map +1 -1
  103. package/build/lib/cross-scope.d.ts +6 -2
  104. package/build/lib/cross-scope.d.ts.map +1 -1
  105. package/build/lib/cross-scope.js +20 -13
  106. package/build/lib/cross-scope.js.map +1 -1
  107. package/build/lib/diagnostics.d.ts +3 -2
  108. package/build/lib/diagnostics.d.ts.map +1 -1
  109. package/build/lib/diagnostics.js +11 -11
  110. package/build/lib/diagnostics.js.map +1 -1
  111. package/build/lib/diff-command.d.ts +9 -3
  112. package/build/lib/diff-command.d.ts.map +1 -1
  113. package/build/lib/diff-command.js +58 -21
  114. package/build/lib/diff-command.js.map +1 -1
  115. package/build/lib/diff.d.ts +8 -4
  116. package/build/lib/diff.d.ts.map +1 -1
  117. package/build/lib/diff.js +23 -4
  118. package/build/lib/diff.js.map +1 -1
  119. package/build/lib/doctor-fix.d.ts +8 -3
  120. package/build/lib/doctor-fix.d.ts.map +1 -1
  121. package/build/lib/doctor-fix.js +50 -3
  122. package/build/lib/doctor-fix.js.map +1 -1
  123. package/build/lib/enabled-list.d.ts +7 -3
  124. package/build/lib/enabled-list.d.ts.map +1 -1
  125. package/build/lib/enabled-list.js +7 -5
  126. package/build/lib/enabled-list.js.map +1 -1
  127. package/build/lib/gitignore.d.ts +8 -0
  128. package/build/lib/gitignore.d.ts.map +1 -1
  129. package/build/lib/gitignore.js +51 -6
  130. package/build/lib/gitignore.js.map +1 -1
  131. package/build/lib/hook-config.d.ts +90 -7
  132. package/build/lib/hook-config.d.ts.map +1 -1
  133. package/build/lib/hook-config.js +135 -11
  134. package/build/lib/hook-config.js.map +1 -1
  135. package/build/lib/hook-script.d.ts +45 -0
  136. package/build/lib/hook-script.d.ts.map +1 -1
  137. package/build/lib/hook-script.js +118 -1
  138. package/build/lib/hook-script.js.map +1 -1
  139. package/build/lib/init.d.ts +34 -12
  140. package/build/lib/init.d.ts.map +1 -1
  141. package/build/lib/init.js +180 -32
  142. package/build/lib/init.js.map +1 -1
  143. package/build/lib/install-targets.d.ts +20 -6
  144. package/build/lib/install-targets.d.ts.map +1 -1
  145. package/build/lib/install-targets.js +65 -8
  146. package/build/lib/install-targets.js.map +1 -1
  147. package/build/lib/installer.d.ts +15 -5
  148. package/build/lib/installer.d.ts.map +1 -1
  149. package/build/lib/installer.js +201 -41
  150. package/build/lib/installer.js.map +1 -1
  151. package/build/lib/local-edits.d.ts +15 -2
  152. package/build/lib/local-edits.d.ts.map +1 -1
  153. package/build/lib/local-edits.js +40 -13
  154. package/build/lib/local-edits.js.map +1 -1
  155. package/build/lib/lockfile.d.ts +2 -2
  156. package/build/lib/lockfile.js +4 -4
  157. package/build/lib/lockfile.js.map +1 -1
  158. package/build/lib/mover.d.ts +5 -4
  159. package/build/lib/mover.d.ts.map +1 -1
  160. package/build/lib/mover.js +43 -35
  161. package/build/lib/mover.js.map +1 -1
  162. package/build/lib/multi-tool-install.d.ts +28 -5
  163. package/build/lib/multi-tool-install.d.ts.map +1 -1
  164. package/build/lib/multi-tool-install.js +105 -26
  165. package/build/lib/multi-tool-install.js.map +1 -1
  166. package/build/lib/named-entry.d.ts +12 -0
  167. package/build/lib/named-entry.d.ts.map +1 -1
  168. package/build/lib/named-entry.js +16 -8
  169. package/build/lib/named-entry.js.map +1 -1
  170. package/build/lib/notices.d.ts +2 -0
  171. package/build/lib/notices.d.ts.map +1 -1
  172. package/build/lib/notices.js +10 -0
  173. package/build/lib/notices.js.map +1 -1
  174. package/build/lib/preferred-scope.d.ts +19 -5
  175. package/build/lib/preferred-scope.d.ts.map +1 -1
  176. package/build/lib/preferred-scope.js +38 -18
  177. package/build/lib/preferred-scope.js.map +1 -1
  178. package/build/lib/schemas/adapter.d.ts +33 -0
  179. package/build/lib/schemas/adapter.d.ts.map +1 -1
  180. package/build/lib/schemas/adapter.js +31 -5
  181. package/build/lib/schemas/adapter.js.map +1 -1
  182. package/build/lib/self-upgrade.d.ts +66 -0
  183. package/build/lib/self-upgrade.d.ts.map +1 -0
  184. package/build/lib/self-upgrade.js +183 -0
  185. package/build/lib/self-upgrade.js.map +1 -0
  186. package/build/lib/sync.d.ts +39 -0
  187. package/build/lib/sync.d.ts.map +1 -1
  188. package/build/lib/sync.js +181 -10
  189. package/build/lib/sync.js.map +1 -1
  190. package/build/lib/touched-paths.d.ts.map +1 -1
  191. package/build/lib/touched-paths.js +2 -1
  192. package/build/lib/touched-paths.js.map +1 -1
  193. package/build/lib/uninstaller.d.ts +29 -1
  194. package/build/lib/uninstaller.d.ts.map +1 -1
  195. package/build/lib/uninstaller.js +99 -5
  196. package/build/lib/uninstaller.js.map +1 -1
  197. package/build/lib/update-check.d.ts +27 -1
  198. package/build/lib/update-check.d.ts.map +1 -1
  199. package/build/lib/update-check.js +74 -8
  200. package/build/lib/update-check.js.map +1 -1
  201. package/build/lib/updater.d.ts +2 -0
  202. package/build/lib/updater.d.ts.map +1 -1
  203. package/build/lib/updater.js +36 -3
  204. package/build/lib/updater.js.map +1 -1
  205. package/build/lib/version.d.ts +12 -4
  206. package/build/lib/version.d.ts.map +1 -1
  207. package/build/lib/version.js +19 -7
  208. package/build/lib/version.js.map +1 -1
  209. package/package.json +1 -1
  210. package/tool-adapters/claude-code.json +2 -1
  211. package/tool-adapters/codex-cli.json +5 -1
  212. package/tool-adapters/copilot-cli.json +58 -9
@@ -5,12 +5,12 @@ import { z } from 'zod';
5
5
  import { CrossScopeWarning, DryRunBanner, ErrorView, InstallSummary, MultiSelectList, PreferredScopeQuestion, PreferredScopeWarning, Spinner, } from '../components/index.js';
6
6
  import { useCommand } from '../hooks/useCommand.js';
7
7
  import { useResolvedScope } from '../hooks/useResolvedScope.js';
8
- import { placesAsset } from '../lib/asset-tools.js';
8
+ import { placesAsset, takesEntrypoint } from '../lib/asset-tools.js';
9
9
  import { resolveBundleVersion } from '../lib/bundle-version.js';
10
10
  import { loadConfig } from '../lib/config.js';
11
11
  import { crossScopeNotice, findCrossScopeInstalls } from '../lib/cross-scope.js';
12
12
  import { errorGuidance, errorMessage } from '../lib/errors.js';
13
- import { bundleMembers, inPlacePin, installPlannedTargets, isBundleInPlace, planTargetsInstall, } from '../lib/install-targets.js';
13
+ import { bundleInPlacePin, bundleMembers, inPlacePin, installPlannedTargets, isBundleInPlace, membersInPlace, pinMembersInPlace, planTargetsInstall, } from '../lib/install-targets.js';
14
14
  import { isInstalledForTool } from '../lib/installed-for-tool.js';
15
15
  import { InstallerError } from '../lib/installer.js';
16
16
  import { addAssetToLockfile, findInstalledAsset, identityKey, pinAssetVersion, readLockfile, upgradeToDirectInstall, withLockfileErrorHandling, writeLockfile, } from '../lib/lockfile.js';
@@ -19,7 +19,7 @@ import { addNotice } from '../lib/notices.js';
19
19
  import { formatOrgName, inlineOrgOf, isBareOrgScope, parseNameScope, resolveActiveOrg, resolveSpecOrg, } from '../lib/org.js';
20
20
  import { renderJson, useNonInteractive } from '../lib/output.js';
21
21
  import { argument, option } from '../lib/pastel/index.js';
22
- import { canInstallAt, preferredScopeNotice, preferredScopeOf } from '../lib/preferred-scope.js';
22
+ import { preferredScopeNotice, preferredScopeOf, scopeReadiness } from '../lib/preferred-scope.js';
23
23
  import { fetchRegistry, findAsset, findAssetsByName, findBundle, getAssetsByOrg, isDeprecated, isLatestAlias, } from '../lib/registry.js';
24
24
  import { resolveBundleInstallPlan, resolveInstallPlan, resolveMultipleInstallPlans, ResolverError, } from '../lib/resolver.js';
25
25
  import { scopeLabel } from '../lib/scope.js';
@@ -152,6 +152,15 @@ async function bundleAtRequestedVersion(entry, requested, progress) {
152
152
  }
153
153
  return resolution.bundle;
154
154
  }
155
+ /** What `--pin` did, or would do, with the members of a bundle in place. */
156
+ function BundlePinLine({ dryRun = false, pin }) {
157
+ if (pin === 'pinned') {
158
+ return (_jsxs(Text, { children: [_jsx(Text, { color: 'green', children: "\u2713" }), " Its members ", dryRun ? 'would be' : 'are now', " pinned at their installed versions."] }));
159
+ }
160
+ if (pin === 'already-pinned')
161
+ return _jsx(Text, { children: "Its members are already pinned at their installed versions." });
162
+ return null;
163
+ }
155
164
  /**
156
165
  * What a bundle install says about its members outside the bundle (`kept`) and the members it
157
166
  * `adopted`. A member with no origin can be adopted; another bundle's member stays with that bundle.
@@ -257,7 +266,7 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
257
266
  };
258
267
  // Once answered, the install goes where the answer said, with nothing more to say about it. When
259
268
  // a bundle's members disagree, the command installs only the members that prefer the other scope.
260
- const preferredScope = (plan) => answered
269
+ const preferredScope = async (plan) => answered
261
270
  ? {}
262
271
  : preferredScopeField(preferredScopeOf(plan, installScope), (preferred) => preferredScopeCommand(preferred, {
263
272
  adopt,
@@ -266,14 +275,15 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
266
275
  pin,
267
276
  spec: indexBundle && preferred.conflict ? undefined : otherScopeSpec(plan, { always: false }),
268
277
  tool,
269
- }), effectiveJson);
278
+ }), { json: effectiveJson, tool });
270
279
  // A terminal run asks before it installs, unless --yes, or the targets' authors disagree on the
271
- // scope, or there is no other scope to move to (a --user install outside any project).
280
+ // scope, or the install moved there wouldn't resolve its tools (--tool, or that scope's own): the
281
+ // user scope isn't set up, or a --user install's cwd is the user root or a folder with no tools.
272
282
  const askScope = async (plan, bundleName) => {
273
283
  if (answered || yes || effectiveJson)
274
284
  return undefined;
275
285
  const preferred = preferredScopeOf(plan, installScope);
276
- if (!preferred || preferred.conflict || !(await canInstallAt(preferred.scope)))
286
+ if (!preferred || preferred.conflict || !(await scopeReadiness(preferred.scope, tool)).ready)
277
287
  return undefined;
278
288
  return {
279
289
  ...(bundleName ? { bundleName } : {}),
@@ -341,8 +351,52 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
341
351
  user,
342
352
  })
343
353
  : '';
354
+ // Whether every targeted tool has the bundle whole, which the install leaves as it is.
355
+ const isBundleHere = (lockfile) => bundle !== undefined &&
356
+ !force &&
357
+ isBundleInPlace(registry, bundle, lockfile, { members, projectDir, requiredBundleVersion, tools });
358
+ // With --pin, what the install does with the pins of a bundle in place.
359
+ const bundlePinField = (installed) => {
360
+ const bundlePin = pin ? bundleInPlacePin(installed) : undefined;
361
+ return bundlePin ? { pin: bundlePin } : {};
362
+ };
363
+ // The asset installed already, when every targeted tool has it in place, which the install leaves
364
+ // where it is. The lockfile is shared across tools, so tools that can't place the asset (its type,
365
+ // or a hook its manifest doesn't declare) have nothing to check; when none of them can, the
366
+ // installer says why instead. The registry identity is resolved first so the check matches on
367
+ // (name, type, org), not name alone. A version asked for that resolves to another one (`latest`
368
+ // and ranges included) goes to the resolver: the install makes the asset direct and checks its
369
+ // pin and dependents.
370
+ const assetInPlace = (lockfile) => {
371
+ if (bundle || force)
372
+ return undefined;
373
+ const registryMatch = findAsset(registry, name, undefined, effectiveVersion, org);
374
+ const existing = registryMatch
375
+ ? findInstalledAsset(lockfile, name, registryMatch.asset.type, registryMatch.asset.org)
376
+ : undefined;
377
+ if (!existing || !registryMatch)
378
+ return undefined;
379
+ const supportingTools = tools.filter((t) => placesAsset(t.adapter, existing.type, registryMatch.versionData.tools) &&
380
+ takesEntrypoint(t.adapter, existing.type, existing.entrypoint));
381
+ const inPlace = supportingTools.length > 0 &&
382
+ supportingTools.every((t) => isInstalledForTool(existing, t.adapter, projectDir)) &&
383
+ (!effectiveVersion || registryMatch.version === existing.version);
384
+ return inPlace ? existing : undefined;
385
+ };
386
+ // What the install does with an asset in place: makes a dependency direct and, with --pin, pins
387
+ // it at its version, as `atk pin` would.
388
+ const inPlaceReport = (existing) => ({
389
+ name: existing.name,
390
+ ...(existing.org ? { org: existing.org } : {}),
391
+ outcome: (existing.installReason ?? 'direct') === 'dependency' ? 'upgraded-to-direct' : 'already-installed',
392
+ ...(pin ? { pin: inPlacePin(existing) } : {}),
393
+ type: existing.type,
394
+ version: existing.version,
395
+ });
396
+ const nothingToInstall = { entries: [], totalCount: 0 };
344
397
  // Dry-run: resolve plan without acquiring lockfile lock or executing. The install leaves
345
- // dependencies already in place alone and refuses to move a pinned one, and so does the plan.
398
+ // dependencies already in place alone and refuses to move a pinned one, and so does the plan,
399
+ // and it says what it would do with a target in place, as the install would.
346
400
  if (dryRun) {
347
401
  const asInstalled = (resolved) => withoutKeptDependencies(resolved, currentLockfile, tools, {
348
402
  named: { force },
@@ -352,19 +406,41 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
352
406
  scope: installScope,
353
407
  });
354
408
  if (bundle) {
355
- progress('Resolving bundle assets...');
356
- const resolved = resolveBundleInstallPlan(registry, bundle);
357
409
  // Nothing is written, so the members an install would adopt are the ones with no origin now.
358
410
  const outside = membersOutsideBundle(currentLockfile, members, bundle);
411
+ const report = bundleReport(adopt ? outside.filter((m) => m.bundle) : outside, adopt ? outside.filter((m) => !m.bundle) : [], { adoptCommand, bundle });
412
+ if (isBundleHere(currentLockfile)) {
413
+ return {
414
+ bundleName: bundle.name,
415
+ inPlace: true,
416
+ outcome: 'dry-run-bundle',
417
+ ...bundlePinField(membersInPlace(currentLockfile, members)),
418
+ plan: nothingToInstall,
419
+ tools: toolNames,
420
+ version: bundle.version,
421
+ ...report,
422
+ };
423
+ }
424
+ progress('Resolving bundle assets...');
425
+ const resolved = resolveBundleInstallPlan(registry, bundle);
359
426
  return {
360
427
  bundleName: bundle.name,
361
428
  outcome: 'dry-run-bundle',
362
429
  plan: asInstalled(resolved),
363
430
  tools: toolNames,
364
431
  version: bundle.version,
365
- ...bundleReport(adopt ? outside.filter((m) => m.bundle) : outside, adopt ? outside.filter((m) => !m.bundle) : [], { adoptCommand, bundle }),
432
+ ...report,
366
433
  ...(await crossScope(resolved)),
367
- ...preferredScope(resolved),
434
+ ...(await preferredScope(resolved)),
435
+ };
436
+ }
437
+ const existing = assetInPlace(currentLockfile);
438
+ if (existing) {
439
+ return {
440
+ assets: [inPlaceReport(existing)],
441
+ outcome: 'dry-run-install',
442
+ plan: nothingToInstall,
443
+ tools: toolNames,
368
444
  };
369
445
  }
370
446
  const versionLabel = effectiveVersion ? `@${effectiveVersion}` : '';
@@ -375,7 +451,7 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
375
451
  plan: asInstalled(resolved),
376
452
  tools: toolNames,
377
453
  ...(await crossScope(resolved)),
378
- ...preferredScope(resolved),
454
+ ...(await preferredScope(resolved)),
379
455
  };
380
456
  }
381
457
  return await withLockfileErrorHandling(projectDir, async () => {
@@ -387,27 +463,31 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
387
463
  version: bundle.version,
388
464
  };
389
465
  // Bundle installation flow — check if already installed for ALL tools
390
- if (!force) {
391
- if (isBundleInPlace(registry, bundle, before, { members, projectDir, requiredBundleVersion, tools })) {
392
- // Adopting a bundle that is in place only records its origin on the members with none:
393
- // their files, versions and pins stay as they are. Another bundle's member stays its.
394
- const outside = membersOutsideBundle(before, members, bundle);
395
- const adopted = adopt ? outside.filter((member) => !member.bundle) : [];
396
- if (adopted.length > 0) {
397
- let lockfile = before;
398
- for (const { name: memberName, org: memberOrg, type } of adopted) {
399
- const installed = findInstalledAsset(lockfile, memberName, type, memberOrg);
400
- lockfile = addAssetToLockfile(lockfile, { ...installed, bundleOrigin });
401
- }
402
- await writeLockfile(projectDir, lockfile);
466
+ if (isBundleHere(before)) {
467
+ // Adopting a bundle that is in place only records its origin on the members with none:
468
+ // their files, versions and pins stay as they are. Another bundle's member stays its.
469
+ // --pin pins every member at its version, as a fresh install with --pin would.
470
+ const outside = membersOutsideBundle(before, members, bundle);
471
+ const adopted = adopt ? outside.filter((member) => !member.bundle) : [];
472
+ const installedMembers = membersInPlace(before, members);
473
+ const pinField = bundlePinField(installedMembers);
474
+ if (adopted.length > 0 || pinField.pin === 'pinned') {
475
+ let lockfile = before;
476
+ for (const { name: memberName, org: memberOrg, type } of adopted) {
477
+ const installed = findInstalledAsset(lockfile, memberName, type, memberOrg);
478
+ lockfile = addAssetToLockfile(lockfile, { ...installed, bundleOrigin });
403
479
  }
404
- return {
405
- bundleName: bundle.name,
406
- outcome: 'bundle-already-installed',
407
- version: bundle.version,
408
- ...bundleReport(outside.filter((member) => !adopted.includes(member)), adopted, { adoptCommand, bundle }),
409
- };
480
+ if (pinField.pin === 'pinned')
481
+ lockfile = pinMembersInPlace(lockfile, installedMembers);
482
+ await writeLockfile(projectDir, lockfile);
410
483
  }
484
+ return {
485
+ bundleName: bundle.name,
486
+ outcome: 'bundle-already-installed',
487
+ ...pinField,
488
+ version: bundle.version,
489
+ ...bundleReport(outside.filter((member) => !adopted.includes(member)), adopted, { adoptCommand, bundle }),
490
+ };
411
491
  }
412
492
  progress('Resolving bundle assets...');
413
493
  const plan = resolveBundleInstallPlan(registry, bundle);
@@ -436,52 +516,30 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
436
516
  version: bundle.version,
437
517
  ...bundleReport(kept, adopted, { adoptCommand, bundle }),
438
518
  ...(await crossScope(plan, projectDir)),
439
- ...preferredScope(plan),
519
+ ...(await preferredScope(plan)),
440
520
  };
441
521
  }
442
522
  // Single asset installation flow
443
- if (!force) {
444
- const lockfile = await readLockfile(projectDir);
445
- // Resolve the registry identity first so the already-installed check matches on
446
- // (name, type, org), not name alone — a same-named asset of a different type or
447
- // org must not short-circuit this install. The lockfile is shared across tools, so
448
- // the asset only counts as installed when every targeted tool has it in place.
449
- const registryMatch = findAsset(registry, name, undefined, effectiveVersion, org);
450
- const existing = registryMatch
451
- ? findInstalledAsset(lockfile, name, registryMatch.asset.type, registryMatch.asset.org)
452
- : undefined;
453
- // Tools that cannot place this asset (its type, or a hook its manifest doesn't declare)
454
- // have nothing to check. When none of the targeted tools can, fall through so the
455
- // installer reports why instead of claiming the asset is already installed.
456
- const supportingTools = existing && registryMatch
457
- ? tools.filter((t) => placesAsset(t.adapter, existing.type, registryMatch.versionData.tools))
458
- : [];
459
- // A version asked for that resolves to another one (`latest` and ranges included) falls through
460
- // to the resolver: the install makes the asset direct and checks its pin and dependents.
461
- if (existing &&
462
- supportingTools.length > 0 &&
463
- supportingTools.every((t) => isInstalledForTool(existing, t.adapter, projectDir)) &&
464
- (!effectiveVersion || registryMatch?.version === existing.version)) {
465
- // If it was auto-installed as a dependency, upgrade it to a direct install; --pin pins it
466
- // at its version, as `atk pin` would.
467
- const dependency = (existing.installReason ?? 'direct') === 'dependency';
468
- const pinField = pin ? { pin: inPlacePin(existing) } : {};
469
- if (dependency || pinField.pin === 'pinned') {
470
- let updated = lockfile;
471
- if (dependency)
472
- updated = upgradeToDirectInstall(updated, name, existing.type, existing.org);
473
- if (pinField.pin === 'pinned') {
474
- updated = pinAssetVersion(updated, name, existing.version, existing.type, existing.org);
475
- }
476
- await writeLockfile(projectDir, updated);
523
+ const lockfile = force ? undefined : await readLockfile(projectDir);
524
+ const existing = lockfile && assetInPlace(lockfile);
525
+ if (lockfile && existing) {
526
+ const { outcome, pin: pinned } = inPlaceReport(existing);
527
+ if (outcome === 'upgraded-to-direct' || pinned === 'pinned') {
528
+ let updated = lockfile;
529
+ if (outcome === 'upgraded-to-direct') {
530
+ updated = upgradeToDirectInstall(updated, name, existing.type, existing.org);
477
531
  }
478
- return {
479
- name,
480
- outcome: dependency ? 'upgraded-to-direct' : 'already-installed',
481
- ...pinField,
482
- version: existing.version,
483
- };
532
+ if (pinned === 'pinned') {
533
+ updated = pinAssetVersion(updated, name, existing.version, existing.type, existing.org);
534
+ }
535
+ await writeLockfile(projectDir, updated);
484
536
  }
537
+ return {
538
+ name,
539
+ outcome: outcome === 'upgraded-to-direct' ? 'upgraded-to-direct' : 'already-installed',
540
+ ...(pinned ? { pin: pinned } : {}),
541
+ version: existing.version,
542
+ };
485
543
  }
486
544
  const versionLabel = effectiveVersion ? `@${effectiveVersion}` : '';
487
545
  progress(`Resolving dependencies${versionLabel}...`);
@@ -502,7 +560,7 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
502
560
  outcome: 'installed',
503
561
  toolResults,
504
562
  ...(await crossScope(plan, projectDir)),
505
- ...preferredScope(plan),
563
+ ...(await preferredScope(plan)),
506
564
  };
507
565
  });
508
566
  }, [adopt, cliOrg, dryRun, force, inlineOrg, name, pin, requestedVersion, tool]);
@@ -532,7 +590,7 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
532
590
  return renderJson({ ...data, ...fields });
533
591
  }
534
592
  if (data.outcome === 'bundle-already-installed') {
535
- return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: data.bundleName }), " is already fully installed (v", data.version, ")", where, "."] }), _jsx(Text, { dimColor: true, children: "Use --force to reinstall." }), _jsx(BundleReportLines, { bundleName: data.bundleName, report: data })] }));
593
+ return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: data.bundleName }), " is already fully installed (v", data.version, ")", where, "."] }), _jsx(BundlePinLine, { pin: data.pin }), _jsx(Text, { dimColor: true, children: "Use --force to reinstall." }), _jsx(BundleReportLines, { bundleName: data.bundleName, report: data })] }));
536
594
  }
537
595
  if (data.outcome === 'bundle-installed') {
538
596
  return (_jsxs(Box, { flexDirection: 'column', children: [data.toolResults.map(({ results, skipped, tool: toolName, warnings }) => (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { color: 'green', children: ["\u2713 Bundle ", _jsx(Text, { bold: true, children: data.bundleName }), " v", data.version, " \u2014 ", results.length, " asset", results.length !== 1 ? 's' : ''] }), _jsx(InstallSummary, { results: results, skipped: skipped, tools: [toolName], warnings: warnings, where: label })] }, toolName))), _jsx(BundleReportLines, { bundleName: data.bundleName, report: data }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
@@ -551,10 +609,10 @@ function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAns
551
609
  : '', "."] }), _jsx(Text, { dimColor: true, children: "It will no longer be auto-removed when its parent is uninstalled." })] }));
552
610
  }
553
611
  if (data.outcome === 'dry-run-install') {
554
- return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
612
+ return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), _jsx(NamedAssetLines, { assets: data.assets ?? [], dryRun: true, where: label }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
555
613
  }
556
614
  if (data.outcome === 'dry-run-bundle') {
557
- return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsxs(Text, { children: [_jsxs(Text, { bold: true, color: 'magenta', children: ["Bundle: ", data.bundleName] }), _jsxs(Text, { dimColor: true, children: [" v", data.version] })] }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), _jsx(BundleReportLines, { bundleName: data.bundleName, dryRun: true, report: data }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
615
+ return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsxs(Text, { children: [_jsxs(Text, { bold: true, color: 'magenta', children: ["Bundle: ", data.bundleName] }), _jsxs(Text, { dimColor: true, children: [" v", data.version] })] }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), data.inPlace && (_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: data.bundleName }), " is already fully installed (v", data.version, ")", where, "."] })), _jsx(BundlePinLine, { dryRun: true, pin: data.pin }), _jsx(BundleReportLines, { bundleName: data.bundleName, dryRun: true, report: data }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
558
616
  }
559
617
  if (data.outcome === 'deprecated') {
560
618
  return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { color: 'yellow', children: ["Warning: \"", data.name, "\" is deprecated \u2014 ", data.reason] }), data.replacement && (_jsxs(Text, { children: ["Consider using", ' ', _jsx(Text, { bold: true, color: 'cyan', children: data.replacement }), ' ', "instead."] })), _jsx(Text, { dimColor: true, children: "Use --force to install anyway." })] }));
@@ -696,6 +754,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
696
754
  name: bundle.name,
697
755
  ...(bundle.org ? { org: bundle.org } : {}),
698
756
  outcome: 'already-installed',
757
+ ...(request.pin ? { pin: request.pin } : {}),
699
758
  version: bundle.version,
700
759
  ...bundleReport(membersOutsideBundle(currentLockfile, bundleMembers(registry, bundle, tools), bundle), [], {
701
760
  adoptCommand: adoptCommandFor(request),
@@ -710,7 +769,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
710
769
  orgActive: Boolean(cliOrg || currentLockfile.org || config.org),
711
770
  pin,
712
771
  tool,
713
- }), effectiveJson);
772
+ }), { json: effectiveJson, tool });
714
773
  // Each bundle in the plan, in the order named, then the ones left out; and the orgs.
715
774
  const targetsField = (lockfile, planned) => {
716
775
  const installedBundles = toInstall.flatMap((request) => {
@@ -751,7 +810,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
751
810
  }),
752
811
  tools: toolNames,
753
812
  ...(await crossScope(plan)),
754
- ...preferredScope(plan),
813
+ ...(await preferredScope(plan)),
755
814
  };
756
815
  }
757
816
  return await withLockfileErrorHandling(projectDir, async () => {
@@ -773,7 +832,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
773
832
  outcome: 'installed',
774
833
  toolResults,
775
834
  ...(await crossScope(plan, projectDir)),
776
- ...preferredScope(plan),
835
+ ...(await preferredScope(plan)),
777
836
  };
778
837
  });
779
838
  }, [adopt, all, cliOrg, dryRun, force, pin, specs.join(' '), tool]);
@@ -911,7 +970,7 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
911
970
  // The picker already chose what installs here, so a preference for the other scope only gets a
912
971
  // notice, once the run has planned or installed (a failed install records none). An org's assets
913
972
  // are all its own, so each is named `@org/name`.
914
- const preferredScope = () => preferredScopeField(preferredScopeOf(plan, ctx.scope), (preferred) => preferredScopeCommand(preferred, { force, pin, tool }), effectiveJson);
973
+ const preferredScope = () => preferredScopeField(preferredScopeOf(plan, ctx.scope), (preferred) => preferredScopeCommand(preferred, { force, pin, tool }), { json: effectiveJson, tool });
915
974
  if (dryRun) {
916
975
  // An org's assets aren't named one by one, so --force doesn't move them past a pin or a dependent.
917
976
  const kept = withoutKeptDependencies(plan, ctx.lockfile, ctx.tools, {
@@ -920,8 +979,9 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
920
979
  scope: ctx.scope,
921
980
  });
922
981
  const field = await crossScope(plan);
982
+ const preferredField = await preferredScope();
923
983
  if (!cancelled) {
924
- setState({ phase: 'dry-run', plan: kept, tools: ctx.toolNames, ...field, ...preferredScope() });
984
+ setState({ phase: 'dry-run', plan: kept, tools: ctx.toolNames, ...field, ...preferredField });
925
985
  }
926
986
  return;
927
987
  }
@@ -942,8 +1002,9 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
942
1002
  scope: ctx.scope,
943
1003
  }));
944
1004
  const field = await crossScope(plan, ctx.projectDir);
1005
+ const preferredField = await preferredScope();
945
1006
  if (!cancelled)
946
- setState({ phase: 'done', toolResults, ...field, ...preferredScope() });
1007
+ setState({ phase: 'done', toolResults, ...field, ...preferredField });
947
1008
  }
948
1009
  catch (err) {
949
1010
  showError(err);
@@ -1141,19 +1202,29 @@ function plannedOutsideBundle(plan, lockfile, members, bundle) {
1141
1202
  /** The install of the targets that prefer the other scope, at that scope, with the run's own flags. */
1142
1203
  function preferredScopeCommand({ assets, scope }, { adopt, force, orgActive = false, pin, spec, tool, }) {
1143
1204
  const names = assets.map((asset) => asset.org ? formatOrgName(asset.org, asset.name) : orgActive ? `global:${asset.name}` : asset.name);
1144
- return installCommandFor(spec ?? names.join(' '), { adopt, force, pin, tool, user: scope === 'user' });
1205
+ // --adopt takes one bundle, so it goes with the spec (the bundle) and not with the members' names.
1206
+ return installCommandFor(spec ?? names.join(' '), {
1207
+ adopt: spec !== undefined && adopt,
1208
+ force,
1209
+ pin,
1210
+ tool,
1211
+ user: scope === 'user',
1212
+ });
1145
1213
  }
1146
1214
  /**
1147
1215
  * The plan's direct targets that prefer the other scope, as the outcome's `preferredScope`, with
1148
- * `command`, which installs them there. In JSON mode it also records the `preferred-scope` notice; a
1149
- * TTY run shows `PreferredScopeWarning` under its summary instead.
1216
+ * `command`, which installs them there, and `setup` when the user scope must be set up for `tool`
1217
+ * first. In JSON mode it also records the `preferred-scope` notice; a TTY run shows
1218
+ * `PreferredScopeWarning` under its summary instead.
1150
1219
  */
1151
- function preferredScopeField(preferred, command, json) {
1220
+ async function preferredScopeField(preferred, command, { json, tool }) {
1152
1221
  if (!preferred)
1153
1222
  return {};
1154
- const field = { ...preferred, command: command(preferred) };
1223
+ const readiness = await scopeReadiness(preferred.scope, tool);
1224
+ const setup = readiness.ready ? undefined : readiness.setup;
1225
+ const field = { ...preferred, command: command(preferred), ...(setup ? { setup } : {}) };
1155
1226
  if (json)
1156
- addNotice(preferredScopeNotice(preferred, field.command));
1227
+ addNotice(preferredScopeNotice(preferred, field.command, setup));
1157
1228
  return { preferredScope: field };
1158
1229
  }
1159
1230
  /**
@@ -1164,7 +1235,7 @@ function TargetLines({ bundles = [], dryRun = false, orgs = [], where, }) {
1164
1235
  const inScope = where ? ` in ${where}` : '';
1165
1236
  return (_jsxs(_Fragment, { children: [bundles.map((bundle) => {
1166
1237
  const spec = formatOrgName(bundle.org, bundle.name);
1167
- return (_jsxs(Fragment, { children: [bundle.outcome === 'already-installed' ? (_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: spec }), " is already fully installed (v", bundle.version, ")", inScope, "."] })) : (_jsxs(Text, { children: [_jsx(Text, { color: 'green', children: "\u2713" }), " Bundle ", _jsx(Text, { bold: true, children: spec }), " v", bundle.version, ' ', dryRun ? 'would be installed' : 'installed', inScope, "."] })), _jsx(BundleReportLines, { bundleName: spec, dryRun: dryRun, report: bundle })] }, spec));
1238
+ return (_jsxs(Fragment, { children: [bundle.outcome === 'already-installed' ? (_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: spec }), " is already fully installed (v", bundle.version, ")", inScope, "."] })) : (_jsxs(Text, { children: [_jsx(Text, { color: 'green', children: "\u2713" }), " Bundle ", _jsx(Text, { bold: true, children: spec }), " v", bundle.version, ' ', dryRun ? 'would be installed' : 'installed', inScope, "."] })), _jsx(BundlePinLine, { dryRun: dryRun, pin: bundle.pin }), _jsx(BundleReportLines, { bundleName: spec, dryRun: dryRun, report: bundle })] }, spec));
1168
1239
  }), orgs.map(({ count, org }) => (_jsxs(Text, { children: [_jsxs(Text, { bold: true, color: 'magenta', children: ["Org: @", org] }), _jsxs(Text, { dimColor: true, children: [' ', "\u2014 all ", count, " asset", count !== 1 ? 's' : ''] })] }, org)))] }));
1169
1240
  }
1170
1241
  //# sourceMappingURL=install.js.map