nowaikit 2.5.3 → 3.0.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 (151) hide show
  1. package/dist/cli/index.js +89 -1
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/direct/executor.d.ts +28 -0
  4. package/dist/direct/executor.d.ts.map +1 -0
  5. package/dist/direct/executor.js +228 -0
  6. package/dist/direct/executor.js.map +1 -0
  7. package/dist/direct/llm-client.d.ts +32 -0
  8. package/dist/direct/llm-client.d.ts.map +1 -0
  9. package/dist/direct/llm-client.js +122 -0
  10. package/dist/direct/llm-client.js.map +1 -0
  11. package/dist/prompts/capabilities/build-app.d.ts +4 -0
  12. package/dist/prompts/capabilities/build-app.d.ts.map +1 -0
  13. package/dist/prompts/capabilities/build-app.js +238 -0
  14. package/dist/prompts/capabilities/build-app.js.map +1 -0
  15. package/dist/prompts/capabilities/build-business-rule.d.ts +4 -0
  16. package/dist/prompts/capabilities/build-business-rule.d.ts.map +1 -0
  17. package/dist/prompts/capabilities/build-business-rule.js +93 -0
  18. package/dist/prompts/capabilities/build-business-rule.js.map +1 -0
  19. package/dist/prompts/capabilities/build-catalog.d.ts +4 -0
  20. package/dist/prompts/capabilities/build-catalog.d.ts.map +1 -0
  21. package/dist/prompts/capabilities/build-catalog.js +350 -0
  22. package/dist/prompts/capabilities/build-catalog.js.map +1 -0
  23. package/dist/prompts/capabilities/build-client-script.d.ts +4 -0
  24. package/dist/prompts/capabilities/build-client-script.d.ts.map +1 -0
  25. package/dist/prompts/capabilities/build-client-script.js +157 -0
  26. package/dist/prompts/capabilities/build-client-script.js.map +1 -0
  27. package/dist/prompts/capabilities/build-flow.d.ts +4 -0
  28. package/dist/prompts/capabilities/build-flow.d.ts.map +1 -0
  29. package/dist/prompts/capabilities/build-flow.js +243 -0
  30. package/dist/prompts/capabilities/build-flow.js.map +1 -0
  31. package/dist/prompts/capabilities/build-portal.d.ts +4 -0
  32. package/dist/prompts/capabilities/build-portal.d.ts.map +1 -0
  33. package/dist/prompts/capabilities/build-portal.js +250 -0
  34. package/dist/prompts/capabilities/build-portal.js.map +1 -0
  35. package/dist/prompts/capabilities/build-rest-api.d.ts +4 -0
  36. package/dist/prompts/capabilities/build-rest-api.d.ts.map +1 -0
  37. package/dist/prompts/capabilities/build-rest-api.js +293 -0
  38. package/dist/prompts/capabilities/build-rest-api.js.map +1 -0
  39. package/dist/prompts/capabilities/build-test-plan.d.ts +4 -0
  40. package/dist/prompts/capabilities/build-test-plan.d.ts.map +1 -0
  41. package/dist/prompts/capabilities/build-test-plan.js +162 -0
  42. package/dist/prompts/capabilities/build-test-plan.js.map +1 -0
  43. package/dist/prompts/capabilities/build-uib.d.ts +4 -0
  44. package/dist/prompts/capabilities/build-uib.d.ts.map +1 -0
  45. package/dist/prompts/capabilities/build-uib.js +309 -0
  46. package/dist/prompts/capabilities/build-uib.js.map +1 -0
  47. package/dist/prompts/capabilities/docs-app.d.ts +4 -0
  48. package/dist/prompts/capabilities/docs-app.d.ts.map +1 -0
  49. package/dist/prompts/capabilities/docs-app.js +234 -0
  50. package/dist/prompts/capabilities/docs-app.js.map +1 -0
  51. package/dist/prompts/capabilities/docs-release.d.ts +4 -0
  52. package/dist/prompts/capabilities/docs-release.d.ts.map +1 -0
  53. package/dist/prompts/capabilities/docs-release.js +197 -0
  54. package/dist/prompts/capabilities/docs-release.js.map +1 -0
  55. package/dist/prompts/capabilities/docs-runbook.d.ts +4 -0
  56. package/dist/prompts/capabilities/docs-runbook.d.ts.map +1 -0
  57. package/dist/prompts/capabilities/docs-runbook.js +223 -0
  58. package/dist/prompts/capabilities/docs-runbook.js.map +1 -0
  59. package/dist/prompts/capabilities/docs-script.d.ts +4 -0
  60. package/dist/prompts/capabilities/docs-script.d.ts.map +1 -0
  61. package/dist/prompts/capabilities/docs-script.js +242 -0
  62. package/dist/prompts/capabilities/docs-script.js.map +1 -0
  63. package/dist/prompts/capabilities/ops-deploy.d.ts +4 -0
  64. package/dist/prompts/capabilities/ops-deploy.d.ts.map +1 -0
  65. package/dist/prompts/capabilities/ops-deploy.js +193 -0
  66. package/dist/prompts/capabilities/ops-deploy.js.map +1 -0
  67. package/dist/prompts/capabilities/ops-risk.d.ts +4 -0
  68. package/dist/prompts/capabilities/ops-risk.d.ts.map +1 -0
  69. package/dist/prompts/capabilities/ops-risk.js +227 -0
  70. package/dist/prompts/capabilities/ops-risk.js.map +1 -0
  71. package/dist/prompts/capabilities/ops-triage.d.ts +4 -0
  72. package/dist/prompts/capabilities/ops-triage.d.ts.map +1 -0
  73. package/dist/prompts/capabilities/ops-triage.js +183 -0
  74. package/dist/prompts/capabilities/ops-triage.js.map +1 -0
  75. package/dist/prompts/capabilities/review-acls.d.ts +4 -0
  76. package/dist/prompts/capabilities/review-acls.d.ts.map +1 -0
  77. package/dist/prompts/capabilities/review-acls.js +142 -0
  78. package/dist/prompts/capabilities/review-acls.js.map +1 -0
  79. package/dist/prompts/capabilities/review-code.d.ts +4 -0
  80. package/dist/prompts/capabilities/review-code.d.ts.map +1 -0
  81. package/dist/prompts/capabilities/review-code.js +155 -0
  82. package/dist/prompts/capabilities/review-code.js.map +1 -0
  83. package/dist/prompts/capabilities/review-flows.d.ts +4 -0
  84. package/dist/prompts/capabilities/review-flows.d.ts.map +1 -0
  85. package/dist/prompts/capabilities/review-flows.js +413 -0
  86. package/dist/prompts/capabilities/review-flows.js.map +1 -0
  87. package/dist/prompts/capabilities/review-scripts.d.ts +4 -0
  88. package/dist/prompts/capabilities/review-scripts.d.ts.map +1 -0
  89. package/dist/prompts/capabilities/review-scripts.js +160 -0
  90. package/dist/prompts/capabilities/review-scripts.js.map +1 -0
  91. package/dist/prompts/capabilities/scan-automation.d.ts +4 -0
  92. package/dist/prompts/capabilities/scan-automation.d.ts.map +1 -0
  93. package/dist/prompts/capabilities/scan-automation.js +449 -0
  94. package/dist/prompts/capabilities/scan-automation.js.map +1 -0
  95. package/dist/prompts/capabilities/scan-cmdb.d.ts +4 -0
  96. package/dist/prompts/capabilities/scan-cmdb.d.ts.map +1 -0
  97. package/dist/prompts/capabilities/scan-cmdb.js +450 -0
  98. package/dist/prompts/capabilities/scan-cmdb.js.map +1 -0
  99. package/dist/prompts/capabilities/scan-debt.d.ts +4 -0
  100. package/dist/prompts/capabilities/scan-debt.d.ts.map +1 -0
  101. package/dist/prompts/capabilities/scan-debt.js +287 -0
  102. package/dist/prompts/capabilities/scan-debt.js.map +1 -0
  103. package/dist/prompts/capabilities/scan-health.d.ts +4 -0
  104. package/dist/prompts/capabilities/scan-health.d.ts.map +1 -0
  105. package/dist/prompts/capabilities/scan-health.js +235 -0
  106. package/dist/prompts/capabilities/scan-health.js.map +1 -0
  107. package/dist/prompts/capabilities/scan-security.d.ts +4 -0
  108. package/dist/prompts/capabilities/scan-security.d.ts.map +1 -0
  109. package/dist/prompts/capabilities/scan-security.js +370 -0
  110. package/dist/prompts/capabilities/scan-security.js.map +1 -0
  111. package/dist/prompts/capabilities/scan-upgrade.d.ts +4 -0
  112. package/dist/prompts/capabilities/scan-upgrade.d.ts.map +1 -0
  113. package/dist/prompts/capabilities/scan-upgrade.js +327 -0
  114. package/dist/prompts/capabilities/scan-upgrade.js.map +1 -0
  115. package/dist/prompts/index.d.ts +24 -2
  116. package/dist/prompts/index.d.ts.map +1 -1
  117. package/dist/prompts/index.js +160 -14
  118. package/dist/prompts/index.js.map +1 -1
  119. package/dist/prompts/knowledge.d.ts +10 -0
  120. package/dist/prompts/knowledge.d.ts.map +1 -0
  121. package/dist/prompts/knowledge.js +604 -0
  122. package/dist/prompts/knowledge.js.map +1 -0
  123. package/dist/prompts/types.d.ts +38 -0
  124. package/dist/prompts/types.d.ts.map +1 -0
  125. package/dist/prompts/types.js +8 -0
  126. package/dist/prompts/types.js.map +1 -0
  127. package/dist/server.js +3 -3
  128. package/dist/server.js.map +1 -1
  129. package/dist/servicenow/client.d.ts +15 -0
  130. package/dist/servicenow/client.d.ts.map +1 -1
  131. package/dist/servicenow/client.js +107 -0
  132. package/dist/servicenow/client.js.map +1 -1
  133. package/dist/tools/core.d.ts +68 -0
  134. package/dist/tools/core.d.ts.map +1 -1
  135. package/dist/tools/core.js +58 -0
  136. package/dist/tools/core.js.map +1 -1
  137. package/dist/tools/fluent.d.ts +161 -0
  138. package/dist/tools/fluent.d.ts.map +1 -0
  139. package/dist/tools/fluent.js +277 -0
  140. package/dist/tools/fluent.js.map +1 -0
  141. package/dist/tools/index.d.ts +214 -0
  142. package/dist/tools/index.d.ts.map +1 -1
  143. package/dist/tools/index.js +12 -6
  144. package/dist/tools/index.js.map +1 -1
  145. package/dist/tools/now-assist.d.ts.map +1 -1
  146. package/dist/tools/now-assist.js +8 -0
  147. package/dist/tools/now-assist.js.map +1 -1
  148. package/dist/tools/script.d.ts.map +1 -1
  149. package/dist/tools/script.js +12 -0
  150. package/dist/tools/script.js.map +1 -1
  151. package/package.json +11 -3
