@salesforce/afv-skills 1.68.0 → 1.69.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 (188) hide show
  1. package/package.json +1 -1
  2. package/skills/afcc-setup-coordinate/SKILL.md +348 -0
  3. package/skills/afcc-setup-coordinate/assets/console-app/AFCC_Service_Console.app-meta.xml +19 -0
  4. package/skills/afcc-setup-coordinate/assets/console-app/Admin.profile-meta.xml +8 -0
  5. package/skills/afcc-setup-coordinate/assets/console-app/Standard.profile-meta.xml +8 -0
  6. package/skills/afcc-setup-coordinate/assets/gap_report_template.md +35 -0
  7. package/skills/afcc-setup-coordinate/assets/org_profile_template.json +16 -0
  8. package/skills/afcc-setup-coordinate/references/gotchas.md +22 -0
  9. package/skills/afcc-setup-coordinate/scripts/audit_org.sh +159 -0
  10. package/skills/agentforce-bot-upgrade/SKILL.md +117 -66
  11. package/skills/agentforce-bot-upgrade/assets/_vendored/agent-spec-template.md +139 -0
  12. package/skills/agentforce-bot-upgrade/references/_vendored/agent-design-and-spec-creation.md +1211 -0
  13. package/skills/agentforce-bot-upgrade/references/_vendored/agent-script-core-language.md +1390 -0
  14. package/skills/agentforce-bot-upgrade/references/_vendored/agent-subagent-map-diagrams.md +341 -0
  15. package/skills/agentforce-bot-upgrade/references/_vendored/agent-user-setup.md +672 -0
  16. package/skills/agentforce-bot-upgrade/references/_vendored/agent-validation-and-debugging.md +904 -0
  17. package/skills/agentforce-bot-upgrade/references/_vendored/agentscript-toolchain.md +112 -0
  18. package/skills/agentforce-bot-upgrade/references/_vendored/architecture-patterns.md +277 -0
  19. package/skills/agentforce-bot-upgrade/references/_vendored/common-control-flow-pitfalls.md +255 -0
  20. package/skills/agentforce-bot-upgrade/references/_vendored/control-flow-actions-sequencing.md +198 -0
  21. package/skills/agentforce-bot-upgrade/references/_vendored/control-flow-lifecycle-side-effects.md +87 -0
  22. package/skills/agentforce-bot-upgrade/references/_vendored/data-library-reference.md +891 -0
  23. package/skills/agentforce-bot-upgrade/references/_vendored/instruction-resolution.md +658 -0
  24. package/skills/agentforce-bot-upgrade/references/_vendored/org-setup-for-adl.md +551 -0
  25. package/skills/agentforce-bot-upgrade/references/_vendored/patterns-by-requirement.md +88 -0
  26. package/skills/agentforce-bot-upgrade/references/_vendored/posture-and-determinism.md +215 -0
  27. package/skills/agentforce-bot-upgrade/references/extraction-blueprint.md +11 -4
  28. package/skills/agentforce-bot-upgrade/references/generate-agent-spec.md +19 -3
  29. package/skills/agentforce-bot-upgrade/references/handoff-output-format.md +82 -52
  30. package/skills/agentforce-bot-upgrade/references/input-contract.md +8 -8
  31. package/skills/agentforce-bot-upgrade/references/mapping-rules.md +19 -6
  32. package/skills/agentforce-bot-upgrade/references/post-conversion-enhancements-reference.md +65 -6
  33. package/skills/agentforce-bot-upgrade/references/quality-checklist.md +4 -4
  34. package/skills/agentforce-bot-upgrade/references/sf-cli-bot-reference.md +17 -3
  35. package/skills/agentforce-hyperclassifier-configure/README.md +24 -0
  36. package/skills/agentforce-hyperclassifier-configure/SKILL.md +111 -0
  37. package/skills/agentforce-hyperclassifier-configure/assets/customer-org.env.example +4 -0
  38. package/skills/agentforce-hyperclassifier-configure/assets/sample_descriptions.json +8 -0
  39. package/skills/agentforce-hyperclassifier-configure/assets/sample_evals.csv +17 -0
  40. package/skills/agentforce-hyperclassifier-configure/references/api-contract.md +41 -0
  41. package/skills/agentforce-hyperclassifier-configure/references/authentication.md +35 -0
  42. package/skills/agentforce-hyperclassifier-configure/references/evaluation.md +46 -0
  43. package/skills/agentforce-hyperclassifier-configure/references/installation.md +35 -0
  44. package/skills/agentforce-hyperclassifier-configure/references/onboarding.md +93 -0
  45. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/__init__.py +1 -0
  46. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/client.py +219 -0
  47. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/eca.py +178 -0
  48. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/evaluation.py +207 -0
  49. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/onboarding.py +191 -0
  50. package/skills/agentforce-hyperclassifier-configure/scripts/hcopt/optimizer.py +187 -0
  51. package/skills/agentforce-hyperclassifier-configure/scripts/hyperclassifier.py +111 -0
  52. package/skills/agentforce-hyperclassifier-configure/scripts/report_hyperclassifier.py +149 -0
  53. package/skills/agentforce-hyperclassifier-configure/scripts/setup_hyperclassifier.py +74 -0
  54. package/skills/agentforce-hyperclassifier-configure/scripts/tests/test_hyperclassifier_skill.py +887 -0
  55. package/skills/agentforce-offline-experimentation-run/scripts/btlib/judge.py +23 -31
  56. package/skills/agentforce-offline-experimentation-run/scripts/btlib/messages.py +2 -1
  57. package/skills/agentforce-offline-experimentation-run/scripts/btlib/sfap.py +118 -2
  58. package/skills/agentforce-offline-experimentation-run/scripts/build_report.py +2 -2
  59. package/skills/agentforce-offline-experimentation-run/scripts/resolve-token.sh +9 -2
  60. package/skills/agentforce-offline-experimentation-run/scripts/sfap_replay.py +12 -1
  61. package/skills/commerce-react-storefront-create/SKILL.md +54 -21
  62. package/skills/dx-lifecycle-center/SKILL.md +24 -18
  63. package/skills/dx-lifecycle-center/examples/workflows.md +57 -34
  64. package/skills/dx-lifecycle-center/references/connect-api.md +33 -4
  65. package/skills/dx-lifecycle-center/references/connect-org.md +59 -28
  66. package/skills/dx-lifecycle-center/references/deploy.md +3 -3
  67. package/skills/dx-lifecycle-center/references/hub-org.md +19 -3
  68. package/skills/dx-lifecycle-center/references/list-orgs.md +50 -24
  69. package/skills/dx-lifecycle-center/references/troubleshooting.md +22 -1
  70. package/skills/dx-lifecycle-center/scripts/hub-get.sh +41 -0
  71. package/skills/dx-lifecycle-center/scripts/resolve-environment.sh +151 -4
  72. package/skills/dx-packaging-convert-1gp-to-2gp-create/SKILL.md +63 -0
  73. package/skills/dx-packaging-convert-1gp-to-2gp-create/references/conversion-operations.md +252 -0
  74. package/skills/dx-packaging-move-to-2gp-migrate/SKILL.md +2 -3
  75. package/skills/dx-packaging-move-to-2gp-migrate/references/api-operations.md +10 -7
  76. package/skills/dx-packaging-push-upgrade-configure/README.md +47 -0
  77. package/skills/dx-packaging-push-upgrade-configure/SKILL.md +355 -0
  78. package/skills/dx-packaging-push-upgrade-configure/references/best-practices.md +61 -0
  79. package/skills/dx-packaging-push-upgrade-configure/references/cli-reference.md +148 -0
  80. package/skills/dx-packaging-push-upgrade-configure/references/objects.md +106 -0
  81. package/skills/dx-packaging-push-upgrade-configure/references/soql-recipes.md +144 -0
  82. package/skills/experience-afv-analytics-query/SKILL.md +239 -0
  83. package/skills/experience-afv-analytics-query/references/references.md +176 -0
  84. package/skills/experience-app-mcp-delivery-generate/SKILL.md +142 -0
  85. package/skills/experience-app-mcp-delivery-generate/references/eca-consumer-key.md +26 -0
  86. package/skills/experience-app-mcp-delivery-generate/references/mcp-config-delivery.md +38 -0
  87. package/skills/experience-app-mcp-delivery-generate/references/plugin-format-and-publishing.md +80 -0
  88. package/skills/experience-app-mcp-delivery-generate/scripts/developer_name.mjs +9 -0
  89. package/skills/experience-app-mcp-delivery-generate/scripts/discover_mcp_context.mjs +114 -0
  90. package/skills/experience-app-mcp-delivery-generate/scripts/generate_mcp_config.mjs +27 -0
  91. package/skills/experience-app-mcp-delivery-generate/scripts/generate_plugin.mjs +184 -0
  92. package/skills/experience-app-mcp-delivery-generate/scripts/mcp_config.mjs +57 -0
  93. package/skills/experience-app-mcp-delivery-generate/scripts/preflight.mjs +109 -0
  94. package/skills/experience-app-mcp-delivery-generate/scripts/retrieve_eca_consumer_key.mjs +143 -0
  95. package/skills/experience-app-mcp-generate/SKILL.md +174 -0
  96. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.eca-meta.xml +7 -0
  97. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.ecaGlblOauth-meta.xml +15 -0
  98. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.ecaOauth-meta.xml +6 -0
  99. package/skills/experience-app-mcp-generate/assets/__ECA_NAME__.ecaOauthPlcy-meta.xml +12 -0
  100. package/skills/experience-app-mcp-generate/assets/__ECA_NAME___defaultPolicy.ecaPlcy-meta.xml +7 -0
  101. package/skills/experience-app-mcp-generate/assets/__MCP_SERVER_NAME__.mcpServerDefinition-meta.xml +5 -0
  102. package/skills/experience-app-mcp-generate/references/eca-fields.md +76 -0
  103. package/skills/experience-app-mcp-generate/references/mcp-objects.md +66 -0
  104. package/skills/experience-app-mcp-generate/references/tool-bindings.md +85 -0
  105. package/skills/experience-app-mcp-generate/references/troubleshooting.md +41 -0
  106. package/skills/experience-app-mcp-generate/references/ui-frameworks.md +19 -0
  107. package/skills/experience-app-mcp-generate/references/widget-resources.md +96 -0
  108. package/skills/experience-app-mcp-generate/scripts/activate_server.mjs +166 -0
  109. package/skills/experience-app-mcp-generate/scripts/check_setup_progress.mjs +212 -0
  110. package/skills/experience-app-mcp-generate/scripts/list_sites.mjs +211 -0
  111. package/skills/experience-app-mcp-generate/scripts/merge_tools.mjs +407 -0
  112. package/skills/experience-app-mcp-generate/scripts/preflight.mjs +127 -0
  113. package/skills/experience-app-mcp-generate/scripts/render_eca.mjs +144 -0
  114. package/skills/experience-app-mcp-generate/scripts/render_mcp_server.mjs +64 -0
  115. package/skills/experience-app-mcp-generate/scripts/retrieve_existing_prompts.mjs +145 -0
  116. package/skills/experience-app-mcp-generate/scripts/retrieve_existing_tools.mjs +72 -0
  117. package/skills/experience-app-mcp-generate/scripts/scan_tool_candidates.mjs +195 -0
  118. package/skills/experience-app-mcp-generate/scripts/utils/callback_url.mjs +36 -0
  119. package/skills/experience-app-mcp-generate/scripts/utils/developer_name.mjs +9 -0
  120. package/skills/experience-app-mcp-generate/scripts/utils/eca_check.mjs +156 -0
  121. package/skills/experience-app-mcp-generate/scripts/utils/metadata_path.mjs +13 -0
  122. package/skills/experience-app-mcp-generate/scripts/verify_server.mjs +118 -0
  123. package/skills/experience-cms-content-type-generate/SKILL.md +1 -1
  124. package/skills/nonprofit-fundraising-configure/SKILL.md +1 -1
  125. package/skills/nonprofit-fundraising-configure/references/mcp-invocation.md +52 -4
  126. package/skills/nonprofit-fundraising-configure/references/permission-targeting.md +19 -2
  127. package/skills/platform-custom-field-generate/SKILL.md +24 -16
  128. package/skills/platform-custom-metadata-type-generate/SKILL.md +1 -0
  129. package/skills/platform-custom-setting-generate/SKILL.md +1 -0
  130. package/skills/platform-dataspace-access-configure/SKILL.md +25 -10
  131. package/skills/platform-flexipage-generate/SKILL.md +7 -10
  132. package/skills/platform-flexipage-generate/references/mcp_action_examples.md +42 -38
  133. package/skills/platform-policy-rule-generate/SKILL.md +9 -7
  134. package/skills/platform-policy-rule-generate/references/condition-model.md +3 -3
  135. package/skills/platform-policy-rule-generate/references/conjunction-expression.md +9 -1
  136. package/skills/platform-policy-rule-generate/references/consumer-datacloud-ui.md +9 -1
  137. package/skills/platform-policy-rule-generate/references/examples/ExistsJoinRLS/policyRuleDefinitionSets/ExistsJoinRLS.policyRuleDefinitionSet +1 -2
  138. package/skills/platform-policy-rule-generate/references/examples/FieldReadDeny/policyRuleDefinitionSets/FieldReadDeny.policyRuleDefinitionSet +1 -2
  139. package/skills/platform-policy-rule-generate/references/examples/LastCharactersFieldMasking/policyRuleDefinitionSets/LastCharactersFieldMasking.policyRuleDefinitionSet +1 -2
  140. package/skills/platform-policy-rule-generate/references/examples/PrincipalFieldMatchRLS/policyRuleDefinitionSets/PrincipalFieldMatchRLS.policyRuleDefinitionSet +1 -2
  141. package/skills/platform-policy-rule-generate/references/examples/TaggedObjectAccess/policyRuleDefinitionSets/TaggedObjectAccess.policyRuleDefinitionSet +1 -0
  142. package/skills/platform-policy-rule-generate/references/headless-transport.md +2 -2
  143. package/skills/platform-policy-rule-generate/references/policy-schema-full.md +1 -1
  144. package/skills/platform-policy-rule-generate/references/policy-shapes.md +33 -0
  145. package/skills/platform-policy-rule-generate/references/templates-advanced.md +1 -1
  146. package/skills/platform-policy-rule-generate/references/ui-compatibility.md +5 -5
  147. package/skills/platform-report-generate/SKILL.md +20 -1
  148. package/skills/platform-report-generate/references/summary-formulas-sorting-limits.md +118 -0
  149. package/skills/platform-report-generate/references/verification-checklist.md +12 -0
  150. package/skills/service-digital-engagement-channel-configure/SKILL.md +44 -107
  151. package/skills/service-digital-engagement-channel-configure/assets/messaging_channel_template.xml +2 -0
  152. package/skills/service-digital-engagement-channel-configure/examples/asa_agent_channel.xml +2 -2
  153. package/skills/service-digital-engagement-channel-configure/examples/auth_queue_channel.xml +58 -0
  154. package/skills/service-digital-engagement-channel-configure/examples/omni_flow_channel.xml +2 -2
  155. package/skills/service-digital-engagement-channel-configure/examples/omni_queue_channel.xml +3 -3
  156. package/skills/service-digital-engagement-channel-configure/references/channel_settings.md +18 -14
  157. package/skills/service-digital-engagement-channel-configure/references/onboarding_contract.md +16 -20
  158. package/skills/service-digital-engagement-channel-configure/references/prechat_params.md +10 -0
  159. package/skills/service-digital-engagement-channel-configure/references/recaptcha_handoff.md +38 -0
  160. package/skills/service-digital-engagement-channel-configure/references/user_verification.md +9 -0
  161. package/skills/service-digital-engagement-channel-configure/scripts/check-api-version.sh +4 -4
  162. package/skills/service-digital-engagement-channel-configure/scripts/normalize-channel-name.sh +12 -7
  163. package/skills/service-e911-configure/SKILL.md +242 -0
  164. package/skills/service-itsm-agentic-setup-agent-runtime-access-assign/SKILL.md +1 -1
  165. package/skills/service-itsm-agentic-setup-agentforce-coordinate/SKILL.md +1 -1
  166. package/skills/service-itsm-agentic-setup-agentforce-studio-configure/SKILL.md +1 -1
  167. package/skills/service-itsm-agentic-setup-agentforce-studio-validate/SKILL.md +1 -1
  168. package/skills/service-itsm-agentic-setup-employee-agent-configure/SKILL.md +1 -1
  169. package/skills/service-itsm-agentic-setup-fulfiller-agent-configure/SKILL.md +1 -1
  170. package/skills/service-itsm-agentic-setup-incident-management/SKILL.md +47 -44
  171. package/skills/service-itsm-agentic-setup-incident-management/examples/output-templates.md +110 -83
  172. package/skills/service-itsm-agentic-setup-incident-management/references/manage-incidents-with-ai.md +7 -3
  173. package/skills/service-itsm-agentic-setup-incident-management/references/priority-matrix.md +7 -5
  174. package/skills/service-itsm-agentic-setup-incident-management/references/sla-milestones.md +2 -2
  175. package/skills/service-itsm-agentic-setup-incident-management/references/status-checks.md +437 -0
  176. package/skills/service-itsm-agentic-setup-itsm-agentforce-permset-assign/SKILL.md +1 -1
  177. package/skills/agentforce-bot-upgrade/references/planner-workflow-reference.md +0 -78
  178. package/skills/dx-lifecycle-center/assets/widgets/connect-connected/connect-connected.json +0 -65
  179. package/skills/dx-lifecycle-center/assets/widgets/connect-connected/schema.json +0 -32
  180. package/skills/dx-lifecycle-center/assets/widgets/connect-sign-in/connect-sign-in.json +0 -57
  181. package/skills/dx-lifecycle-center/assets/widgets/connect-sign-in/schema.json +0 -21
  182. package/skills/dx-lifecycle-center/scripts/card-policy.jq +0 -71
  183. package/skills/dx-lifecycle-center/scripts/fill-widget.jq +0 -29
  184. package/skills/dx-lifecycle-center/scripts/widget.sh +0 -28
  185. package/skills/experience-content-media-image-generate/SKILL.md +0 -83
  186. package/skills/experience-content-media-image-generate/scripts/download-image.sh +0 -84
  187. package/skills/experience-content-media-stock-image-search/SKILL.md +0 -193
  188. package/skills/experience-content-media-stock-image-search/scripts/download-stock-image.py +0 -102
