@crypto512/jicon-mcp 1.0.4 → 1.1.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 (113) hide show
  1. package/README.md +40 -3
  2. package/TOOL_LIST.md +261 -140
  3. package/dist/config/constants.d.ts +2 -0
  4. package/dist/config/constants.d.ts.map +1 -1
  5. package/dist/config/constants.js +2 -0
  6. package/dist/config/constants.js.map +1 -1
  7. package/dist/config/loader.d.ts.map +1 -1
  8. package/dist/config/loader.js +2 -0
  9. package/dist/config/loader.js.map +1 -1
  10. package/dist/config/types.d.ts +6 -0
  11. package/dist/config/types.d.ts.map +1 -1
  12. package/dist/config/types.js +4 -0
  13. package/dist/config/types.js.map +1 -1
  14. package/dist/confluence/client.d.ts +11 -2
  15. package/dist/confluence/client.d.ts.map +1 -1
  16. package/dist/confluence/client.js +29 -12
  17. package/dist/confluence/client.js.map +1 -1
  18. package/dist/confluence/tools.d.ts +2 -2
  19. package/dist/confluence/tools.d.ts.map +1 -1
  20. package/dist/confluence/tools.js +95 -58
  21. package/dist/confluence/tools.js.map +1 -1
  22. package/dist/index.js +17 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/jira/client.d.ts.map +1 -1
  25. package/dist/jira/client.js +3 -13
  26. package/dist/jira/client.js.map +1 -1
  27. package/dist/jira/tools.d.ts.map +1 -1
  28. package/dist/jira/tools.js +9 -30
  29. package/dist/jira/tools.js.map +1 -1
  30. package/dist/permissions/tool-registry.d.ts +4 -2
  31. package/dist/permissions/tool-registry.d.ts.map +1 -1
  32. package/dist/permissions/tool-registry.js +14 -2
  33. package/dist/permissions/tool-registry.js.map +1 -1
  34. package/dist/tempo/formatters.d.ts.map +1 -1
  35. package/dist/tempo/formatters.js +1 -16
  36. package/dist/tempo/formatters.js.map +1 -1
  37. package/dist/tempo/tools.d.ts +2 -2
  38. package/dist/tempo/tools.d.ts.map +1 -1
  39. package/dist/tempo/tools.js +5 -13
  40. package/dist/tempo/tools.js.map +1 -1
  41. package/dist/utils/buffer-tools.d.ts +115 -63
  42. package/dist/utils/buffer-tools.d.ts.map +1 -1
  43. package/dist/utils/buffer-tools.js +385 -388
  44. package/dist/utils/buffer-tools.js.map +1 -1
  45. package/dist/utils/content-buffer.d.ts +24 -1
  46. package/dist/utils/content-buffer.d.ts.map +1 -1
  47. package/dist/utils/content-buffer.js +49 -39
  48. package/dist/utils/content-buffer.js.map +1 -1
  49. package/dist/utils/jicon-help.d.ts +5 -5
  50. package/dist/utils/jicon-help.d.ts.map +1 -1
  51. package/dist/utils/jicon-help.js +258 -588
  52. package/dist/utils/jicon-help.js.map +1 -1
  53. package/dist/utils/plantuml/client.d.ts +1 -1
  54. package/dist/utils/plantuml/client.d.ts.map +1 -1
  55. package/dist/utils/plantuml/client.js +34 -59
  56. package/dist/utils/plantuml/client.js.map +1 -1
  57. package/dist/utils/plantuml/docker-manager.d.ts +3 -1
  58. package/dist/utils/plantuml/docker-manager.d.ts.map +1 -1
  59. package/dist/utils/plantuml/docker-manager.js +6 -2
  60. package/dist/utils/plantuml/docker-manager.js.map +1 -1
  61. package/dist/utils/plantuml/include-expander.d.ts +32 -0
  62. package/dist/utils/plantuml/include-expander.d.ts.map +1 -0
  63. package/dist/utils/plantuml/include-expander.js +129 -0
  64. package/dist/utils/plantuml/include-expander.js.map +1 -0
  65. package/dist/utils/plantuml/index.d.ts +2 -1
  66. package/dist/utils/plantuml/index.d.ts.map +1 -1
  67. package/dist/utils/plantuml/index.js +3 -1
  68. package/dist/utils/plantuml/index.js.map +1 -1
  69. package/dist/utils/plantuml/service.d.ts +32 -8
  70. package/dist/utils/plantuml/service.d.ts.map +1 -1
  71. package/dist/utils/plantuml/service.js +108 -15
  72. package/dist/utils/plantuml/service.js.map +1 -1
  73. package/dist/utils/plantuml/tools.d.ts +4 -4
  74. package/dist/utils/plantuml/tools.d.ts.map +1 -1
  75. package/dist/utils/plantuml/tools.js +50 -5
  76. package/dist/utils/plantuml/tools.js.map +1 -1
  77. package/dist/utils/plantuml/types.d.ts +4 -4
  78. package/dist/utils/plantuml/validation-helper.d.ts +33 -0
  79. package/dist/utils/plantuml/validation-helper.d.ts.map +1 -0
  80. package/dist/utils/plantuml/validation-helper.js +97 -0
  81. package/dist/utils/plantuml/validation-helper.js.map +1 -0
  82. package/dist/utils/response-formatter.js +7 -7
  83. package/dist/utils/response-formatter.js.map +1 -1
  84. package/dist/utils/time-formatter.d.ts +10 -0
  85. package/dist/utils/time-formatter.d.ts.map +1 -0
  86. package/dist/utils/time-formatter.js +22 -0
  87. package/dist/utils/time-formatter.js.map +1 -0
  88. package/dist/utils/xhtml/error-locator.d.ts +70 -0
  89. package/dist/utils/xhtml/error-locator.d.ts.map +1 -0
  90. package/dist/utils/xhtml/error-locator.js +229 -0
  91. package/dist/utils/xhtml/error-locator.js.map +1 -0
  92. package/dist/utils/xhtml/index.d.ts +6 -3
  93. package/dist/utils/xhtml/index.d.ts.map +1 -1
  94. package/dist/utils/xhtml/index.js +7 -3
  95. package/dist/utils/xhtml/index.js.map +1 -1
  96. package/dist/utils/xhtml/operations.d.ts +54 -0
  97. package/dist/utils/xhtml/operations.d.ts.map +1 -1
  98. package/dist/utils/xhtml/operations.js +205 -0
  99. package/dist/utils/xhtml/operations.js.map +1 -1
  100. package/dist/utils/xhtml/plantuml.d.ts +1 -1
  101. package/dist/utils/xhtml/plantuml.d.ts.map +1 -1
  102. package/dist/utils/xhtml/plantuml.js +19 -30
  103. package/dist/utils/xhtml/plantuml.js.map +1 -1
  104. package/dist/utils/xhtml/serializer.d.ts +5 -0
  105. package/dist/utils/xhtml/serializer.d.ts.map +1 -1
  106. package/dist/utils/xhtml/serializer.js +18 -4
  107. package/dist/utils/xhtml/serializer.js.map +1 -1
  108. package/dist/utils/xhtml/types.d.ts +3 -3
  109. package/dist/utils/xhtml/types.d.ts.map +1 -1
  110. package/dist/utils/xhtml/validator.d.ts.map +1 -1
  111. package/dist/utils/xhtml/validator.js +87 -4
  112. package/dist/utils/xhtml/validator.js.map +1 -1
  113. package/package.json +1 -1