@@ -0,0 +1,350 @@
1
+ const capability = {
2
+ name: 'build-catalog',
3
+ title: 'Build Catalog Item',
4
+ description: 'End-to-end catalog item creation — variables, UI policies, client scripts, approval rules, fulfillment workflow',
5
+ category: 'build',
6
+ arguments: [
7
+ {
8
+ name: 'description',
9
+ description: 'what the catalog item should provide / what users are requesting',
10
+ required: true,
11
+ },
12
+ {
13
+ name: 'category',
14
+ description: 'catalog category (e.g., Hardware, Software, Access, Services)',
15
+ required: false,
16
+ },
17
+ {
18
+ name: 'fulfillment_type',
19
+ description: 'flow, workflow, approval_only. Default: flow',
20
+ required: false,
21
+ },
22
+ ],
23
+ recommendedTools: [
24
+ 'query_records',
25
+ 'list_catalog_items',
26
+ 'get_catalog_item',
27
+ 'create_catalog_item',
28
+ 'create_catalog_variable',
29
+ 'create_catalog_ui_policy',
30
+ 'create_approval_rule',
31
+ 'create_flow',
32
+ 'get_table_schema',
33
+ ],
34
+ buildPrompt(args = {}) {
35
+ const desc = args.description ?? '<not provided>';
36
+ const category = args.category ?? '<not specified>';
37
+ const fulfillmentType = args.fulfillment_type ?? 'flow';
38
+ return [
39
+ {
40
+ role: 'assistant',
41
+ content: {
42
+ type: 'text',
43
+ text: [
44
+ '# Capability: Build Catalog Item',
45
+ '',
46
+ '## ServiceNow Service Catalog — Platform Knowledge',
47
+ '',
48
+ '### Catalog Item Architecture',
49
+ '- **Catalog Item** (`sc_cat_item`): the requestable service. Contains metadata (name, description, category, price, picture), variables, workflows, and policies.',
50
+ '- **Category** (`sc_category`): organizational hierarchy for catalog items. Supports nesting (parent → child categories).',
51
+ '- **Variables** (`item_option_new`): form fields on the catalog item. Typed, ordered, and can be mandatory/optional.',
52
+ '- **Variable Sets** (`item_option_new_set`): reusable groups of variables shared across multiple catalog items.',
53
+ '- **Catalog Client Scripts** (`catalog_script_client`): JavaScript that runs on the catalog form (onChange, onLoad, onSubmit). Separate from standard client scripts.',
54
+ '- **Catalog UI Policies** (`catalog_ui_policy`): declarative show/hide/mandatory/read-only rules for catalog variables.',
55
+ '- **Approval Rules** or flows that govern the approval process.',
56
+ '- **Fulfillment** via Flow Designer, Legacy Workflow, or manual task creation.',
57
+ '',
58
+ '### Request Model (REQ / RITM / TASK)',
59
+ '- **Request (REQ)** (`sc_request`): the parent container for one or more ordered items. Created when the user submits the cart.',
60
+ '- **Requested Item (RITM)** (`sc_req_item`): one per catalog item ordered. Contains the variable values the user submitted. Tracks fulfillment state.',
61
+ '- **Catalog Task (SCTASK)** (`sc_task`): sub-tasks under a RITM for fulfillment steps (e.g., "Provision Access", "Ship Hardware"). Assigned to fulfillment groups.',
62
+ '- **Execution Plan:** defines the task sequence for fulfillment — parallel, sequential, or conditional task generation.',
63
+ '',
64
+ '### Variable Types',
65
+ '- **Single Line Text:** free-text input. Max length configurable. Supports regex validation.',
66
+ '- **Multi Line Text:** textarea for longer input.',
67
+ '- **Select Box (Choice):** dropdown with predefined choices. Choices defined inline or from a choice table.',
68
+ '- **Lookup Select Box:** dropdown with choices from a GlideRecord query (filtered, dynamic).',
69
+ '- **Reference:** reference to a record on another table (e.g., sys_user, cmdb_ci). Supports reference qualifiers.',
70
+ '- **Checkbox:** boolean true/false.',
71
+ '- **CheckBox (Yes/No):** explicit Yes/No label checkboxes.',
72
+ '- **Date / Date-Time:** date picker with configurable format.',
73
+ '- **Email / URL / IP Address:** text with built-in format validation.',
74
+ '- **Numeric Scale:** slider or numeric input with min/max/step.',
75
+ '- **Masked:** password-style masked input for sensitive data.',
76
+ '- **List Collector:** multi-select from a reference table (e.g., select multiple users).',
77
+ '- **Multi-Row Variable Set (MRVS):** table-like input where users add multiple rows of structured data (e.g., multiple software titles, multiple users). Each row has its own variables.',
78
+ '- **Container Start / Container End / Container Split:** layout controls for grouping variables visually.',
79
+ '- **Label / Break / Macro:** display-only elements for instructions, spacing, or custom UI.',
80
+ '',
81
+ '### Variable Attributes',
82
+ '- `ref_qual_elements`: reference qualifier for Reference variables (JavaScript function or encoded query).',
83
+ '- `max_length`: character limit for text fields.',
84
+ '- `default_value`: pre-populated value.',
85
+ '- `tooltip`: help text shown on hover.',
86
+ '- `read_only`: prevents user modification.',
87
+ '- `hidden`: hides the variable (still submitted).',
88
+ '- `mandatory`: requires a value before submission.',
89
+ '- `order`: display order (lower = higher on form).',
90
+ '- `question_text`: the label shown to the user.',
91
+ '- `help_text`: additional guidance shown in a help popover.',
92
+ '',
93
+ '### Catalog Client Script Patterns',
94
+ '- **onChange:** `function onChange(control, oldValue, newValue, isLoading) { ... }`. Trigger field specified in script configuration.',
95
+ '- **onLoad:** `function onLoad() { ... }`. Runs when the catalog form loads.',
96
+ '- **onSubmit:** `function onSubmit() { ... return true; }`. Return `false` to prevent submission.',
97
+ '- Use `g_form.getControl(variableName)` to access DOM elements of catalog variables.',
98
+ '- Use `g_form.setValue(variableName, value)` / `g_form.getValue(variableName)` for variable values.',
99
+ '- Use `g_form.setDisplay(variableName, true/false)` to show/hide variables programmatically.',
100
+ '- Use `g_form.setMandatory(variableName, true/false)` for dynamic mandatory rules.',
101
+ '- Use GlideAjax for server-side lookups (same pattern as standard client scripts but targeting catalog Script Includes).',
102
+ '',
103
+ '### Approval Engines',
104
+ '- **Approval Rules** (`sysapproval_approver`): condition-based rules that create approval records. Conditions based on RITM field values.',
105
+ '- **Approval Group:** set an approval group on the catalog item — all members must approve (or configure "anyone").',
106
+ '- **Manager Approval:** use `requested_for.manager` to route to the requester\'s manager.',
107
+ '- **Multi-Level Approval:** chain approval rules (Level 1 → Level 2) using "approval for" relationships or flow-based approval sequences.',
108
+ '- **Auto-Approve:** skip approval for certain roles or dollar thresholds using conditions.',
109
+ '- **Rejection Handling:** define what happens on rejection — cancel RITM, notify requester, allow resubmission.',
110
+ '',
111
+ '### Fulfillment Options',
112
+ '- **Flow Designer (recommended):** create a flow triggered by RITM creation/approval. Use flow actions to create tasks, send notifications, provision resources. Supports error handling, subflows, approval steps.',
113
+ '- **Legacy Workflow:** older visual workflow engine. Still functional but being replaced by Flow Designer.',
114
+ '- **Execution Plan:** define catalog tasks with assignment rules, SLA, and sequencing. Simpler than flows for basic task-based fulfillment.',
115
+ '- **Approval Only:** no fulfillment automation — after approval, the RITM is manually handled by fulfillment groups.',
116
+ '',
117
+ '### Pricing & Cost',
118
+ '- `price`: the price shown to the user (informational or chargeback).',
119
+ '- `recurring_price`: for subscription-style items.',
120
+ '- `cost`: internal cost (not shown to users). Used for budgeting.',
121
+ '- Variables can contribute to dynamic pricing via `price_if_checked` attribute.',
122
+ '',
123
+ '---',
124
+ '',
125
+ `Starting catalog item build for: **${desc}**`,
126
+ category !== '<not specified>'
127
+ ? `Category: **${category}**`
128
+ : 'Category: to be determined from requirement analysis',
129
+ `Fulfillment type: **${fulfillmentType}**`,
130
+ ].join('\n'),
131
+ },
132
+ },
133
+ {
134
+ role: 'user',
135
+ content: {
136
+ type: 'text',
137
+ text: [
138
+ `Build an end-to-end catalog item for the following requirement:`,
139
+ `**Requirement:** ${desc}`,
140
+ `**Category:** ${category}`,
141
+ `**Fulfillment type:** ${fulfillmentType}`,
142
+ '',
143
+ 'Follow these steps exactly:',
144
+ '',
145
+ '### Step 1 — Understand the Requirement',
146
+ 'Analyze the requirement and determine:',
147
+ '- **What service** is being offered — what does the end user receive when the request is fulfilled.',
148
+ '- **Who can request** — all users, specific roles, specific departments, specific locations.',
149
+ '- **What data is needed** — what information must the requester provide (justification, manager approval, asset selection, etc.).',
150
+ '- **Approval path** — who approves and under what conditions. Is auto-approval possible for certain scenarios.',
151
+ '- **Fulfillment steps** — what actions are performed after approval (provision access, ship hardware, create account, assign license).',
152
+ '- **SLA expectations** — how quickly should the request be fulfilled.',
153
+ category !== '<not specified>'
154
+ ? `- **Category:** ${category}. Verify this category exists using **query_records** on sc_category.`
155
+ : '- **Category:** determine the appropriate category. Use **query_records** on sc_category to find existing categories.',
156
+ '',
157
+ '### Step 2 — Check Existing Catalog Items',
158
+ 'Use **list_catalog_items** to find similar items:',
159
+ '- Items with similar names or descriptions.',
160
+ '- Items in the same category that might overlap.',
161
+ '- Items that could be extended or cloned instead of building from scratch.',
162
+ '- Variable sets that are already shared across items and could be reused.',
163
+ '',
164
+ 'If a very similar item exists, recommend whether to modify it, clone it, or create a new one.',
165
+ '',
166
+ '### Step 3 — Design Variable Layout',
167
+ 'Plan all variables the catalog form needs:',
168
+ '',
169
+ '```',
170
+ 'CATALOG ITEM: [Name]',
171
+ ' VARIABLES:',
172
+ ' --- Container: "Request Details" ---',
173
+ ' 1. variable_name (Type) [mandatory?] — description',
174
+ ' Attributes: default, ref_qual, tooltip',
175
+ ' 2. ...',
176
+ ' --- Container End ---',
177
+ ' ',
178
+ ' --- Variable Set: "Common Fields" (reuse existing if available) ---',
179
+ ' 3. ...',
180
+ ' --- Variable Set End ---',
181
+ ' ',
182
+ ' --- MRVS: "Items" (if multi-row needed) ---',
183
+ ' 4. row_field_1 (Type) — description',
184
+ ' 5. row_field_2 (Type) — description',
185
+ ' --- MRVS End ---',
186
+ '```',
187
+ '',
188
+ 'For each variable, specify:',
189
+ '- **Name:** snake_case, descriptive.',
190
+ '- **Question text:** user-facing label.',
191
+ '- **Type:** Single Line Text, Select Box, Reference, Checkbox, Date, MRVS, etc.',
192
+ '- **Mandatory:** yes/no (consider making fields conditionally mandatory via UI policies).',
193
+ '- **Order:** display order (use increments of 100 for easy insertion).',
194
+ '- **Default value:** pre-populate if appropriate.',
195
+ '- **Help text / Tooltip:** guidance for the requester.',
196
+ '- **Reference qualifier:** for Reference variables, define the filter (e.g., "active=true^department=IT").',
197
+ '- **Validation:** regex pattern for text fields, min/max for numeric fields.',
198
+ '',
199
+ 'Use **create_catalog_variable** for each variable.',
200
+ '',
201
+ '### Step 4 — Create UI Policies',
202
+ 'Define declarative rules for dynamic form behavior:',
203
+ '',
204
+ 'For each UI policy, specify:',
205
+ '- **Condition:** when the policy applies (e.g., `variable_type == "Hardware"`).',
206
+ '- **Actions:** show/hide, mandatory/not mandatory, read-only/editable for target variables.',
207
+ '- **Reverse if false:** whether to reverse the actions when the condition is no longer met.',
208
+ '- **On load:** whether to evaluate on initial form load.',
209
+ '',
210
+ 'Common patterns:',
211
+ '- Show additional fields when a category or type is selected.',
212
+ '- Make justification mandatory when cost exceeds a threshold.',
213
+ '- Hide approval-related fields from non-approver users.',
214
+ '- Show/hide MRVS based on a checkbox or select value.',
215
+ '',
216
+ 'Use **create_catalog_ui_policy** for each policy.',
217
+ '',
218
+ '### Step 5 — Create Catalog Client Scripts',
219
+ 'For dynamic behavior that UI policies cannot express:',
220
+ '',
221
+ '**onChange scripts:**',
222
+ '- Populate dependent fields based on a selection (e.g., selecting a CI populates its location and support group).',
223
+ '- Calculate estimated cost based on variable selections.',
224
+ '- Dynamic reference qualifier updates.',
225
+ '- Use GlideAjax for server-side lookups (do NOT use synchronous GlideRecord on the client).',
226
+ '',
227
+ '**onLoad scripts:**',
228
+ '- Pre-populate variables from URL parameters or user profile.',
229
+ '- Set dynamic defaults based on the requester\'s department, location, or role.',
230
+ '- Initialize complex variable interactions.',
231
+ '',
232
+ '**onSubmit scripts:**',
233
+ '- Client-side validation that is too complex for UI policies (cross-variable validation, date range checks).',
234
+ '- Confirmation dialogs for high-impact requests.',
235
+ '- Always back up client validation with server-side validation (client scripts can be bypassed).',
236
+ '',
237
+ 'For each script, generate the code and use the appropriate creation tool. If GlideAjax is needed, create the corresponding client-callable Script Include.',
238
+ '',
239
+ '### Step 6 — Design Approval Workflow',
240
+ 'Define the approval chain based on the requirement:',
241
+ '',
242
+ '**Approval Design:**',
243
+ '- **Level 1:** [who approves] — [condition for this level].',
244
+ '- **Level 2 (if needed):** [who approves] — [condition].',
245
+ '- **Auto-approve conditions:** [when approval is skipped].',
246
+ '- **Rejection handling:** [what happens when rejected — cancel, allow resubmission, notify].',
247
+ '- **Escalation:** [what happens if approval is not acted on within SLA — remind, escalate to manager\'s manager].',
248
+ '',
249
+ 'Common approval patterns:',
250
+ '- **Manager approval:** route to `requested_for.manager`. Simple, works for most HR/IT requests.',
251
+ '- **Group approval:** route to a specific group (e.g., "IT Security Approvers"). Use when specialized knowledge is needed.',
252
+ '- **Cost-based:** auto-approve below $X, manager approval $X-$Y, VP approval above $Y.',
253
+ '- **Role-based bypass:** users with `catalog_admin` role skip approval.',
254
+ '',
255
+ 'Use **create_approval_rule** for each approval level.',
256
+ '',
257
+ '### Step 7 — Create Fulfillment Flow',
258
+ `Fulfillment type: **${fulfillmentType}**.`,
259
+ '',
260
+ fulfillmentType === 'flow'
261
+ ? [
262
+ 'Create a Flow Designer flow triggered by RITM approval:',
263
+ '',
264
+ '1. **Trigger:** Record update on `sc_req_item` when `approval = approved` and `stage = waiting_for_approval → fulfillment`.',
265
+ '2. **Read variables:** extract variable values from the RITM for use in fulfillment actions.',
266
+ '3. **Create fulfillment tasks (SCTASK):**',
267
+ ' - One task per fulfillment step (e.g., "Provision Account", "Ship Hardware", "Configure Software").',
268
+ ' - Assign to appropriate fulfillment groups.',
269
+ ' - Set SLA on each task.',
270
+ ' - Include variable values in task description for fulfiller reference.',
271
+ '4. **Send notifications:**',
272
+ ' - Notify requester that their request is being fulfilled.',
273
+ ' - Notify fulfillers of new tasks.',
274
+ '5. **Completion logic:**',
275
+ ' - When all tasks are closed, close the RITM.',
276
+ ' - Send fulfillment confirmation to requester.',
277
+ '6. **Error handling:**',
278
+ ' - Try/catch around provisioning steps.',
279
+ ' - On failure: notify support, update RITM work notes, do NOT close the RITM.',
280
+ '',
281
+ 'Use **create_flow** to build the fulfillment flow.',
282
+ ].join('\n')
283
+ : fulfillmentType === 'workflow'
284
+ ? [
285
+ 'Design a legacy workflow for fulfillment:',
286
+ '',
287
+ '- Triggered on RITM approval.',
288
+ '- Create catalog tasks with assignment rules.',
289
+ '- Include approval activities if multi-stage approval is needed.',
290
+ '- Add notification activities for requester and fulfillers.',
291
+ '- Include error handling with "Run Script" activities for complex logic.',
292
+ '',
293
+ 'Note: Flow Designer is recommended for new development. Consider using Flow Designer instead.',
294
+ ].join('\n')
295
+ : [
296
+ 'No automated fulfillment — approval only:',
297
+ '',
298
+ '- After approval, the RITM moves to "Open" state for manual handling.',
299
+ '- Ensure the RITM assignment group is set so fulfillers know to pick it up.',
300
+ '- Add a notification to alert the fulfillment group when a new approved RITM is ready.',
301
+ ].join('\n'),
302
+ '',
303
+ '### Step 8 — Create the Catalog Item',
304
+ 'Use **create_catalog_item** with:',
305
+ '- Name, description, short description.',
306
+ '- Category assignment.',
307
+ '- Price (if applicable).',
308
+ '- Availability (active, visible on portal).',
309
+ '- Icon/picture.',
310
+ '- All variables, UI policies, and client scripts linked.',
311
+ '- Fulfillment flow/workflow associated.',
312
+ '',
313
+ 'Report the sys_id of the created catalog item and all associated artifacts:',
314
+ '',
315
+ '| Artifact | Type | sys_id | Name |',
316
+ '|----------|------|--------|------|',
317
+ '| Catalog Item | sc_cat_item | ... | ... |',
318
+ '| Variable 1 | item_option_new | ... | ... |',
319
+ '| Variable 2 | item_option_new | ... | ... |',
320
+ '| UI Policy 1 | catalog_ui_policy | ... | ... |',
321
+ '| Client Script 1 | catalog_script_client | ... | ... |',
322
+ '| Approval Rule | sysapproval_approver | ... | ... |',
323
+ '| Fulfillment Flow | sys_hub_flow | ... | ... |',
324
+ '',
325
+ '### Step 9 — Suggest Test Scenarios',
326
+ 'Provide a comprehensive test matrix covering the full request lifecycle:',
327
+ '',
328
+ '| # | Scenario | Setup | Steps | Expected Result |',
329
+ '|---|----------|-------|-------|-----------------|',
330
+ '',
331
+ 'Include at minimum:',
332
+ '- **Order happy path:** user opens catalog → fills variables → submits → approval requested → approved → tasks created → tasks completed → RITM closed → user notified.',
333
+ '- **Variable validation:** submit with missing mandatory fields, invalid formats, boundary values. Verify error messages are shown.',
334
+ '- **UI policy behavior:** change variable values to trigger each UI policy. Verify show/hide/mandatory/read-only states change correctly.',
335
+ '- **Client script behavior:** trigger each onChange/onLoad/onSubmit script. Verify GlideAjax lookups return correct data.',
336
+ '- **Approval path:** test with different requesters (different managers) and different variable values (different cost tiers) to verify routing.',
337
+ '- **Rejection path:** approve at level 1, reject at level 2 (if multi-level). Verify RITM state, requester notification, and resubmission flow.',
338
+ '- **Fulfillment:** verify each catalog task is created with correct assignment, description, and SLA.',
339
+ '- **Task completion:** close all tasks and verify RITM auto-closes with correct state.',
340
+ '- **Error path:** simulate fulfillment failure. Verify error handling, notifications, and RITM state.',
341
+ '- **Role-based access:** verify the catalog item is visible only to authorized users/roles.',
342
+ '- **Portal rendering:** verify the catalog item renders correctly in Service Portal (variable layout, UI policies, client scripts).',
343
+ ].join('\n'),
344
+ },
345
+ },
346
+ ];
347
+ },
348
+ };
349
+ export default capability;
350
+ //# sourceMappingURL=build-catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-catalog.js","sourceRoot":"","sources":["../../../src/prompts/capabilities/build-catalog.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAyB;IACvC,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EACT,iHAAiH;IACnH,QAAQ,EAAE,OAAO;IACjB,SAAS,EAAE;QACT;YACE,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,kEAAkE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CAAC,IAAI,CAAC,IAAI,CAAC;wBAClB,EAAE;wBACF,sCAAsC;wBACtC,mCAAmC;wBACnC,yCAAyC;wBACzC,wBAAwB;wBACxB,0BAA0B;wBAC1B,6CAA6C;wBAC7C,iBAAiB;wBACjB,0DAA0D;wBAC1D,yCAAyC;wBACzC,EAAE;wBACF,6EAA6E;wBAC7E,EAAE;wBACF,qCAAqC;wBACrC,qCAAqC;wBACrC,4CAA4C;wBAC5C,8CAA8C;wBAC9C,8CAA8C;wBAC9C,iDAAiD;wBACjD,yDAAyD;wBACzD,sDAAsD;wBACtD,iDAAiD;wBACjD,EAAE;wBACF,qCAAqC;wBACrC,0EAA0E;wBAC1E,EAAE;wBACF,oDAAoD;wBACpD,oDAAoD;wBACpD,EAAE;wBACF,qBAAqB;wBACrB,yKAAyK;wBACzK,qIAAqI;wBACrI,2IAA2I;wBAC3I,2HAA2H;wBAC3H,kJAAkJ;wBAClJ,iJAAiJ;wBACjJ,uGAAuG;wBACvG,wFAAwF;wBACxF,uGAAuG;wBACvG,6FAA6F;wBAC7F,qIAAqI;qBACtI,CAAC,IAAI,CAAC,IAAI,CAAC;iBACb;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { CapabilityDefinition } from '../types.js';
2
+ declare const capability: CapabilityDefinition;
3
+ export default capability;
4
+ //# sourceMappingURL=build-client-script.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-client-script.d.ts","sourceRoot":"","sources":["../../../src/prompts/capabilities/build-client-script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,QAAA,MAAM,UAAU,EAAE,oBA4JjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,157 @@
1
+ const capability = {
2
+ name: 'build-client-script',
3
+ title: 'Build Client Script',
4
+ description: 'Guided client script creation — onChange, onLoad, onSubmit with g_form/g_user best practices and GlideAjax patterns',
5
+ category: 'build',
6
+ arguments: [
7
+ {
8
+ name: 'description',
9
+ description: 'what the client script should do',
10
+ required: true,
11
+ },
12
+ {
13
+ name: 'table',
14
+ description: 'target table',
15
+ required: true,
16
+ },
17
+ {
18
+ name: 'type',
19
+ description: 'onChange, onLoad, onSubmit, onCellEdit. Default: onChange',
20
+ required: false,
21
+ },
22
+ {
23
+ name: 'field',
24
+ description: 'field name for onChange scripts',
25
+ required: false,
26
+ },
27
+ ],
28
+ recommendedTools: [
29
+ 'create_client_script',
30
+ 'list_client_scripts',
31
+ 'get_client_script',
32
+ 'create_ui_policy',
33
+ 'get_table_schema',
34
+ 'create_script_include',
35
+ ],
36
+ buildPrompt(args = {}) {
37
+ const desc = args.description ?? '<not provided>';
38
+ const table = args.table ?? '<not provided>';
39
+ const type = args.type ?? 'onChange';
40
+ const field = args.field ?? '<none specified>';
41
+ return [
42
+ {
43
+ role: 'user',
44
+ content: {
45
+ type: 'text',
46
+ text: [
47
+ `Build a client script for the **${table}** table.`,
48
+ `**Type:** ${type}`,
49
+ `**Field:** ${field}`,
50
+ `**Requirement:** ${desc}`,
51
+ '',
52
+ 'Follow these steps exactly:',
53
+ '',
54
+ '### Step 1 — Decide: UI Policy vs Client Script',
55
+ 'Evaluate whether the requirement can be met with a **UI Policy** instead of a client script. Use a UI Policy if the behavior is purely:',
56
+ '- Show / hide a field',
57
+ '- Make a field mandatory / not mandatory',
58
+ '- Make a field read-only / editable',
59
+ '- Set a field value based on a simple condition',
60
+ '',
61
+ 'If a UI Policy is sufficient, recommend that approach and use **create_ui_policy** instead. Explain the trade-offs (UI Policies are declarative, easier to maintain, and do not require scripting). Only proceed with a client script if the requirement involves complex logic, GlideAjax calls, or dynamic behavior that UI Policies cannot express.',
62
+ '',
63
+ '### Step 2 — Check Existing Client Scripts on the Table',
64
+ `Use **list_client_scripts** filtered to table="${table}". Summarize active scripts in a table (name, type, field, order, description). Flag any that overlap with the new requirement or that run on the same field/event. Identify potential ordering conflicts.`,
65
+ '',
66
+ '### Step 3 — Check Table Schema',
67
+ `Use **get_table_schema** for "${table}". Verify every field name used in the requirement exists. Note field types (reference fields need special handling with getDisplayValue/getReference). If the field argument is set to "${field}", confirm it exists and note its type.`,
68
+ '',
69
+ '### Step 4 — Generate the Script',
70
+ `Generate the client script with the correct function signature for type **${type}**:`,
71
+ '',
72
+ '**onChange:**',
73
+ '```javascript',
74
+ 'function onChange(control, oldValue, newValue, isLoading, isTemplate) {',
75
+ ' if (isLoading || newValue === \'\') return;',
76
+ ' // logic here',
77
+ '}',
78
+ '```',
79
+ '',
80
+ '**onLoad:**',
81
+ '```javascript',
82
+ 'function onLoad() {',
83
+ ' // logic here',
84
+ '}',
85
+ '```',
86
+ '',
87
+ '**onSubmit:**',
88
+ '```javascript',
89
+ 'function onSubmit() {',
90
+ ' // return false to abort submission',
91
+ ' // logic here',
92
+ ' return true;',
93
+ '}',
94
+ '```',
95
+ '',
96
+ '**onCellEdit:**',
97
+ '```javascript',
98
+ 'function onCellEdit(sysIDs, table, oldValues, newValue, callback) {',
99
+ ' // callback invocation is required',
100
+ ' callback();',
101
+ '}',
102
+ '```',
103
+ '',
104
+ 'Apply these best practices:',
105
+ '- Always check `isLoading` and `isTemplate` in onChange to avoid running on form load.',
106
+ '- Use `g_form.getReference(field, callback)` (async) instead of synchronous GlideRecord on the client.',
107
+ '- Prefer `g_form.setValue()`, `g_form.setDisplay()`, `g_form.setMandatory()`, `g_form.setReadOnly()`.',
108
+ '- Use `g_user.hasRole()` for client-side role checks (but never trust these for security).',
109
+ '- Minimize DOM manipulation — use g_form APIs exclusively.',
110
+ '- Include a JSDoc comment block: purpose, author, date.',
111
+ '',
112
+ '### Step 5 — GlideAjax Pattern (if needed)',
113
+ 'If the client script needs server-side data, generate a **GlideAjax** call AND the corresponding **Script Include**:',
114
+ '',
115
+ '**Client side:**',
116
+ '```javascript',
117
+ 'var ga = new GlideAjax(\'MyScriptInclude\');',
118
+ 'ga.addParam(\'sysparm_name\', \'myMethod\');',
119
+ 'ga.addParam(\'sysparm_my_param\', value);',
120
+ 'ga.getXMLAnswer(function(answer) {',
121
+ ' // handle response',
122
+ '});',
123
+ '```',
124
+ '',
125
+ '**Script Include (client-callable):**',
126
+ '```javascript',
127
+ 'var MyScriptInclude = Class.create();',
128
+ 'MyScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {',
129
+ ' myMethod: function() {',
130
+ ' var param = this.getParameter(\'sysparm_my_param\');',
131
+ ' // server logic, return result',
132
+ ' return JSON.stringify(result);',
133
+ ' },',
134
+ ' type: \'MyScriptInclude\'',
135
+ '});',
136
+ '```',
137
+ '',
138
+ 'Use **create_script_include** to create it with `client_callable: true`. Report both artifacts.',
139
+ '',
140
+ '### Step 6 — Review for Security & Quality',
141
+ 'Audit the generated script:',
142
+ '- **XSS:** Never inject unsanitized user input into DOM or g_form display values.',
143
+ '- **Client-only validation is insufficient:** If onSubmit validates data, ensure a corresponding server-side business rule also validates (client scripts can be bypassed via API/import).',
144
+ '- **Performance:** Avoid synchronous GlideRecord, excessive GlideAjax calls, or heavy DOM queries.',
145
+ '- **Scoping:** Ensure the script works in both standard and workspace/agent views if applicable.',
146
+ '- **Mobile:** Note if the script will NOT work on mobile/service portal (client scripts are form-view only).',
147
+ '',
148
+ '### Step 7 — Create the Artifact(s)',
149
+ `Use **create_client_script** with the final script, table="${table}", type="${type}"${type === 'onChange' ? `, field="${field}"` : ''}. If a Script Include was generated in Step 5, create it as well. Report the sys_id(s) of all created artifacts.`,
150
+ ].join('\n'),
151
+ },
152
+ },
153
+ ];
154
+ },
155
+ };
156
+ export default capability;
157
+ //# sourceMappingURL=build-client-script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-client-script.js","sourceRoot":"","sources":["../../../src/prompts/capabilities/build-client-script.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAyB;IACvC,IAAI,EAAE,qBAAqB;IAC3B,KAAK,EAAE,qBAAqB;I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C9G,EAAE;wBACF,qCAAqC;wBACrC,8DAA8D,KAAK,YAAY,IAAI,IAAI,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,YAAY,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,kHAAkH;qBACzP,CAAC,IAAI,CAAC,IAAI,CAAC;iBACb;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { CapabilityDefinition } from '../types.js';
2
+ declare const capability: CapabilityDefinition;
3
+ export default capability;
4
+ //# sourceMappingURL=build-flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-flow.d.ts","sourceRoot":"","sources":["../../../src/prompts/capabilities/build-flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,QAAA,MAAM,UAAU,EAAE,oBAmPjB,CAAC;AAEF,eAAe,UAAU,CAAC"}