@salesforce/afv-skills 1.31.0 → 1.32.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 (98) hide show
  1. package/package.json +1 -1
  2. package/skills/agentforce-bot-upgrade/SKILL.md +217 -0
  3. package/skills/agentforce-bot-upgrade/references/extraction-blueprint.md +242 -0
  4. package/skills/agentforce-bot-upgrade/references/generate-agent-spec.md +128 -0
  5. package/skills/agentforce-bot-upgrade/references/handoff-output-format.md +208 -0
  6. package/skills/agentforce-bot-upgrade/references/input-contract.md +101 -0
  7. package/skills/agentforce-bot-upgrade/references/mapping-rules.md +113 -0
  8. package/skills/agentforce-bot-upgrade/references/planner-workflow-reference.md +78 -0
  9. package/skills/agentforce-bot-upgrade/references/post-conversion-enhancements-reference.md +67 -0
  10. package/skills/agentforce-bot-upgrade/references/quality-checklist.md +33 -0
  11. package/skills/agentforce-bot-upgrade/references/sf-cli-bot-reference.md +116 -0
  12. package/skills/dx-devops-work-item-manage/SKILL.md +270 -0
  13. package/skills/dx-devops-work-item-manage/examples/common-workflows.md +479 -0
  14. package/skills/dx-devops-work-item-manage/references/cli-commands.md +476 -0
  15. package/skills/dx-org-manage/SKILL.md +8 -5
  16. package/skills/dx-org-trial-expiration-check/SKILL.md +239 -0
  17. package/skills/dx-org-trial-expiration-check/scripts/check_expiration.sh +588 -0
  18. package/skills/experience-ui-bundle-app-coordinate/SKILL.md +12 -9
  19. package/skills/experience-ui-bundle-custom-app-generate/SKILL.md +29 -5
  20. package/skills/experience-ui-bundle-custom-app-generate/references/configure-metadata-custom-application.md +1 -1
  21. package/skills/experience-ui-bundle-custom-app-generate/scripts/resolve-uibundle-path.sh +30 -0
  22. package/skills/experience-ui-bundle-features-generate/SKILL.md +86 -11
  23. package/skills/experience-ui-bundle-features-generate/references/conflict-resolution-schema.json +20 -0
  24. package/skills/experience-ui-bundle-features-generate/scripts/verify-react-bundle.sh +14 -0
  25. package/skills/experience-ui-bundle-frontend-generate/SKILL.md +6 -1
  26. package/skills/experience-ui-bundle-frontend-generate/references/component.md +34 -1
  27. package/skills/experience-ui-bundle-frontend-generate/references/page.md +1 -1
  28. package/skills/experience-ui-bundle-project-generate/SKILL.md +111 -0
  29. package/skills/experience-ui-bundle-project-generate/scripts/flatten-project.mjs +33 -0
  30. package/skills/platform-custom-lightning-type-generate/SKILL.md +9 -14
  31. package/skills/platform-custom-lightning-type-generate/references/widget-rendition.md +27 -111
  32. package/skills/platform-lightning-type-widget-coordinate/SKILL.md +214 -0
  33. package/skills/platform-lightning-type-widget-coordinate/examples/existing-lightning-type-with-widget-prompt.md +80 -0
  34. package/skills/platform-lightning-type-widget-coordinate/examples/new-lightning-type-with-widget-prompt.md +75 -0
  35. package/skills/platform-lightning-type-widget-coordinate/references/build-plan-format.md +67 -0
  36. package/skills/platform-lightning-type-widget-coordinate/references/lightning-type-discovery.md +124 -0
  37. package/skills/platform-lightning-type-widget-coordinate/references/validation-gates.md +130 -0
  38. package/skills/platform-sharing-owd-configure/SKILL.md +142 -0
  39. package/skills/platform-sharing-owd-configure/examples/get_owd_output.md +38 -0
  40. package/skills/platform-sharing-owd-configure/examples/update_owd_output.md +44 -0
  41. package/skills/platform-sharing-owd-configure/references/access_levels.md +49 -0
  42. package/skills/platform-sharing-owd-configure/references/metadata_api_approach.md +69 -0
  43. package/skills/platform-sharing-rules-generate/SKILL.md +89 -19
  44. package/skills/platform-sharing-rules-generate/examples/test-cases.md +381 -0
  45. package/skills/platform-widget-generate/SKILL.md +241 -0
  46. package/skills/platform-widget-generate/examples/conditional.json +73 -0
  47. package/skills/platform-widget-generate/examples/list-with-foreach.json +66 -0
  48. package/skills/platform-widget-generate/examples/single-object.json +64 -0
  49. package/skills/platform-widget-generate/references/schema-from-lightning-type.md +76 -0
  50. package/skills/platform-widget-generate/references/widget-bundle-layout.md +116 -0
  51. package/skills/platform-widget-generate/references/widget-meta-directives.md +130 -0
  52. package/skills/sales-agentforce-pipeline-management-configure/SKILL.md +268 -0
  53. package/skills/sales-agentforce-pipeline-management-configure/assets/field-completion-template.genAiPromptTemplate-meta.xml +141 -0
  54. package/skills/sales-agentforce-pipeline-management-configure/assets/pipeline_management_flow.flow-meta.xml +548 -0
  55. package/skills/sales-agentforce-pipeline-management-configure/assets/sales_management_agent.agent +2938 -0
  56. package/skills/sales-agentforce-pipeline-management-configure/assets/sales_management_agent.bundle-meta.xml +4 -0
  57. package/skills/sales-agentforce-pipeline-management-configure/assets/sfdx-project.json +12 -0
  58. package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/bant.txt +11 -0
  59. package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/meddic.txt +11 -0
  60. package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/spiced.txt +11 -0
  61. package/skills/sales-agentforce-pipeline-management-configure/examples/custom-prompt-instructions.md +317 -0
  62. package/skills/sales-agentforce-pipeline-management-configure/references/admin-communication.md +355 -0
  63. package/skills/sales-agentforce-pipeline-management-configure/references/agent-creation.md +383 -0
  64. package/skills/sales-agentforce-pipeline-management-configure/references/auth-and-cli.md +146 -0
  65. package/skills/sales-agentforce-pipeline-management-configure/references/automation-matrix.md +23 -0
  66. package/skills/sales-agentforce-pipeline-management-configure/references/autonomous-updates.md +215 -0
  67. package/skills/sales-agentforce-pipeline-management-configure/references/canonical-agent-path.md +75 -0
  68. package/skills/sales-agentforce-pipeline-management-configure/references/data-sources.md +155 -0
  69. package/skills/sales-agentforce-pipeline-management-configure/references/field-completion-prompt-template.md +120 -0
  70. package/skills/sales-agentforce-pipeline-management-configure/references/field-completion-prompts.md +149 -0
  71. package/skills/sales-agentforce-pipeline-management-configure/references/flags.md +13 -0
  72. package/skills/sales-agentforce-pipeline-management-configure/references/flow-clone-from-template.md +447 -0
  73. package/skills/sales-agentforce-pipeline-management-configure/references/metadata-inventory.md +330 -0
  74. package/skills/sales-agentforce-pipeline-management-configure/references/opportunity-stages.md +246 -0
  75. package/skills/sales-agentforce-pipeline-management-configure/references/repair-diagnostics.md +265 -0
  76. package/skills/sales-agentforce-pipeline-management-configure/references/setup-order.md +263 -0
  77. package/skills/sales-agentforce-pipeline-management-configure/references/soap-api-enablement.md +528 -0
  78. package/skills/sales-agentforce-pipeline-management-configure/scripts/CHANGES.md +180 -0
  79. package/skills/sales-agentforce-pipeline-management-configure/scripts/README.md +56 -0
  80. package/skills/sales-agentforce-pipeline-management-configure/scripts/add-field-suggestion.sh +679 -0
  81. package/skills/sales-agentforce-pipeline-management-configure/scripts/create-agent.sh +302 -0
  82. package/skills/sales-agentforce-pipeline-management-configure/scripts/create-flow.sh +250 -0
  83. package/skills/sales-agentforce-pipeline-management-configure/scripts/define-agent-access.sh +430 -0
  84. package/skills/sales-agentforce-pipeline-management-configure/scripts/deploy-settings.sh +77 -0
  85. package/skills/sales-agentforce-pipeline-management-configure/scripts/enable-deal-agent.sh +241 -0
  86. package/skills/sales-agentforce-pipeline-management-configure/scripts/enable-prerequisites.sh +538 -0
  87. package/skills/sales-agentforce-pipeline-management-configure/scripts/flow-debug-and-verify.sh +385 -0
  88. package/skills/sales-agentforce-pipeline-management-configure/scripts/retrieve-settings.sh +131 -0
  89. package/skills/sales-agentforce-pipeline-management-configure/scripts/setup-all.sh +2791 -0
  90. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/agent-bundle-publish.sh +189 -0
  91. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/agent-detection.sh +239 -0
  92. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/flow-builder.sh +238 -0
  93. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/psg.sh +48 -0
  94. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/soap.sh +140 -0
  95. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/stage-descriptions.sh +448 -0
  96. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/test-opp.sh +166 -0
  97. package/skills/sales-agentforce-pipeline-management-configure/scripts/verify-all.sh +636 -0
  98. package/skills/sales-agentforce-pipeline-management-configure/scripts/verify-prompt-generation.sh +346 -0
