@salesforce/afv-skills 1.71.0 → 1.72.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 (116) hide show
  1. package/package.json +1 -1
  2. package/skills/agentforce-generate/SKILL.md +8 -0
  3. package/skills/agentforce-generate/assets/agents/README.md +1 -1
  4. package/skills/agentforce-generate/references/actions-reference.md +4 -0
  5. package/skills/agentforce-generate/references/mcp-actions-in-agent-script.md +233 -0
  6. package/skills/agentforce-generate/references/reference-map.md +1 -0
  7. package/skills/dx-packaging-convert-1gp-to-2gp-create/SKILL.md +9 -7
  8. package/skills/dx-packaging-convert-1gp-to-2gp-create/references/conversion-operations.md +78 -4
  9. package/skills/dx-packaging-move-to-2gp-migrate/SKILL.md +17 -13
  10. package/skills/dx-packaging-move-to-2gp-migrate/references/api-operations.md +110 -9
  11. package/skills/experience-app-mcp-generate/references/troubleshooting.md +1 -1
  12. package/skills/experience-app-mcp-generate/scripts/merge_tools.mjs +49 -18
  13. package/skills/experience-app-mcp-generate/scripts/render_eca.mjs +1 -1
  14. package/skills/experience-app-mcp-generate/scripts/render_mcp_server.mjs +1 -1
  15. package/skills/experience-app-mcp-generate/scripts/scan_tool_candidates.mjs +3 -1
  16. package/skills/experience-ui-bundle-custom-app-generate/SKILL.md +32 -26
  17. package/skills/experience-ui-bundle-custom-app-generate/references/configure-metadata-custom-application.md +6 -24
  18. package/skills/nonprofit-fundraising-configure/references/mcp-invocation.md +4 -6
  19. package/skills/platform-apex-generate/SKILL.md +2 -1
  20. package/skills/platform-apex-generate/assets/abstract.cls +0 -4
  21. package/skills/platform-apex-generate/assets/invocable-action-extension.invocableactionextension-meta.xml +28 -0
  22. package/skills/platform-apex-generate/assets/invocable.cls +2 -0
  23. package/skills/platform-apex-generate/references/dml-declarations.md +69 -0
  24. package/skills/platform-metadata-discovery-get/SKILL.md +15 -10
  25. package/skills/platform-metadata-grounding-get/SKILL.md +5 -3
  26. package/skills/service-add-agents-to-contact-center-create/SKILL.md +138 -0
  27. package/skills/service-agentforce-contact-center-coordinate/SKILL.md +5 -5
  28. package/skills/service-agentforce-contact-center-coordinate/references/omni-flow-routing.md +3 -3
  29. package/skills/service-agentforce-contact-center-coordinate/scripts/create-routing-flows.sh +8 -3
  30. package/skills/service-agentforce-contact-center-coordinate/scripts/create-voice-agent.sh +5 -5
  31. package/skills/service-agentforce-contact-center-coordinate/scripts/resolve-acc-queue.sh +10 -1
  32. package/skills/service-agentforce-contact-center-coordinate/scripts/resolve-channel-line.sh +4 -0
  33. package/skills/service-agentforce-contact-center-coordinate/scripts/resolve-flow-definition.sh +5 -0
  34. package/skills/service-agentforce-contact-center-coordinate/scripts/verify-number-live.sh +6 -1
  35. package/skills/service-concierge-portal-generate/SKILL.md +1 -1
  36. package/skills/service-concierge-portal-generate/references/portal-deploy-runbook.md +21 -8
  37. package/skills/service-digital-engagement-channel-configure/SKILL.md +45 -32
  38. package/skills/service-digital-engagement-channel-configure/assets/public_key_certificate_set_jwks_template.xml +20 -0
  39. package/skills/service-digital-engagement-channel-configure/assets/public_key_certificate_set_jwks_url_template.xml +23 -0
  40. package/skills/service-digital-engagement-channel-configure/assets/public_key_certificate_template.xml +15 -0
  41. package/skills/service-digital-engagement-channel-configure/examples/asa_agent_channel.xml +1 -1
  42. package/skills/service-digital-engagement-channel-configure/examples/auth_queue_channel.xml +3 -3
  43. package/skills/service-digital-engagement-channel-configure/examples/jwks_upload_key.xml +11 -0
  44. package/skills/service-digital-engagement-channel-configure/examples/jwks_upload_keyset.xml +13 -0
  45. package/skills/service-digital-engagement-channel-configure/examples/jwks_url_keyset.xml +17 -0
  46. package/skills/service-digital-engagement-channel-configure/examples/omni_flow_channel.xml +3 -3
  47. package/skills/service-digital-engagement-channel-configure/examples/omni_queue_channel.xml +3 -3
  48. package/skills/service-digital-engagement-channel-configure/examples/user_channel.xml +1 -1
  49. package/skills/service-digital-engagement-channel-configure/references/_vendored/service-onboarding-delegation-guidelines.md +43 -0
  50. package/skills/service-digital-engagement-channel-configure/references/channel_settings.md +1 -1
  51. package/skills/service-digital-engagement-channel-configure/references/keyset_settings.md +46 -0
  52. package/skills/service-digital-engagement-channel-configure/references/keyset_setup.md +42 -0
  53. package/skills/service-digital-engagement-channel-configure/references/onboarding_contract.md +28 -27
  54. package/skills/service-digital-engagement-channel-configure/references/recaptcha_handoff.md +2 -5
  55. package/skills/service-digital-engagement-channel-configure/references/routing_transitions.md +2 -2
  56. package/skills/service-digital-engagement-channel-configure/references/user_verification.md +3 -4
  57. package/skills/service-digital-engagement-channel-configure/references/user_verification_client.md +51 -0
  58. package/skills/service-digital-engagement-channel-configure/scripts/check-api-version.sh +7 -0
  59. package/skills/service-digital-engagement-deployment-configure/SKILL.md +28 -10
  60. package/skills/service-digital-engagement-deployment-configure/references/_vendored/service-onboarding-delegation-guidelines.md +43 -0
  61. package/skills/service-digital-engagement-deployment-configure/references/branding_and_tooling.md +2 -2
  62. package/skills/service-digital-engagement-deployment-configure/references/code_snippet.md +2 -2
  63. package/skills/service-digital-engagement-deployment-configure/references/connect_api_creation.md +13 -7
  64. package/skills/service-digital-engagement-deployment-configure/references/custom_labels.md +127 -0
  65. package/skills/service-digital-engagement-deployment-configure/references/deployment_settings.md +2 -1
  66. package/skills/service-digital-engagement-deployment-configure/references/onboarding_contract.md +24 -25
  67. package/skills/service-digital-engagement-deployment-configure/references/prechat_forms.md +1 -1
  68. package/skills/service-digital-engagement-deployment-configure/scripts/check-api-version.sh +7 -0
  69. package/skills/service-email-to-case-configure/SKILL.md +89 -80
  70. package/skills/service-email-to-case-configure/assets/CaseSettings.settings-meta.xml +1 -1
  71. package/skills/service-email-to-case-configure/examples/CaseSettings-two-addresses.settings-meta.xml +6 -3
  72. package/skills/service-email-to-case-configure/references/_vendored/service-onboarding-delegation-guidelines.md +43 -0
  73. package/skills/service-email-to-case-configure/references/agent-delegation.md +22 -0
  74. package/skills/service-email-to-case-configure/references/apply-mechanics.md +15 -12
  75. package/skills/service-email-to-case-configure/references/end-to-end-proof.md +14 -0
  76. package/skills/service-email-to-case-configure/references/onboarding-delegated-run.md +66 -0
  77. package/skills/service-email-to-case-configure/references/routing_address_reference.md +6 -2
  78. package/skills/service-email-to-case-configure/references/troubleshooting.md +17 -9
  79. package/skills/service-email-to-case-configure/scripts/apply-casesettings.py +863 -925
  80. package/skills/service-email-to-case-configure/scripts/tests/_agent.py +162 -0
  81. package/skills/service-email-to-case-configure/scripts/tests/_fakeorg.py +119 -155
  82. package/skills/service-email-to-case-configure/scripts/tests/_run.py +10 -17
  83. package/skills/service-email-to-case-configure/scripts/tests/test_apply_org_scenarios.py +14 -14
  84. package/skills/service-email-to-case-configure/scripts/tests/test_dispatch_contract.py +316 -0
  85. package/skills/service-email-to-case-configure/scripts/tests/test_new_capabilities.py +12 -43
  86. package/skills/service-email-to-case-configure/scripts/tests/test_validate_casesettings.py +13 -0
  87. package/skills/service-email-to-case-configure/scripts/validate-casesettings.py +17 -5
  88. package/skills/service-itsm-agentic-setup-incident-management/references/status-checks.md +11 -11
  89. package/skills/service-remove-agents-from-contact-center-assign/SKILL.md +145 -0
  90. package/skills/service-voice-configuration-manage/SKILL.md +206 -0
  91. package/skills/service-voice-configuration-manage/assets/regions.json +23 -0
  92. package/skills/service-voice-configuration-manage/references/lookups.md +91 -0
  93. package/skills/service-voice-configuration-manage/references/voice_config_api.md +169 -0
  94. package/skills/service-voice-configuration-manage/scripts/create-configuration.sh +20 -0
  95. package/skills/service-voice-configuration-manage/scripts/delete-configuration.sh +31 -0
  96. package/skills/service-voice-configuration-manage/scripts/get-configuration.sh +18 -0
  97. package/skills/service-voice-configuration-manage/scripts/lib.sh +22 -0
  98. package/skills/service-voice-configuration-manage/scripts/list-configurations.sh +18 -0
  99. package/skills/service-voice-configuration-manage/scripts/lookup-caller-lines.sh +30 -0
  100. package/skills/service-voice-configuration-manage/scripts/lookup-flows.sh +29 -0
  101. package/skills/service-voice-configuration-manage/scripts/lookup-profiles.sh +29 -0
  102. package/skills/service-voice-configuration-manage/scripts/lookup-users.sh +29 -0
  103. package/skills/service-voice-configuration-manage/scripts/update-configuration.sh +20 -0
  104. package/skills/tableau-next-asset-create/SKILL.md +10 -4
  105. package/skills/tableau-next-asset-create/references/dashboard-design-principles.md +133 -0
  106. package/skills/tableau-next-asset-create/references/data-transform-gotchas.md +284 -128
  107. package/skills/tableau-next-asset-create/references/deep-reference-index.md +3 -3
  108. package/skills/tableau-next-asset-create/references/edit-dashboard.md +1 -1
  109. package/skills/tableau-next-asset-create/references/edit-visualization.md +678 -468
  110. package/skills/tableau-next-asset-create/references/shared-gates.md +1 -1
  111. package/skills/tableau-next-asset-create/references/tasks/create-data-transform.md +120 -42
  112. package/skills/tableau-next-asset-create/references/tasks/create-viz.md +8 -0
  113. package/skills/tableau-next-asset-create/references/tasks/edit-viz.md +7 -4
  114. package/skills/tableau-next-asset-create/references/tasks/promote-or-reuse.md +9 -4
  115. package/skills/tableau-next-asset-create/references/viz-authoring.md +1 -1
  116. package/skills/service-email-to-case-configure/scripts/tests/test_get_session.py +0 -134