@@ -7,9 +7,11 @@ The targets are the DX Inspector environments, **not** the orgs authorized on th
7
7
  ## 1. Run the resolver
8
8
 
9
9
  ```bash
10
- bash <skill_dir>/scripts/resolve-environment.sh <source-org-alias> [identifier]
10
+ bash scripts/resolve-environment.sh "<source-org-alias>" ["<identifier>"] [--check-sessions]
11
11
  ```
12
12
 
13
+ Add `--check-sessions` when showing the list (section 4). It probes each workspace login that belongs to a listed environment with one cheap query and fills `session`. Leave it off when only resolving a target for Deploy or Connect: the session probes are skipped there (the per-user sign-in check and the hub read still run, in parallel with a timeout), so that path needs no extra org calls.
14
+
13
15
  `<source-org-alias>` is the alias the user named, else the default org from `sf org display --json`. Pass `identifier` exactly as the user gave it. It accepts:
14
16
 
15
17
  | The user gives | Example |
@@ -22,10 +24,10 @@ bash <skill_dir>/scripts/resolve-environment.sh <source-org-alias> [identifier]
22
24
  The script runs `SELECT Id, Name, NamedCredential, OrgType, IsExpired, OrgUrl, OrgIdentifier FROM DevopsEnvironment ORDER BY Name` and prints one JSON document:
23
25
 
24
26
  - `source`: `alias`, `username`, `orgId`, `instanceUrl` of the source org.
25
- - `environments[]`: each row with `state` of `selectable`, `expired`, or `unauthenticated`.
27
+ - `environments[]`: each row with `state` (`selectable`, `expired`, `unauthenticated`) and the workspace fields. `workspaceAlias` is `registered`, `missing`, or `unknown`, and `workspaceAliasName` is the `sf` alias that holds the login (named like the environment, or any alias on the same org). `session` is `valid`, `expired`, or `unknown` (only with `--check-sessions`; `unknown` also covers a probe that timed out). `userAuth` is `configured`, `notConfigured`, or `unknown`: whether the **current user** has signed in to that environment (rows are shared by everyone with access to the dev org, the login is per user; `unknown` means the check failed, never treated as not signed in). `aliasConflict` is `true` when an alias named like the environment points at a different org. `readiness` combines them: `ready`, `needs-sync`, `needs-refresh`, `alias-conflict`, `needs-my-signin`, `needs-signin`, `retired`, or `unverified`. `needs-my-signin` wins over every sync state: the row is connected, but not by this user. Aliases are never used to choose a target.
26
28
  - With an identifier: `matchStatus`, `matches[]`, `match`, and `sourceMatched`.
27
29
 
28
- The Lifecycle Center org's own row is never returned (see `hub-org.md`).
30
+ The Lifecycle Center org's own row is never in `environments[]`. The resolver reports it separately as `hub` (`label`, `url`, `userAuth`, `workspaceAlias` as `registered`, `missing`, `conflict` or `unknown`, `cliAlias`, `isDeployTarget: false`), present only when the hub is connected: its row exists or its credential is readable (see `hub-org.md`).
29
31
 
30
32
  ## 2. If the script fails
31
33
 
@@ -34,7 +36,7 @@ It exits `1` and prints one reason on stderr. Say only what the reason supports:
34
36
  | Script says | Tell the user | Then |
35
37
  |---|---|---|
36
38
  | `DevOps Center not enabled or no access` | "DX Inspector isn't enabled for this org or user, so there are no environments to list or deploy to. An admin needs to enable it." | Stop. Do not run another query, do not fall back to `sf org list`, and do not offer a deploy. |
37
- | `query failed, not an enablement problem` | The error in plain words (often an expired session). | Tell them to reconnect the source org (in Builder Central use the Reconnect prompt; running the CLI locally, `sf org login web --alias <alias>`), then try again. Never say DX Inspector is disabled. |
39
+ | `query failed, not an enablement problem` | The error in plain words (often an expired session). | Tell them to reconnect the source org (in Builder Central use the Reconnect prompt; running the CLI locally, `sf org login web --alias "<alias>"`), then try again. Never say DX Inspector is disabled. |
38
40
  | `unexpected query result` | The environment lookup returned something unreadable. | Report that and stop. Do not guess a list. |
39
41
  | `cannot read source org` | The source org is not authorized on this machine. | Ask which org they build in. If it is not authorized, reconnect it the same way as above, then start again. |
40
42
  | `jq required` | `jq` is missing from the environment. | Report it and stop. |
@@ -52,43 +54,67 @@ It exits `1` and prints one reason on stderr. Say only what the reason supports:
52
54
  | `not-connected` | Not in DX Inspector. Offer to connect it (`connect-org.md`). If the identifier was an alias, URL, or org id, carry it into the connect flow so only the missing inputs are asked. |
53
55
  | `none-requested` | No target named: show the list (section 4). |
54
56
 
55
- When the identifier is an alias that is not connected, `sf org display --target-org <alias> --json` gives its URL, which sets the `orgType` by the host table in `connect-org.md`. Use the alias as the suggested environment name (letters only) and still ask the user to confirm the type if the host does not decide it.
57
+ When the identifier is an alias that is not connected, `sf org display --target-org "<alias>" --json` gives its URL, which sets the `orgType` by the host table in `connect-org.md`. Use the alias as the suggested environment name and still ask the user to confirm the type if the host does not decide it.
56
58
 
57
59
  ## 4. Show the list
58
60
 
59
- A numbered table with the columns `#`, `Name`, `Type`, `URL`, `Org id`, `Status`:
61
+ Show the orgs the user can use, then say in one line what is left out.
62
+
63
+ **Table** (columns `#`, `Name`, `Type`, `URL`, `Org id`): one row per environment with `state = selectable`. **Never list the current (source) org.** It is not a deploy target, so leave out any row with `isSource: true` and do not append a row for `source`. Mention the current org only if the user asks about it (section 5).
60
64
 
61
- - One row per entry in `environments[]`, then the **source org** as the last row. A row with `isSource: true` is the source org: show it once, as that last row, never as a selectable environment.
65
+ - **Lifecycle Center row.** When `hub` is present and `hub.userAuth` is `configured`, add one last row: Name `Lifecycle Center (Production Org)`, Type `Production`, URL from `hub.url`, Org id `—`. Follow the table with: "Lifecycle Center (Production Org) is the Lifecycle Center hub. It is not a deploy target." It gets no button and is never in Sync all. If `hub` is null or not `configured`, say nothing about it.
62
66
  - Always include the `Org id` column. Write `—` for any empty cell.
63
- - The source org's `Type` is always `—`: `source` carries no org type, so never infer one.
64
- - Never show row ids or credential names.
65
- - If several rows share a name, tell them apart by URL.
67
+ - **Same org under several names.** Environments are separate connections, so two or more can point at one org (same `Org id`). Keep each row, but add one line after the table: "`<A>`, `<B>` and `<C>` are three connections to the same org (`<Org id>`)." Tell the user this whenever they ask to copy or move something between two of them: it would do nothing or create a duplicate, so offer a genuinely different org instead.
68
+ - Never show row ids or credential names. If several rows share a name, tell them apart by URL.
69
+ - There is no status column. The state is shown as the **action button** under the table (below), so the user fixes a row with one click instead of reading a status.
66
70
 
67
- | Row | Status column |
68
- |---|---|
69
- | `state = selectable` | Selectable |
70
- | `state = expired` | Retired or replaced |
71
- | `state = unauthenticated` | Not authenticated |
72
- | The source org | `<alias> (current org, source)`. It is the source, so it is **not** a deploy target. If the user picks it, explain that and ask for another. |
71
+ **Where the list comes from.** Rows are the DX Inspector environments, so an org connected in DX Inspector (the Lifecycle Center UI) is listed even though it was never connected from Builder Central chat. Such an org has a credential but **no workspace CLI alias**, so `sf ... --target-org "<name>"` fails here until it is synced. An org connected from Builder Central chat gets both the row and the alias. The buttons cover both cases.
72
+
73
+ **Actions.** Under the table, offer one text action per selectable row, plus the batch action, as a short list. The user replying with the action (or the message shown) is their confirmation. The label depends on `readiness`:
74
+
75
+ | `readiness` | Button label | Message sent on click | What the click does |
76
+ |---|---|---|---|
77
+ | `needs-sync` | Sync `<name>` | `Sync workspace access for <name>` | Sync procedure (`connect-org.md`, *Sync workspace access*) |
78
+ | `unverified` | Sync `<name>` | same | same |
79
+ | `needs-refresh` | Refresh `<name>` | `Refresh workspace access for <name>` | same procedure |
80
+ | `ready` | Re-sync `<name>` | `Sync workspace access for <name>` | same procedure (safe: it overwrites the same alias with a fresh token) |
81
+ | `alias-conflict` | Fix name `<name>` | `Fix the workspace alias name for <name>` | Do **not** PATCH. Explain the clash and offer `sf alias unset` or a different name (`troubleshooting.md`) |
82
+ | `needs-my-signin` | Sign in as me: `<name>` | `Sign me in to <name>` | Per-user sign-in: repair path in `connect-org.md` (fresh link, login as this user, PATCH once). No sync before it; a sync would fail with 401/403 |
83
+ | `needs-signin` | Finish sign-in `<name>` | `Finish connecting <name>` | Repair path in `connect-org.md` |
84
+ | `retired` | none | | Not repairable; goes in the left-out line |
85
+
86
+ - When **two or more** rows are `needs-sync`, `needs-refresh`, or `unverified`, add a first button **Sync all N** (message `Sync workspace access for all connected orgs`). The batch runs the sync procedure for each of those rows in turn, one PATCH each, never in parallel, and reports one line per org.
87
+ - The source org row has no button.
88
+ - **Orgs connected by someone else.** Everyone with access to the dev org sees the same environments, but the sign-in belongs to one user. A `needs-my-signin` row is listed with its "Sign in as me" button, and one line goes after the table: "N orgs were connected by someone else; sign in to use them." Never offer Sync (or include the row in Sync all) for such a row. Do not claim it is unusable: deploys use the signed-in user's credential, so it is not deployable for this user until they sign in.
89
+ - No selectable row needs an action: skip the list. Otherwise, if the list would be long, add one sentence after the table naming the rows that need syncing and asking if they want them synced.
90
+ - Deploys run through DX Inspector's credential, not the workspace alias, so a row that needs a sync is still deployable. Say so only if the user asks.
91
+ - **Never sync by itself while listing.** A list is read-only. The sync runs only after a button click or an explicit request.
92
+
93
+ After a click the agent runs the procedure, then **shows the list again**, so the user sees the result. The list is rebuilt from a fresh resolver run, not from memory.
94
+
95
+ **Left-out line** (only if any row is `needs-signin` or `retired`; one sentence, placed after the table): "Not shown as usable: `<name>` (sign-in not finished), `<name>` (retired or replaced)." Details only if the user asks.
96
+
97
+ **Example** (table, then the button row):
98
+
99
+ | # | Name | Type | URL | Org id |
100
+ |---|---|---|---|---|
101
+ | 1 | MySandbox | Sandbox | mydomain--mysandbox.sandbox.my.salesforce.com | 00D5g000001AbCd |
102
+ | 2 | QaSandbox | Sandbox | mydomain--qa.sandbox.my.salesforce.com | 00D5g000001QqQq |
73
103
 
