Conversation
Adds iTop-create-incident, iTop-update-incident and
iTop-search-incident-by-caller-status-start-date, duplicating the
existing UserRequest tools and their Twig templates. The search OQL
uses alias I instead of U for readability, and its tool docstring
points to get-class-schema('Incident') since Incident statuses differ
from UserRequest's.
There was a problem hiding this comment.
Pull request overview
Adds dedicated Incident creation, update, and caller-history tools mirroring UserRequest workflows.
Changes:
- Adds Incident create and update tools.
- Adds filtered Incident search.
- Adds corresponding JSON and TOON templates.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/Tools/core/create/iTopCreateTools.php |
Registers Incident creation. |
src/Tools/core/update/iTopUpdateTools.php |
Registers Incident updates. |
src/Tools/core/get/iTopGetTools.php |
Adds filtered Incident search. |
templates/createIncident-input.json.twig |
Builds creation requests. |
templates/updateIncident-input.json.twig |
Builds update requests. |
templates/searchIncidentFromCallerStatusDate-input.json.twig |
Builds search queries. |
templates/Incident-output.toon.twig |
Formats Incident results. |
Suppressed comments (1)
src/Tools/core/get/iTopGetTools.php:137
- Any condition value other than the exact string
greater_thanis silently treated asless_than. A typo therefore reverses the requested date filter instead of producing a validation error; reject values outside the two documented options.
'condition' => $condition === 'greater_than' ? '>=' : '<=',
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| { | ||
| "operation":"core/get", | ||
| "class": "Incident", | ||
| "key": "SELECT Incident AS I JOIN Person AS P ON I.caller_id = P.id WHERE P.email='{{caller_email}}'{% if statuses !== ''%} AND I.status IN({{ statuses }}){% endif%}{% if start_date !== '' %} AND I.start_date {{ condition }} '{{start_date}}'{% endif%}", |
| #[McpTool(name: TOOL_PREFIX.'search-incident-by-caller-status-start-date', annotations: new ToolAnnotations(null, true, false, true, false))] | ||
| public function searchIncidentByCallerStatusStartDate(#[Schema(format: 'email')] string $caller_email, array $statuses = [], string $start_date = '', string $condition = 'greater_than'): string | ||
| { | ||
| return $this->runToolFromTemplates('searchIncidentFromCallerStatusDate', 'Incident', |
| * @param string $start_date Optional, the start date-time of the Incident (format as a MySQL DateTime (YYYY-MM-DD hh:ii:ss) | ||
| * @param string $condition Optional, the condiotnal operator for the start date: either 'greater_than" or 'less_than' |
| * @param string $additionalLogEntryHtml An new entry to add to the log of the Incident - NOTE the log entry MUST BE formatted in HTML | ||
| * @param string $title Specify the new title for the Incident (leave empty for no change) | ||
| * @param string $descriptionHtml Specify the new description for the Incident (leave empty for no change) - NOTE the descriptipon MUST BE formatted in HTML |
searchIncidentByCallerStatusStartDate interpolates caller_email/statuses/start_date into an OQL query string, the same pattern PR Combodo#8 fixes for the pre-existing UserRequest/Person tools. Combodo#8 can't cover this site (it's based on master before Incident tools exist), so this PR escapes it locally rather than shipping a new instance of the same class of issue. escapeOqlLiteral() is duplicated from Combodo#8 rather than shared, since these are two independent, isolated proposals - intentional and temporary, to be collapsed into one definition once both land.
|
This tool interpolates caller-supplied values into OQL, so it escapes them locally |
Adds
iTop-create-incident,iTop-update-incidentandiTop-search-incident-by-caller-status-start-date, mirroring the existingUser Request tools and their Twig templates.
The search OQL uses alias
Ifor readability. Its documentation points toget-class-schema('Incident'), since Incident statuses differ fromUser Request statuses.
Base information
Objective
Provide dedicated Incident tools instead of requiring agents to use generic
tools for the common Incident workflow:
Proposed solution
Add the three Incident-specific tools and four Twig templates. They mirror the
existing User Request implementation while using the
Incidentclass and itsown status workflow.
Validation
git diff --checkpasses.workflow.
upstream/master(two failures and one error in existingdatamodel/telephone tests).
passing datamodel fixture for this workflow.
Checklist before requesting a review
covers this Incident workflow.
Checklist of things to do before PR is ready to merge
iTop versions.