@@ -4,9 +4,10 @@ description: "Use this skill when users want to finalize the irreversible, one-w
4
4
  metadata:
5
5
  relatedSkills:
6
6
  - dx-org-devhub-configure
7
+ - dx-packaging-convert-1gp-to-2gp-create
7
8
  - dx-pkg-post-install-configure
8
9
  - experience-ui-bundle-2gp-deploy
9
- version: "1.1"
10
+ version: "1.2.0"
10
11
  accessCheck: "UserPermissions.CreatePackaging"
11
12
  cliTools:
12
13
  - tool:
@@ -30,8 +31,8 @@ BACKEND / VERSIONING MECHANICS (relocated from the discover card — describe-on
30
31
  - FINALIZE DISPATCH (266+): the agent-dispatchable path is the packaging Connect API POST /services/data/v69.0/connect/packaging/package/{packageId}/finalize-move-to-2gp (operationId finalizeMoveTo2gp), which runs against the 1GP DE org. The endpoint enforces the CreatePackaging edit-access gate, requires all three affirmation flags true, and verifies the {packageId} in the URL matches the package the org is currently converting — a mismatch returns 400. On success it finalizes the conversion, after which PackageConversion.EndDate is set (observable via verify-finalize-on-packaging-org). It performs the same finalize action that was previously available only through the Setup UI's Move-to-2GP dialog.
31
32
  - PRE-266 HISTORY / FALLBACK: before 266 no public agent-dispatchable API existed — finalize was available only as a Setup-page action the user completed in the browser, with no stable programmatic contract. The fallback delivers the user to the package's Setup detail page at `/udd/AllPackage/viewAllPackage.apexp` (any authenticated browser session to the packaging org reaches it), which hosts the "Move to Second-Generation Managed Packaging" dialog and its Proceed action. This remains the fallback for orgs on a pre-266 release.
32
33
  - CANNOT-CREATE BOUNDARY, MECHANICS: after finalize, new major/minor 1GP versions cannot be created — neither via `sf package1 version create` nor via the major/minor upload flow on viewAllPackage.apexp; all new major/minor innovation must use 2GP via `sf package version create`. Customers running on prior 1GP versions are unaffected.
33
- - PATCH EXCEPTION (surface conversationally only when the user asks e.g. "can I still cut a patch?"): PATCH versions of major.minor versions that existed BEFORE finalize remain permitted, to hotfix 1GP subscribers not yet migrated to 2GP. This exception is intentionally NOT part of the affirmation prompt the user confirms (the Setup dialog uses the same headline framing) — never put it in the affirmation.
34
- - ELIGIBILITY GATE (3-part proactive pre-check, two-org query): (a) the 1GP package's highest Released major.minor version, queried from the 1GP DE org via MetadataPackageVersion; (b) a corresponding 2GP-converted Package2Version at the same major.minor on DevHub, AND that 2GP version is Released; (c) no native 2GP version exists yet on DevHub (its presence means Move-to-2GP already happened — early exit). Parts (b)/(c) are the DevHub-side pre-check: run them when DevHub is authenticated to give the user a clear up-front answer; if (a) or (b) fails, surface what's missing + the fix (typically promote the converted 2GP version to Released). When DevHub is unavailable, this proactive check is skipped and the finalize endpoint enforces the same eligibility server-side (→ 400 on mismatch). DevHub eligibility queries hit the Package2 / Package2Version 0Ho-prefix entity.
34
+ - PATCH EXCEPTION (surface conversationally only when the user asks e.g. "can I still cut a patch?"): 1GP PATCH versions stay permitted only for major.minor versions LOWER than the finalized version, to hotfix 1GP subscribers not yet migrated to 2GP. Patches for the finalized major.minor itself must be built in 2GP: after finalizing at 1.4.0, a 1GP 1.3.x patch is allowed, but a 1GP 1.4.x patch is not. This exception is intentionally NOT part of the affirmation prompt the user confirms (the Setup dialog uses the same headline framing) — never put it in the affirmation.
35
+ - ELIGIBILITY GATE (3-part proactive pre-check, two-org query): (a) the 1GP package's highest Released version (major.minor.patch), queried from the 1GP DE org via MetadataPackageVersion; (b) a corresponding 2GP-converted Package2Version at the same major.minor.patch on DevHub, AND that 2GP version is Released (a patch as the highest Released 1GP version is never eligible); (c) no native 2GP version exists yet on DevHub (its presence means Move-to-2GP already happened — early exit). Parts (b)/(c) are the DevHub-side pre-check: run them when DevHub is authenticated to give the user a clear up-front answer; if (a) or (b) fails, surface what's missing + the fix (typically promote the converted 2GP version to Released). When DevHub is unavailable, this proactive check is skipped and the finalize endpoint enforces the same eligibility server-side (→ 400 on mismatch). DevHub eligibility queries hit the Package2 / Package2Version 0Ho-prefix entity.
35
36
  - PRE-FLIGHT (mandatory): Salesforce docs state "Before you complete your move to 2GP package development, it's critical that you thoroughly test package conversions and subscriber migrations first." Never invoke the manual step without explicit user affirmation that conversion + subscriber-migration testing is complete.
36
37
  - RELEASE HISTORY (both milestones shipped): 264 exposed the PackageConversion object read-only via the Tooling API (available when packaging is enabled for the org), lighting up verify-finalize-on-packaging-org as an EndDate-based wire-verify. 266 shipped the Connect API finalize endpoint POST /services/data/v69.0/connect/packaging/package/{packageId}/finalize-move-to-2gp (operationId finalizeMoveTo2gp), driven by the 1GP MetadataPackage Id (033-prefix) with the three affirmation flags in the request body; finalize-move-to-2gp dispatches invocation.kind: rest, is status: implemented, and the skill is now fully agent-driveable end-to-end. The manual browser fallback path is retained only as a pre-266 fallback.
37
38
  - WIRE-VERIFICATION (264+): the canonical post-finalize signal is PackageConversion.EndDate (non-null) on the 1GP DE org, queryable via the read-only Tooling exposure shipped in 264. The finalize endpoint's own response also returns finalizedAt + conversionId directly. Move-to-2GP does NOT auto-create a native (non-converted) Package2Version on DevHub — native versions are created later by a separate user-driven `sf package version create`, so their absence immediately post-finalize is expected, not a failure signal (i.e. there is no Package2Version-based wire-verify; EndDate is the reliable signal). verify-finalize-by-user-confirmation remains available as an optional human cross-check but is no longer the only verification surface.
@@ -42,22 +43,21 @@ BACKEND / VERSIONING MECHANICS (relocated from the discover card — describe-on
42
43
  **Preconditions:**
43
44
 
44
45
  - REQUIRED: the 1GP DE (packaging) org must be reachable with valid credentials. This is the one org the finalize path needs — an `sf` alias is the convenient way to authenticate, but the skill is NOT coupled to the `sf` CLI: any caller that can present a valid bearer token for this org (e.g. a raw REST call) works equally. The 1GP DE org hosts MetadataPackageVersion (the authoritative highest-Released 1GP version for the eligibility gate), is the org the finalize Connect API endpoint (266) runs against, hosts the read-only PackageConversion Tooling exposure (264) the wire-verify queries, and is the org the pre-266 manual browser fallback opens. (check: `PackagingOrgAuthenticated`)
45
- - OPTIONAL (recommended): authenticating the DevHub org lets the agent proactively pre-check eligibility before dispatching finalize — the converted 2GP Package2Version at the matching major.minor exists and is Released (Package2 + Package2Version live on DevHub). It is NOT a hard prerequisite: if DevHub is unavailable the skill can still finalize, because the Connect endpoint validates eligibility server-side and returns a 400 with a specific reason (e.g. version mismatch) when the latest released version has not been converted + promoted. Skipping the pre-check trades a clear up-front message for a server-side reject; it does not make the workflow unsafe (the irreversibility is gated by the three affirmations, not by DevHub). (check: `DevHubOrgAuthenticated`)
46
+ - OPTIONAL (recommended): authenticating the DevHub org lets the agent proactively pre-check eligibility before dispatching finalize — the converted 2GP Package2Version at the same major.minor.patch as the highest Released 1GP version exists and is Released (a patch is never eligible) (Package2 + Package2Version live on DevHub). It is NOT a hard prerequisite: if DevHub is unavailable the skill can still finalize, because the Connect endpoint validates eligibility server-side and returns a 400 with a specific reason (e.g. version mismatch) when the latest released version has not been converted + promoted. Skipping the pre-check trades a clear up-front message for a server-side reject; it does not make the workflow unsafe (the irreversibility is gated by the three affirmations, not by DevHub). (check: `DevHubOrgAuthenticated`)
46
47
  - User must have the CreatePackaging user permission (which implies CustomizeApplication) plus dev-org ownership of the package. This is the exact edit-access gate the finalize Connect endpoint enforces server-side — the same edit-access check the package's Setup detail page applies. A caller lacking it gets a 403 from the endpoint before any state is inspected (note: sysadmins do NOT clear this gate — edit access is org-dev scoped, not sysadmin-scoped). (check: Create Packaging permission [CreatePackaging])
47
48
  - Package conversion testing must be complete. Per the Salesforce documentation, "Before you complete your move to 2GP package development, it's critical that you thoroughly test package conversions and subscriber migrations first." An agent MUST explicitly confirm this with the user before proceeding to the finalize step. See "Test Converted Packages and Subscriber Migrations" (linked from the workflow doc) for the testing checklist. (check: `ConversionTestingComplete`)
48
- - Source files for the package's latest converted version should be retrieved before finalize. Per the docs, the user runs `sf package version retrieve --package 04tXXX --output-dir my-folder --target-dev-hub <devhub>` to retrieve, then edits sfdx-project.json's versionName, versionNumber, and ancestorVersion. This is preparatory work for ongoing 2GP development AFTER finalize, but the doc places it in the workflow sequence — the agent should remind the user. (check: `PackageSourceRetrievedAndProjectFileUpdated`)
49
+ - Source files for the package's latest converted version should be retrieved before finalize. Per the docs, the user runs `sf package version retrieve --package 04tXXX --output-dir my-folder --target-dev-hub <devhub>` to retrieve, then edits sfdx-project.json's versionName, versionNumber, and ancestorVersion. Retrieval needs the Download Package Version Zip Files user permission on the DevHub user; if retrieve fails with DeveloperUsePkgZipFieldUnavailableError, the user's DevHub admin must grant that permission (for example in a permission set) before retrying. This is preparatory work for ongoing 2GP development AFTER finalize, but the doc places it in the workflow sequence — the agent should remind the user. (check: `PackageSourceRetrievedAndProjectFileUpdated`)
49
50
 
50
51
  **Operational rules:**
51
52
 
52
53
  - AT START — the finalize path needs ONE org: the 1GP DE (packaging) org, reachable with valid credentials. A DevHub org is OPTIONAL-but-recommended, used only to proactively pre-check eligibility. Auth is not coupled to the `sf` CLI: an `sf` alias is convenient, but any valid bearer token for the org works for a raw REST call. Ask the user for the packaging-org alias (and, if they want the eligibility pre-check, the DevHub alias) at the start if not already provided; `sf org list --json` confirms what's authed. If the packaging org is missing, instruct the user to make it reachable (e.g. `sf org login web --alias <name>`) and wait. If only DevHub is missing you may still finalize — skip the DevHub-side eligibility queries and rely on the endpoint's server-side validation (a not-yet-converted/not-promoted package returns a 400 with a specific reason), and tell the user the proactive pre-check was skipped.
53
- MULTI-ORG DISPATCH (read once, important): this workflow spans two orgs — the 1GP DE (packaging) org and the DevHub org. Each step's `invocation` block carries a `target_org` field naming which org the call must hit (`{packaging_org_alias}` vs `{devhub_alias}`); route each call to the org its `target_org` names rather than assuming a single org for the whole workflow. Route to the DevHub org: discover-package-on-devhub, check-eligibility-2gp-converted-released, and check-already-done. Route to the packaging org: check-eligibility-1gp-released, finalize-move-to-2gp, and verify-finalize-on-packaging-org. If your execution channel can only reach one connected org at a time, run each off-target read-only step against the org named in its `target_org` before dispatching the finalize against the packaging org; a CLI-driven runner can map that routing onto its own tooling. A step sent to the wrong org returns empty or misleading results.
54
+ MULTI-ORG DISPATCH (read once, important): this workflow spans two orgs — the 1GP DE (packaging) org and the DevHub org. Each step's `invocation` block carries a `target_org` field naming which org the call must hit (`{packaging_org_alias}` vs `{devhub_alias}`); route each call to the org its `target_org` names rather than assuming a single org for the whole workflow. Route to the DevHub org: discover-package-on-devhub, check-eligibility-2gp-converted-released, and check-already-done. Route to the packaging org: check-eligibility-1gp-released, finalize-move-to-2gp, and verify-finalize-on-packaging-org (its PackageConversion query also runs before confirm-affirmations, with or without DevHub, on orgs at release 264 or later). If your execution channel can only reach one connected org at a time, run each off-target read-only step against the org named in its `target_org` before dispatching the finalize against the packaging org; a CLI-driven runner can map that routing onto its own tooling. A step sent to the wrong org returns empty or misleading results.
54
55
  TWO ROOT INTENTS — pick by user phrasing.
55
56
  INTENT A — "tell me how to move my package to 2GP" (planning /
56
57
  education): walk the user through the full sequence —
57
58
  discover-package-on-devhub → check-eligibility-1gp-released →
58
59
  check-eligibility-2gp-converted-released → check-already-done →
59
- remind-of-prerequisites (testing, source retrieval) → describe the
60
- manual finalize step in Setup. Treat this as a planning
60
+ remind-of-prerequisites (testing, source retrieval) → describe the finalize step (Connect API POST on 266+; the Setup dialog only for pre-266 orgs). Treat this as a planning
61
61
  conversation, NOT a dispatch action.
62
62
  - INTENT B — "do the move-to-2GP step now" (action request):
63
63
  discover-package-on-devhub → check-eligibility-1gp-released →
@@ -68,14 +68,18 @@ INTENT A — "tell me how to move my package to 2GP" (planning /
68
68
  (optional cross-check). The finalize step now dispatches the
69
69
  packaging Connect API POST directly against the 1GP DE org — the
70
70
  agent does NOT open a browser tab in the normal path. It MUST
71
- still obtain the three explicit affirmations in confirm-affirmations
71
+ still obtain each affirmation individually in confirm-affirmations
72
72
  first (the endpoint requires all three flags true and rejects the
73
73
  call otherwise), then POST, then wire-verify EndDate. The manual
74
74
  browser fallback path is retained only as a fallback for orgs on a
75
75
  pre-266 release (see finalize-move-to-2gp.invocation.fallback).
76
- - HARD STOP CONTRACT: this workflow is irrevocable. Per the documentation's "After you click Proceed, you can no longer create new major or minor versions in the packaging org." An agent MUST NOT instruct the user to click Proceed in Setup until ALL THREE of the following have been explicitly confirmed: (a) conversion testing is done, (b) subscriber migration testing is done, (c) the user understands the irreversibility. Skipping any of these is a contract violation regardless of how the user phrased the original request.
77
- EARLY EXIT: if check-already-done returns ≥1 row (a Package2Version exists with ConvertedFromVersionId = NULL), the move-to-2GP has ALREADY been completed — or the package was 2GP-native to start with. Report this to the user and stop. Do NOT proceed to affirmations or finalize.
78
- ELIGIBILITY GATING: if check-eligibility-1gp-released returns no Released 1GP version, OR if check-eligibility-2gp-converted-released returns no matching Released 2GP-converted version at the same major.minor, the user is NOT eligible to Move to 2GP. Surface the specific missing piece and what to do — typically "you need to promote 2GP version X.Y to Released before you can move-to-2GP." If DevHub is not authenticated, skip the proactive 2GP eligibility query and rely on the endpoint's server-side validation instead — the finalize call returns a 400 with a specific reason (e.g. version mismatch) when the latest released version has not been converted + promoted; relay that message to the user.
76
+ - HARD STOP CONTRACT: this workflow is irrevocable. Per the documentation's "After you click Proceed, you can no longer create new major or minor versions in the packaging org." An agent MUST NOT dispatch finalize-move-to-2gp, and MUST NOT instruct the user to click Proceed in Setup, until EACH of the following has been individually and explicitly confirmed in its own question: (a) the user understands the irreversibility, (b) conversion testing is done, (c) subscriber migration testing is done, (d) source files are retrieved and sfdx-project.json is updated. These are four questions, asked in this order, even though the endpoint takes three flags (acknowledgedTestingComplete needs both (b) and (c)). A single bare "yes" or "yes to all" never confirms more than one of these; re-ask each individually. If any is declined or unclear, STOP. Skipping any of these is a contract violation regardless of how the user phrased the original request.
77
+ - VALIDATE INPUTS EXACTLY AS GIVEN: check every user-supplied Id against its validation rule as a whole value. Use the org aliases (devhub_alias, packaging_org_alias) exactly as given, passed as a single-quoted shell argument (never inside double quotes, where `$(...)` and backticks still run); if an alias contains a newline, `;`, `|`, `&`, `$`, or a backtick, ask the customer to confirm or re-enter it (`pkgA; sf org list` is not shortened to `pkgA`). Never trim, split, extract a matching substring, or otherwise rewrite it to make it pass (e.g. `033xx0000004Fpd ; sf org list` is rejected, not shortened to `033xx0000004Fpd`); on mismatch, stop and ask for the exact value. Also check values returned by earlier steps before substituting them into later queries (package2_id must match the 0Ho Id pattern; MajorVersion / MinorVersion must be non-negative integers).
78
+ - PACKAGE2 LOOKUP: find the converted Package2 on DevHub by `Package2.ConvertedFromPackageId = '<1GP 033 Id>'`. Never look it up by `Package2.SubscriberPackageId` — a converted Package2 has its own, different 033 SubscriberPackageId, so that query returns 0 rows.
79
+ READ COMMANDS: Package2, Package2Version, MetadataPackage, MetadataPackageVersion and PackageConversion are Tooling API objects; the standard API returns INVALID_TYPE for them. Every read uses `sf data query --use-tooling-api`. Run each step's exact **Command** from the operations reference, with the single-quoted alias and only Ids that already passed validation.
80
+ ID FORMAT CHECKS: an Id is valid if it is exactly 15 or 18 letters and digits and starts with its prefix. Count the characters with a tool when one is available rather than by eye, and give one final verdict: never say a value is invalid and then correct yourself in the same answer.
81
+ EARLY EXIT if EITHER (a) check-already-done returns ≥1 row (a Package2Version exists with ConvertedFromVersionId = NULL): the move-to-2GP has ALREADY been completed, or the package was 2GP-native to start with; OR (b) PackageConversion.EndDate on the packaging org is set. A finalize creates no native version, so ALWAYS run (b), the verify-finalize-on-packaging-org Tooling API query, before confirm-affirmations, even when (a) returns 0 rows or DevHub is not available. The one exception is an org on a release before 264, where the query fails with INVALID_TYPE because PackageConversion doesn't exist there (only when run with --use-tooling-api; without it the same error means the command is wrong): don't fix or retry it; rely on (a), which needs DevHub, and on the Setup page (before any affirmation, ask the user, as one question, whether the package detail page still shows the Move to 2GP button; if it doesn't, the move is done). If (b) returns 0 rows, this org has no conversion record for the package (not converted yet, or wrong packaging org): stop before the questions and route the user to the conversion process. If EndDate is set, the move is already done. Report this to the user and stop. Do NOT proceed to affirmations or finalize.
82
+ ELIGIBILITY GATING: if check-eligibility-1gp-released returns no Released 1GP version, OR if check-eligibility-2gp-converted-released returns no matching Released 2GP-converted version at the same major.minor.patch, or the highest Released 1GP version is a patch, the user is NOT eligible to Move to 2GP. Surface the specific missing piece and what to do — typically "you need to promote the converted 2GP version X.Y.Z (its 04t) to Released before you can move-to-2GP." If DevHub is not authenticated, skip the proactive 2GP eligibility query and rely on the endpoint's server-side validation instead — the finalize call returns a 400 with a specific reason (e.g. version mismatch) when the latest released version has not been converted + promoted; relay that message to the user.
79
83
  RELEASE HISTORY (both milestones now shipped — describe-only, not an ongoing constraint): 264 shipped the read-only PackageConversion Tooling exposure, lighting up verify-finalize-on-packaging-org (EndDate-based wire-verify). 266 shipped the finalize Connect API — finalize-move-to-2gp now dispatches POST /services/data/v69.0/connect/packaging/package/{packageId}/finalize-move-to-2gp against the 1GP DE org (invocation.kind: rest, operationId finalizeMoveTo2gp, MCP-enabled). The endpoint requires the three affirmation flags (acknowledgedIrrevocable / acknowledgedTestingComplete / acknowledgedSourceRetrieved) all true in the request body, mirroring the Setup dialog's checkboxes — this is the load-bearing safety gate, so the confirm-affirmations step remains mandatory. For orgs still on a pre-266 release, the manual browser fallback applies.
80
84
  Only the 1GP DE (packaging) org is required for the finalize dispatch + wire-verify. The DevHub org is optional — used only for the proactive eligibility pre-check; the endpoint validates eligibility server-side regardless.
81
85
 
@@ -83,6 +87,6 @@ Only the 1GP DE (packaging) org is required for the finalize dispatch + wire-ver
83
87
 
84
88
  After every write operation, confirm the effect by re-reading state:
85
89
 
86
- - After `finalize-move-to-2gp`: call `verify-finalize-on-packaging-org` directly (normal 266+ path) OR `verify-finalize-by-user-confirmation` then `verify-finalize-on-packaging-org` (pre-266 manual fallback only).
90
+ - After `finalize-move-to-2gp`: call `verify-finalize-on-packaging-org` directly (normal 266+ path) OR, on the pre-266 manual fallback, `verify-finalize-by-user-confirmation`, then `verify-finalize-on-packaging-org` only on release 264-265 (before 264 the user's report is the only verification).
87
91
 
88
92
  Read [Operations reference](references/api-operations.md) before executing this workflow. It contains the original operation definitions, dependencies, inputs, and verification instructions.
@@ -2,6 +2,10 @@
2
2
 
3
3
  Operations grouped by purpose. Use these as the building blocks for the workflows above.
4
4
 
5
+ **Running the reads:** Package2, Package2Version, MetadataPackage, MetadataPackageVersion and PackageConversion are Tooling API objects. The standard API returns `INVALID_TYPE` for them, so every read below uses `sf data query --use-tooling-api`. Run each **Command** as shown: pass aliases single-quoted, and substitute only Ids that already passed their validation pattern.
6
+
7
+ **Id checks:** an Id is valid if it is exactly 15 or 18 letters and digits and starts with its prefix. Count the characters with a tool when one is available rather than by eye, and give one final verdict. Never say a value is invalid and then correct yourself in the same answer.
8
+
5
9
  ### Summary
6
10
 
7
11
  | Operation | Purpose | Status | Call | Depends on |
@@ -13,7 +17,7 @@ Operations grouped by purpose. Use these as the building blocks for the workflow
13
17
  | `confirm-affirmations` | validate | implemented | — | `check-already-done` |
14
18
  | `finalize-move-to-2gp` | write | implemented | `finalizeMoveTo2gp` | `confirm-affirmations` |
15
19
  | `verify-finalize-by-user-confirmation` | verify | implemented | — | `finalize-move-to-2gp` |
16
- | `verify-finalize-on-packaging-org` | verify | implemented | `queryPackageConversion` | `finalize-move-to-2gp` |
20
+ | `verify-finalize-on-packaging-org` | verify | implemented | `queryPackageConversion` | `finalize-move-to-2gp` (264 and later only) |
17
21
 
18
22
  ### Dependency graph
19
23
 
@@ -33,24 +37,34 @@ graph TD
33
37
  check_already_done --> confirm_affirmations
34
38
  confirm_affirmations --> finalize_move_to_2gp
35
39
  finalize_move_to_2gp --> verify_finalize_by_user_confirmation
36
- finalize_move_to_2gp --> verify_finalize_on_packaging_org
40
+ finalize_move_to_2gp -->|264+| verify_finalize_on_packaging_org
37
41
  ```
38
42
 
39
43
  ### Read operations
40
44
 
41
45
  #### `discover-package-on-devhub`
42
46
 
43
- Look up the 2GP Package2 record on DevHub for the 1GP package the user wants to move. The user provides the 1GP package by name (the customer-facing label) or by SubscriberPackageId (the 033... key prefix). Returns the Package2 Id (0Ho... key prefix) and namespace prefix, plus the SubscriberPackageId for use in eligibility queries. This is the DevHub-side anchor for the DevHub-side eligibility checks; the 1GP-side eligibility check uses the SubscriberPackageId (which equals the MetadataPackage Id on the 1GP DE org) directly.
47
+ Look up the 2GP Package2 record on DevHub for the 1GP package the user wants to move. The user provides the 1GP package by name (the customer-facing label) or by SubscriberPackageId (the 033... key prefix). Returns the Package2 Id (0Ho... key prefix), namespace prefix, and ContainerOptions of the converted Package2, plus its ConvertedFromPackageId (the 1GP 033 Id) for use in eligibility queries. This is the DevHub-side anchor for the DevHub-side eligibility checks; the 1GP-side eligibility check uses the 1GP package's 033 Id (the MetadataPackage Id on the 1GP DE org) directly.
48
+
49
+ **Lookup key:** find the converted Package2 with `SELECT Id, Name, NamespacePrefix, ConvertedFromPackageId, ContainerOptions FROM Package2 WHERE ConvertedFromPackageId = '<1GP 033 Id>'`. Do NOT query `Package2 WHERE SubscriberPackageId = '<1GP 033 Id>'` — a converted Package2 has its own, different SubscriberPackageId (a new 033 Id), so that query returns 0 rows for a correctly converted package. The 1GP 033 Id only appears on the converted Package2 as `ConvertedFromPackageId`.
44
50
 
45
51
  **Call:** `queryPackage2ByConvertedFrom` — status: `implemented`
46
52
 
47
53
  **Inputs:**
48
54
 
49
55
  - `devhub_alias` *(`String`)* — Source: user_input. The `sf` alias of the user's DevHub org. Captured at skill start (see agent_guidance "AT START").
56
+ - **Use exactly as given:** use the alias exactly as the customer gave it, and pass it as a single-quoted shell argument (never inside double quotes, where `$(...)` and backticks still run). If it contains a newline, `;`, `|`, `&`, `$`, or a backtick, it looks like it carries an extra command. Ask the customer to confirm or re-enter it. Never trim, split, or otherwise alter it; for example, `pkgA; sf org list` is not shortened to `pkgA`.
50
57
  - `subscriber_package_id` *(`String`)* — The 1GP package's SubscriberPackageId (033... key prefix). User provides this directly, or agent obtains it via a MetadataPackage name lookup on the 1GP DE org (see agent_guidance). Validate it against the `validation` pattern before substituting it into any query or URL path; if it does not match, stop and ask the user for the correct Id.
51
58
  - **Validation:** Must match `/^033[A-Za-z0-9]{12}([A-Za-z0-9]{3})?$/` (a 15- or 18-character 033-prefix Id). Reject any value containing single quotes, backslashes, or whitespace.
59
+ - **Validate exactly as given:** apply the pattern to the whole value the user supplied. Never trim, split, extract a matching substring, or otherwise rewrite it to make it pass. For example, `033xx0000004Fpd ; sf org list` does NOT match and must be rejected — do not keep the `033xx0000004Fpd` prefix. On any mismatch, stop and ask the user to re-enter just the Id.
60
+
61
+ **Command:** `sf data query --use-tooling-api --target-org '<devhub_alias>' --query "SELECT Id, Name, NamespacePrefix, ConvertedFromPackageId, ContainerOptions FROM Package2 WHERE ConvertedFromPackageId = '<1GP 033 Id>'" --json`
62
+
63
+ **Name lookup:** if the user only knows the package name, run `sf data query --use-tooling-api --target-org '<packaging_org_alias>' --query "SELECT Id, Name, NamespacePrefix FROM MetadataPackage" --json` on the 1GP DE org and filter the results client-side by Name. Do not interpolate user input into SOQL literals. The MetadataPackage `Id` is the 1GP 033 Id this step needs; validate it against the `validation` pattern before using it. If multiple packages match, list them and ask the user to pick by NamespacePrefix.
52
64
 
53
- **Name lookup:** if the user only knows the package name, query `SELECT Id, Name, NamespacePrefix FROM MetadataPackage` on the 1GP DE org and filter the results client-side by Name. Do not interpolate user input into SOQL literals.
65
+ **Validate returned values before reuse:** before substituting any value returned by this step or by `check-eligibility-1gp-released` into a later query, confirm `package2_id` matches `/^0Ho[A-Za-z0-9]{12}([A-Za-z0-9]{3})?$/` and that `MajorVersion` / `MinorVersion` are non-negative integers. If any value fails, stop — do not substitute it.
66
+
67
+ **Interpreting the result:** if the Package2 query returns 0 rows, the 1GP package has not been converted to 2GP yet. Stop and tell the user: "I can't find a 2GP-converted Package2 record for your 1GP package on this DevHub. The package needs to be converted to 2GP before Move-to-2GP can complete. See the [Move to 2GP workflow documentation](https://developer.salesforce.com/docs/atlas.en-us.pkg1_dev.meta/pkg1_dev/migration_move_to_2gp_workflow.htm) for the conversion process." Before concluding that, confirm the query used `ConvertedFromPackageId` (not `SubscriberPackageId`) and the correct DevHub alias.
54
68
 
55
69
  ### Write operations
56
70
 
@@ -72,6 +86,27 @@ Irrevocably finalize the Move-to-2GP transition by POSTing to the packaging Conn
72
86
 
73
87
  **Depends on:** `confirm-affirmations`
74
88
 
89
+ **Command** (run it only when all four questions in `confirm-affirmations` were confirmed, so each bound flag below is genuinely true; otherwise don't run it): `sf api request rest '/services/data/v69.0/connect/packaging/package/<1GP 033 Id>/finalize-move-to-2gp' --method POST --body '{"acknowledgedIrrevocable": true, "acknowledgedTestingComplete": true, "acknowledgedSourceRetrieved": true}' --target-org '<packaging_org_alias>'`
90
+
91
+ **Before dispatching:** dispatch the POST directly; do not open a browser tab in the normal path. Don't POST when the release is already known to be before 266 (`INVALID_TYPE` on the PackageConversion query, or an earlier 404 from this endpoint after a PackageConversion row); use the pre-266 fallback. Dispatch only when the eligibility gate passed and every affirmation in `confirm-affirmations` was individually confirmed by the user. Bind each body flag to the value the user confirmed (acknowledgedIrrevocable ← acknowledged_irrevocable, acknowledgedTestingComplete ← acknowledged_testing_complete, acknowledgedSourceRetrieved ← acknowledged_source_retrieved). Never hard-code them true. If any flag was not genuinely confirmed, STOP and do not dispatch — never attest on the user's behalf. The endpoint's own 400 on a false flag is a backstop, not a substitute for per-flag confirmation. `target_org` is the 1GP DE (packaging) org alias.
92
+
93
+ **Interpreting the response:**
94
+
95
+ - **200 with `successfullyFinalized=true`** — the move is done. Capture `finalizedAt` and `conversionId`, then run `verify-finalize-on-packaging-org`. Remind the user: "Your next step is to run `sf package version create` from your DX project to create your first native 2GP version."
96
+ - **400 `INVALID_INPUT`** — the request was rejected. Business-rule 400s use the error code `INVALID_INPUT`; tell the causes apart by the meaning of the message (it is localized, so don't match exact wording), and surface it verbatim. Common causes:
97
+ - An affirmation flag is missing or false — re-run `confirm-affirmations`.
98
+ - The URL packageId doesn't match the package being converted for this org — wrong package or wrong packaging org; re-check the discover output.
99
+ - "Package has already been moved to 2GP" — the move already happened. Run `verify-finalize-on-packaging-org`; if EndDate is set, report the move as done (an early-exit success, not an error). `check-already-done` should have caught this before the questions.
100
+ - "you must first convert and release the highest released version" — a newer 1GP version has no released converted 2GP equivalent. `check-eligibility-2gp-converted-released` should have caught this; flag that the eligibility query may need review.
101
+ - "Cannot finalize: ... has active released patch versions" — the highest released 1GP version is a patch. Same remediation as "A patch is not eligible" in `check-eligibility-1gp-released`: create the next major or minor 1GP version, convert it, promote it, then retry.
102
+ - "Cannot finalize: An active patch org exists" — tell the user what the message asks them to do.
103
+ - **403** — the caller lacks CreatePackaging edit access (or dev-org ownership), the feature is disabled org-wide, or the packageId does not exist (the access gate reports a missing package as 403, not 404). Confirm the user has CreatePackaging and is authenticated to the correct 1GP DE org.
104
+ - **404** — the package is editable but the org has no PackageConversion record; the package was never converted to 2GP. Route the user to run the conversion process first. Exception: if the PackageConversion query already returned a row for this package, a 404 means the endpoint itself is unavailable (org on release 264-265); use the pre-266 fallback instead.
105
+ - **400 `REQUIRED_FIELD_MISSING` or `INVALID_TYPE`** — the agent built the request wrong (missing packageId or body, or a wrong body type). Fix the request; don't re-ask the user.
106
+ - **500 `INTERNAL_ERROR`** — first run `verify-finalize-on-packaging-org`; if EndDate is set, the move is done. Otherwise, for "We couldn't verify the package", retry once; for any other 500, surface the message with its reference ID and point the user to Salesforce Partner Support.
107
+
108
+ **Pre-266 fallback:** use it only if the endpoint is unavailable (org on a release before 266). Open the fallback Setup path in the browser, walk the user through clicking Move to 2GP → Proceed, wait for their "done", then run `verify-finalize-by-user-confirmation`, followed by `verify-finalize-on-packaging-org` on release 264-265 only. To tell the release: `INVALID_TYPE` on the PackageConversion query, run with `--use-tooling-api`, means before 264; a PackageConversion row plus a 404 from the finalize endpoint means 264-265. The same rule applies: do not direct the user to click Proceed until every affirmation in `confirm-affirmations` is individually confirmed.
109
+
75
110
  ### Verify operations
76
111
 
77
112
  #### `verify-finalize-by-user-confirmation`
@@ -87,9 +122,15 @@ Human cross-check for the pre-266 manual fallback path ONLY: ask the user what t
87
122
 
88
123
  **Depends on:** `finalize-move-to-2gp`
89
124
 
125
+ **Interpreting the user's report (fallback path only):**
126
+
127
+ - **Success** — the user reports a success message and that the Move to 2GP button is gone. Report success with the package name and remind them to run `sf package version create` for their first native 2GP version of <package_name>.
128
+ - **Ambiguous** — the page didn't visibly change or the user isn't sure. Ask them to return to the package detail page and check whether the Move to 2GP button is still visible. If it is, finalize did NOT happen — walk them through it again. On 264+ orgs, `verify-finalize-on-packaging-org` gives the authoritative answer: EndDate populated means success regardless of the button.
129
+ - **Error** — capture the message verbatim and point the user to Salesforce Support; do not speculate about the internal cause. Common dialog causes: feature disabled org-wide, or an eligibility failure (a 1GP version newer than its converted 2GP equivalent).
130
+
90
131
  #### `verify-finalize-on-packaging-org`
91
132
 
92
- The canonical wire-verification: re-query the PackageConversion record on the 1GP DE org to confirm EndDate is populated (non-null). EndDate is set by the package-conversion finalization service as part of finalize and is the reliable post-finalize wire signal. Uses the read-only PackageConversion Tooling exposure shipped in 264 (1GP DE org auth is already a hard precondition for this skill, so no auth-state branching needed). This is the canonical wire-verify and runs directly after finalize-move-to-2gp; on the pre-266 manual fallback it also follows the user attestation in verify-finalize-by-user-confirmation. Note: the finalize step's own 266 response also returns finalizedAt + conversionId directly, so this step is a durable cross-check rather than the sole success signal.
133
+ The canonical wire-verification: re-query the PackageConversion record on the 1GP DE org to confirm EndDate is populated (non-null). EndDate is set by the package-conversion finalization service as part of finalize and is the reliable post-finalize wire signal. Uses the read-only PackageConversion Tooling exposure shipped in 264, so it applies only to orgs on release 264 or later. This is the canonical wire-verify and runs directly after finalize-move-to-2gp; on the pre-266 manual fallback it follows the user attestation in verify-finalize-by-user-confirmation on release 264-265 only. Before 264 the user's report is the only verification. Note: the finalize step's own 266 response also returns finalizedAt + conversionId directly, so this step is a durable cross-check rather than the sole success signal.
93
134
 
94
135
  **Call:** `queryPackageConversion` — status: `implemented`
95
136
 
@@ -102,26 +143,39 @@ The canonical wire-verification: re-query the PackageConversion record on the 1G
102
143
 
103
144
  **Depends on:** `finalize-move-to-2gp`
104
145
 
146
+ **Command:** `sf data query --use-tooling-api --target-org '<packaging_org_alias>' --query "SELECT Id, EndDate, FinalizedVersionId, FinalizedVersionNumber FROM PackageConversion WHERE ConvertedFromPackageId = '<1GP 033 Id>'" --json`
147
+
148
+ **Also runs before the affirmations (264 and later):** the same query runs from `check-already-done`, before `confirm-affirmations`, using `packaging_org_alias` from `check-eligibility-1gp-released` and `subscriber_package_id` from `discover-package-on-devhub`.
149
+
105
150
  **Notes:** 264 shipped the read-only public Tooling exposure of PackageConversion (available when packaging is enabled for the org). The fields queried here — Id, EndDate, FinalizedVersionId (FK → SubscriberPackageVersion), FinalizedVersionNumber, and the WHERE key ConvertedFromPackageId (FK → SubscriberPackage) — are all exposed read-only. EndDate non-null means finalize completed. Move-to-2GP does NOT auto-create native Package2Version records on DevHub (native creation is a separate user-driven step), so there is no Package2Version-based wire-verify; EndDate is the reliable signal.
106
151
 
152
+ **Interpreting the result:** EndDate populated → finalize completed; report success. EndDate still null after a successful finalize response (or a reported success on the fallback) → surface it as an anomaly. Possible causes: (a) finalize reported success but did not persist (report to Salesforce Support); (b) brief eventual-consistency lag (retry once after 30s); (c) the finalize ran against a different 1GP DE org than the one queried here (check that `packaging_org_alias` is the alias used for the POST). The finalize response's `finalizedAt` / `conversionId` are authoritative for that call.
153
+
107
154
  ### Other operations
108
155
 
109
156
  #### `check-eligibility-1gp-released`
110
157
 
111
- Find the highest Released 1GP major.minor version of the package by querying MetadataPackageVersion on the 1GP DE org. MetadataPackageVersion is the 1GP DE-side view of `all_package_version` joined with `dev_package_version`, with a `ReleaseState` STATICENUM field whose Released picklist value is `"Released"`.
158
+ Find the highest Released 1GP version (major.minor.patch, then build) of the package by querying MetadataPackageVersion on the 1GP DE org. MetadataPackageVersion is the 1GP DE-side view of `all_package_version` joined with `dev_package_version`, with a `ReleaseState` STATICENUM field whose Released picklist value is `"Released"`.
112
159
 
113
160
  **Call:** `queryHighestReleased1GPVersion` — status: `implemented`
114
161
 
115
162
  **Inputs:**
116
163
 
117
164
  - `packaging_org_alias` *(`String`)* — Source: user_input. The `sf` alias of the user's 1GP DE (packaging) org. Captured at skill start (see agent_guidance "AT START").
118
- - `subscriber_package_id` *(`String`)* — Source - output of discover-package-on-devhub. Note: the SubscriberPackageId (033... key prefix) on DevHub is the same Id as MetadataPackage on the 1GP DE org — both wrap the same all_package row.
165
+ - **Use exactly as given:** same rule as `devhub_alias` in `discover-package-on-devhub`. Never trim, split, or otherwise alter it.
166
+ - `subscriber_package_id` *(`String`)* — Source - output of discover-package-on-devhub. This is the 1GP package's 033 Id (the MetadataPackage Id on the 1GP DE org), which discover-package-on-devhub matched against `Package2.ConvertedFromPackageId`. It is NOT the converted Package2's own SubscriberPackageId, which is a different 033 Id.
119
167
 
120
168
  **Depends on:** `discover-package-on-devhub`
121
169
 
170
+ **Command:** `sf data query --use-tooling-api --target-org '<packaging_org_alias>' --query "SELECT Id, MajorVersion, MinorVersion, PatchVersion, ReleaseState FROM MetadataPackageVersion WHERE MetadataPackageId = '<1GP 033 Id>' AND ReleaseState = 'Released' ORDER BY MajorVersion DESC, MinorVersion DESC, PatchVersion DESC, BuildNumber DESC LIMIT 1" --json`
171
+
172
+ **Interpreting the result:** 0 rows means the package has no Released 1GP versions, so Move-to-2GP cannot proceed. Tell the user: "Your 1GP package has no Released versions on the packaging org. You need at least one Released 1GP version (whose 2GP conversion is also Released) before you can Move to 2GP." Otherwise capture `MajorVersion`, `MinorVersion` and `PatchVersion` as the target X.Y.Z for the next step, after checking all three are non-negative integers (see `discover-package-on-devhub`). The query orders by patch and build too, so this is the same highest Released version the finalize endpoint uses.
173
+
174
+ **A patch is not eligible:** if `PatchVersion` is greater than 0, the highest Released 1GP version is a patch (for example 1.4.1), and the endpoint rejects finalize for it, even if a converted 1.4.0 is Released. Never say eligibility is judged on major.minor only. Tell the user: "Your highest Released 1GP version, X.Y.Z, is a patch version, and Move-to-2GP can't be finalized at a patch. Create the next major or minor 1GP version, convert it, promote the converted version to Released, then try again." Do not ask the affirmation questions.
175
+
122
176
  #### `check-eligibility-2gp-converted-released`
123
177
 
124
- Confirm a 2GP-converted Package2Version exists at the same major.minor as the highest Released 1GP version, AND that the 2GP version is Released. This is the second half of the eligibility gate — Move-to-2GP requires the highest 1GP major.minor to have a corresponding RELEASED 2GP-converted equivalent. Queries Package2Version on DevHub.
178
+ Confirm a 2GP-converted Package2Version exists at the same major.minor.patch as the highest Released 1GP version, AND that the 2GP version is Released. This is the second half of the eligibility gate — Move-to-2GP requires the highest Released 1GP version to have a RELEASED 2GP-converted equivalent at the same major.minor.patch. Queries Package2Version on DevHub.
125
179
 
126
180
  **Call:** `queryReleased2GPConvertedVersion` — status: `implemented`
127
181
 
@@ -136,10 +190,40 @@ Confirm a 2GP-converted Package2Version exists at the same major.minor as the hi
136
190
 
137
191
  **Depends on:** `check-eligibility-1gp-released`
138
192
 
193
+ **Command:** `sf data query --use-tooling-api --target-org '<devhub_alias>' --query "SELECT Id, SubscriberPackageVersionId, MajorVersion, MinorVersion, PatchVersion, IsReleased, ConvertedFromVersionId, HasPassedCodeCoverageCheck FROM Package2Version WHERE Package2Id = '<0Ho>' AND MajorVersion = <X> AND MinorVersion = <Y> AND ConvertedFromVersionId != NULL ORDER BY PatchVersion DESC, BuildNumber DESC" --json`
194
+
195
+ **Interpreting the result:** the query returns every converted version at X.Y, Released or not, so one read tells the cases apart. Before using any returned value, check `Id` matches `/^05i[A-Za-z0-9]{12}([A-Za-z0-9]{3})?$/`, `SubscriberPackageVersionId` matches `/^04t[A-Za-z0-9]{12}([A-Za-z0-9]{3})?$/`, and `PatchVersion` is a non-negative integer; stop if any fails.
196
+
197
+ The user is **eligible** only if a row has `IsReleased = true` and the same `PatchVersion` as the highest Released 1GP version. The endpoint compares the full major.minor.patch, not just major.minor. Otherwise the user is BLOCKED. Tell them which case applies, and don't ask the affirmation questions:
198
+
199
+ - **0 rows:** "I see your highest Released 1GP version is X.Y.Z, but no 2GP-converted version exists at X.Y. You need to convert X.Y.Z before Move-to-2GP can complete."
200
+ - **Rows exist, but none is Released at patch Z:** the converted X.Y.Z must be promoted to Released. Use the first row with `PatchVersion` = Z (the latest build).
201
+ - If its `HasPassedCodeCoverageCheck` is not true, it can't be promoted. The user must convert X.Y.Z again with code coverage (the `dx-packaging-convert-1gp-to-2gp-create` skill).
202
+ - If it is true, promotion uses the row's 04t `SubscriberPackageVersionId`, never the 05i `Id`, which `sf package version promote` rejects: `sf package version promote --package '<04t>' --target-dev-hub '<devhub_alias>' --no-prompt`.
203
+ - Promotion to Released is also irreversible, so it's a separate decision. Show the command and ask whether to promote as its own question. Never run it as part of the move, and never infer consent from the move request. After any promotion, run this check again.
204
+
205
+ Do not proceed to `confirm-affirmations` until this step finds the Released converted X.Y.Z.
206
+
207
+ **Server-only check:** the endpoint also refuses to finalize while an active patch org exists for X.Y without an uploaded patch. No public query shows this, so passing these checks doesn't guarantee finalize succeeds. If the finalize 400 says an active patch org exists, relay what the message asks the user to do.
208
+
139
209
  #### `check-already-done`
140
210
 
141
211
  Detect the early-exit case — if a native (non-converted) Package2Version exists for this Package2, Move-to-2GP has ALREADY happened OR the package was 2GP-native to start with. Native 2GP versions are characterized by ConvertedFromVersionId = NULL. If any such Package2Version exists, the skill exits immediately.
142
212
 
213
+ **Also check the packaging org:** a finalize does not create a native Package2Version, so a package that was finalized but has no native version yet passes the query above.
214
+
215
+ **Before 264:** the PackageConversion query fails with `INVALID_TYPE`, because the object doesn't exist on these releases. Leaving off `--use-tooling-api` gives the same error, so this counts only when the query was run with `--use-tooling-api` exactly as shown; otherwise fix the command. This is the only case where you skip the query instead of fixing it. Rely on the native-version check above (needs DevHub) and on the Setup page: before any affirmation, ask the user, as one question, whether the Move to 2GP button is still shown on the package detail page. If it isn't, the move is done.
216
+
217
+ **264 and later:** before `confirm-affirmations`, also run the `verify-finalize-on-packaging-org` query (`SELECT Id, EndDate, FinalizedVersionId, FinalizedVersionNumber FROM PackageConversion WHERE ConvertedFromPackageId = '<1GP 033 Id>'`) against `packaging_org_alias`, using the Tooling API (for example `sf data query --use-tooling-api`). Run it whether or not DevHub is available. If `EndDate` is set, the move is already done: report it, with `FinalizedVersionNumber`, and stop. Do not ask the affirmation questions. If it returns 0 rows, the org has no conversion record for this package (not converted yet, or wrong packaging org): stop before the questions and route the user to the conversion process. On 264 and later, if the query fails, fix the command; don't skip the check.
218
+
219
+ | Release | Finalize | Verify |
220
+ |---|---|---|
221
+ | Before 264 | Browser flow in Setup | The user's report of the Setup page (`verify-finalize-by-user-confirmation`) |
222
+ | 264–265 | Browser flow in Setup | The user's report, then `PackageConversion.EndDate` (`verify-finalize-on-packaging-org`) |
223
+ | 266 and later | Connect API `finalize-move-to-2gp` | `PackageConversion.EndDate` (`verify-finalize-on-packaging-org`) |
224
+
225
+ **Command:** `sf data query --use-tooling-api --target-org '<devhub_alias>' --query "SELECT Id, MajorVersion, MinorVersion, IsReleased FROM Package2Version WHERE Package2Id = '<0Ho>' AND ConvertedFromVersionId = NULL LIMIT 1" --json`
226
+
143
227
  **Call:** `queryNativePackage2Version` — status: `implemented`
144
228
 
145
229
  **Inputs:**
@@ -151,9 +235,11 @@ Detect the early-exit case — if a native (non-converted) Package2Version exist
151
235
 
152
236
  **Depends on:** `check-eligibility-2gp-converted-released`
153
237
 
238
+ **Interpreting the result:** 1 or more native rows, or a PackageConversion `EndDate` that is set, means EARLY EXIT. Either the move already happened (ConvertedFromPackageId was non-null at discovery) or the package was 2GP-native from the start. ContainerOptions can't tell these apart; both are `Managed`. Either way, tell the user: "Move-to-2GP has already been completed for this package — no further action needed." Proceed to `confirm-affirmations` only if 0 native rows return AND, on 264 and later, `EndDate` is null; before 264, only if the Move to 2GP button is still on the package detail page.
239
+
154
240
  #### `confirm-affirmations`
155
241
 
156
- Present the irrevocability + testing affirmations to the user, mirroring the "Move to Second-Generation Managed Packaging" dialog shown in Setup UI. The user must explicitly confirm each affirmation before the agent proceeds to the (manual) finalize step. This step has no API surface — it's a structured agent-to-user interaction encoded in the SOR for contract consistency between the eventual 266 Connect API (which is expected to require these as request-body fields) and the pre-266 manual flow.
242
+ Present the irrevocability + testing affirmations to the user, mirroring the "Move to Second-Generation Managed Packaging" dialog shown in Setup UI. The user must explicitly confirm each affirmation before the agent proceeds to the finalize step. This step has no API surface — it's a structured agent-to-user interaction whose answers become the request-body flags of `finalize-move-to-2gp` (and gate the pre-266 manual flow).
157
243
 
158
244
  **Status:** `implemented`
159
245
 
@@ -165,3 +251,18 @@ Present the irrevocability + testing affirmations to the user, mirroring the "Mo
165
251
  - **Source:** output of `discover-package-on-devhub`
166
252
 
167
253
  **Depends on:** `check-already-done`
254
+
255
+ **Ask four separate questions, one at a time, and wait for an answer to each:**
256
+
257
+ 1. **Irreversibility** — "Moving to 2GP development is IRREVERSIBLE. After this step, you can no longer create new major or minor 1GP versions of this package — neither via `sf package1 version create` nor via the upload flow on viewAllPackage.apexp. All future development must use 2GP via `sf package version create`. Confirm you understand this is a one-way transition."
258
+ 2. **Conversion testing** — "Have you completed package conversion testing for this package?"
259
+ 3. **Subscriber migration testing** — "Have you completed subscriber migration testing (migrating a test subscriber org from the 1GP package to the converted 2GP package)?"
260
+ 4. **Source retrieved** — "Have you run `sf package version retrieve --package <04t...> --output-dir <folder> --target-dev-hub <devhub>` and updated `versionName`, `versionNumber`, and `ancestorVersion` in sfdx-project.json?" If the user says retrieve failed with `DeveloperUsePkgZipFieldUnavailableError`, their DevHub user needs the **Download Package Version Zip Files** user permission (for example through a permission set their admin assigns). They retry after it's granted; the answer stays no until then.
261
+
262
+ This is the same order as the Setup dialog: irreversibility, then testing, then source. Question 1 sets `acknowledged_irrevocable`. Questions 2 and 3 are different tests: ask them separately and never merge them into one question. `acknowledged_testing_complete` is true only if the user confirmed BOTH. Question 4 sets `acknowledged_source_retrieved`.
263
+
264
+ **What counts as a confirmation:** each answer applies only to the question it replies to. A single bare "yes", "ok", "yes to all", or "I confirm everything" never confirms more than one question. If the user answers that way to several questions at once, re-ask each unconfirmed question individually. An answer the user gave before you asked a question doesn't confirm it either.
265
+
266
+ **If any answer is no or unclear:** STOP. Do not call `finalize-move-to-2gp` and do not direct the user to click Proceed. Tell them what is blocked and what to do first (run conversion tests, run subscriber migration tests, or run `sf package version retrieve`).
267
+
268
+ **Patch follow-up:** the irreversibility question does not mention patches; don't add that caveat to it. If the user asks whether they can still cut a patch, answer exactly: 1GP patch versions stay permitted only for major.minor versions *lower* than the finalized version, so unmigrated 1GP subscribers on those versions can still get hotfixes. Patches for the finalized major.minor itself must be built in 2GP. For example, after finalizing at 1.4.0, a 1GP 1.3.x patch is allowed, but a 1GP 1.4.x patch is not.
@@ -20,7 +20,7 @@ Read only the section relevant to the failed phase. Apply Phase 0's disclosure r
20
20
 
21
21
  **A bound tool is missing from the client:** Confirm that the global invocable Apex action or eligible autolaunched Flow exists in the org, that its `aa:` or `fa:` identifier is correct, and that the org's invocable-action MCP gate is enabled.
22
22
 
23
- **A discovery pass returns no candidates:** An empty local scan means the scanned source tree has no eligible metadata. Empty Apex and Flow action arrays mean the authenticated user has no runtime candidates exposed by those endpoints. A non-zero exit means the REST listing failed or returned an invalid envelope, so do not treat it as an empty result. If a specific describe call fails, omit that candidate and report why it couldn't be evaluated; don't infer that other candidates are unavailable.
23
+ **A discovery pass returns no candidates:** A local scan with exit 0 and no candidates means the scanned source tree has no eligible metadata. Exit 2 means the scan was incomplete; review its directory warnings and do not infer that no eligible source exists. Empty Apex and Flow action arrays mean the authenticated user has no runtime candidates exposed by those endpoints. A non-zero exit from runtime listing means the REST listing failed or returned an invalid envelope, so do not treat it as an empty result. If a specific describe call fails, omit that candidate and report why it couldn't be evaluated; don't infer that other candidates are unavailable.
24
24
 
25
25
  **Prompt discovery fails or returns no candidates:** `retrieve_existing_prompts.mjs` reads active templates through Connect REST and available prompt-template actions through the Actions API. A non-zero exit is an incomplete read, not proof of absence; check Prompt Builder enablement, the authenticated user's access, and the reported endpoint before retrying. A successful empty list means no candidates were exposed to that user.
26
26
 
@@ -57,25 +57,43 @@ const ALLOWED_KEYS = new Set([
57
57
 
58
58
  // --- minimal XML parser/serializer, scoped to Salesforce metadata XML shape ---
59
59
 
60
+ const MAX_XML_BYTES = 10 * 1024 * 1024;
61
+ const MAX_XML_DEPTH = 256;
62
+ const MAX_XML_ITEMS = 100_000;
63
+
60
64
  function decodeEntities(s) {
61
65
  return s.replace(/&(amp|lt|gt|quot|apos);/g, (_, e) => ({ amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" }[e]));
62
66
  }
63
67
 
64
68
  function parseXml(text) {
69
+ if (Buffer.byteLength(text, "utf8") > MAX_XML_BYTES) {
70
+ throw new Error("XML input exceeds the 10 MiB limit");
71
+ }
65
72
  let i = 0;
66
73
  const n = text.length;
74
+ let parsedItems = 0;
75
+
76
+ function consumeItem() {
77
+ parsedItems++;
78
+ if (parsedItems > MAX_XML_ITEMS) {
79
+ throw new Error(`XML structure exceeds ${MAX_XML_ITEMS} elements and attributes`);
80
+ }
81
+ }
67
82
 
68
83
  function skipWs() {
69
84
  while (i < n && /\s/.test(text[i])) i++;
70
85
  }
71
86
 
72
- function parseElement() {
87
+ function parseElement(depth = 1) {
88
+ if (depth > MAX_XML_DEPTH) throw new Error(`XML nesting exceeds ${MAX_XML_DEPTH} elements`);
73
89
  skipWs();
74
90
  if (text[i] !== "<") throw new Error(`expected '<' at offset ${i}`);
75
91
  i++;
76
92
  const tagStart = i;
77
93
  while (i < n && !/[\s>/]/.test(text[i])) i++;
78
94
  const tag = text.slice(tagStart, i);
95
+ if (!/^[A-Za-z_][A-Za-z0-9_.:-]*$/.test(tag)) throw new Error(`invalid or missing element name at offset ${tagStart}`);
96
+ consumeItem();
79
97
  const attrs = {};
80
98
  while (true) {
81
99
  skipWs();
@@ -87,20 +105,24 @@ function parseXml(text) {
87
105
  i++;
88
106
  break;
89
107
  }
108
+ if (i >= n) throw new Error(`unterminated opening tag <${tag}>`);
90
109
  const nameStart = i;
91
- while (i < n && text[i] !== "=" && !/\s/.test(text[i])) i++;
110
+ while (i < n && !/[\s=/>]/.test(text[i])) i++;
92
111
  const name = text.slice(nameStart, i);
112
+ if (!/^[A-Za-z_][A-Za-z0-9_.:-]*$/.test(name)) throw new Error(`invalid attribute name at offset ${nameStart}`);
113
+ consumeItem();
93
114
  skipWs();
94
- if (text[i] === "=") {
95
- i++;
96
- skipWs();
97
- const quote = text[i];
98
- i++;
99
- const valStart = i;
100
- while (i < n && text[i] !== quote) i++;
101
- attrs[name] = decodeEntities(text.slice(valStart, i));
102
- i++;
103
- }
115
+ if (text[i] !== "=") throw new Error(`expected '=' after attribute ${name}`);
116
+ i++;
117
+ skipWs();
118
+ const quote = text[i];
119
+ if (quote !== "'" && quote !== '"') throw new Error(`expected quoted value for attribute ${name}`);
120
+ i++;
121
+ const valStart = i;
122
+ while (i < n && text[i] !== quote) i++;
123
+ if (i >= n) throw new Error(`unterminated quoted value for attribute ${name}`);
124
+ attrs[name] = decodeEntities(text.slice(valStart, i));
125
+ i++;
104
126
  }
105
127
  const node = { tag, attrs, children: [], text: null };
106
128
  let textBuf = "";
@@ -108,8 +130,11 @@ function parseXml(text) {
108
130
  if (text.slice(i, i + 2) === "</") {
109
131
  i += 2;
110
132
  const closeStart = i;
111
- while (i < n && text[i] !== ">") i++;
133
+ while (i < n && !/[\s>]/.test(text[i])) i++;
112
134
  const closeTag = text.slice(closeStart, i);
135
+ if (!/^[A-Za-z_][A-Za-z0-9_.:-]*$/.test(closeTag)) throw new Error(`invalid closing tag at offset ${closeStart}`);
136
+ skipWs();
137
+ if (text[i] !== ">") throw new Error(`unterminated closing tag </${closeTag}`);
113
138
  i++;
114
139
  if (closeTag !== tag) {
115
140
  throw new Error(`mismatched close tag: expected </${tag}>, got </${closeTag}>`);
@@ -117,12 +142,15 @@ function parseXml(text) {
117
142
  break;
118
143
  } else if (text.slice(i, i + 4) === "<!--") {
119
144
  const end = text.indexOf("-->", i);
120
- i = end === -1 ? n : end + 3;
145
+ if (end === -1) throw new Error("unterminated XML comment");
146
+ i = end + 3;
121
147
  } else if (text[i] === "<") {
122
- node.children.push(parseElement());
148
+ node.children.push(parseElement(depth + 1));
123
149
  } else {
124
- textBuf += text[i];
125
- i++;
150
+ const nextTag = text.indexOf("<", i);
151
+ if (nextTag === -1) throw new Error(`unterminated element <${tag}>`);
152
+ textBuf += text.slice(i, nextTag);
153
+ i = nextTag;
126
154
  }
127
155
  }
128
156
  if (node.children.length === 0) {
@@ -135,7 +163,8 @@ function parseXml(text) {
135
163
  skipWs();
136
164
  if (text.slice(i, i + 2) === "<?") {
137
165
  const end = text.indexOf("?>", i);
138
- i = end === -1 ? i : end + 2;
166
+ if (end === -1) throw new Error("unterminated XML declaration");
167
+ i = end + 2;
139
168
  }
140
169
  return parseElement();
141
170
  }
@@ -315,6 +344,8 @@ function main() {
315
344
  promptSpecs = [];
316
345
  }
317
346
 
347
+ const xmlSize = fs.statSync(xmlPath).size;
348
+ if (xmlSize > MAX_XML_BYTES) throw new Error("XML input exceeds the 10 MiB limit");
318
349
  const xmlText = fs.readFileSync(xmlPath, "utf-8");
319
350
  const root = parseXml(xmlText);
320
351
 
@@ -138,7 +138,7 @@ if (checkOnly) {
138
138
  } else {
139
139
  for (const { destDir, dest, expected } of plan) {
140
140
  fs.mkdirSync(destDir, { recursive: true });
141
- fs.writeFileSync(dest, expected, "utf-8");
141
+ fs.writeFileSync(dest, expected, { encoding: "utf-8", flag: "wx" });
142
142
  }
143
143
  console.log(`Rendered ECA metadata in ${defaultDir}`);
144
144
  }
@@ -59,6 +59,6 @@ function escapeXml(s) {
59
59
  let text = fs.readFileSync(template, "utf-8");
60
60
  text = text.split("__MCP_SERVER_LABEL__").join(escapeXml(serverLabel));
61
61
  text = text.split("__MCP_SERVER_DESC__").join(escapeXml(serverDesc));
62
- fs.writeFileSync(dest, text, "utf-8");
62
+ fs.writeFileSync(dest, text, { encoding: "utf-8", flag: "wx" });
63
63
 
64
64
  console.log(`Rendered MCP server component at ${dest}`);
@@ -30,7 +30,9 @@ function* walk(dir) {
30
30
  let entries;
31
31
  try {
32
32
  entries = fs.readdirSync(dir, { withFileTypes: true });
33
- } catch {
33
+ } catch (error) {
34
+ process.stderr.write(`WARNING: unable to scan directory ${dir}: ${error.message}\n`);
35
+ process.exitCode = 2;
34
36
  return;
35
37
  }
36
38
  for (const e of entries) {