$npx -y skills add opendatahub-io/ai-helpers --skill jira-workitem-commentAdd comments to Jira tickets using simple text or Jira markup (ADF JSON). Supports rich formatting with code blocks, lists, mentions, and links. Use when user wants to comment on a ticket.
| 1 | # Jira Workitem Comment |
| 2 | |
| 3 | Add comments to Jira tickets using the `acli` CLI with support for both simple text and rich Atlassian Document Format (ADF). |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | - `acli` must be installed and authenticated (`acli jira auth`) |
| 8 | |
| 9 | ## Implementation |
| 10 | |
| 11 | ### Step 1: Verify ACLi Setup |
| 12 | |
| 13 | Before proceeding, verify that acli is installed and authenticated by invoking the `acli-setup-check` skill: |
| 14 | |
| 15 | ``` |
| 16 | /acli-setup-check |
| 17 | ``` |
| 18 | |
| 19 | If the setup check fails, stop execution and guide the user to fix the issue. |
| 20 | |
| 21 | ### Step 2: Determine Ticket Key and Comment Content |
| 22 | |
| 23 | 1. **Ticket Key**: |
| 24 | - If provided by user, use it |
| 25 | - Otherwise, search conversation history for ticket references matching the pattern `[A-Z]+-\d+` |
| 26 | - If not found, ask: "Which ticket should I comment on?" |
| 27 | |
| 28 | 2. **Comment Content**: |
| 29 | - If the user provides comment text, use it |
| 30 | - If the user wants to document a conversation or finding, infer the content from context |
| 31 | - If unclear, ask: "What would you like to say in the comment?" |
| 32 | |
| 33 | 3. **Comment Type**: |
| 34 | - **Simple text**: Default for straightforward comments |
| 35 | - **Rich format**: Use when comment includes code blocks, lists, or structured content |
| 36 | |
| 37 | ### Step 3a: Add Simple Text Comment (Default) |
| 38 | |
| 39 | For plain text comments, write the comment text to a temporary file and use acli to create the comment: |
| 40 | |
| 41 | ```bash |
| 42 | # Validate ticket key format (PROJECT-NUMBER) |
| 43 | TICKET_KEY="<ticket-key-from-step-2>" |
| 44 | if [[ ! "$TICKET_KEY" =~ ^[A-Z]+-[0-9]+$ ]]; then |
| 45 | echo "Error: Invalid ticket key format. Expected PROJECT-NUMBER (e.g., AIPCC-1234)" |
| 46 | exit 1 |
| 47 | fi |
| 48 | |
| 49 | # Write comment to temp file (uses system temp directory) |
| 50 | TMPFILE=$(mktemp -t acli-comment-XXXX.txt) |
| 51 | cat > "$TMPFILE" << 'EOF' |
| 52 | <comment text goes here> |
| 53 | EOF |
| 54 | |
| 55 | # Create the comment with validated ticket key |
| 56 | acli jira workitem comment create --key "$TICKET_KEY" --body-file "$TMPFILE" |
| 57 | |
| 58 | # Clean up |
| 59 | rm -f "$TMPFILE" |
| 60 | ``` |
| 61 | |
| 62 | ### Step 3b: Add Rich ADF Comment (For Formatted Content) |
| 63 | |
| 64 | For comments that need rich formatting (code blocks, lists, mentions, links), construct an ADF JSON structure. |
| 65 | |
| 66 | #### ADF Structure Examples |
| 67 | |
| 68 | **Basic text with formatting:** |
| 69 | ```json |
| 70 | { |
| 71 | "version": 1, |
| 72 | "type": "doc", |
| 73 | "content": [ |
| 74 | { |
| 75 | "type": "paragraph", |
| 76 | "content": [ |
| 77 | {"type": "text", "text": "This is "}, |
| 78 | {"type": "text", "text": "bold text", "marks": [{"type": "strong"}]}, |
| 79 | {"type": "text", "text": " and "}, |
| 80 | {"type": "text", "text": "italic text", "marks": [{"type": "em"}]} |
| 81 | ] |
| 82 | } |
| 83 | ] |
| 84 | } |
| 85 | ``` |
| 86 | |
| 87 | **Code block:** |
| 88 | ```json |
| 89 | { |
| 90 | "version": 1, |
| 91 | "type": "doc", |
| 92 | "content": [ |
| 93 | { |
| 94 | "type": "paragraph", |
| 95 | "content": [ |
| 96 | {"type": "text", "text": "Here's the fix:"} |
| 97 | ] |
| 98 | }, |
| 99 | { |
| 100 | "type": "codeBlock", |
| 101 | "attrs": {"language": "python"}, |
| 102 | "content": [ |
| 103 | { |
| 104 | "type": "text", |
| 105 | "text": "def hello():\n print('Hello, world!')" |
| 106 | } |
| 107 | ] |
| 108 | } |
| 109 | ] |
| 110 | } |
| 111 | ``` |
| 112 | |
| 113 | **Bullet list:** |
| 114 | ```json |
| 115 | { |
| 116 | "version": 1, |
| 117 | "type": "doc", |
| 118 | "content": [ |
| 119 | { |
| 120 | "type": "bulletList", |
| 121 | "content": [ |
| 122 | { |
| 123 | "type": "listItem", |
| 124 | "content": [ |
| 125 | { |
| 126 | "type": "paragraph", |
| 127 | "content": [{"type": "text", "text": "First item"}] |
| 128 | } |
| 129 | ] |
| 130 | }, |
| 131 | { |
| 132 | "type": "listItem", |
| 133 | "content": [ |
| 134 | { |
| 135 | "type": "paragraph", |
| 136 | "content": [{"type": "text", "text": "Second item"}] |
| 137 | } |
| 138 | ] |
| 139 | } |
| 140 | ] |
| 141 | } |
| 142 | ] |
| 143 | } |
| 144 | ``` |
| 145 | |
| 146 | **Link:** |
| 147 | ```json |
| 148 | { |
| 149 | "version": 1, |
| 150 | "type": "doc", |
| 151 | "content": [ |
| 152 | { |
| 153 | "type": "paragraph", |
| 154 | "content": [ |
| 155 | {"type": "text", "text": "See "}, |
| 156 | { |
| 157 | "type": "text", |
| 158 | "text": "the documentation", |
| 159 | "marks": [ |
| 160 | { |
| 161 | "type": "link", |
| 162 | "attrs": {"href": "https://example.com/docs"} |
| 163 | } |
| 164 | ] |
| 165 | } |
| 166 | ] |
| 167 | } |
| 168 | ] |
| 169 | } |
| 170 | ``` |
| 171 | |
| 172 | **User mention:** |
| 173 | ```json |
| 174 | { |
| 175 | "version": 1, |
| 176 | "type": "doc", |
| 177 | "content": [ |
| 178 | { |
| 179 | "type": "paragraph", |
| 180 | "content": [ |
| 181 | { |
| 182 | "type": "mention", |
| 183 | "attrs": { |
| 184 | "id": "557058:12345678-abcd-1234-abcd-123456789012", |
| 185 | "text": "@code-samurai" |
| 186 | } |
| 187 | }, |
| 188 | {"type": "text", "text": " please review"} |
| 189 | ] |
| 190 | } |
| 191 | ] |
| 192 | } |
| 193 | ``` |
| 194 | |
| 195 | Write the ADF JSON to a temporary file and create the comment: |
| 196 | |
| 197 | ```bash |
| 198 | # Validate ticket key format (PROJECT-NUMBER) |
| 199 | TICKET_KEY="<ticket-key-from-step-2>" |
| 200 | if [[ ! "$TICKET_KEY" =~ ^[A-Z]+-[0-9]+$ ]]; then |
| 201 | echo "Error: Invalid ticket key format. Expected PROJECT-NUMBER (e.g., AIPCC-1234)" |
| 202 | exit 1 |
| 203 | fi |
| 204 | |
| 205 | # Write ADF JSON to temp file (uses system temp directory) |
| 206 | TMPFILE=$(mktemp -t acli-comment- |