@crypto512/jicon-mcp 0.7.1 → 1.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 (129) hide show
  1. package/README.md +128 -395
  2. package/TOOL_LIST.md +810 -120
  3. package/dist/config/constants.d.ts +1 -0
  4. package/dist/config/constants.d.ts.map +1 -1
  5. package/dist/config/constants.js +1 -0
  6. package/dist/config/constants.js.map +1 -1
  7. package/dist/config/loader.d.ts +1 -0
  8. package/dist/config/loader.d.ts.map +1 -1
  9. package/dist/config/loader.js +27 -1
  10. package/dist/config/loader.js.map +1 -1
  11. package/dist/config/types.d.ts +8 -0
  12. package/dist/config/types.d.ts.map +1 -1
  13. package/dist/config/types.js +2 -0
  14. package/dist/config/types.js.map +1 -1
  15. package/dist/confluence/client.d.ts +38 -0
  16. package/dist/confluence/client.d.ts.map +1 -1
  17. package/dist/confluence/client.js +117 -0
  18. package/dist/confluence/client.js.map +1 -1
  19. package/dist/confluence/tools.d.ts +102 -75
  20. package/dist/confluence/tools.d.ts.map +1 -1
  21. package/dist/confluence/tools.js +510 -151
  22. package/dist/confluence/tools.js.map +1 -1
  23. package/dist/confluence/types.d.ts +55 -1
  24. package/dist/confluence/types.d.ts.map +1 -1
  25. package/dist/index.js +88 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/jira/tools.d.ts +0 -5
  28. package/dist/jira/tools.d.ts.map +1 -1
  29. package/dist/jira/tools.js +40 -87
  30. package/dist/jira/tools.js.map +1 -1
  31. package/dist/permissions/filter.d.ts +5 -0
  32. package/dist/permissions/filter.d.ts.map +1 -1
  33. package/dist/permissions/filter.js +29 -12
  34. package/dist/permissions/filter.js.map +1 -1
  35. package/dist/permissions/tool-registry.d.ts +23 -25
  36. package/dist/permissions/tool-registry.d.ts.map +1 -1
  37. package/dist/permissions/tool-registry.js +41 -45
  38. package/dist/permissions/tool-registry.js.map +1 -1
  39. package/dist/permissions/write-home-validator.d.ts +35 -0
  40. package/dist/permissions/write-home-validator.d.ts.map +1 -0
  41. package/dist/permissions/write-home-validator.js +140 -0
  42. package/dist/permissions/write-home-validator.js.map +1 -0
  43. package/dist/tempo/tools.d.ts.map +1 -1
  44. package/dist/tempo/tools.js +43 -44
  45. package/dist/tempo/tools.js.map +1 -1
  46. package/dist/utils/buffer-tools.d.ts +119 -1
  47. package/dist/utils/buffer-tools.d.ts.map +1 -1
  48. package/dist/utils/buffer-tools.js +610 -3
  49. package/dist/utils/buffer-tools.js.map +1 -1
  50. package/dist/utils/content-buffer.d.ts +34 -0
  51. package/dist/utils/content-buffer.d.ts.map +1 -1
  52. package/dist/utils/content-buffer.js +79 -0
  53. package/dist/utils/content-buffer.js.map +1 -1
  54. package/dist/utils/http-client.d.ts.map +1 -1
  55. package/dist/utils/http-client.js +4 -4
  56. package/dist/utils/http-client.js.map +1 -1
  57. package/dist/utils/jicon-help.d.ts +29 -0
  58. package/dist/utils/jicon-help.d.ts.map +1 -0
  59. package/dist/utils/jicon-help.js +873 -0
  60. package/dist/utils/jicon-help.js.map +1 -0
  61. package/dist/utils/plantuml/client.d.ts +40 -0
  62. package/dist/utils/plantuml/client.d.ts.map +1 -0
  63. package/dist/utils/plantuml/client.js +306 -0
  64. package/dist/utils/plantuml/client.js.map +1 -0
  65. package/dist/utils/plantuml/docker-manager.d.ts +35 -0
  66. package/dist/utils/plantuml/docker-manager.d.ts.map +1 -0
  67. package/dist/utils/plantuml/docker-manager.js +280 -0
  68. package/dist/utils/plantuml/docker-manager.js.map +1 -0
  69. package/dist/utils/plantuml/index.d.ts +11 -0
  70. package/dist/utils/plantuml/index.d.ts.map +1 -0
  71. package/dist/utils/plantuml/index.js +16 -0
  72. package/dist/utils/plantuml/index.js.map +1 -0
  73. package/dist/utils/plantuml/service.d.ts +46 -0
  74. package/dist/utils/plantuml/service.d.ts.map +1 -0
  75. package/dist/utils/plantuml/service.js +96 -0
  76. package/dist/utils/plantuml/service.js.map +1 -0
  77. package/dist/utils/plantuml/tools.d.ts +65 -0
  78. package/dist/utils/plantuml/tools.d.ts.map +1 -0
  79. package/dist/utils/plantuml/tools.js +272 -0
  80. package/dist/utils/plantuml/tools.js.map +1 -0
  81. package/dist/utils/plantuml/types.d.ts +130 -0
  82. package/dist/utils/plantuml/types.d.ts.map +1 -0
  83. package/dist/utils/plantuml/types.js +66 -0
  84. package/dist/utils/plantuml/types.js.map +1 -0
  85. package/dist/utils/response-formatter.d.ts +14 -0
  86. package/dist/utils/response-formatter.d.ts.map +1 -1
  87. package/dist/utils/response-formatter.js +84 -1
  88. package/dist/utils/response-formatter.js.map +1 -1
  89. package/dist/utils/url-tools.d.ts +49 -0
  90. package/dist/utils/url-tools.d.ts.map +1 -0
  91. package/dist/utils/url-tools.js +141 -0
  92. package/dist/utils/url-tools.js.map +1 -0
  93. package/dist/utils/xhtml/confluence-schema.d.ts +55 -0
  94. package/dist/utils/xhtml/confluence-schema.d.ts.map +1 -0
  95. package/dist/utils/xhtml/confluence-schema.js +215 -0
  96. package/dist/utils/xhtml/confluence-schema.js.map +1 -0
  97. package/dist/utils/xhtml/index.d.ts +17 -0
  98. package/dist/utils/xhtml/index.d.ts.map +1 -0
  99. package/dist/utils/xhtml/index.js +21 -0
  100. package/dist/utils/xhtml/index.js.map +1 -0
  101. package/dist/utils/xhtml/operations.d.ts +100 -0
  102. package/dist/utils/xhtml/operations.d.ts.map +1 -0
  103. package/dist/utils/xhtml/operations.js +596 -0
  104. package/dist/utils/xhtml/operations.js.map +1 -0
  105. package/dist/utils/xhtml/parser.d.ts +64 -0
  106. package/dist/utils/xhtml/parser.d.ts.map +1 -0
  107. package/dist/utils/xhtml/parser.js +180 -0
  108. package/dist/utils/xhtml/parser.js.map +1 -0
  109. package/dist/utils/xhtml/plantuml.d.ts +112 -0
  110. package/dist/utils/xhtml/plantuml.d.ts.map +1 -0
  111. package/dist/utils/xhtml/plantuml.js +251 -0
  112. package/dist/utils/xhtml/plantuml.js.map +1 -0
  113. package/dist/utils/xhtml/selector.d.ts +35 -0
  114. package/dist/utils/xhtml/selector.d.ts.map +1 -0
  115. package/dist/utils/xhtml/selector.js +358 -0
  116. package/dist/utils/xhtml/selector.js.map +1 -0
  117. package/dist/utils/xhtml/serializer.d.ts +26 -0
  118. package/dist/utils/xhtml/serializer.d.ts.map +1 -0
  119. package/dist/utils/xhtml/serializer.js +170 -0
  120. package/dist/utils/xhtml/serializer.js.map +1 -0
  121. package/dist/utils/xhtml/types.d.ts +134 -0
  122. package/dist/utils/xhtml/types.d.ts.map +1 -0
  123. package/dist/utils/xhtml/types.js +65 -0
  124. package/dist/utils/xhtml/types.js.map +1 -0
  125. package/dist/utils/xhtml/validator.d.ts +67 -0
  126. package/dist/utils/xhtml/validator.d.ts.map +1 -0
  127. package/dist/utils/xhtml/validator.js +300 -0
  128. package/dist/utils/xhtml/validator.js.map +1 -0
  129. package/package.json +5 -1