@@ -7,159 +7,74 @@
7
7
  import { z } from "zod";
8
8
  import { formatSuccess, formatError } from "./response-formatter.js";
9
9
  // Available topics
10
- const TOPICS = ["jql", "cql", "storage", "plantuml"];
10
+ const TOPICS = ["jql", "cql", "storage", "plantuml", "buffers"];
11
11
  // Default workflow guide (shown when no topic specified)
12
12
  const WORKFLOW_GUIDE = `# Jicon Quick Reference
13
13
 
14
- ## Topics Available
15
- \`help(topic="jql|cql|storage|plantuml")\`
14
+ ## Decision Tree - Which Topic?
16
15
 
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
- \`\`\`
16
+ | Task | First Step |
17
+ |------|------------|
18
+ | Edit Confluence page | \`help(topic="buffers")\` ← Element ID editing |
19
+ | Create page with diagram | \`help(topic="plantuml")\` |
20
+ | XHTML syntax needed | \`help(topic="storage")\` |
21
+ | Search Confluence | \`help(topic="cql")\` |
22
+ | Search Jira | \`jira_get_issue_types()\` then \`help(topic="jql")\` |
23
+ | Log/get time | \`tempo_get_user_info()\` first |
67
24
 
68
25
  ---
69
26
 
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
- \`\`\`
27
+ ## Core Workflows
85
28
 
86
- ### Worklogs
29
+ ### Create/Edit Confluence Page
87
30
  \`\`\`
88
- jira_get_issue_worklogs(issueKey) [single issue]
89
- jira_get_total_worklogs(epicKey) [epic + children]
90
- -> workload_convert/workload_sum for calculations
31
+ 1. confluence_draft_create(spaceKey, title, content) OR confluence_get_page(pageId)
32
+ Returns: bufferId, structure (element IDs)
33
+ 2. buffer_edit(bufferId, after=ID, content="<p>text</p>")
34
+ → Use IDs from structure to position content
35
+ 3. confluence_draft_save(draftId, bufferId)
36
+ → Returns: url for preview
37
+ 4. User publishes via Confluence UI
91
38
  \`\`\`
92
39
 
93
- ---
94
-
95
- ## Tempo Workflows
96
-
97
- ### Log Work
40
+ ### Insert PlantUML Diagram
98
41
  \`\`\`
99
- tempo_log_work(issueKey, hours, date, description)
42
+ 1. plantuml_validate(code="@startuml...") Validate FIRST
43
+ 2. buffer_edit(bufferId, after=ID, plantuml="@startuml...")
44
+ → Auto-wraps in Confluence macro
100
45
  \`\`\`
46
+ **Multiple diagrams?** See \`help(topic="plantuml")\` for direct macro embedding (fewer tool calls).
101
47
 
102
- ### Get Worklogs
48
+ ### Search
103
49
  \`\`\`
104
- tempo_get_user_info() <- GET workerKey FIRST
105
- -> tempo_get_worklogs(dateFrom, dateTo, workerKey)
106
- WARNING: No workerKey = ALL worklogs (slow!)
50
+ Confluence: confluence_search_content(cql="space=KEY AND text~\\"term\\"")
51
+ Jira: jira_search_issues(jql="project=KEY AND type=Bug")
107
52
  \`\`\`
108
53
 
109
- ### Epic Analysis
54
+ ### Tempo Time
110
55
  \`\`\`
111
- tempo_get_epic_worklogs(epicKey) [more efficient than Jira API]
56
+ tempo_get_user_info() workerKey
57
+ tempo_get_worklogs(dateFrom, dateTo, workerKey=workerKey)
58
+ tempo_log_work(issueKey, hours, date)
112
59
  \`\`\`
113
60
 
114
61
  ---
115
62
 
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
- ---
63
+ ## Element ID System (Key Concept)
135
64
 
136
- ## Utility Tools
65
+ Every XHTML element gets a stable ID. Use IDs for precise positioning:
137
66
 
138
- ### fullurl - Clickable Links (display only)
139
67
  \`\`\`
140
- fullurl("PROJ-123") -> Jira URL
141
- fullurl("123456") -> Confluence page URL
142
- \`\`\`
143
- WARNING: Never persist fullurl output to Jira/Confluence
68
+ structure: [{id:1, type:"h1"}, {id:2, type:"p"}, {id:3, type:"ul"}]
144
69
 
145
- ### workload_convert / workload_sum
146
- \`\`\`
147
- workload_convert(28800, "seconds") -> 8h, 1d
148
- workload_sum([...]) -> total in all units
70
+ buffer_edit(bufferId, after=1, content="<p>New</p>") → Insert after h1
71
+ buffer_edit(bufferId, replace=2, content="<p>Updated</p>") → Replace p
72
+ buffer_edit(bufferId, remove=3) Delete ul
73
+ buffer_edit(bufferId, append=true, plantuml="@startuml...") Add at end
149
74
  \`\`\`
150
75
 
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 |
76
+ **IDs are STABLE** - never change when content is inserted/deleted.
77
+ See \`help(topic="buffers")\` for full details.
163
78
  `;