74
- Example:
104
+ The current org (`my-alias`) is not listed. Buttons: **Sync all 2**, **Re-sync MySandbox**, **Refresh QaSandbox**.
75
105
 
76
- | # | Name | Type | URL | Org id | Status |
77
- |---|---|---|---|---|---|
78
- | 1 | MySandbox | Sandbox | mydomain--mysandbox.sandbox.my.salesforce.com | 00D5g000001AbCd | Selectable |
79
- | 2 | OldSandbox | Sandbox | mydomain--old.sandbox.my.salesforce.com | — | Retired or replaced |
80
- | 3 | my-alias *(current org, source)* | — | mydomain.my.salesforce.com | 00D5g000001XyZw | — |
106
+ Not shown as usable: OldSandbox (retired or replaced).
81
107
 
82
108
  End the list with exactly this sentence and nothing after it:
83
109
 
84
110
  > Want to deploy to an org that isn't listed? I can help you connect a new one.
85
111
 
86
- Do not add any other offer, summary, or follow-up.
112
+ Do not add any other offer, summary, or follow-up. The action buttons are the only addition.
87
113
 
88
114
  | Situation | Reply instead of the table |
89
115
  |---|---|
90
116
  | No environments | "No environments are connected to DX Inspector in `<source-org-alias>` yet." Then the closing sentence. |
91
- | Every environment is expired or unauthenticated | "None of the connected environments can accept a deploy right now: <names and reasons>." Then the closing sentence. |
117
+ | No row has `state = selectable` | "None of the connected environments can accept a deploy right now: <names and reasons>." Then the closing sentence. |
92
118
 
93
119
  ## 5. Current-org details
94
120
 
@@ -14,10 +14,15 @@ Explain each problem to the user in plain language. Never echo raw JSON or token
14
14
  | User can't use the credential | Missing **Access DevOps Center Named Credentials** (`AccessDevOpsCenterNamedCredentials`) | Assign that permission set to the user in the dev org. |
15
15
  | Hub PATCH returns `404 Named credential does not exist` | POST never created the NC, or the name differs | Re-check the exact name (case-sensitive) and re-run Step 1. |
16
16
  | Hub PATCH returns `DOCE_CONNECTION_UPDATE_FAILED` | The `userinfo` callout failed, usually because the OAuth token is missing or expired | Confirm the principal is `Configured`, then re-run Steps 1–4. The user's saved DX Inspector selections were cleared, so they must pick them again. |
17
- | Deploy environment PATCH returns `TARGET_ORG_AUTHENTICATION_STATUS_CHECK_FAILED` (401/403), `TARGET_ORG_AUTHENTICATION_TIMEOUT` (408/504), or `TARGET_ORG_UNKNOWN_ERROR` (includes "Environment record not found" and "does not have a named credential") | The login is missing or expired, the callout timed out, or the id is wrong | Confirm the principal is `Configured` and the `id` is the POST's. Give a fresh link and PATCH once. Do not loop. |
17
+ | Deploy environment PATCH returns `TARGET_ORG_AUTHENTICATION_TIMEOUT` (408/504) | The target org or its login service did not answer in time. This says nothing about the credential | Wait about 10 seconds and PATCH once more. If it times out again, tell the user the org didn't respond and to try later. Do not give a sign-in link and do not delete or recreate anything. |
18
+ | Deploy environment PATCH returns `TARGET_ORG_AUTHENTICATION_STATUS_CHECK_FAILED` (401/403) | The login is missing, expired, or revoked | Confirm the principal is `Configured` and the `id` is the POST's. Give a fresh link and PATCH once. Do not loop. |
19
+ | Deploy environment PATCH returns `TARGET_ORG_UNKNOWN_ERROR` (includes "Environment record not found" and "does not have a named credential") | The id is wrong, or the connect never finished | Re-resolve the id from the environment list. If the row has no credential, use the repair path. Do not loop. |
18
20
  | PATCH `calloutUrl` or `orgUrl` is still a login host | Unexpected `userinfo` response | Stop and report. Do not hand the NC to deploy. |
19
21
  | Hub mode: `doceConnectionType` fails | The hub user lacks **DevOps Center User** | Assign the permission set in the Lifecycle Center org, then re-run the check. |
20
22
  | Deploy: `TARGET_ORG_SESSION_EXPIRED` or `Bad_OAuth_Token` | The target refresh token was revoked or expired. A stale token is not visible in the environment list; it only shows at deploy time | Repair: fresh link from `GET /connect/devops/environment/<id>`, user logs in, PATCH once. |
23
+ | Connected, but `sf ... --target-org "<name>"` says the alias is unknown | The alias POST is best effort and its failure is swallowed (no running workspace, workspace still booting past the retries, or the environment name was blank, had spaces, or was `default-org`) | Repeat the connect PATCH with `?registerWorkspaceAlias=true` and `--body '{}'` once, then re-check with `resolve-environment.sh`. If it is still missing, say the org is connected and deploys still work, and stop. |
24
+ | `sf` with the alias says `Session expired or invalid` (also `INVALID_SESSION_ID`, `RefreshTokenAuthError`) | The token the workspace holds is short-lived and was not refreshed. This is the workspace login, not the DX Inspector credential | Map the alias to its environment, say "Your workspace login to `<name>` expired", repeat the same PATCH once (no browser needed), then retry the failed command once. If the PATCH fails on auth, the DX Inspector login is stale: repair path (fresh sign-in link, login, PATCH). Never retry with another org's alias or `default-org`. |
25
+ | Environment shows `alias-conflict` | An `sf` alias with the environment name already points at a different org in this workspace. Repeating the PATCH would overwrite that alias | Do not repeat the PATCH. Ask the user to remove or rename the other alias (`sf alias unset "<name>"`), or reconnect under a different name. |
21
26
  | Environment shows `unauthenticated` (empty `OrgUrl` or `OrgIdentifier`) | The connect never finished: POST ran but login or PATCH did not | Same repair: fresh link, login, PATCH once. Do not POST again. |
22
27
  | `Doce Hub Environment` row is missing from the environment list | By design: the resolver drops the hub row (credential `ALMDevOpsCenterHub`, empty `OrgUrl`) because it is the Lifecycle Center hub, not a deploy target | Nothing to repair. To deploy to that org, connect it as a deploy target with the Environment API. |
23
28
  | Environment shows `expired` | `IsExpired` is set when an environment is retired or replaced by a swap; it is not an OAuth expiry | Do not repair it. Pick another environment or connect a new one. |
@@ -29,3 +34,19 @@ Explain each problem to the user in plain language. Never echo raw JSON or token
29
34
  **Hub:** delete both the **Named Credential** and the **External Credential** named `ALMDevOpsCenterHub` in Setup → Named Credentials (and the External Credentials tab), and run the skill again.
30
35
 
31
36
  For the hub, the **Remove DevOps Center Connection** option in DX Inspector does the same teardown.