@@ -0,0 +1,873 @@
1
+ /**
2
+ * Unified help tool for Jicon MCP Server
3
+ *
4
+ * Provides workflow guides and syntax references via topic parameter.
5
+ * Entry point for all help content - no API calls.
6
+ */
7
+ import { z } from "zod";
8
+ import { formatSuccess, formatError } from "./response-formatter.js";
9
+ // Available topics
10
+ const TOPICS = ["jql", "cql", "storage", "plantuml"];
11
+ // Default workflow guide (shown when no topic specified)
12
+ const WORKFLOW_GUIDE = `# Jicon Quick Reference
13
+
14
+ ## Topics Available
15
+ \`help(topic="jql|cql|storage|plantuml")\`
16
+
17
+ ---
18
+
19
+ ## Confluence Workflows
20
+
21
+ ### Create Page
22
+ \`\`\`
23
+ help(topic="storage") <- GET SYNTAX FIRST
24
+ -> confluence_draft_create(spaceKey, title, content)
25
+ Returns: draftId, bufferId, url
26
+ -> User publishes via Confluence UI
27
+ \`\`\`
28
+
29
+ ### Create Page with Diagram
30
+ \`\`\`
31
+ help(topic="plantuml") <- GET DIAGRAM SYNTAX FIRST
32
+ help(topic="storage") <- GET PAGE SYNTAX
33
+ -> confluence_draft_create(...)
34
+ -> User publishes via Confluence UI
35
+ \`\`\`
36
+
37
+ ### Draft Workflow (iterative editing)
38
+ \`\`\`
39
+ help(topic="storage") <- if syntax needed
40
+ -> confluence_draft_create(spaceKey, title, content)
41
+ Returns: draftId, bufferId, url (click to preview)
42
+ -> buffer_edit_xhtml(...) or buffer_edit(...) [repeat]
43
+ -> confluence_draft_save(draftId, bufferId) [checkpoint]
44
+ -> User publishes manually via Confluence UI
45
+ \`\`\`
46
+
47
+ ### Update Page
48
+ \`\`\`
49
+ confluence_get_page(pageId) -> bufferId
50
+ -> buffer_edit_xhtml(...) or buffer_edit(...)
51
+ -> confluence_draft_create(spaceKey, title, bufferId=bufferId)
52
+ -> User publishes via Confluence UI
53
+ \`\`\`
54
+
55
+ ### Search Pages
56
+ \`\`\`
57
+ help(topic="cql") <- GET QUERY SYNTAX FIRST
58
+ -> confluence_search_content(cql)
59
+ \`\`\`
60
+
61
+ ### Write-Home Restriction
62
+ When enabled, writes restricted to personal space only.
63
+ \`\`\`
64
+ confluence_get_current_user_space() <- GET YOUR SPACE KEY FIRST
65
+ -> use spaceKey for create/update
66
+ \`\`\`
67
+
68
+ ---
69
+
70
+ ## Jira Workflows
71
+
72
+ ### Search Issues
73
+ \`\`\`
74
+ jira_get_issue_types() <- DISCOVER TYPE NAMES FIRST
75
+ help(topic="jql") <- GET QUERY SYNTAX
76
+ -> jira_search_issues(jql)
77
+ \`\`\`
78
+
79
+ ### Create Issue
80
+ \`\`\`
81
+ jira_get_issue_types() <- DISCOVER TYPES FIRST
82
+ -> jira_create_issue(projectKey, issueType, summary)
83
+ -> fullurl(issueKey) for clickable link
84
+ \`\`\`
85
+
86
+ ### Worklogs
87
+ \`\`\`
88
+ jira_get_issue_worklogs(issueKey) [single issue]
89
+ jira_get_total_worklogs(epicKey) [epic + children]
90
+ -> workload_convert/workload_sum for calculations
91
+ \`\`\`
92
+
93
+ ---
94
+
95
+ ## Tempo Workflows
96
+
97
+ ### Log Work
98
+ \`\`\`
99
+ tempo_log_work(issueKey, hours, date, description)
100
+ \`\`\`
101
+
102
+ ### Get Worklogs
103
+ \`\`\`
104
+ tempo_get_user_info() <- GET workerKey FIRST
105
+ -> tempo_get_worklogs(dateFrom, dateTo, workerKey)
106
+ WARNING: No workerKey = ALL worklogs (slow!)
107
+ \`\`\`
108
+
109
+ ### Epic Analysis
110
+ \`\`\`
111
+ tempo_get_epic_worklogs(epicKey) [more efficient than Jira API]
112
+ \`\`\`
113
+
114
+ ---
115
+
116
+ ## Buffer Patterns
117
+
118
+ ### Large Response
119
+ \`\`\`
120
+ [tool] returns bufferId when > 16KB
121
+ -> buffer_get_chunk(bufferId, offset, limit)
122
+ -> buffer_grep(bufferId, pattern) [search]
123
+ \`\`\`
124
+
125
+ ### Edit Before Persist
126
+ \`\`\`
127
+ buffer_create(content) OR [tool that returns bufferId]
128
+ -> buffer_edit(bufferId, old, new)
129
+ -> buffer_get_chunk(bufferId, limit=50000)
130
+ -> confluence_draft_create(..., bufferId=bufferId)
131
+ -> User publishes via Confluence UI
132
+ \`\`\`
133
+
134
+ ---
135
+
136
+ ## Utility Tools
137
+
138
+ ### fullurl - Clickable Links (display only)
139
+ \`\`\`
140
+ fullurl("PROJ-123") -> Jira URL
141
+ fullurl("123456") -> Confluence page URL
142
+ \`\`\`
143
+ WARNING: Never persist fullurl output to Jira/Confluence
144
+
145
+ ### workload_convert / workload_sum
146
+ \`\`\`
147
+ workload_convert(28800, "seconds") -> 8h, 1d
148
+ workload_sum([...]) -> total in all units
149
+ \`\`\`
150
+
151
+ ---
152
+
153
+ ## Decision Tree
154
+
155
+ | Need | Action |
156
+ |------|--------|
157
+ | Create page with diagram | \`help(topic="plantuml")\` then \`help(topic="storage")\` |
158
+ | Create/update page | \`help(topic="storage")\` |
159
+ | Search Confluence | \`help(topic="cql")\` |
160
+ | Search Jira | \`jira_get_issue_types()\` then \`help(topic="jql")\` |
161
+ | User's worklogs | \`tempo_get_user_info()\` first |
162
+ | Write to Confluence | \`confluence_get_current_user_space()\` if restricted |
163
+ `;
164
+ // JQL syntax guide
165
+ const JQL_HELP = `# JQL Syntax Guide
166
+
167
+ ## Operators
168
+ - Field operators: =, !=, >, <, >=, <=, ~, IN, NOT IN
169
+ - Text search: use ~ for "contains" (e.g., summary~"bug")
170
+ - Combine: AND, OR, NOT
171
+ - Order: ORDER BY field ASC/DESC
172
+
173
+ ## Common Examples
174
+ 1. All Epics in a project:
175
+ project = PROJ AND type = Epic
176
+
177
+ 2. Stories in current sprint:
178
+ project = PROJ AND type = Story AND sprint in openSprints()
179
+
180
+ 3. Open bugs by priority:
181
+ project = PROJ AND type = Bug AND status != Done ORDER BY priority DESC
182
+
183
+ 4. Recently updated issues (last 7 days):
184
+ updated >= startOfDay(-7)
185
+
186
+ 5. Issues by assignee:
187
+ assignee = currentUser()
188
+
189
+ 6. Text search in summary/description:
190
+ summary~"login" OR description~"login"
191
+
192
+ 7. Date range:
193
+ created >= "2025-01-01" AND created <= "2025-01-31"
194
+
195
+ 8. Multiple projects:
196
+ project IN (PROJ1, PROJ2, PROJ3)
197
+
198
+ 9. Exclude resolved:
199
+ resolution = Unresolved
200
+
201
+ 10. Issues with specific label:
202
+ labels = "urgent" AND status != Done
203
+
204
+ ## Tips
205
+ - Use jira_get_issue_types first to discover type names for your instance
206
+ - Date functions: startOfDay(), startOfWeek(), startOfMonth(), now()
207
+ - Relative dates: startOfDay(-7) = 7 days ago
208
+ - Always quote field values that contain spaces
209
+ - Issue type names may be localized (e.g., "Epopee" instead of "Epic")`;
210
+ // CQL syntax guide
211
+ const CQL_HELP = `# CQL Syntax Guide
212
+
213
+ ## Operators
214
+ - Text search: text~"term" (searches both title and body)
215
+ - Title only: title~"term"
216
+ - By space: space=KEY (use space KEY, not name!)
217
+ - By type: type=page or type=blogpost
218
+ - Combine: AND, OR, NOT
219
+ - Order: ORDER BY created/lastmodified ASC/DESC
220
+
221
+ ## Critical Warnings
222
+ WARNING: Do NOT use 'content~' or 'body~' - they're invalid! Use 'text~' instead.
223
+
224
+ WARNING: WRONG: text~("term1" OR "term2") - Cannot use OR inside the operator
225
+ OK: (text~"term1" OR text~"term2") - Each term needs its own text~ operator
226
+
227
+ ## Common Examples
228
+ 1. Recently updated pages (last 7 days):
229
+ type=page AND lastmodified >= now("-7d")
230
+
231
+ 2. Pages created by a person:
232
+ type=page AND creator="username"
233
+
234
+ 3. Pages with specific label:
235
+ type=page AND label="meeting-notes"
236
+
237
+ 4. Pages in space modified recently:
238
+ space=DOCS AND lastmodified >= now("-30d") ORDER BY lastmodified DESC
239
+
240
+ 5. Text search in a space:
241
+ text~"API" AND space=DOCS AND type=page
242
+
243
+ 6. Date range:
244
+ lastmodified >= "2025-01-01" AND lastmodified <= "2025-01-31"
245
+
246
+ 7. Multiple spaces:
247
+ space IN (DOCS, PROJ, WIKI)
248
+
249
+ 8. Pages by title pattern:
250
+ type=page AND title~"Sprint Review" ORDER BY created DESC
251
+
252
+ 9. Find by creator name:
253
+ creator.fullname~"John Smith"
254
+
255
+ 10. Pages created this week:
256
+ type=page AND created >= startOfWeek()
257
+
258
+ ## Tips
259
+ - Use space KEY (e.g., 'DOCS') not space name (e.g., 'Documentation')
260
+ - Date functions: now(), startOfDay(), startOfWeek(), startOfMonth()
261
+ - Relative dates: now("-7d") = 7 days ago
262
+ - Results are auto-fetched (up to 5000) and buffered for large responses`;
263
+ // Confluence storage format (unified)
264
+ const STORAGE_FORMAT_HELP = `# Confluence Storage Format
265
+
266
+ XHTML-based format. All tags must be closed (XML rules).
267
+
268
+ ## Workflows
269
+
270
+ ### Create Page
271
+ \`\`\`
272
+ confluence_draft_create(spaceKey, title, content) -> draftId, bufferId, url
273
+ [user previews via url]
274
+ buffer_edit_xhtml(bufferId, ...) [repeat as needed]
275
+ confluence_draft_save(draftId, bufferId) [checkpoint, returns new draftId and url]
276
+ [user publishes via Confluence UI]
277
+ \`\`\`
278
+
279
+ ### Update Page
280
+ \`\`\`
281
+ confluence_get_page(pageId) -> bufferId
282
+ buffer_edit_xhtml(bufferId, ...) or buffer_edit(bufferId, old, new)
283
+ confluence_draft_create(spaceKey, title, bufferId=bufferId) -> draftId, url
284
+ [user publishes via Confluence UI]
285
+ \`\`\`
286
+
287
+ ---
288
+
289
+ ## Basic Elements
290
+
291
+ | Element | Syntax |
292
+ |---------|--------|
293
+ | Paragraph | \`<p>text</p>\` |
294
+ | Headings | \`<h1>\`...\`<h6>\` |
295
+ | Bold/Italic | \`<strong>\`, \`<em>\` |
296
+ | Code | \`<code>text</code>\` |
297
+ | Link | \`<a href="url">text</a>\` |
298
+ | List | \`<ul><li>item</li></ul>\` |
299
+
300
+ ## Tables
301
+ \`\`\`xml
302
+ <table><tbody>
303
+ <tr><th>Header</th></tr>
304
+ <tr><td>Cell</td></tr>
305
+ </tbody></table>
306
+ \`\`\`
307
+ Merge: \`colspan="2"\`, \`rowspan="2"\`
308
+
309
+ ## Layouts
310
+ \`\`\`xml
311
+ <ac:layout>
312
+ <ac:layout-section ac:type="two_equal">
313
+ <ac:layout-cell><p>Left</p></ac:layout-cell>
314
+ <ac:layout-cell><p>Right</p></ac:layout-cell>
315
+ </ac:layout-section>
316
+ </ac:layout>
317
+ \`\`\`
318
+ Types: single, two_equal, two_left_sidebar, two_right_sidebar, three_equal
319
+
320
+ ## Page Links
321
+ \`\`\`xml
322
+ <ac:link><ri:page ri:content-title="Page"/>
323
+ <ac:plain-text-link-body><![CDATA[text]]></ac:plain-text-link-body>
324
+ </ac:link>
325
+ \`\`\`
326
+ Cross-space: add \`ri:space-key="KEY"\`
327
+
328
+ ## Images
329
+ \`\`\`xml
330
+ <ac:image ac:width="300"><ri:attachment ri:filename="img.png"/></ac:image>
331
+ <ac:image><ri:url ri:value="https://..."/></ac:image>
332
+ \`\`\`
333
+
334
+ ## Task List
335
+ \`\`\`xml
336
+ <ac:task-list>
337
+ <ac:task>
338
+ <ac:task-status>incomplete</ac:task-status>
339
+ <ac:task-body>Todo</ac:task-body>
340
+ </ac:task>
341
+ </ac:task-list>
342
+ \`\`\`
343
+
344
+ ---
345
+
346
+ ## Structure Editing (buffer_edit_xhtml)
347
+
348
+ CSS-like selectors to target elements:
349
+ - Tag: \`p\`, \`table\`, \`h1\`
350
+ - Namespaced: \`ac:structured-macro\`, \`ri:page\`
351
+ - Attribute: \`[ac:name="plantuml"]\`, \`ac:structured-macro[ac:name="code"]\`
352
+ - Pseudo: \`:nth-child(2)\`, \`:first-child\`, \`:last-child\`
353
+ - Descendant: \`table tbody tr\`
354
+ - Direct child: \`ul > li\`
355
+
356
+ ### Operations
357
+
358
+ | Op | Use | Required params |
359
+ |----|-----|-----------------|
360
+ | insert | Add element | selector, position, content |
361
+ | update | Change content/attrs | selector, content or attributes |
362
+ | remove | Delete element | selector |
363
+ | move | Relocate element | selector, targetSelector, position |
364
+ | wrap | Wrap with parent | selector, content |
365
+ | insert-plantuml | Add diagram | selector, position, plantuml |
366
+ | update-plantuml | Edit diagram | selector, plantuml |
367
+
368
+ Positions: \`before\`, \`after\`, \`inside-start\`, \`inside-end\`
369
+
370
+ ### Examples
371
+
372
+ **Add row to table:**
373
+ \`\`\`
374
+ buffer_edit_xhtml(bufferId,
375
+ operation="insert",
376
+ selector="table tbody tr:last-child",
377
+ position="after",
378
+ content="<tr><td>New</td><td>Row</td></tr>")
379
+ \`\`\`
380
+
381
+ **Update heading:**
382
+ \`\`\`
383
+ buffer_edit_xhtml(bufferId,
384
+ operation="update",
385
+ selector="h1",
386
+ content="<h1>New Title</h1>")
387
+ \`\`\`
388
+
389
+ **Insert PlantUML (auto-validates + wraps in macro):**
390
+ \`\`\`
391
+ buffer_edit_xhtml(bufferId,
392
+ operation="insert-plantuml",
393
+ selector="h2:first-child",
394
+ position="after",
395
+ plantuml="@startuml\\nA -> B: msg\\n@enduml")
396
+ \`\`\`
397
+
398
+ **Remove element:**
399
+ \`\`\`
400
+ buffer_edit_xhtml(bufferId,
401
+ operation="remove",
402
+ selector="ac:structured-macro[ac:name=\\"toc\\"]")
403
+ \`\`\`
404
+
405
+ Options: \`matchIndex=N\` (0-based) or \`matchAll=true\` for multiple matches`;
406
+ // PlantUML syntax guide
407
+ const PLANTUML_HELP = `# PlantUML in Confluence - Syntax Guide
408
+
409
+ ## PlantUML Workflow
410
+
411
+ PlantUML diagrams must be inserted using \`buffer_edit_xhtml\` with the \`insert-plantuml\` operation.
412
+ Raw @startuml blocks in content are not supported.
413
+
414
+ ### Required Workflow
415
+ \`\`\`
416
+ 1. Create XHTML content (WITHOUT PlantUML)
417
+ 2. plantuml_validate(code="@startuml...") <- Validate syntax first
418
+ 3. buffer_edit_xhtml(bufferId, operation="insert-plantuml", plantuml=code, semanticPosition="...")
419
+ 4. confluence_draft_create/save(bufferId)
420
+ 5. User publishes via Confluence UI
421
+ \`\`\`
422
+
423
+ ### Example
424
+ \`\`\`
425
+ buffer_edit_xhtml(bufferId,
426
+ operation="insert-plantuml",
427
+ semanticPosition="after-title",
428
+ plantuml="@startuml\\nA -> B\\n@enduml")
429
+ \`\`\`
430
+ Validation happens automatically during insertion.
431
+
432
+ ---
433
+
434
+ ## PlantUML Tools (Docker-based)
435
+
436
+ ### Validation
437
+ \`\`\`
438
+ plantuml_validate(code="@startuml\\nA -> B: msg\\n@enduml")
439
+ \`\`\`
440
+ Returns: \`valid\`, \`diagramType\`, \`errors\` with line numbers.
441
+ Docker container starts automatically on first use.
442
+
443
+ **Example Error Response:**
444
+ \`\`\`json
445
+ {
446
+ "valid": false,
447
+ "diagramType": "sequence",
448
+ "errors": [{"line": 3, "message": "Syntax error: unknown arrow type"}]
449
+ }
450
+ \`\`\`
451
+
452
+ ### Rendering
453
+ \`\`\`
454
+ plantuml_render(code="...", format="ascii|svg|png|eps")
455
+ \`\`\`
456
+ Returns: rendered content (ASCII/SVG inline, PNG/EPS as base64).
457
+ Large renders return \`bufferId\` for retrieval.
458
+
459
+ ### Status
460
+ \`\`\`
461
+ plantuml_status()
462
+ \`\`\`
463
+ Returns: whether Docker container is running.
464
+
465
+ ---
466
+
467
+ ## Insert PlantUML with Semantic Positions
468
+
469
+ Use \`buffer_edit_xhtml\` with \`semanticPosition\` for easy insertion:
470
+
471
+ \`\`\`
472
+ buffer_edit_xhtml(bufferId,
473
+ operation="insert-plantuml",
474
+ semanticPosition="after-title", // No selector needed!
475
+ plantuml="@startuml\\nA -> B\\n@enduml")
476
+ \`\`\`
477
+
478
+ **Semantic positions:**
479
+ - \`after-title\`: After first h1 or h2
480
+ - \`after-heading\`: After first heading (h1-h6)
481
+ - \`before-content\`: At document start
482
+ - \`end\`: At document end
483
+ - \`after-toc\`: After table of contents macro
484
+
485
+ ---
486
+
487
+ ## Confluence Macro Structure
488
+
489
+ PlantUML diagrams MUST use this exact XML structure:
490
+
491
+ \`\`\`xml
492
+ <ac:structured-macro ac:name="plantuml" ac:schema-version="1" ac:macro-id="auto-generated">
493
+ <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
494
+ <ac:plain-text-body><![CDATA[
495
+ @startuml
496
+ ' Your diagram code here
497
+ @enduml
498
+ ]]></ac:plain-text-body>
499
+ </ac:structured-macro>
500
+ \`\`\`
501
+
502
+ **Required attributes:**
503
+ - \`ac:name="plantuml"\` - Macro identifier
504
+ - \`ac:schema-version="1"\` - Must be "1"
505
+ - \`ac:macro-id\` - Any unique ID (use "auto-generated" or UUID)
506
+
507
+ **Required parameter:**
508
+ - \`atlassian-macro-output-type=INLINE\` - Renders diagram inline
509
+
510
+ **Required body:**
511
+ - \`ac:plain-text-body\` with \`CDATA\` wrapping
512
+ - Newline before \`@startuml\` marker
513
+
514
+ ---
515
+
516
+ ## Choosing the Right Diagram
517
+
518
+ | Diagram | Use When |
519
+ |---------|----------|
520
+ | Sequence | API calls, request/response flows, message exchanges between systems |
521
+ | Class | Data models, entity relationships, object structures |
522
+ | Activity | Workflows, business processes, decision trees, algorithms |
523
+ | Component | System architecture, module dependencies, deployment structure |
524
+ | State | Lifecycle states, status transitions, finite state machines |
525
+ | Use Case | User requirements, system features, actor interactions |
526
+ | Context (C4) | High-level system overview, external dependencies |
527
+ | Container (C4) | Application architecture, runtime components |
528
+ | Component (C4) | Internal structure of a container/service |
529
+
530
+ ---
531
+
532
+ ## Diagram Types
533
+
534
+ ### Sequence Diagram
535
+ **Use for:** API call flows, request/response interactions, message exchanges, authentication flows
536
+ \`\`\`
537
+ @startuml
538
+ participant Alice
539
+ participant Bob
540
+
541
+ Alice -> Bob: Request
542
+ Bob --> Alice: Response
543
+ @enduml
544
+ \`\`\`
545
+
546
+ ### Class Diagram
547
+ **Use for:** Data models, entity relationships, database schemas, object structures
548
+ \`\`\`
549
+ @startuml
550
+ class User {
551
+ +id: string
552
+ +name: string
553
+ +login(): boolean
554
+ }
555
+
556
+ class Order {
557
+ +items: Item[]
558
+ +total(): number
559
+ }
560
+
561
+ User "1" --> "*" Order : places
562
+ @enduml
563
+ \`\`\`
564
+
565
+ ### Activity Diagram
566
+ **Use for:** Workflows, business processes, decision trees, algorithms, approval flows
567
+ \`\`\`
568
+ @startuml
569
+ start
570
+ :Initialize;
571
+ if (Valid?) then (yes)
572
+ :Process;
573
+ else (no)
574
+ :Reject;
575
+ endif
576
+ stop
577
+ @enduml
578
+ \`\`\`
579
+
580
+ ### Component Diagram
581
+ **Use for:** System architecture, module dependencies, package structure, deployment topology
582
+ \`\`\`
583
+ @startuml
584
+ package "Frontend" {
585
+ [Web App]
586
+ [Mobile App]
587
+ }
588
+
589
+ package "Backend" {
590
+ [API Server]
591
+ [Database]
592
+ }
593
+
594
+ [Web App] --> [API Server]
595
+ [Mobile App] --> [API Server]
596
+ [API Server] --> [Database]
597
+ @enduml
598
+ \`\`\`
599
+
600
+ ### State Diagram
601
+ **Use for:** Object lifecycle, status transitions, order states, ticket workflows
602
+ \`\`\`
603
+ @startuml
604
+ [*] --> Draft
605
+ Draft --> Review : submit
606
+ Review --> Approved : approve
607
+ Review --> Draft : reject
608
+ Approved --> Published : publish
609
+ Published --> [*]
610
+ @enduml
611
+ \`\`\`
612
+
613
+ ### Use Case Diagram
614
+ **Use for:** User requirements, feature overview, actor roles, system boundaries
615
+ \`\`\`
616
+ @startuml
617
+ actor User
618
+ actor Admin
619
+
620
+ rectangle System {
621
+ usecase "Login" as UC1
622
+ usecase "View Data" as UC2
623
+ usecase "Manage Users" as UC3
624
+ }
625
+
626
+ User --> UC1
627
+ User --> UC2
628
+ Admin --> UC1
629
+ Admin --> UC3
630
+ @enduml
631
+ \`\`\`
632
+
633
+ ---
634
+
635
+ ## C4-Style Architecture Diagrams
636
+
637
+ C4-style diagrams for architecture documentation. These use native PlantUML syntax (no external includes required).
638
+
639
+ ### Context Diagram
640
+ **Use for:** High-level system overview, stakeholders, external dependencies, system boundaries
641
+ \`\`\`
642
+ @startuml
643
+ title System Context
644
+
645
+ skinparam rectangle {
646
+ BackgroundColor<<person>> #08427B
647
+ FontColor<<person>> white
648
+ BackgroundColor<<system>> #1168BD
649
+ FontColor<<system>> white
650
+ BackgroundColor<<external>> #999999
651
+ FontColor<<external>> white
652
+ }
653
+
654
+ rectangle "User" <<person>> as user
655
+ rectangle "My System" <<system>> as system
656
+ rectangle "External API" <<external>> as external
657
+
658
+ user --> system : Uses
659
+ system --> external : Calls API
660
+ @enduml
661
+ \`\`\`
662
+
663
+ ### Container Diagram
664
+ **Use for:** Application architecture, runtime components, technology choices, data stores
665
+ \`\`\`
666
+ @startuml
667
+ title Container Diagram
668
+
669
+ skinparam rectangle {
670
+ BackgroundColor<<container>> #438DD5
671
+ FontColor<<container>> white
672
+ BackgroundColor<<database>> #438DD5
673
+ FontColor<<database>> white
674
+ }
675
+
676
+ actor "User" as user
677
+
678
+ rectangle "My System" {
679
+ rectangle "Web App\\n[React]" <<container>> as web
680
+ rectangle "API Server\\n[Node.js]" <<container>> as api
681
+ database "Database\\n[PostgreSQL]" <<database>> as db
682
+ }
683
+
684
+ user --> web : Uses [HTTPS]
685
+ web --> api : Calls [REST/JSON]
686
+ api --> db : Reads/Writes [SQL]
687
+ @enduml
688
+ \`\`\`
689
+
690
+ ### Component Diagram
691
+ **Use for:** Internal structure of a container, code organization, module responsibilities
692
+ \`\`\`
693
+ @startuml
694
+ title API Components
695
+
696
+ skinparam component {
697
+ BackgroundColor #85BBF0
698
+ BorderColor #5588BB
699
+ }
700
+
701
+ package "API Application" {
702
+ component "Auth Controller" as auth
703
+ component "User Controller" as userCtrl
704
+ component "User Service" as service
705
+ database "User Repository" as repo
706
+ }
707
+
708
+ auth --> service : Uses
709
+ userCtrl --> service : Uses
710
+ service --> repo : Queries
711
+ @enduml
712
+ \`\`\`
713
+
714
+ ---
715
+
716
+ ## Common Styling
717
+
718
+ ### Colors and Themes
719
+ \`\`\`
720
+ @startuml
721
+ skinparam backgroundColor #FEFEFE
722
+ skinparam roundcorner 10
723
+
724
+ skinparam class {
725
+ BackgroundColor #E8F4FD
726
+ BorderColor #2196F3
727
+ ArrowColor #1976D2
728
+ }
729
+
730
+ class Example
731
+ @enduml
732
+ \`\`\`
733
+
734
+ ### Notes
735
+ \`\`\`
736
+ @startuml
737
+ Alice -> Bob: Message
738
+ note right: This is a note
739
+ note over Alice, Bob: Shared note
740
+ @enduml
741
+ \`\`\`
742
+
743
+ ### Grouping
744
+ \`\`\`
745
+ @startuml
746
+ box "Service A" #LightBlue
747
+ participant A1
748
+ participant A2
749
+ end box
750
+
751
+ box "Service B" #LightGreen
752
+ participant B1
753
+ end box
754
+
755
+ A1 -> B1: Request
756
+ @enduml
757
+ \`\`\`
758
+
759
+ ---
760
+
761
+ ## Common Pitfalls
762
+
763
+ **Avoid:**
764
+ - Missing \`ac:schema-version="1"\`
765
+ - Using \`ac:rich-text-body\` instead of \`ac:plain-text-body\`
766
+ - No CDATA wrapper around diagram code
767
+ - No newline before \`@startuml\`
768
+ - Missing \`@startuml\`/\`@enduml\` markers
769
+
770
+ **Always:**
771
+ - Use exact macro structure shown above
772
+ - Wrap diagram code in CDATA
773
+ - Include \`atlassian-macro-output-type=INLINE\` parameter
774
+ - Start with \`@startuml\` and end with \`@enduml\`
775
+
776
+ ---
777
+
778
+ ## IMPORTANT: External Includes NOT Supported
779
+
780
+ **Never use external !include statements:**
781
+ \`\`\`
782
+ !include https://raw.githubusercontent.com/... <-- NOT SUPPORTED
783
+ \`\`\`
784
+
785
+ Confluence's PlantUML plugin cannot fetch external URLs.
786
+ Use native PlantUML syntax instead (see C4-Style examples above).
787
+
788
+ ---
789
+
790
+ ## Full Example
791
+
792
+ Complete Confluence storage format for a sequence diagram:
793
+
794
+ \`\`\`xml
795
+ <ac:structured-macro ac:name="plantuml" ac:schema-version="1" ac:macro-id="diagram-1">
796
+ <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
797
+ <ac:plain-text-body><![CDATA[
798
+ @startuml
799
+ skinparam backgroundColor #FEFEFE
800
+
801
+ participant "Client" as C
802
+ participant "Server" as S
803
+ database "Database" as DB
804
+
805
+ C -> S: POST /api/data
806
+ S -> DB: INSERT
807
+ DB --> S: OK
808
+ S --> C: 201 Created
809
+ @enduml
810
+ ]]></ac:plain-text-body>
811
+ </ac:structured-macro>
812
+ \`\`\``;
813
+ // Topic content map
814
+ const TOPIC_CONTENT = {
815
+ jql: JQL_HELP,
816
+ cql: CQL_HELP,
817
+ storage: STORAGE_FORMAT_HELP,
818
+ plantuml: PLANTUML_HELP,
819
+ };
820
+ export function createJiconHelpTools() {
821
+ return {
822
+ help: {
823
+ description: `Get Jicon MCP Server help - workflows and syntax guides.
824
+
825
+ Without topic: Returns workflow quick reference with decision trees.
826
+ With topic: Returns detailed syntax guide.
827
+
828
+ Available topics:
829
+ - jql: JQL (Jira Query Language) syntax
830
+ - cql: CQL (Confluence Query Language) syntax
831
+ - storage: Confluence storage format + structure editing (buffer_edit_xhtml)
832
+ - plantuml: PlantUML diagram syntax for Confluence
833
+
834
+ Examples:
835
+ help() -> Workflow guide
836
+ help(topic="storage") -> Confluence format guide
837
+ help(topic="plantuml") -> Diagram syntax guide`,
838
+ inputSchema: z.object({
839
+ topic: z
840
+ .enum(TOPICS)
841
+ .optional()
842
+ .describe('Topic for detailed help: "jql", "cql", "storage", "plantuml"'),
843
+ }),
844
+ handler: async (args) => {
845
+ const { topic } = args;
846
+ // No topic: return workflow guide
847
+ if (!topic) {
848
+ return formatSuccess({
849
+ guide: WORKFLOW_GUIDE,
850
+ });
851
+ }
852
+ // Valid topic: return specific guide
853
+ if (topic in TOPIC_CONTENT) {
854
+ return formatSuccess({
855
+ topic,
856
+ guide: TOPIC_CONTENT[topic],
857
+ });
858
+ }
859
+ // Invalid topic (shouldn't happen with zod validation, but just in case)
860
+ return formatError({
861
+ error: true,
862
+ message: `Invalid topic: "${topic}". Available topics: ${TOPICS.join(", ")}`,
863
+ statusCode: 400,
864
+ });
865
+ },
866
+ },
867
+ };
868
+ }
869
+ // Tool names for registry
870
+ export const JICON_HELP_TOOLS = ["help"];
871
+ // Export workflow guide for MCP prompt
872
+ export { WORKFLOW_GUIDE };
873
+ //# sourceMappingURL=jicon-help.js.map