164
79
  // JQL syntax guide
165
80
  const JQL_HELP = `# JQL Syntax Guide
@@ -260,31 +175,25 @@ OK: (text~"term1" OR text~"term2") - Each term needs its own text~ operator
260
175
  - Date functions: now(), startOfDay(), startOfWeek(), startOfMonth()
261
176
  - Relative dates: now("-7d") = 7 days ago
262
177
  - 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
178
+ // Confluence storage format (XHTML syntax only)
179
+ const STORAGE_FORMAT_HELP = `# Confluence Storage Format (XHTML)
265
180
 
266
- XHTML-based format. All tags must be closed (XML rules).
181
+ All tags must be closed (XML rules). For editing workflow, see \`help(topic="buffers")\`.
267
182
 
268
- ## Workflows
183
+ ## CRITICAL: CDATA Usage
269
184
 
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
- \`\`\`
185
+ **NEVER wrap content in \`<![CDATA[...]]>\`**
278
186
 
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
- \`\`\`
187
+ CDATA is ONLY used inside \`<ac:plain-text-body>\` elements (code blocks, PlantUML):
188
+ \`\`\`xml
189
+ <!-- CORRECT: CDATA inside ac:plain-text-body -->
190
+ <ac:structured-macro ac:name="code">
191
+ <ac:plain-text-body><![CDATA[code here]]></ac:plain-text-body>
192
+ </ac:structured-macro>
286
193
 
287
- ---
194
+ <!-- WRONG: CDATA wrapping content -->
195
+ <![CDATA[<h1>Title</h1>]]>
196
+ \`\`\`
288
197
 
289
198
  ## Basic Elements
290
199
 
@@ -293,18 +202,18 @@ confluence_draft_create(spaceKey, title, bufferId=bufferId) -> draftId, url
293
202
  | Paragraph | \`<p>text</p>\` |
294
203
  | Headings | \`<h1>\`...\`<h6>\` |
295
204
  | Bold/Italic | \`<strong>\`, \`<em>\` |
296
- | Code | \`<code>text</code>\` |
205
+ | Code inline | \`<code>text</code>\` |
297
206
  | Link | \`<a href="url">text</a>\` |
298
- | List | \`<ul><li>item</li></ul>\` |
207
+ | List | \`<ul><li>item</li></ul>\` or \`<ol>\` |
299
208
 
300
209
  ## Tables
301
210
  \`\`\`xml
302
211
  <table><tbody>
303
- <tr><th>Header</th></tr>
304
- <tr><td>Cell</td></tr>
212
+ <tr><th>Header1</th><th>Header2</th></tr>
213
+ <tr><td>Cell1</td><td>Cell2</td></tr>
305
214
  </tbody></table>
306
215
  \`\`\`
307
- Merge: \`colspan="2"\`, \`rowspan="2"\`
216
+ Merge cells: \`colspan="2"\`, \`rowspan="2"\`
308
217
 
309
218
  ## Layouts
310
219
  \`\`\`xml
@@ -315,560 +224,320 @@ Merge: \`colspan="2"\`, \`rowspan="2"\`
315
224
  </ac:layout-section>
316
225
  </ac:layout>
317
226
  \`\`\`
318
- Types: single, two_equal, two_left_sidebar, two_right_sidebar, three_equal
227
+ Types: \`single\`, \`two_equal\`, \`two_left_sidebar\`, \`two_right_sidebar\`, \`three_equal\`
319
228
 
320
229
  ## Page Links
321
230
  \`\`\`xml
322
- <ac:link><ri:page ri:content-title="Page"/>
323
- <ac:plain-text-link-body><![CDATA[text]]></ac:plain-text-link-body>
231
+ <ac:link><ri:page ri:content-title="Page Title"/>
232
+ <ac:plain-text-link-body><![CDATA[Link Text]]></ac:plain-text-link-body>
324
233
  </ac:link>
325
234
  \`\`\`
326
- Cross-space: add \`ri:space-key="KEY"\`
235
+ Cross-space: add \`ri:space-key="KEY"\` to ri:page
327
236
 
328
237
  ## Images
329
238
  \`\`\`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>
239
+ <ac:image ac:width="300"><ri:attachment ri:filename="image.png"/></ac:image>
240
+ <ac:image><ri:url ri:value="https://example.com/img.png"/></ac:image>
332
241
  \`\`\`
333
242
 
334
243
  ## Task List
335
244
  \`\`\`xml
336
245
  <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>
246
+ <ac:task><ac:task-status>incomplete</ac:task-status><ac:task-body>Todo item</ac:task-body></ac:task>
341
247
  </ac:task-list>
342
248
  \`\`\`
343
249
 
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>")
250
+ ## Emoticons
251
+ \`\`\`xml
252
+ <ac:emoticon ac:name="tick"/> <!-- tick, cross, warning, information -->
253
+ <ac:emoticon ac:name="thumbs-up"/> <!-- thumbs-up/down, plus, minus -->
387
254
  \`\`\`
388
255
 
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")
256
+ ## Code Block Macro
257
+ \`\`\`xml
258
+ <ac:structured-macro ac:name="code" ac:schema-version="1">
259
+ <ac:parameter ac:name="language">python</ac:parameter>
260
+ <ac:plain-text-body><![CDATA[def hello(): pass]]></ac:plain-text-body>
261
+ </ac:structured-macro>
396
262
  \`\`\`
397
263
 
398
- **Remove element:**
399
- \`\`\`
400
- buffer_edit_xhtml(bufferId,
401
- operation="remove",
402
- selector="ac:structured-macro[ac:name=\\"toc\\"]")
264
+ ## Info/Warning Panels
265
+ \`\`\`xml
266
+ <ac:structured-macro ac:name="info" ac:schema-version="1">
267
+ <ac:rich-text-body><p>Info message</p></ac:rich-text-body>
268
+ </ac:structured-macro>
403
269
  \`\`\`
270
+ Types: \`info\`, \`note\`, \`warning\`, \`tip\`
404
271
 
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
- \`\`\`
272
+ ## Macro Rules
422
273
 
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.
274
+ | Element | Content Allowed |
275
+ |---------|-----------------|
276
+ | \`ac:parameter\` | Plain text only (no child elements) |
277
+ | \`ac:plain-text-body\` | Raw text, wrap in \`<![CDATA[...]]>\` |
278
+ | \`ac:rich-text-body\` | XHTML for info/warning panels |
431
279
 
432
280
  ---
433
281
 
434
- ## PlantUML Tools (Docker-based)
282
+ For element ID editing workflow, see \`help(topic="buffers")\`.
283
+ For PlantUML diagrams, see \`help(topic="plantuml")\`.`;
284
+ // PlantUML syntax guide (Confluence-specific only - LLMs know PlantUML syntax)
285
+ const PLANTUML_HELP = `# PlantUML in Confluence
435
286
 
436
- ### Validation
437
- \`\`\`
438
- plantuml_validate(code="@startuml\\nA -> B: msg\\n@enduml")
287
+ ## Workflow
439
288
  \`\`\`
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
- }
289
+ 1. plantuml_validate(code="@startuml...@enduml") ← Validate FIRST
290
+ 2. buffer_edit(bufferId, after=ID, plantuml="@startuml...@enduml")
291
+ → Auto-wraps in Confluence macro, auto-validates
292
+ 3. confluence_draft_save(draftId, bufferId)
450
293
  \`\`\`
451
294
 
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
- \`\`\`
295
+ ## Tools
477
296
 
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:
297
+ | Tool | Use |
298
+ |------|-----|
299
+ | \`plantuml_validate(code)\` | Check syntax before insert |
300
+ | \`plantuml_render(code, format)\` | Preview: ascii, svg, png, eps |
301
+ | \`plantuml_status()\` | Check Docker container status |
490
302
 
303
+ ## Confluence Macro Structure (auto-generated by buffer_edit)
491
304
  \`\`\`xml
492
- <ac:structured-macro ac:name="plantuml" ac:schema-version="1" ac:macro-id="auto-generated">
305
+ <ac:structured-macro ac:name="plantuml" ac:schema-version="1" ac:macro-id="uuid">
493
306
  <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
494
307
  <ac:plain-text-body><![CDATA[
495
308
  @startuml
496
- ' Your diagram code here
309
+ ' diagram code
497
310
  @enduml
498
311
  ]]></ac:plain-text-body>
499
312
  </ac:structured-macro>
500
313
  \`\`\`
501
314
 
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
315
+ ## Critical Rules
513
316
 
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 |
317
+ 1. **Always validate first**: \`plantuml_validate(code)\` before inserting
318
+ 2. **Use plantuml parameter**: \`buffer_edit(..., plantuml="...")\` not \`content\`
319
+ 3. **Include markers**: Always use \`@startuml\` and \`@enduml\`
529
320
 
530
- ---
321
+ ## Stdlib Includes (C4, AWS, Azure)
531
322
 
532
- ## Diagram Types
323
+ C4-PlantUML, AWS icons, and Azure diagrams are supported via \`!include\`:
533
324
 
534
- ### Sequence Diagram
535
- **Use for:** API call flows, request/response interactions, message exchanges, authentication flows
536
325
  \`\`\`
537
326
  @startuml
538
- participant Alice
539
- participant Bob
540
-
541
- Alice -> Bob: Request
542
- Bob --> Alice: Response
327
+ !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
328
+ Person(user, "User")
329
+ System(sys, "My System")
330
+ Rel(user, sys, "Uses")
543
331
  @enduml
544
332
  \`\`\`
545
333
 
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
- }
334
+ **Supported URL prefixes (whitelisted):**
335
+ - \`https://raw.githubusercontent.com/plantuml-stdlib/\` - C4, Azure, Kubernetes, etc.
336
+ - \`https://raw.githubusercontent.com/plantuml/\` - Official PlantUML stdlib
337
+ - \`https://raw.githubusercontent.com/awslabs/aws-icons-for-plantuml/\` - AWS icons
555
338
 
556
- class Order {
557
- +items: Item[]
558
- +total(): number
559
- }
339
+ **Include files are expanded client-side** before validation and Confluence upload.
560
340
 
561
- User "1" --> "*" Order : places
562
- @enduml
563
- \`\`\`
341
+ ## Quick Examples
564
342
 
565
- ### Activity Diagram
566
- **Use for:** Workflows, business processes, decision trees, algorithms, approval flows
343
+ **Sequence:**
567
344
  \`\`\`
568
345
  @startuml
569
- start
570
- :Initialize;
571
- if (Valid?) then (yes)
572
- :Process;
573
- else (no)
574
- :Reject;
575
- endif
576
- stop
346
+ Alice -> Bob: Request
347
+ Bob --> Alice: Response
577
348
  @enduml
578
349
  \`\`\`
579
350
 
580
- ### Component Diagram
581
- **Use for:** System architecture, module dependencies, package structure, deployment topology
351
+ **Class:**
582
352
  \`\`\`
583
353
  @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]
354
+ class User { +name: string }
355
+ class Order
356
+ User --> Order
597
357
  @enduml
598
358
  \`\`\`
599
359
 
600
- ### State Diagram
601
- **Use for:** Object lifecycle, status transitions, order states, ticket workflows
360
+ **C4 Context Diagram:**
602
361
  \`\`\`
603
362
  @startuml
604
- [*] --> Draft
605
- Draft --> Review : submit
606
- Review --> Approved : approve
607
- Review --> Draft : reject
608
- Approved --> Published : publish
609
- Published --> [*]
363
+ !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
364
+ Person(user, "Customer", "Uses the system")
365
+ System(sys, "E-Commerce", "Online store")
366
+ System_Ext(pay, "Payment Gateway", "Processes payments")
367
+ Rel(user, sys, "Shops")
368
+ Rel(sys, pay, "Pays via")
610
369
  @enduml
611
370
  \`\`\`
612
371
 
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
- }
372
+ ## Supported Diagram Types
625
373
 
626
- User --> UC1
627
- User --> UC2
628
- Admin --> UC1
629
- Admin --> UC3
630
- @enduml
631
- \`\`\`
374
+ | Type | Marker | Use Case |
375
+ |------|--------|----------|
376
+ | **sequence** | \`@startuml\` | API flows, service interactions, request/response |
377
+ | **class** | \`@startuml\` | OOP design, data models, inheritance |
378
+ | **activity** | \`@startuml\` | Workflows, business processes, flowcharts |
379
+ | **state** | \`@startuml\` | State machines, lifecycle, status transitions |
380
+ | **component** | \`@startuml\` | System architecture, modules, dependencies |
381
+ | **usecase** | \`@startuml\` | User stories, actors, requirements |
382
+ | **object** | \`@startuml\` | Instance diagrams, runtime snapshots |
383
+ | **deployment** | \`@startuml\` | Infrastructure, nodes, servers, containers |
384
+ | **timing** | \`@startuml\` | Time-based signals, hardware timing |
385
+ | **c4** | \`@startuml\` + \`!include C4_*.puml\` | C4 Model (requires stdlib include) |
386
+ | **mindmap** | \`@startmindmap\` | Brainstorming, hierarchical ideas |
387
+ | **gantt** | \`@startgantt\` | Project schedules, timelines |
388
+ | **wbs** | \`@startwbs\` | Work Breakdown Structure, task hierarchy |
389
+ | **json** | \`@startjson\` | JSON data visualization |
390
+ | **yaml** | \`@startyaml\` | YAML data visualization |
632
391
 
633
- ---
392
+ **Note**: C4 diagrams require \`!include\` to load the C4 library. Use \`C4_Context.puml\`, \`C4_Container.puml\`, \`C4_Component.puml\`, or \`C4_Dynamic.puml\` from plantuml-stdlib.
634
393
 
635
- ## C4-Style Architecture Diagrams
394
+ ## Troubleshooting
636
395
 
637
- C4-style diagrams for architecture documentation. These use native PlantUML syntax (no external includes required).
396
+ | Error | Fix |
397
+ |-------|-----|
398
+ | "PlantUML syntax error" | Run \`plantuml_validate\` first |
399
+ | "Element not found" | Check \`buffer_get_structure\` for valid IDs |
400
+ | "XHTML invalid" | Create fresh buffer, insert diagram |
638
401
 
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
- }
402
+ ## Advanced: Direct Macro Embedding
653
403
 
654
- rectangle "User" <<person>> as user
655
- rectangle "My System" <<system>> as system
656
- rectangle "External API" <<external>> as external
404
+ For pages with **multiple diagrams**, reduce tool calls by embedding macros directly:
657
405
 
658
- user --> system : Uses
659
- system --> external : Calls API
660
- @enduml
661
406
  \`\`\`
662
-
663
- ### Container Diagram
664
- **Use for:** Application architecture, runtime components, technology choices, data stores
407
+ 1. plantuml_validate(code) × N ← Validate ALL diagrams first (parallel)
408
+ 2. buffer_create with embedded macros:
665
409
  \`\`\`
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
410
 
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
411
+ \`\`\`xml
412
+ <h2>Architecture</h2>
413
+ <ac:structured-macro ac:name="plantuml" ac:schema-version="1" ac:macro-id="diag-1">
414
+ <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
415
+ <ac:plain-text-body><![CDATA[@startuml
416
+ ...validated code...
417
+ @enduml]]></ac:plain-text-body>
418
+ </ac:structured-macro>
419
+ <h2>Sequence Flow</h2>
420
+ <ac:structured-macro ac:name="plantuml" ac:schema-version="1" ac:macro-id="diag-2">
421
+ ...second diagram...
422
+ </ac:structured-macro>
688
423
  \`\`\`
689
424
 
690
- ### Component Diagram
691
- **Use for:** Internal structure of a container, code organization, module responsibilities
692
425
  \`\`\`
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
426
+ 3. confluence_draft_create(bufferId=...)
712
427
  \`\`\`
713
428
 
714
- ---
715
-
716
- ## Common Styling
429
+ **Benefit**: 3 diagrams = 5 calls (vs 8 with buffer_edit per diagram)
717
430
 
718
- ### Colors and Themes
719
- \`\`\`
720
- @startuml
721
- skinparam backgroundColor #FEFEFE
722
- skinparam roundcorner 10
431
+ For element ID editing: \`help(topic="buffers")\``;
432
+ // Buffers help guide (canonical element ID reference)
433
+ const BUFFERS_HELP = `# Buffer & Element ID Editing
723
434
 
724
- skinparam class {
725
- BackgroundColor #E8F4FD
726
- BorderColor #2196F3
727
- ArrowColor #1976D2
728
- }
435
+ ## Element ID System (Key Concept)
729
436
 
730
- class Example
731
- @enduml
732
- \`\`\`
437
+ Every XHTML element gets a **stable** ID. IDs never change when content is inserted/deleted.
733
438
 
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
439
  \`\`\`
742
-
743
- ### Grouping
440
+ confluence_get_page(pageId) → structure: [
441
+ { id: 1, type: "h1", text: "Title" },
442
+ { id: 2, type: "h2", text: "Section" },
443
+ { id: 3, type: "p", text: "Paragraph..." },
444
+ { id: 4, type: "plantuml", text: "Diagram" }
445
+ ]
744
446
  \`\`\`
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
447
 
755
- A1 -> B1: Request
756
- @enduml
757
- \`\`\`
448
+ ## buffer_edit Operations (XHTML)
758
449
 
759
- ---
450
+ | Operation | Example | Result |
451
+ |-----------|---------|--------|
452
+ | Insert after | \`after=2, content="<p>New</p>"\` | New element after h2, gets id=5 |
453
+ | Insert before | \`before=3, content="<p>New</p>"\` | New element before paragraph |
454
+ | Replace | \`replace=4, plantuml="@startuml..."\` | Replaces diagram, keeps id=4 |
455
+ | Remove | \`remove=3\` | Deletes paragraph |
456
+ | Append | \`append=true, content="<p>End</p>"\` | Adds at document end |
760
457
 
761
- ## Common Pitfalls
458
+ **Content options:** \`content="<xhtml>"\` or \`plantuml="@startuml..."\`
762
459
 
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
460
+ ## Batch Operations (Efficient)
769
461
 
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\`
462
+ For multiple edits, use \`operations\` array - **much faster** than multiple calls:
775
463
 
776
- ---
777
-
778
- ## IMPORTANT: External Includes NOT Supported
779
-
780
- **Never use external !include statements:**
781
464
  \`\`\`
782
- !include https://raw.githubusercontent.com/... <-- NOT SUPPORTED
465
+ buffer_edit(bufferId, operations=[
466
+ { after: 6, plantuml: "@startuml...@enduml" },
467
+ { after: 8, plantuml: "@startuml...@enduml" },
468
+ { after: 10, content: "<p>New paragraph</p>" },
469
+ { remove: 12 }
470
+ ])
783
471
  \`\`\`
784
472
 
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
473
+ **Benefits:**
474
+ - Parse once, serialize once (vs N times for N calls)
475
+ - Single tool call (reduces latency)
476
+ - All insertedIds returned together
477
+ - Operations execute sequentially; stops on first error
800
478
 
801
- participant "Client" as C
802
- participant "Server" as S
803
- database "Database" as DB
479
+ ## Complete Workflow
804
480
 
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
481
  \`\`\`
482
+ 1. confluence_get_page(pageId) OR confluence_draft_create(...)
483
+ → bufferId, structure
813
484
 
814
- ---
815
-
816
- ## Troubleshooting PlantUML Insertion
485
+ 2. buffer_edit(bufferId, after=2, content="<p>Added</p>")
486
+ → { insertedIds: [5], structure: [...] }
817
487
 
818
- ### If insert-plantuml fails:
488
+ 3. buffer_edit(bufferId, after=5, plantuml="@startuml...")
489
+ → { insertedIds: [6], structure: [...] }
819
490
 
820
- 1. **Validate diagram first:**
821
- \`\`\`
822
- plantuml_validate(code="@startuml\\n...\\n@enduml")
823
- \`\`\`
824
- Fix any errors before retrying insertion.
491
+ 4. confluence_draft_save(draftId, bufferId)
492
+ → url for preview
493
+ \`\`\`
825
494
 
826
- 2. **Check buffer content:**
827
- \`\`\`
828
- buffer_get_chunk(bufferId, limit=5000)
829
- buffer_validate_xhtml(bufferId)
830
- \`\`\`
495
+ ## Other Buffer Tools
831
496
 
832
- 3. **Ask user about placement:**
833
- If semantic position fails, ASK the user where they want the diagram.
834
- Do NOT automatically add diagrams at "end" - wrong placement is worse than no placement.
497
+ | Tool | Use |
498
+ |------|-----|
499
+ | \`buffer_get_structure(bufferId)\` | View current element IDs |
500
+ | \`buffer_get_element(bufferId, elementId)\` | Get raw XHTML of specific element |
501
+ | \`buffer_get_chunk(bufferId, offset, limit)\` | Read content in chunks |
502
+ | \`buffer_grep(bufferId, pattern, "-C"=2)\` | Search with context |
503
+ | \`buffer_validate_xhtml(bufferId)\` | Check XHTML validity |
504
+ | \`buffer_list()\` | See all active buffers |
505
+ | \`buffer_clear(bufferId)\` | Delete buffer |
835
506
 
836
- 4. **Insert diagrams one at a time:**
837
- Validate after each insertion before adding more.
507
+ ## Plain/JSON Editing (non-XHTML)
838
508
 
839
- 5. **If XHTML parsing error persists:**
840
- - Create a new buffer with simpler content
841
- - Insert diagram into the fresh buffer
842
- - Build up complexity gradually
509
+ \`\`\`
510
+ buffer_edit(bufferId, old_string="foo", new_string="bar", replace_all=true)
511
+ \`\`\`
843
512
 
844
- ### Common Errors and Fixes:
513
+ ## Common Errors & Recovery
845
514
 
846
- | Error | Cause | Fix |
847
- |-------|-------|-----|
848
- | "PlantUML syntax error" | Invalid diagram code | Use plantuml_validate first |
849
- | "Could not resolve semantic position" | Document structure issue | Ask user for placement |
850
- | "Resulting XHTML is invalid" | Corrupted buffer | Create new buffer, restart |
851
- | "No elements match selector" | Wrong selector | Ask user for correct selector |
515
+ | Error | Fix |
516
+ |-------|-----|
517
+ | "Element not found: N" | Check \`buffer_get_structure\` for valid IDs |
518
+ | "Buffer expired" | Re-fetch content, buffers expire in 10 min |
519
+ | Multiple occurrences | Use \`replace_all=true\` for string edit |
520
+ | XHTML parsing error | Check \`suggestedActions\` in error response |
852
521
 
853
- ### Recovery Workflow:
522
+ **XHTML Error Recovery**: When \`confluence_draft_create/save\` fails with an XHTML error:
523
+ 1. Error response includes \`errorLocation\` (element ID) and \`suggestedActions\`
524
+ 2. Use \`buffer_get_element(bufferId, elementId)\` to inspect problematic element
525
+ 3. Use \`buffer_edit(bufferId, replace=elementId, content="...")\` to fix
854
526
 
855
- If you see repeated errors, reset and try this sequence:
856
- \`\`\`
857
- 1. plantuml_validate(code=diagram) <- Validate diagram syntax FIRST
858
- 2. ASK the user: "The diagram placement failed. Where would you like it inserted?"
859
- 3. buffer_create(content=simpleXhtml) <- Fresh buffer with minimal XHTML
860
- 4. buffer_edit_xhtml(operation="insert-plantuml", selector=userChoice, plantuml=diagram)
861
- 5. buffer_validate_xhtml(bufferId) <- Verify result
862
- 6. confluence_draft_create(spaceKey, title, bufferId=bufferId)
863
- \`\`\`
527
+ ## Tips
864
528
 
865
- IMPORTANT: Never claim diagrams were added if insertion failed. Check contentSummary.plantumlDiagrams in the response.`;
529
+ - IDs are **stable**: insert between 2 and 3 new element gets id=5, element 3 unchanged
530
+ - Use \`buffer_get_structure\` after edits to see updated structure
531
+ - Buffers expire in 10 min (24h if modified)
532
+ - XHTML syntax: \`help(topic="storage")\`
533
+ - PlantUML: \`help(topic="plantuml")\``;
866
534
  // Topic content map