37
+
38
+ ## Org connected in DX Inspector, not in Builder Central
39
+
40
+ An environment connected through the DX Inspector UI (Lifecycle Center) has a `DevopsEnvironment` row and a credential but no workspace alias. It appears in the list with a **Sync** button; `sf ... --target-org "<name>"` fails until it is synced (`connect-org.md`, *Sync workspace access*). No sign-in is needed while the credential is `Configured`.
41
+
42
+ ## Alias registration does not happen even after a sync
43
+
44
+ The PATCH succeeds but the alias never appears. The causes are on the server and invisible to the CLI: the feature gate is closed for the org, no workspace is running for the user, or the environment name is blank, contains whitespace, or is `default-org` in any casing. Repeat the sync once. If it still shows `needs-sync`, say the org is connected and deployable but has no CLI alias here, and stop.
45
+
46
+ ## Org listed, but connected by another user
47
+
48
+ | Symptom | Cause | Fix |
49
+ |---|---|---|
50
+ | Row shows `needs-my-signin` (`userAuth: notConfigured`) | DX Inspector environments are shared by everyone with access to the dev org, but the OAuth login is per user and this user has not signed in | Use the "Sign in as me" button: fresh sign-in link, log in **as this user**, PATCH once (repair path in `connect-org.md`). Do not sync first |
51
+ | Sync or deploy returns 401/403 on an org someone else connected | Same cause, found late | Treat as `needs-my-signin` |
52
+ | `userAuth: unknown` on every row | The credential status call failed (API version, permission, network) | List as usual; if a click then fails with 401/403, go to the row above |
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env bash
2
+ # Read-only GET against the Lifecycle Center org through the DX Inspector credential (ALMDevOpsCenterHub).
3
+ # No workspace alias and no record change: the call runs as the signed-in user, from the source org.
4
+ #
5
+ # Usage: hub-get.sh <source-org-alias> </services/data/vNN.N/...path?query>
6
+ # Prints the response body (JSON) on stdout. Exit codes: 0 HTTP 2xx, 1 usage / not 2xx / call failed.
7
+ set -uo pipefail
8
+
9
+ command -v jq >/dev/null || { echo "jq required" >&2; exit 1; }
10
+ SRC="${1:-}"; REQ="${2:-}"
11
+ [ -n "$SRC" ] && [ -n "$REQ" ] || { echo "usage: hub-get.sh <source-org-alias> </services/data/vNN.N/...>" >&2; exit 1; }
12
+ case "$REQ" in */../*|*/..|*%2e%2e*|*%2E%2E*) echo "path must not contain .." >&2; exit 1 ;; esac
13
+ printf '%s' "$REQ" | grep -Eq '^/services/data/v[0-9]+\.[0-9]+/' || { echo "path must start with /services/data/v<version>/" >&2; exit 1; }
14
+ # The path goes into an Apex string literal: allow only URL-safe characters (no quotes, backslashes, or whitespace).
15
+ printf '%s' "$REQ" | grep -Eq "^[A-Za-z0-9/._~%+=&?,:*()-]+$" || { echo "path has characters that are not allowed (encode spaces as %20 and quotes as %27)" >&2; exit 1; }
16
+
17
+ apex=$(mktemp "${TMPDIR:-/tmp}/hub-get.XXXXXX") || exit 1
18
+ trap 'rm -f "$apex"' EXIT
19
+ cat > "$apex" <<APEX
20
+ HttpRequest r = new HttpRequest();
21
+ r.setEndpoint('callout:ALMDevOpsCenterHub${REQ}');
22
+ r.setMethod('GET');
23
+ r.setHeader('Accept', 'application/json');
24
+ HttpResponse s = new Http().send(r);
25
+ System.debug('HUBGET ' + s.getStatusCode() + ' ' + EncodingUtil.base64Encode(Blob.valueOf(s.getBody())));
26
+ APEX
27
+ # One retry after a short pause covers a refreshing session or a transient hub error.
28
+ for attempt in 1 2; do
29
+ out=$(env FORCE_COLOR=0 SF_CLI_DISABLE_AUTOUPDATE=true sf apex run --file "$apex" --target-org "$SRC" --json 2>/dev/null) && \
30
+ line=$(printf '%s' "$out" | jq -r '.result.logs // ""' | grep -o 'HUBGET [0-9]* [A-Za-z0-9+/=]*' | head -1) || line=""
31
+ case "$line" in "HUBGET 5"*|"HUBGET 408"*|"") [ "$attempt" = 1 ] && { sleep 3; continue; } ;; esac
32
+ break
33
+ done
34
+ [ -n "$line" ] || { echo "no response captured; the callout failed (session expired, Apex not permitted, or the credential is not usable for this user): $(printf '%s' "$out" | jq -r '.result.exceptionMessage // .message // "unknown"' 2>/dev/null | head -c 200)" >&2; exit 1; }
35
+ code=$(printf '%s' "$line" | cut -d' ' -f2)
36
+ b64=$(printf '%s' "$line" | cut -d' ' -f3)
37
+ body=$(printf '%s' "$b64" | base64 -d 2>/dev/null || printf '%s' "$b64" | base64 -D 2>/dev/null)
38
+ # A truncated debug log decodes to partial JSON: never return it as a success.
39
+ printf '%s' "$body" | jq -e . >/dev/null 2>&1 || { echo "response was cut off or is not JSON; narrow the query (add LIMIT)" >&2; exit 1; }
40
+ printf '%s\n' "$body"
41
+ case "$code" in 2??) exit 0 ;; *) echo "hub returned HTTP $code" >&2; exit 1 ;; esac
@@ -3,8 +3,13 @@
3
3
  # identifier (alias, username, My Domain URL, 15/18-char org id, or environment name)
4
4
  # to one of them. Read-only. Prints one JSON document on stdout.
5
5
  #
6
- # Usage: resolve-environment.sh <source-org-alias> [identifier] [--rows-file <file>]
7
- # --rows-file read the DevopsEnvironment query result JSON from a file (tests)
6
+ # Usage: resolve-environment.sh <source-org-alias> [identifier] [--rows-file <file>] [--user-auth-file <file>] [--check-sessions]
7
+ # --rows-file read the DevopsEnvironment query result JSON from a file (tests)
8
+ # --user-auth-file read the per-user sign-in map (named credential -> configured | notConfigured | unknown)
9
+ # from a file instead of calling the org (tests)
10
+ # --check-sessions probe each workspace login that belongs to a listed environment with one
11
+ # cheap query (SELECT Id FROM Organization LIMIT 1) and report .session
12
+ # (valid / expired / unknown). Off by default: one org call per login.
8
13
  #
9
14
  # Exit codes: 0 ok (check .match / .matchStatus), 1 usage or call error.
10
15
  set -uo pipefail
@@ -13,15 +18,19 @@ command -v jq >/dev/null || { echo "jq required" >&2; exit 1; }
13
18
  SRC="${1:-}"
14
19
  [ -n "$SRC" ] || { echo "usage: resolve-environment.sh <source-org-alias> [identifier] [--rows-file <file>]" >&2; exit 1; }
15
20
  shift
16
- IDENT=""; ROWS_FILE=""
21
+ IDENT=""; ROWS_FILE=""; USER_AUTH_FILE=""; CHECK_SESSIONS=0
17
22
  while [ $# -gt 0 ]; do
18
23
  case "$1" in
19
24
  --rows-file) [ $# -ge 2 ] || { echo "--rows-file needs a value" >&2; exit 1; }; ROWS_FILE="$2"; shift 2 ;;
20
- *) IDENT="$1"; shift ;;
25
+ --user-auth-file) [ $# -ge 2 ] || { echo "--user-auth-file needs a value" >&2; exit 1; }; USER_AUTH_FILE="$2"; shift 2 ;;
26
+ --check-sessions) CHECK_SESSIONS=1; shift ;;
27
+ -*) echo "unknown option $1" >&2; exit 1 ;;
28
+ *) [ -z "$IDENT" ] || { echo "one identifier only; quote a name with spaces: \"Dev 12 Org\"" >&2; exit 1; }; IDENT="$1"; shift ;;
21
29
  esac
22
30
  done
23
31
 
24
32
  sfj() { env FORCE_COLOR=0 SF_CLI_DISABLE_AUTOUPDATE=true "$@" 2>/dev/null; }
33
+ tmpd=$(mktemp -d); trap 'rm -rf "$tmpd"' EXIT
25
34
 
26
35
  # Source org (the org the user built in).
27
36
  src_json=$(sfj sf org display --target-org "$SRC" --json) \
@@ -49,6 +58,115 @@ fi
49
58
  printf '%s' "$rows_json" | jq -e '.result.records' >/dev/null 2>&1 \
50
59
  || { echo "unexpected query result" >&2; exit 1; }
51
60
 