@@ -0,0 +1,330 @@
1
+ # Pipeline Management Metadata Inventory
2
+
3
+ Complete inventory of all metadata components auto-provisioned by Pipeline Management. Use this as a reference for org inspection, troubleshooting, and metadata migration.
4
+
5
+ ---
6
+
7
+ ## Metadata Types and Components
8
+
9
+ ### 1. Settings
10
+
11
+ | Metadata Type | Full Name | Key Fields | API | Notes |
12
+ |--------------|-----------|-----------|-----|-------|
13
+ | `SalesDealAgentSettings` | `SalesDealAgent` | `enableDealAgent`, `enableDealAgentAutoApproveAllTasks` | SOAP v64.0+ only | CLI returns 'Settings type is unknown' |
14
+ | `EinsteinGptSettings` | `EinsteinGpt` | `enableGptAnswerGenerationForKbArticles` | SOAP v62.0+ or CLI | Required prerequisite |
15
+ | `EinsteinCopilotSettings` | `EinsteinCopilot` | `enableAgentLiveSuggestionsInTab` | SOAP v62.0+ or CLI | Required prerequisite |
16
+ | `EnhancedNotesSettings` | `EnhancedNotes` | `enableEnhancedNotes` | CLI retrieve+deploy | Prerequisite for note ingestion |
17
+ | `EmailAdministrationSettings` | `EmailAdministration` | `enableInternalNotesInEmailSnippet` | CLI retrieve+deploy | Prerequisite for email ingestion |
18
+ | `OpportunitySettings` | `Opportunity` | `enableFindSimilarOpportunities` | CLI retrieve+deploy | Prerequisite for grounding data |
19
+
20
+ **Retrieval**:
21
+ ```bash
22
+ sf project retrieve start --metadata "Settings:SalesDealAgentSettings" --target-org $ORG 2>/dev/null
23
+ sf project retrieve start --metadata "Settings:EinsteinGptSettings" --target-org $ORG 2>/dev/null
24
+ sf project retrieve start --metadata "Settings:EinsteinCopilotSettings" --target-org $ORG 2>/dev/null
25
+ sf project retrieve start --metadata "Settings:EnhancedNotesSettings" --target-org $ORG 2>/dev/null
26
+ sf project retrieve start --metadata "Settings:EmailAdministrationSettings" --target-org $ORG 2>/dev/null
27
+ sf project retrieve start --metadata "Settings:OpportunitySettings" --target-org $ORG 2>/dev/null
28
+ ```
29
+
30
+ ---
31
+
32
+ ### 2. Permission Set Groups
33
+
34
+ | Developer Name | API Name | Purpose | Auto-Assigned To |
35
+ |----------------|----------|---------|------------------|
36
+ | `SalesManagementUserPsg` | `SalesManagementUserPsg` | Grants end users access to Pipeline Management features | Sales users (manual assignment required) |
37
+ | `SalesManagementAgentUserPsg` | `SalesManagementAgentUserPsg` | Grants agent system user access to opportunity data | Agent user (auto-assigned on creation) |
38
+
39
+ **SOQL Query**:
40
+ ```bash
41
+ sf data query -q "SELECT Id, DeveloperName, MasterLabel FROM PermissionSetGroup WHERE DeveloperName LIKE 'SalesManagement%'" --target-org $ORG --json 2>/dev/null
42
+ ```
43
+
44
+ **Contained Permission Sets** (in `SalesManagementAgentUserPsg`):
45
+ - `PipelineManagementAgentAutonomousUser` — Allows autonomous field updates
46
+ - `PipelineManagementAgentBase` — Base permissions for agent operations
47
+ - (Other permission sets may vary by org edition/license)
48
+
49
+ ---
50
+
51
+ ### 3. Bot (Agent)
52
+
53
+ | Developer Name | Label | Type | Status | Template |
54
+ |----------------|-------|------|--------|----------|
55
+ | `SalesAgent` | `Sales Management Agent` | Agentforce | Active/Draft | `SalesMgmt__SalesAgent` |
56
+
57
+ **SOQL Query** (standard SOQL — BotDefinition has no `Label` or `Status` column, and is not supported by the Tooling API):
58
+ ```bash
59
+ sf data query -q "SELECT Id, DeveloperName, Description FROM BotDefinition WHERE DeveloperName = 'SalesAgent'" --target-org $ORG --json 2>/dev/null
60
+ ```
61
+
62
+ **Retrieval**:
63
+ ```bash
64
+ sf project retrieve start --metadata "Bot:SalesAgent" --target-org $ORG 2>/dev/null
65
+ ```
66
+
67
+ **Components**:
68
+ - Bot metadata file: `force-app/main/default/bots/SalesAgent.bot-meta.xml`
69
+ - Bot versions (auto-versioned on publish)
70
+
71
+ ---
72
+
73
+ ### 4. BotVersion
74
+
75
+ Active bot version(s) for `SalesAgent`. Multiple versions may exist (draft, published, active).
76
+
77
+ **SOQL Query** (standard SOQL — `BotVersion`, like `BotDefinition`, is NOT supported by the Tooling API):
78
+ ```bash
79
+ sf data query -q "SELECT Id, BotDefinition.DeveloperName, VersionNumber, Status FROM BotVersion WHERE BotDefinition.DeveloperName = 'SalesAgent' ORDER BY VersionNumber DESC" --target-org $ORG --json 2>/dev/null
80
+ ```
81
+
82
+ ---
83
+
84
+ ### 5. Flows
85
+
86
+ | API Name | Label | Type | Template | Purpose |
87
+ |----------|-------|------|----------|---------|
88
+ | `sales_pipe_mgmt__OppSuggGenSchFlow` | `Opportunity Suggestion Generation Scheduled Flow` | Scheduled-Triggered | **Yes** (do not activate directly) | Template flow for suggestion processing |
89
+ | `Process_Field_Update_Suggestions` | `Process Field Update Suggestions` | Scheduled-Triggered | No (cloned from template) | Active flow that processes suggestions |
90
+ | `sales_pipe_mgmt__GetOppGroundingData` | `Get Opportunity Grounding Data` | Invocable | No | Retrieves notes, emails, calls for grounding |
91
+ | `sales_pipe_mgmt__GetRcmdConvTscp` | `Get Recommended Conversation Transcript` | Invocable | No | Retrieves conversation transcripts |
92
+
93
+ **SOQL Queries** — use `FlowDefinitionView` (data API). `FlowDefinition` is a **metadata**
94
+ type, not a data-API sObject (`sObject type 'FlowDefinition' is not supported`, and
95
+ `--use-tooling-api` does NOT fix it — it lives in the Metadata API); `FlowDefinitionView`
96
+ is the queryable view, uses `IsActive` (not `Status`), and is what the live scripts use:
97
+ ```bash
98
+ # Check all Pipeline Management flows
99
+ sf data query -q "SELECT ApiName, Label, ProcessType, IsActive, IsTemplate FROM FlowDefinitionView WHERE ApiName LIKE '%sales_pipe_mgmt%' OR ApiName LIKE '%Field_Update_Suggestions%'" --target-org $ORG --json 2>/dev/null
100
+
101
+ # Check if template flow exists
102
+ sf data query -q "SELECT ApiName, IsTemplate FROM FlowDefinitionView WHERE ApiName = 'sales_pipe_mgmt__OppSuggGenSchFlow'" --target-org $ORG --json 2>/dev/null
103
+
104
+ # Check cloned flow — query by ApiName. A Metadata-API deploy of the template does NOT
105
+ # populate FlowDefinitionView.SourceTemplateId (org-verified), so detect by name;
106
+ # SourceTemplateId is populated only for Setup-UI "Save As" clones.
107
+ sf data query -q "SELECT Id, ApiName, Label, IsActive, SourceTemplateId FROM FlowDefinitionView WHERE ApiName = 'Process_Field_Update_Suggestions' AND IsTemplate = false" --target-org $ORG --json 2>/dev/null
108
+ ```
109
+
110
+ **Retrieval**:
111
+ ```bash
112
+ sf project retrieve start --metadata "Flow:sales_pipe_mgmt__OppSuggGenSchFlow" --target-org $ORG 2>/dev/null
113
+ sf project retrieve start --metadata "Flow:Process_Field_Update_Suggestions" --target-org $ORG 2>/dev/null
114
+ sf project retrieve start --metadata "Flow:sales_pipe_mgmt__GetOppGroundingData" --target-org $ORG 2>/dev/null
115
+ sf project retrieve start --metadata "Flow:sales_pipe_mgmt__GetRcmdConvTscp" --target-org $ORG 2>/dev/null
116
+ ```
117
+
118
+ ---
119
+
120
+ ### 6. GenAiPromptTemplate
121
+
122
+ | Developer Name | Label | Type | Purpose |
123
+ |----------------|-------|------|---------|
124
+ | `sales_pipe_mgmt__RecommendStageforOpp` | `Recommend Stage for Opportunity` | Prompt Template | Generates stage recommendations |
125
+ | `sales_pipe_mgmt__RecommendNextStepforOpp` | `Recommend Next Step for Opportunity` | Prompt Template | Generates next step suggestions |
126
+
127
+ **Discovery** — `GenAiPromptTemplate` is **not SOQL-queryable** (Tooling or standard both return "sObject type 'GenAiPromptTemplate' is not supported"). Use the REST discovery endpoint instead:
128
+ ```bash
129
+ sf api request rest "/services/data/v64.0/einstein/prompt-templates" --target-org $ORG 2>/dev/null \
130
+ | jq -r '.promptRecords[]? | select(.fields.DeveloperName.value | test("sales_pipe_mgmt")) | "\(.fields.DeveloperName.value) active=\(.fields.IsActive.value)"'
131
+ ```
132
+
133
+ **Retrieval**:
134
+ ```bash
135
+ sf project retrieve start --metadata "GenAiPromptTemplate:sales_pipe_mgmt__RecommendStageforOpp" --target-org $ORG 2>/dev/null
136
+ sf project retrieve start --metadata "GenAiPromptTemplate:sales_pipe_mgmt__RecommendNextStepforOpp" --target-org $ORG 2>/dev/null
137
+ ```
138
+
139
+ ---
140
+
141
+ ### 7. Agent User
142
+
143
+ | Field | Value |
144
+ |-------|-------|
145
+ | **Username pattern** | `salesmanagementagentuser@<uuid>.<org-domain>.ext` |
146
+ | **Profile** | `System Administrator` or dedicated agent profile |
147
+ | **IsActive** | `true` |
148
+ | **UserType** | `CspLitePortal` or similar agent-specific type |
149
+
150
+ **SOQL Query**:
151
+ ```bash
152
+ sf data query -q "SELECT Id, Username, Name, Profile.Name, IsActive, UserType FROM User WHERE Username LIKE '%salesmanagementagentuser%'" --target-org $ORG --json 2>/dev/null
153
+ ```
154
+
155
+ **Permission Set Group Assignment**:
156
+ ```bash
157
+ # Get agent user ID
158
+ AGENT_USER_ID=$(sf data query -q "SELECT Id FROM User WHERE Username LIKE '%salesmanagementagentuser%'" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
159
+
160
+ # Check PSG assignment
161
+ sf data query -q "SELECT AssigneeId, PermissionSetGroup.DeveloperName FROM PermissionSetAssignment WHERE AssigneeId = '${AGENT_USER_ID}' AND PermissionSetGroup.DeveloperName = 'SalesManagementAgentUserPsg'" --target-org $ORG --json 2>/dev/null
162
+ ```
163
+
164
+ ---
165
+
166
+ ### 8. Setup Entities & Standard Objects
167
+
168
+ #### OpptStageDescription (Opportunity Stage Descriptions)
169
+
170
+ `OpptStageDescription` is a **Tooling-API setup entity** — NOT a `__c` custom object. It has no
171
+ `Stage__c`/`Description__c` fields and is not accessible via `sf sobject describe` or the plain data
172
+ API. It appears in `EntityDefinition`, is queryable **only with `--use-tooling-api`**, and is
173
+ auto-provisioned when Pipeline Management is enabled (test orgs show pre-populated MEDDIC rows).
174
+ Field names verified on a live org (`pm-new-org`).
175
+
176
+ | Purpose | Key fields (Tooling) | API Name | Access |
177
+ |---------|----------------------|----------|--------|
178
+ | Stores stage-to-description mappings for stage-suggestion grounding | `OpportunityStageApiName` (the stage picklist value), `Description`, `MasterLabel`, `DeveloperName` | `OpptStageDescription` (no `__c`) | Tooling API only |
179
+
180
+ > **Note:** `OpptStageDescription` has **no `OpportunityRecordTypeId` column** — descriptions are global-per-stage, keyed only by `OpportunityStageApiName`. A single description record applies across all Opportunity record types that expose that stage. (W-23356857)
181
+
182
+ **SOQL Query** (Tooling API):
183
+ ```bash
184
+ sf data query -q "SELECT Id, OpportunityStageApiName, Description FROM OpptStageDescription" --target-org $ORG --use-tooling-api --json 2>/dev/null
185
+ ```
186
+
187
+ `setup-all.sh` creates/updates these rows via `sf data create/update record --sobject OpptStageDescription`
188
+ (Tooling-backed); see the stage-description handling in `scripts/shared/stage-descriptions.sh`
189
+ (`run_stage_descriptions`), invoked from setup-all.sh Phase 4c.5 — BEFORE the StageName
190
+ prompt is deployed/tested, since the descriptions are that prompt's grounding.
191
+
192
+ #### AiGenActionItem (Field Update Suggestions)
193
+
194
+ `AiGenActionItem` is the **standard** object (no `__c` suffix) where Pipeline Management stores every field-update suggestion. There is **no** `FieldCompletion` / `FieldCompletion__c` object — that name does not exist on any org; do not query it.
195
+
196
+ | Purpose | Key fields (all standard) | API Name |
197
+ |---------|---------------------------|----------|
198
+ | Stores field-update suggestions (pending/applied/expired) | `ParentId` (= the Opportunity Id, filterable), `Subject` (= the field API name, e.g. `Risk__c`), `Type` (`FIELD_UPDATE`), `Status` (`WAITING`/`EXPIRED`), `SuggestedNewValue` (textarea), `AgentType` (`SALES_MANAGEMENT_AGENT`) | `AiGenActionItem` |
199
+
200
+ **SOQL Query** (filter by Opportunity via `ParentId`; `SuggestedNewValue` is not filterable):
201
+ ```bash
202
+ sf data query -q "SELECT Id, ParentId, Subject, Type, Status, SuggestedNewValue FROM AiGenActionItem WHERE Type = 'FIELD_UPDATE' AND ParentId = '<oppId>' ORDER BY CreatedDate DESC LIMIT 10" --target-org $ORG --json 2>/dev/null
203
+ ```
204
+
205
+ ---
206
+
207
+ ### 9. Apex Classes (if present)
208
+
209
+ Pipeline Management may deploy supporting Apex classes for:
210
+ - Custom grounding data retrieval
211
+ - Stage transition validation
212
+ - Suggestion filtering logic
213
+
214
+ **Check for Apex**:
215
+ ```bash
216
+ sf data query -q "SELECT Id, Name FROM ApexClass WHERE Name LIKE '%SalesPipeMgmt%' OR Name LIKE '%DealAgent%'" --target-org $ORG --use-tooling-api --json 2>/dev/null
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Metadata Dependency Graph
222
+
223
+ ```text
224
+ SalesDealAgentSettings (root)
225
+ ├── EinsteinGptSettings (required)
226
+ │ └── EinsteinCopilotSettings (required)
227
+ ├── EnhancedNotesSettings (recommended)
228
+ ├── EmailAdministrationSettings (recommended)
229
+ ├── OpportunitySettings (recommended)
230
+ ├── BotDefinition: SalesAgent
231
+ │ ├── Agent User (salesmanagementagentuser@...)
232
+ │ │ └── PermissionSetGroup: SalesManagementAgentUserPsg
233
+ │ ├── Flows
234
+ │ │ ├── sales_pipe_mgmt__OppSuggGenSchFlow (template)
235
+ │ │ ├── Process_Field_Update_Suggestions (active)
236
+ │ │ ├── sales_pipe_mgmt__GetOppGroundingData
237
+ │ │ └── sales_pipe_mgmt__GetRcmdConvTscp
238
+ │ ├── GenAiPromptTemplates
239
+ │ │ ├── sales_pipe_mgmt__RecommendStageforOpp
240
+ │ │ └── sales_pipe_mgmt__RecommendNextStepforOpp
241
+ │ ├── Setup Entities (Tooling API)
242
+ │ │ └── OpptStageDescription (OpportunityStageApiName, Description) ← global-per-stage, no RT column
243
+ │ └── Standard Objects
244
+ │ └── AiGenActionItem (field-update suggestions)
245
+ └── PermissionSetGroup: SalesManagementUserPsg (assigned to end users)
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Metadata Retrieval Script
251
+
252
+ Complete script to retrieve all Pipeline Management metadata:
253
+
254
+ ```bash
255
+ #!/bin/bash
256
+ ORG="pipeline-mgmt-org"
257
+
258
+ echo "Retrieving Pipeline Management metadata..."
259
+
260
+ # Settings
261
+ sf project retrieve start --metadata "Settings:SalesDealAgentSettings" --target-org $ORG 2>/dev/null
262
+ sf project retrieve start --metadata "Settings:EinsteinGptSettings" --target-org $ORG 2>/dev/null
263
+ sf project retrieve start --metadata "Settings:EinsteinCopilotSettings" --target-org $ORG 2>/dev/null
264
+ sf project retrieve start --metadata "Settings:EnhancedNotesSettings" --target-org $ORG 2>/dev/null
265
+ sf project retrieve start --metadata "Settings:EmailAdministrationSettings" --target-org $ORG 2>/dev/null
266
+ sf project retrieve start --metadata "Settings:OpportunitySettings" --target-org $ORG 2>/dev/null
267
+
268
+ # Permission Set Groups
269
+ sf project retrieve start --metadata "PermissionSetGroup:SalesManagementUserPsg" --target-org $ORG 2>/dev/null
270
+ sf project retrieve start --metadata "PermissionSetGroup:SalesManagementAgentUserPsg" --target-org $ORG 2>/dev/null
271
+
272
+ # Bot
273
+ sf project retrieve start --metadata "Bot:SalesAgent" --target-org $ORG 2>/dev/null
274
+
275
+ # Flows
276
+ sf project retrieve start --metadata "Flow:sales_pipe_mgmt__OppSuggGenSchFlow" --target-org $ORG 2>/dev/null
277
+ sf project retrieve start --metadata "Flow:Process_Field_Update_Suggestions" --target-org $ORG 2>/dev/null
278
+ sf project retrieve start --metadata "Flow:sales_pipe_mgmt__GetOppGroundingData" --target-org $ORG 2>/dev/null
279
+ sf project retrieve start --metadata "Flow:sales_pipe_mgmt__GetRcmdConvTscp" --target-org $ORG 2>/dev/null
280
+
281
+ # Prompt Templates
282
+ sf project retrieve start --metadata "GenAiPromptTemplate:sales_pipe_mgmt__RecommendStageforOpp" --target-org $ORG 2>/dev/null
283
+ sf project retrieve start --metadata "GenAiPromptTemplate:sales_pipe_mgmt__RecommendNextStepforOpp" --target-org $ORG 2>/dev/null
284
+
285
+ # Setup entities / standard objects need no metadata retrieve:
286
+ # OpptStageDescription is a Tooling setup entity (query with --use-tooling-api)
287
+ # AiGenActionItem is a standard object
288
+
289
+ echo "Retrieval complete. Check force-app/main/default/ for metadata."
290
+ ```
291
+
292
+ ---
293
+
294
+ ## Metadata Inspection Queries
295
+
296
+ ### Check All Pipeline Management Components
297
+
298
+ ```bash
299
+ # Settings
300
+ sf data query -q "SELECT enableDealAgent, enableDealAgentAutoApproveAllTasks FROM SalesDealAgentSettings" --target-org $ORG --json 2>/dev/null
301
+
302
+ # Agent (BotDefinition has no Status column; query Id/DeveloperName only)
303
+ sf data query -q "SELECT Id, DeveloperName FROM BotDefinition WHERE DeveloperName = 'SalesAgent'" --target-org $ORG --json 2>/dev/null
304
+
305
+ # Agent User
306
+ sf data query -q "SELECT Id, Username FROM User WHERE Username LIKE '%salesmanagementagentuser%'" --target-org $ORG --json 2>/dev/null
307
+
308
+ # Flows (FlowDefinition is unsupported on the data API — query FlowDefinitionView; use IsActive, not Status)
309
+ sf data query -q "SELECT ApiName, IsActive, IsTemplate FROM FlowDefinitionView WHERE ApiName LIKE '%sales_pipe_mgmt%'" --target-org $ORG --json 2>/dev/null
310
+
311
+ # Prompt Templates (GenAiPromptTemplate is NOT SOQL-queryable — use the REST endpoint)
312
+ sf api request rest "/services/data/v64.0/einstein/prompt-templates" --target-org $ORG 2>/dev/null | jq -r '.promptRecords[]?.fields.DeveloperName.value'
313
+
314
+ # Stage Descriptions (Tooling setup entity — requires --use-tooling-api)
315
+ sf data query -q "SELECT COUNT() FROM OpptStageDescription" --target-org $ORG --use-tooling-api --json 2>/dev/null
316
+
317
+ # Recent Suggestions
318
+ sf data query -q "SELECT COUNT() FROM AiGenActionItem WHERE Type = 'FIELD_UPDATE' AND CreatedDate = TODAY" --target-org $ORG --json 2>/dev/null
319
+ ```
320
+
321
+ ---
322
+
323
+ ## Notes
324
+
325
+ - Not all components are retrievable via Metadata API (e.g., agent user must be queried via SOQL)
326
+ - Component availability varies by org edition and license
327
+ - Template flows (`isTemplate=true`) should not be activated directly — always clone first
328
+ - SOAP API required for `SalesDealAgentSettings` only (CLI returns 'Settings type is unknown'). `EinsteinGptSettings` and `EinsteinCopilotSettings` work with both CLI and SOAP.
329
+ - `BotDefinition` and `BotVersion` use **standard SOQL** — NOT `--use-tooling-api` (Tooling API returns "sObject type not supported"). `BotDefinition` has no `Label` or `Status` column; `BotVersion` exposes `Status`. `GenAiPromptTemplate` is not queryable via SOQL (Tooling or standard) — inspect it via the Metadata API / retrieve.
330
+ - All `sf ... --json` commands piped to jq should include `2>/dev/null` for clean parsing
@@ -0,0 +1,246 @@
1
+ # Opportunity Stage Descriptions
2
+
3
+ The Pipeline Management agent reads stage semantics from the `OpptStageDescription` setup entity (Tooling API), NOT from the standard `OpportunityStage.Description` field.
4
+
5
+ ---
6
+
7
+ ## Storage Entity: `OpptStageDescription`
8
+
9
+ | Fact | Detail |
10
+ |------|--------|
11
+ | **Entity** | `OpptStageDescription` (setup BPO) |
12
+ | **Fields** | `DeveloperName` (required), `MasterLabel` (required), `OpportunityStageApiName` (required), `Description` (required) |
13
+ | **Access** | Tooling API only — full CRUD |
14
+ | **Scope** | Per-record-type |
15
+ | **Requirement** | Pipeline Management must be enabled |
16
+
17
+ **CRITICAL — Visibility Prerequisite**: The `OpptStageDescription` Tooling API object is **ONLY visible and accessible AFTER Pipeline Management is enabled** (`SalesDealAgentSettings.enableDealAgent = true`). Before enablement:
18
+ - Tooling API queries return `INVALID_TYPE` or empty results
19
+ - The object does not appear in Tooling API describe calls
20
+ - Setup UI pages for stage descriptions are hidden
21
+
22
+ **You MUST enable Pipeline Management (Phase 3 in setup-all.sh) BEFORE attempting any OpptStageDescription queries or DML.**
23
+
24
+ **How it feeds the prompt**: The flow calls `GetOpportunityStageDetailsInvocableAction`, which queries `OpptStageDescription` records and injects them as grounding data into the Recommend Stage for Opportunity prompt template.
25
+
26
+ ---
27
+
28
+ ## Auto-Provisioned Descriptions
29
+
30
+ **Important**: When Pipeline Management is enabled, the platform MAY auto-provision stage descriptions for all active stages. This behavior was observed in test orgs — MEDDIC-aligned descriptions appeared automatically.
31
+
32
+ **Always check for existing descriptions BEFORE creating**. If you attempt to create a description for a stage that already has one, you get a `DUPLICATE_VALUE` error.
33
+
34
+ ---
35
+
36
+ ## CLI Automation (Tooling API)
37
+
38
+ ### Query existing stage descriptions
39
+
40
+ ```bash
41
+ sf data query -q "SELECT Id, OpportunityStageApiName, Description FROM OpptStageDescription" \
42
+ --target-org pipeline-mgmt-org --use-tooling-api --json 2>/dev/null
43
+ ```
44
+
45
+ ### Detect stages without descriptions
46
+
47
+ ```bash
48
+ # Get all active stages
49
+ sf data query -q "SELECT MasterLabel, ApiName FROM OpportunityStage WHERE IsActive = true ORDER BY SortOrder" \
50
+ --target-org pipeline-mgmt-org --json 2>/dev/null
51
+
52
+ # Get all described stages
53
+ sf data query -q "SELECT OpportunityStageApiName FROM OpptStageDescription" \
54
+ --target-org pipeline-mgmt-org --use-tooling-api --json 2>/dev/null
55
+
56
+ # Compare — any active stage NOT in OpptStageDescription needs a description
57
+ ```
58
+
59
+ ### Create a stage description
60
+
61
+ ```bash
62
+ sf data create record --sobject OpptStageDescription \
63
+ --values "DeveloperName='Qualification' MasterLabel='Qualification' OpportunityStageApiName='Qualification' Description='Budget confirmed, decision-maker identified, need validated, timeline discussed. All four BANT criteria must be met to advance past this stage.'" \
64
+ --target-org pipeline-mgmt-org --use-tooling-api --json 2>/dev/null
65
+ ```
66
+
67
+ ### Update an existing stage description
68
+
69
+ ```bash
70
+ sf data update record --sobject OpptStageDescription --record-id <Id> \
71
+ --values "Description='Updated: Budget confirmed AND authority identified AND need validated AND timeline within 6 months.'" \
72
+ --target-org pipeline-mgmt-org --use-tooling-api --json 2>/dev/null
73
+ ```
74
+
75
+ ### Upsert pattern (create-or-update)
76
+
77
+ Use this to avoid DUPLICATE_VALUE errors when descriptions may already exist:
78
+
79
+ ```bash
80
+ ORG="pipeline-mgmt-org"
81
+ STAGE_API="Prospecting"
82
+ DESCRIPTION="Initial outreach and qualification. Entry: Lead converted. Exit: Meeting scheduled."
83
+
84
+ # Check if description exists
85
+ EXISTING_ID=$(sf data query -q "SELECT Id FROM OpptStageDescription WHERE OpportunityStageApiName='${STAGE_API}'" \
86
+ --target-org $ORG --use-tooling-api --json 2>/dev/null | jq -r '.result.records[0].Id // empty')
87
+
88
+ if [[ -n "$EXISTING_ID" ]]; then
89
+ # Update
90
+ sf data update record --sobject OpptStageDescription --record-id "$EXISTING_ID" \
91
+ --values "Description='${DESCRIPTION}'" \
92
+ --target-org $ORG --use-tooling-api --json 2>/dev/null
93
+ else
94
+ # Create
95
+ sf data create record --sobject OpptStageDescription \
96
+ --values "DeveloperName='${STAGE_API}' MasterLabel='${STAGE_API}' OpportunityStageApiName='${STAGE_API}' Description='${DESCRIPTION}'" \
97
+ --target-org $ORG --use-tooling-api --json 2>/dev/null
98
+ fi
99
+ ```
100
+
101
+ ---
102
+
103
+ ## OOTB Default Descriptions
104
+
105
+ Use the "propose and correct" pattern — present these defaults to the user, ask what doesn't match their process, then deploy the corrected set.
106
+
107
+ ### Standard B2B Stages
108
+
109
+ | Stage API Name | Description |
110
+ |----------------|-------------|
111
+ | `Prospecting` | Initial outreach and qualification. Entry: Lead converted or manual creation. Exit: Meeting scheduled or qualified out. |
112
+ | `Qualification` | Budget confirmed, decision-maker identified, need validated, timeline discussed. Entry: Prospecting complete. Exit: All BANT criteria met. |
113
+ | `Needs_Analysis` | Deep discovery underway. Pain points validated, technical requirements gathered. Entry: Qualification passed. Exit: Requirements documented. |
114
+ | `Value_Proposition` | Solution presented addressing specific needs. ROI quantified. Entry: Needs analysis complete. Exit: Prospect agrees solution fits needs. |
115
+ | `Id_Decision_Makers` | All stakeholders identified and engaged. Decision process documented. Entry: Value prop accepted. Exit: All decision-makers on board. |
116
+ | `Perception_Analysis` | Prospect evaluating and comparing solutions. Objections being handled. Entry: Decision-makers identified. Exit: Objections resolved, ready for proposal. |
117
+ | `Proposal_Price_Quote` | Formal proposal submitted. Pricing under review. Entry: Perception analysis complete. Exit: Proposal accepted or counter-proposal submitted. |
118
+ | `Negotiation_Review` | Contract terms under discussion. Legal review in progress. Entry: Proposal accepted. Exit: Terms agreed, ready to close. |
119
+ | `Closed_Won` | Deal closed successfully. Contract signed. Entry: Negotiation complete. Exit: None (terminal stage). |
120
+ | `Closed_Lost` | Deal lost. Entry: Any stage. Exit: None (terminal stage). Lost reason required. |
121
+
122
+ ### MEDDIC Methodology
123
+
124
+ | Stage API Name | Description |
125
+ |----------------|-------------|
126
+ | `Metrics` | Quantify economic impact. Entry: Initial contact. Exit: Customer agrees on measurable value. |
127
+ | `Economic_Buyer` | Identify who controls budget. Entry: Metrics defined. Exit: Economic buyer engaged. |
128
+ | `Decision_Criteria` | Understand evaluation criteria. Entry: Economic buyer identified. Exit: Criteria documented and aligned. |
129
+ | `Decision_Process` | Map decision-making process. Entry: Criteria defined. Exit: Process timeline documented. |
130
+ | `Identify_Pain` | Validate business pain. Entry: Decision process mapped. Exit: Pain confirmed and quantified. |
131
+ | `Champion` | Identify internal advocate. Entry: Pain validated. Exit: Champion actively selling internally. |
132
+ | `Proposal` | Present formal proposal. Entry: Champion engaged. Exit: Proposal accepted. |
133
+ | `Negotiation` | Finalize terms. Entry: Proposal accepted. Exit: Contract signed. |
134
+
135
+ ### SPICED Methodology
136
+
137
+ | Stage API Name | Description |
138
+ |----------------|-------------|
139
+ | `Situation` | Understand current state. Entry: First contact. Exit: Current state documented. |
140
+ | `Pain` | Identify pain points. Entry: Situation understood. Exit: Pain points validated. |
141
+ | `Impact` | Quantify impact of pain. Entry: Pain identified. Exit: Impact measured and agreed. |
142
+ | `Critical_Event` | Identify urgency driver. Entry: Impact quantified. Exit: Critical event confirmed. |
143
+ | `Decision` | Understand decision process. Entry: Critical event identified. Exit: Decision process mapped. |
144
+ | `Proposal` | Present solution. Entry: Decision process mapped. Exit: Proposal accepted. |
145
+ | `Negotiation` | Finalize terms. Entry: Proposal accepted. Exit: Contract signed. |
146
+
147
+ ---
148
+
149
+ ## Bulk Create Script
150
+
151
+ ```bash
152
+ ORG="pipeline-mgmt-org"
153
+
154
+ # Standard B2B stages
155
+ declare -a STAGES=(
156
+ "Prospecting|Initial outreach and qualification. Entry: Lead converted or manual creation. Exit: Meeting scheduled or qualified out."
157
+ "Qualification|Budget confirmed, decision-maker identified, need validated, timeline discussed. Entry: Prospecting complete. Exit: All BANT criteria met."
158
+ "Needs_Analysis|Needs Analysis|Deep discovery underway. Pain points validated, technical requirements gathered. Entry: Qualification passed. Exit: Requirements documented."
159
+ "Value_Proposition|Value Proposition|Solution presented addressing specific needs. ROI quantified. Entry: Needs analysis complete. Exit: Prospect agrees solution fits needs."
160
+ "Id_Decision_Makers|Id. Decision Makers|All stakeholders identified and engaged. Decision process documented. Entry: Value prop accepted. Exit: All decision-makers on board."
161
+ "Perception_Analysis|Perception Analysis|Prospect evaluating and comparing solutions. Objections being handled. Entry: Decision-makers identified. Exit: Objections resolved."
162
+ "Proposal_Price_Quote|Proposal/Price Quote|Formal proposal submitted. Pricing under review. Entry: Perception analysis complete. Exit: Proposal accepted."
163
+ "Negotiation_Review|Negotiation/Review|Contract terms under discussion. Legal review in progress. Entry: Proposal accepted. Exit: Terms agreed."
164
+ "Closed_Won|Closed Won|Deal closed successfully. Contract signed. Entry: Negotiation complete. Exit: None (terminal stage)."
165
+ "Closed_Lost|Closed Lost|Deal lost. Entry: Any stage. Exit: None (terminal stage). Lost reason required."
166
+ )
167
+
168
+ for stage_line in "${STAGES[@]}"; do
169
+ API_NAME=$(echo "$stage_line" | cut -d'|' -f1)
170
+ LABEL=$(echo "$stage_line" | cut -d'|' -f2)
171
+ DESC=$(echo "$stage_line" | cut -d'|' -f3)
172
+
173
+ # Handle two-field vs three-field format
174
+ if [ -z "$DESC" ]; then
175
+ DESC="$LABEL"
176
+ LABEL="$API_NAME"
177
+ fi
178
+
179
+ echo "Creating description for stage: $LABEL"
180
+ sf data create record --sobject OpptStageDescription \
181
+ --values "DeveloperName='${API_NAME}' MasterLabel='${LABEL}' OpportunityStageApiName='${LABEL}' Description='${DESC}'" \
182
+ --target-org $ORG --use-tooling-api --json 2>/dev/null
183
+ done
184
+ ```
185
+
186
+ ---
187
+
188
+ ## Propose-and-Correct Pattern
189
+
190
+ Use this workflow with users:
191
+
192
+ 1. **Query active stages** in their org:
193
+ ```bash
194
+ sf data query -q "SELECT MasterLabel, ApiName FROM OpportunityStage WHERE IsActive = true ORDER BY SortOrder" --target-org $ORG --json 2>/dev/null
195
+ ```
196
+
197
+ 2. **Present matching default descriptions** from the tables above
198
+
199
+ 3. **Ask**: "Review these defaults — tell me which ones don't match your process and I'll adjust before deploying"
200
+
201
+ 4. **Apply corrections** based on user feedback
202
+
203
+ 5. **Bulk-create** via Tooling API using the corrected descriptions
204
+
205
+ ---
206
+
207
+ ## Troubleshooting
208
+
209
+ ### Stage suggestions fail
210
+
211
+ **Symptom**: Next Step suggestions work, but Stage suggestions never appear
212
+
213
+ **Cause**: Missing stage descriptions (prompt template calls `GetOpportunityStageDetailsInvocableAction` which returns empty if no descriptions exist)
214
+
215
+ **Fix**: Create descriptions for all active stages
216
+
217
+ ### DUPLICATE_VALUE error
218
+
219
+ **Symptom**: `sf data create record` fails with "Duplicate value"
220
+
221
+ **Cause**: Description already exists for that stage
222
+
223
+ **Fix**: Query existing descriptions, update instead of create
224
+
225
+ ### Stage description not visible in UI
226
+
227
+ **Symptom**: Created via Tooling API but doesn't show in Pipeline Management setup UI
228
+
229
+ **Cause**: UI caching or record type mismatch
230
+
231
+ **Fix**:
232
+ - Refresh UI (hard refresh: Cmd+Shift+R)
233
+ - Verify `OpportunityStageApiName` matches exact stage API name (case-sensitive)
234
+ - Check if stage is active: `SELECT IsActive FROM OpportunityStage WHERE ApiName = 'YourStage'`
235
+
236
+ ---
237
+
238
+ ## Notes
239
+
240
+ - Stage descriptions are **per-record-type** (Setup UI has record type dropdown)
241
+ - If multiple record types use different stages, create separate descriptions for each
242
+ - Use **active voice** ("Entry: X happens", not "Entry: When X happens")
243
+ - Include **entry criteria** (what must be true to enter this stage) and **exit criteria** (what must be true to move to next stage)
244
+ - Descriptions feed the LLM prompt — be specific and actionable
245
+ - `OpptStageDescription` is Tooling API only — NOT accessible via standard SOQL
246
+ - Always use `2>/dev/null` on `sf ... --json` piped to jq