867
535
  const TOPIC_CONTENT = {
868
536
  jql: JQL_HELP,
869
537
  cql: CQL_HELP,
870
538
  storage: STORAGE_FORMAT_HELP,
871
539
  plantuml: PLANTUML_HELP,
540
+ buffers: BUFFERS_HELP,
872
541
  };
873
542
  export function createJiconHelpTools() {
874
543
  return {
@@ -881,18 +550,19 @@ With topic: Returns detailed syntax guide.
881
550
  Available topics:
882
551
  - jql: JQL (Jira Query Language) syntax
883
552
  - cql: CQL (Confluence Query Language) syntax
884
- - storage: Confluence storage format + structure editing (buffer_edit_xhtml)
553
+ - storage: Confluence storage format + structure editing (element IDs)
885
554
  - plantuml: PlantUML diagram syntax for Confluence
555
+ - buffers: Buffer management and large response handling
886
556
 
887
557
  Examples:
888
558
  help() -> Workflow guide
889
559
  help(topic="storage") -> Confluence format guide
890
- help(topic="plantuml") -> Diagram syntax guide`,
560
+ help(topic="buffers") -> Buffer management guide`,
891
561
  inputSchema: z.object({
892
562
  topic: z
893
563
  .enum(TOPICS)
894
564
  .optional()
895
- .describe('Topic for detailed help: "jql", "cql", "storage", "plantuml"'),
565
+ .describe('Topic for detailed help: "jql", "cql", "storage", "plantuml", "buffers"'),
896
566
  }),
897
567
  handler: async (args) => {
898
568
  const { topic } = args;