61
+ # Workspace logins: the aliases (and the org each one points at) that `sf ... --target-org <alias>` accepts
62
+ # here. Core registers an environment's name as an alias when its connect PATCH runs with
63
+ # registerWorkspaceAlias=true. An environment counts as present when an alias carries its name OR points
64
+ # at its org id (several environments can share one org). Local read, no org call.
65
+ # "null" = could not be read: workspace status is then reported as unknown.
66
+ aliases_json=$(sfj sf org list --skip-connection-status --json | jq -c \
67
+ '[.result | to_entries[] | .value | arrays[] | select(.alias != null) | {alias: .alias, orgId: ((.orgId // "")[0:15]), host: ((.instanceUrl // "") | sub("^https?://"; "") | sub("/.*$"; "") | ascii_downcase)}]' 2>/dev/null) || aliases_json=null
68
+ [ -n "$aliases_json" ] || aliases_json=null
69
+
70
+ # Optional session probe. One cheap query per login that belongs to a listed environment.
71
+ # A mapping alias -> valid | expired | unknown. A probe that times out or fails for any other reason is
72
+ # "unknown", never "expired": only a recognised session/refresh-token error counts as expired.
73
+ sessions_json='{}'
74
+ # Bound each probe to 20s with whatever is available (GNU timeout in the image, perl on macOS, else none).
75
+ if command -v timeout >/dev/null; then tmo="timeout 20"
76
+ elif command -v perl >/dev/null; then tmo="perl -e alarm(20);exec(@ARGV) --"
77
+ else tmo=""; fi
78
+ if [ "$CHECK_SESSIONS" = 1 ] && [ "$aliases_json" != null ]; then
79
+ want=$(printf '%s' "$rows_json" | jq -r '[.result.records[]? | (.OrgIdentifier // "")[0:15] | select(. != "")] | unique | .[]')
80
+ # Probes are independent, so run them side by side. Read line by line: an alias may contain spaces ("Dev 12 Org").
81
+ i=0
82
+ while IFS= read -r a; do
83
+ [ -n "$a" ] || continue
84
+ i=$((i+1)); printf '%s' "$a" > "$tmpd/s$i.k"
85
+ (
86
+ out=$(SF_TARGET_ORG="$a" SF_DISABLE_TELEMETRY=true sfj $tmo \
87
+ sf data query --target-org "$a" --json --query "SELECT Id FROM Organization LIMIT 1" </dev/null)
88
+ if printf '%s' "$out" | jq -e '.status == 0' >/dev/null 2>&1; then st=valid
89
+ elif printf '%s' "$out" | grep -Eiq 'INVALID_SESSION_ID|invalid_grant|RefreshTokenAuthError|Bad_OAuth_Token|expired access/refresh|Session expired or invalid'; then st=expired
90
+ else st=unknown; fi
91
+ printf '%s' "$st" > "$tmpd/s$i.v"
92
+ ) &
93
+ done < <(printf '%s' "$aliases_json" | jq -r --arg want "$want" \
94
+ '($want | split("\n")) as $w | .[] | select(.orgId as $o | $w | index($o)) | .alias')
95
+ wait
96
+ for k in "$tmpd"/s*.k; do
97
+ [ -f "$k" ] || continue
98
+ sessions_json=$(printf '%s' "$sessions_json" | jq -c --arg a "$(cat "$k")" --arg s "$(cat "${k%.k}.v" 2>/dev/null || echo unknown)" '. + {($a): $s}')
99
+ done
100
+ fi
101
+
102
+ # Hub credential read starts now and runs alongside the checks below (consumed at the hub step).
103
+ hub_ver="${DLC_API_VERSION:-68.0}"
104
+ if [ -z "$USER_AUTH_FILE" ]; then
105
+ ( sfj $tmo sf api request rest "/services/data/v${hub_ver}/named-credentials/named-credential-setup/ALMDevOpsCenterHub" --target-org "$SRC" </dev/null > "$tmpd/hub.nc"
106
+ sfj $tmo sf api request rest "/services/data/v${hub_ver}/named-credentials/external-credentials/ALMDevOpsCenterHub" --target-org "$SRC" </dev/null > "$tmpd/hub.ec" ) &
107
+ fi
108
+
109
+ # Per-user sign-in. DevopsEnvironment rows are shared by everyone with access to the dev org, but the OAuth
110
+ # token behind each one belongs to a single user (the external credential's PerUserPrincipal). Ask, for the
111
+ # user running this, whether each connected environment's principal is Configured. The external credential
112
+ # carries the same developer name as the row's named credential. A failed or unreadable check is "unknown",
113
+ # never "notConfigured": only an explicit NotConfigured counts.
114
+ user_auth_json='{}'
115
+ if [ -n "$USER_AUTH_FILE" ]; then
116
+ user_auth_json=$(cat "$USER_AUTH_FILE")
117
+ else
118
+ api_ver="${DLC_API_VERSION:-68.0}"
119
+ # One independent call per credential: run them side by side.
120
+ i=0
121
+ for nc in $(printf '%s' "$rows_json" | jq -r '.result.records[]? | select((.IsExpired // false) == false and (.OrgUrl // "") != "" and (.OrgIdentifier // "") != "")
122
+ | (.NamedCredential // "") | gsub("<[^>]*>"; "") | gsub("^\\s+|\\s+$"; "") | select(. != "" and . != "ALMDevOpsCenterHub")' | sort -u); do
123
+ i=$((i+1)); printf '%s' "$nc" > "$tmpd/u$i.k"
124
+ (
125
+ out=$(sfj $tmo sf api request rest "/services/data/v${api_ver}/named-credentials/external-credentials/${nc}" --target-org "$SRC" </dev/null)
126
+ st=$(printf '%s' "$out" | jq -r '[.principals[]? | select(.principalType == "PerUserPrincipal") | .authenticationStatus][0]
127
+ | if . == "Configured" then "configured" elif . == "NotConfigured" then "notConfigured" else "unknown" end' 2>/dev/null)
128
+ printf '%s' "${st:-unknown}" > "$tmpd/u$i.v"
129
+ ) &
130
+ done
131
+ wait
132
+ for k in "$tmpd"/u*.k; do
133
+ [ -f "$k" ] || continue
134
+ user_auth_json=$(printf '%s' "$user_auth_json" | jq -c --arg k "$(cat "$k")" --arg s "$(cat "${k%.k}.v" 2>/dev/null || echo unknown)" '. + {($k): $s}')
135
+ done
136
+ fi
137
+
138
+ # Lifecycle Center hub. Its row is dropped from environments[] (it is never a deploy target) but is reported
139
+ # separately as .hub so a list can show it, labelled. The hub counts as connected when its DevopsEnvironment row
140
+ # exists (made in DX Inspector) or its credential is readable (made by hub mode, which creates no row). The URL and
141
+ # this user's sign-in come from the credential. Unreadable pieces are null / "unknown".
142
+ hub_json=null
143
+ hub_name=$(printf '%s' "$rows_json" | jq -r '[.result.records[]? | select(((.NamedCredential // "") | gsub("<[^>]*>"; "") | gsub("^\\s+|\\s+$"; "")) == "ALMDevOpsCenterHub") | .Name][0] // ""')
144
+ hub_present=0; [ -n "$hub_name" ] && hub_present=1
145
+ hub_url=""; hub_auth=unknown
146
+ if [ -n "$USER_AUTH_FILE" ]; then
147
+ [ "$hub_present" = 1 ] && hub_auth=$(printf '%s' "$user_auth_json" | jq -r '.ALMDevOpsCenterHub // "unknown"')
148
+ else
149
+ wait
150
+ hub_url=$(jq -r '.calloutUrl // empty' "$tmpd/hub.nc" 2>/dev/null)
151
+ [ -n "$hub_url" ] && hub_present=1
152
+ if [ "$hub_present" = 1 ]; then
153
+ hub_auth=$(jq -r '[.principals[]? | select(.principalType == "PerUserPrincipal") | .authenticationStatus][0]
154
+ | if . == "Configured" then "configured" elif . == "NotConfigured" then "notConfigured" else "unknown" end' "$tmpd/hub.ec" 2>/dev/null)
155
+ fi
156
+ fi
157
+ if [ "$hub_present" = 1 ]; then
158
+ # CLI access by alias exists only if something registered the row's name as an alias here (Core skips names
159
+ # with spaces today). "conflict" = an alias of that name points at a different org than the hub.
160
+ hub_host=$(printf '%s' "$hub_url" | sed -E 's#^https?://##; s#[/?].*$##' | tr 'A-Z' 'a-z')
161
+ hub_alias=unknown
162
+ if [ "$aliases_json" != null ] && [ -n "$hub_name" ]; then
163
+ hub_alias=$(printf '%s' "$aliases_json" | jq -r --arg n "$hub_name" --arg h "$hub_host" \
164
+ '[.[] | select(.alias == $n)][0] as $x | if $x == null then "missing" elif ($h != "" and ($x.host // "") != "" and $x.host != $h) then "conflict" else "registered" end')
165
+ fi
166
+ hub_json=$(jq -nc --arg u "$hub_url" --arg a "${hub_auth:-unknown}" --arg w "$hub_alias" --arg n "$hub_name" \
167
+ '{label: "Lifecycle Center (Production Org)", url: (if $u == "" then null else $u end), userAuth: $a, workspaceAlias: $w, cliAlias: (if $n == "" then null else $n end), isDeployTarget: false}')
168
+ fi
169
+
52
170
  # Identifier -> comparable keys: org id (first 15), host, and a lowercase name.
53
171
  # Local alias or username: expand through `sf org display` to its org id and host.
54
172
  id15=""; host=""; name=""
@@ -73,6 +191,10 @@ fi
73
191
  jq -n \
74
192
  --argjson source "$source_obj" \
75
193
  --argjson rows "$rows_json" \
194
+ --argjson aliases "$aliases_json" \
195
+ --argjson sessions "$sessions_json" \
196
+ --argjson userauth "$user_auth_json" \
197
+ --argjson hub "$hub_json" \
76
198
  --arg ident "$IDENT" --arg id15 "$id15" --arg host "$host" --arg name "$name" '
77
199
  # setup and lightning hosts point at the same org as the My Domain host
78
200
  def norm: ascii_downcase | sub("^https?://"; "") | sub("[/?].*$"; "")
@@ -88,6 +210,15 @@ jq -n \
88
210
  def state: if (.IsExpired == true) then "expired"
89
211
  elif ((ncname == "") or (.OrgUrl // "") == "" or (.OrgIdentifier // "") == "") then "unauthenticated"
90
212
  else "selectable" end;
213
+ # The alias that gives this workspace a login for the environment: one named like it, else any alias on its org.
214
+ # A name match only counts when it points at the same org; an alias carrying the environment name, but on
215
+ # another org, is a collision (aliasConflict), never a login for this environment.
216
+ def namedAlias: (.Name // "") as $n | ([ $aliases[]? | select(.alias == $n) ][0]);
217
+ def aliasConflict: (namedAlias) as $a | ((.OrgIdentifier // "")[0:15]) as $o
218
+ | ($a != null and $o != "" and ($a.orgId // "") != "" and $a.orgId != $o);
219
+ def workspaceLogin: (.Name // "") as $n | ((.OrgIdentifier // "")[0:15]) as $o
220
+ | ( if aliasConflict then null else (namedAlias | if . == null then null else .alias end) end
221
+ // (if $o == "" then null else [ $aliases[]? | select(.orgId == $o) | .alias ][0] end) );
91
222
  [ ($rows.result.records // [])[] | select(ncname != "ALMDevOpsCenterHub" and ((.Name // "") != "Doce Hub Environment" or (.OrgUrl // "") != "")) ] as $recs
92
223
  | ($host | if . == "" then "" else norm end) as $h
93
224
  | [ $recs[] | {
@@ -96,6 +227,21 @@ jq -n \
96
227
  orgId: (.OrgIdentifier // null),
97
228
  namedCredential: (ncname | if . == "" then null else . end),
98
229
  state: state,
230
+ workspaceAlias: ( if $aliases == null then "unknown"
231
+ elif (workspaceLogin != null) then "registered"
232
+ else "missing" end ),
233
+ workspaceAliasName: (if $aliases == null then null else workspaceLogin end),
234
+ aliasConflict: (if $aliases == null then false else aliasConflict end),
235
+ userAuth: (if state == "selectable" then ($userauth[ncname] // "unknown") else null end),
236
+ session: ( (workspaceLogin) as $a | if $a == null then null else ($sessions[$a] // "unknown") end ),
237
+ readiness: ( if state == "expired" then "retired"
238
+ elif state == "unauthenticated" then "needs-signin"
239
+ elif ($userauth[ncname] // "unknown") == "notConfigured" then "needs-my-signin"
240
+ elif $aliases == null then "unverified"
241
+ elif aliasConflict and workspaceLogin == null then "alias-conflict"
242
+ elif workspaceLogin == null then "needs-sync"
243
+ elif $sessions[workspaceLogin] == "expired" then "needs-refresh"
244
+ else "ready" end ),
99
245
  isSource: ((.OrgIdentifier // "")[0:15] == ($source.orgId // "")[0:15] and (.OrgIdentifier // "") != "")
100
246
  } ] as $envs
101
247
  | ( if $ident == "" then []
@@ -106,6 +252,7 @@ jq -n \
106
252
  end ) as $m
107
253
  | { source: $source,
108
254
  environments: $envs,
255
+ hub: $hub,
109
256
  identifier: $ident,
110
257
  matchStatus: ( if $ident == "" then "none-requested"
111
258
  elif ($m | length) == 0 then "not-connected"
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: dx-packaging-convert-1gp-to-2gp-create
3
+ description: "Use this skill when users want to convert a managed-released 1GP package to a 2GP package with `sf package convert`, verify the converted package version and its code coverage, and optionally promote it to released. TRIGGER when: the user asks to convert a 1GP managed package to 2GP, create a converted 2GP package version from a released 1GP version, check whether a converted version passed code coverage, or troubleshoot an `sf package convert` failure. DO NOT TRIGGER for: migrating subscriber orgs from 1GP to 2GP, finalizing the irreversible move to 2GP development (use dx-packaging-move-to-2gp-migrate), creating or promoting native 2GP package versions that were not converted from 1GP, or enabling Dev Hub (use dx-org-devhub-configure)."
4
+ metadata:
5
+ relatedSkills:
6
+ - dx-org-devhub-configure
7
+ - dx-packaging-move-to-2gp-migrate
8
+ version: "1.0.0"
9
+ accessCheck: "UserPermissions.CreatePackaging"
10
+ cliTools:
11
+ - tool:
12
+ - "sf"
13
+ semver: ">=2.0.0"
14
+ domains:
15
+ - "Developer Experience"
16
+ ---
17
+
18
+
19
+ # Convert 1GP to 2GP
20
+
21
+ ## When to Use This Skill
22
+
23
+ Convert a managed-released 1GP package to 2GP with `sf package convert` when requested by an ISV. This workflow gathers and validates both Salesforce CLI org aliases, confirms the permanent Dev Hub association, runs conversion with `--code-coverage`, verifies the resulting 08c, 0Ho, 05i, and 04t records, and determines whether the converted beta version passed the code-coverage check required for promotion. After a successful conversion, it asks whether the customer wants to promote the verified version and, on an explicit yes, promotes and verifies it. It does not migrate subscriber orgs or finalize the irreversible Move-to-2GP development cutover.
24
+
25
+ ## Critical Constraints
26
+
27
+ **Preconditions:**
28
+
29
+ - The latest Salesforce CLI must be installed and the customer must be in a Salesforce DX project containing sfdx-project.json. (check: `SalesforceCliAndProjectAvailable`)
30
+ - The customer's Partner Business Org must have Dev Hub and second-generation managed packaging enabled, and its authenticated CLI alias must resolve successfully. (check: `DevHubOrgAuthenticated`)
31
+ - The 1GP packaging org must be authenticated with Salesforce CLI and its alias must resolve successfully. The namespace of the 1GP package must be linked to the selected Dev Hub. (check: `PackagingOrgAuthenticatedAndNamespaceLinked`)
32
+ - The source package must have at least one managed-released 1GP version. Source API-version eligibility is evaluated by the conversion command and is handled only if Salesforce returns that error. (check: `ManagedReleasedPackageVersionEligible`)
33
+ - The customer must choose either an installation key or installation-key bypass. Never ask the customer to paste an installation key into chat or store it in skill output. (check: `InstallationProtectionChoiceProvided`)
34
+
35
+ **Operational rules:**
36
+
37
+ - CONVERSATION RULE: ask exactly one question per turn and wait for the customer's answer before asking the next question. Never combine a confirmation, a command request, and a list of additional inputs in one message. When the customer must run a command, provide only that command and ask for its sanitized result; continue after they respond.
38
+ Start with collect-conversion-details and gather only the identity and package inputs sequentially: Dev Hub alias, 1GP packaging-org alias, 033 package ID, and package namespace. Do not ask about project, version mode, installation protection, wait time, definition file, seed metadata, unpackaged metadata, or apexTestAccess yet. Then run validate-salesforce-cli → validate-devhub-alias → validate-packaging-org-alias → validate-source-package → collect-conversion-options → validate-project-and-namespace → collect-conversion-settings → confirm-conversion-preflight → convert-package → verify-conversion-request → verify-code-coverage. After an explicit yes to the promotion question, continue to promote-converted-version → verify-promoted-version.
39
+ OPTION QUESTIONS: after identifying the package and released source version, ask every configurable option separately, exactly one question per turn. Show that question's default in brackets and accept either a specific answer or the word `default`. A `default` response applies only to the current question; never apply a bundle of defaults or skip later questions. Ask separately for: source version, DX project, installation protection, wait time, definition file changes, seed-metadata availability, unpackaged-metadata availability, and apexTestAccess permission sets. Ask for a seed-metadata directory path only when the customer says seed metadata exists, and for an unpackaged-metadata directory path only when the customer says packaged Apex tests need unpackaged metadata. The option defaults are latest released major.minor; create a new `<namespace>-conversion` project in the current working directory; installation-key bypass; wait 20 minutes; no changes to the project's default definition file; no seed metadata; no unpackaged metadata; and no apexTestAccess permission sets. Before creating a project, state the exact target path. Never silently reuse an existing project from an earlier conversation or run. The permanent Dev Hub association has no default and must be confirmed separately. Do not ask the customer which API version created the source 1GP version.
40
+ PROJECT DEFINITION FILE: create or validate the selected DX project before asking the remaining conversion-setting questions. Resolve and show the exact `<project-directory>/config/project-scratch-def.json` path and its current non-secret contents. Then ask: "Would you like to add or update anything in this definition file for conversion? [default: no changes]" Do not ask the customer to provide a definition-file path. Include `--definition-file` only when the customer confirms the file is required for conversion.
41
+ SEED METADATA: first ask: "Do you have seed metadata to include in the conversion? [default: no]" If the answer is no or `default`, omit `--seed-metadata` and continue. If the answer is yes, ask in the next turn for the exact seed-metadata directory path, validate it, and use that path.
42
+ UNPACKAGED METADATA: after the seed-metadata question, ask: "Do your packaged Apex tests need metadata that is not part of the package in order to run? For example, test-only Apex classes, custom objects or fields, or permission sets that must not ship in the package. [default: no]" If the answer is no or `default`, leave sfdx-project.json unchanged for unpackaged metadata and continue. If the answer is yes, ask in the next turn for the directory path relative to the DX project root, then confirm that the directory exists and contains source-format metadata. Explain the difference when the customer is unsure: seed metadata is deployed so the package metadata itself can deploy, while unpackaged metadata is deployed to the build org only so packaged Apex tests can run for code coverage, and it is never included in the converted package. There is no `sf package convert` flag for unpackaged metadata. Salesforce CLI reads `unpackagedMetadata.path` from the sfdx-project.json packageDirectories entry for this package, and only when `--code-coverage` is set, which this workflow always uses. That entry must have a `package` value that resolves through packageAliases to the converted package's 0Ho ID. On the first conversion, Salesforce CLI adds a packageAliases entry named after the 1GP package when it creates the converted package, so set `package` to the exact name Salesforce CLI uses for that alias; read it from the Dev Hub with `sf data query --use-tooling-api --target-org <devhub-alias> --query "SELECT Name FROM SubscriberPackage WHERE Id = '<033>'"`. On a later conversion, use the existing packageAliases entry or the 0Ho ID. The same `package` requirement applies to apexTestAccess. Show the customer the exact proposed change to that packageDirectories entry, for example `"package": "<package-name>", "unpackagedMetadata": { "path": "<directory>" }`, and update sfdx-project.json only after they confirm. Preserve every other setting in the file. If that entry already declares `package` or `unpackagedMetadata`, show the current values and ask whether to keep or change them instead of proposing a duplicate. When the customer also provides apexTestAccess permission sets, show both changes to the entry together in one proposal.
43
+ Treat the two aliases as different org roles. The Dev Hub alias owns the new converted Package2 and cannot be changed after the first conversion for this 1GP package. The packaging-org alias identifies the source 1GP DE org and is also required for supported org-shape and metadata troubleshooting. If an alias is missing, guide the customer through `sf org login web --alias <alias>` (add `--set-default-dev-hub` for the Dev Hub), then rerun the exact `sf org display` validation. Do not continue until the customer confirms the displayed org IDs match the intended organizations.
44
+ ALIAS DISCOVERY AND AUTHENTICATION: both orgs are required for conversion. Handle one org role at a time. Ask the customer for the packaging-org alias and Dev Hub alias if not already provided; never invent or select an alias. Run `sf org list --json` to check what is authenticated. If an alias is missing, give the customer the exact login command and wait: `sf org login web --alias <packaging-org-alias>` for the packaging org, and `sf org login web --alias <devhub-alias> --set-default-dev-hub` for the Dev Hub. For a nonstandard login domain, append a customer-provided `--instance-url <url>`. After login, require `sf org display --target-org <alias> --json`; show the alias, username, org ID, and instance URL and ask the customer to confirm the intended org. Never ask for or expose an access token, authorization URL, session ID, or credential file.
45
+ AUTHENTICATED TERMINAL: run org discovery, login, validation, package queries, conversion, and reporting in one CLI environment and operating-system user profile. The agent may run the displayed login command locally when browser OAuth is supported; otherwise the customer runs it and all remaining commands in their terminal. Never split validation and conversion across environments. Require a successful `sf org display --target-org <alias> --json` for each alias in the chosen environment. Immediately before conversion, require successful `sf org display` checks for both aliases in that same environment. When chat-local OAuth succeeded, run conversion in that chat-local environment. On the fallback path, present the conversion command with the instruction: "Run this in the same authenticated terminal where both org display checks succeeded." Do not describe an arbitrary new shell as authenticated merely because it can access the project.
46
+ Success requires all of the following: the conversion request reaches Status=Success; Package2Id, Package2VersionId, and SubscriberPackageVersionId are present; the converted version report shows ConvertedFromVersionId; and HasPassedCodeCoverageCheck is true. The converted version remains beta until the customer explicitly chooses promotion.
47
+ SUCCESS RESPONSE: give the customer a complete converted-package summary: source package name, namespace, 033 ID, source version and source 04t; Dev Hub alias and org ID; 08c request ID and status; Package2 name and 0Ho ID; Package2Version 05i ID; SubscriberPackageVersion 04t ID; converted version number; beta/released state; ConvertedFromVersionId; code-coverage percentage and HasPassedCodeCoverageCheck; metadata file count, total metadata size, and whether metadata was removed; build duration when available; installation URL; and any non-secret warnings. State explicitly that the converted version is still beta before promotion.
48
+ If and only if `HasPassedCodeCoverageCheck` is true, end the success response with exactly one question: "Would you like to promote this converted package version now?" If the customer says yes, run `sf package version promote` with the verified 04t and Dev Hub alias, then verify the same 04t reports `IsReleased=true`. Promotion is irreversible, so never infer consent. If the customer says no, leave the version beta. If coverage did not pass, do not offer promotion.
49
+ PROMOTION RESPONSE: after verified promotion, give the customer the complete package details again, including all conversion identifiers and source version details, the converted version number, code coverage, metadata counts and size, build duration, installation URL, and `Release state: Released`. State that promotion succeeded and do not ask the promotion question again.
50
+ CLI COMMAND CONTRACT — run from the validated Salesforce DX project. Validate each org separately with `sf org display --target-org <alias> --json`. Start conversion with `sf package convert --package <033> --target-dev-hub <devhub-alias> --code-coverage --wait 20 --json` plus exactly one of `--installation-key-bypass` or `--installation-key <enter-key-locally>`. Append `--patch-version <major.minor.patch>`, `--definition-file <path>`, or `--seed-metadata <directory>` only when the customer selected those options. Unpackaged metadata is never passed as a flag; it comes from the confirmed `unpackagedMetadata` setting in sfdx-project.json, so run conversion from the DX project root where that relative path resolves. Never place an installation key in chat, logs, generated files, or a command the agent executes on the customer's behalf.
51
+ If the convert command returns before completion, preserve its 08c ID and run `sf package version create report --package-create-request-id <08c> --target-dev-hub <devhub-alias> --json`; do not start a duplicate conversion. Once an 08c ID is available, use this report command immediately and then approximately every two minutes until the request reaches Success or Error. After every report, give the customer a short update containing the 08c ID, current status, and any non-secret status details returned by the CLI. Do not say that the same CLI process is still being monitored when request-report polling is available. After Status=Success, run `sf package version report --package <04t> --target-dev-hub <devhub-alias> --verbose --json` and require both a populated ConvertedFromVersionId and HasPassedCodeCoverageCheck=true.
52
+ TROUBLESHOOTING — do not proactively ask for or confirm the source package version's API version. If conversion returns an error that the selected 1GP version was created with an unsupported API version, tell the customer to upload a new managed-released 1GP version using API 57.0 or later, then retry conversion with that newly released version. For a RecordType dependency, declare the RecordType under object settings in a scratch-org definition file and retry with `--definition-file <path>`. For an org-shape error, run `sf org delete shape --target-org <packaging-org-alias>`, then `sf org create shape --target-org <packaging-org-alias>`, and retry once; recurring org-shape errors go to Salesforce Partner Support. For packaged Apex test or code-coverage errors, add required permission sets through `apexTestAccess` and the package name in sfdx-project.json, then retry. For a StandardValueSet or picklist-value error, retrieve the named StandardValueSet from the packaging org using the official Metadata API workflow, place only StandardValueSet metadata under the seed-metadata directory, and retry with `--seed-metadata <directory>`. When packaged Apex tests fail because test-only metadata that is not in the package is missing, configure unpackaged metadata as described above and retry. If the CLI reports that the un-packaged metadata directory does not exist, correct `unpackagedMetadata.path` so it is relative to the DX project root and retry from that root. If the CLI reports that unpackagedMetadata or apexTestAccess can't be resolved because the packageDirectories entry doesn't specify the package parameter, add `package` to that entry and retry. If it reports that the specified package isn't a valid package ID or package alias, set `package` to the packageAliases entry that maps to the converted 0Ho ID, or to the 0Ho ID itself, and retry; find the 0Ho ID with `sf package list --target-dev-hub <devhub-alias> --json`. If unpackaged metadata is configured but tests still fail as though it were missing, update Salesforce CLI, because older versions can ignore an unresolvable setting instead of reporting it. For unsupported metadata, report the metadata types named by the CLI; the customer must remove them from the source package or wait for managed 2GP support. For "namespace is not owned by the Dev Hub," stop and ask the customer to link the package namespace in Dev Hub Setup under Namespace Registries → Link Namespace. Revalidate both aliases in the same CLI environment, then retry conversion once. For authentication, project, or installation-protection errors, return to the matching validation step.
53
+ Retry conversion at most once after a documented remediation and prerequisite revalidation. For a timeout, poll the existing 08c request instead of converting again. When the CLI returns an internal Salesforce error identifier without a documented customer remediation, tell the customer that conversion failed with that identifier and that the failure could be intermittent. First confirm that no active 08c request exists, revalidate both aliases and the unchanged inputs, then retry the same conversion exactly once. If the retry returns the same identifier or message, stop and recommend a Salesforce Partner Support case. For any repeated or otherwise unclassified error, prepare a sanitized support bundle containing the CLI version, timestamp, exact redacted command, full sanitized output, 033/source-04t/08c identifiers, both org IDs and instance URLs, reproduction steps, relevant project configuration, and business impact. Never include installation keys, access tokens, session IDs, internal systems, or undocumented workarounds.
54
+
55
+ ## Verification Checklist
56
+
57
+ After every write operation, confirm the effect by re-reading state:
58
+
59
+ - After `convert-package`: call `verify-conversion-request`
60
+ - After `verify-conversion-request`: call `verify-code-coverage`
61
+ - After `promote-converted-version`: call `verify-promoted-version`
62
+
63
+ Read [Operations reference](references/conversion-operations.md) before executing this workflow. It contains the original operation definitions, dependencies, inputs, and verification instructions.