@crypto512/jicon-mcp 1.0.4 → 1.1.1

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
package/TOOL_LIST.md CHANGED
@@ -5,11 +5,11 @@ This document provides a comprehensive reference of all available tools in the J
5
5
 
6
6
  ## Summary
7
7
 
8
- **Total Tools**: 63
8
+ **Total Tools**: 64
9
9
  - **Jira Tools**: 18 (13 read + 5 write)
10
10
  - **Confluence Tools**: 17 (11 read + 6 write)
11
11
  - **Tempo Tools**: 12 (9 read + 3 write)
12
- - **Buffer Tools**: 9
12
+ - **Buffer Tools**: 10
13
13
  - **Workload Tools**: 2
14
14
  - **URL Tools**: 1
15
15
  - **Jicon Help Tools**: 1
@@ -273,7 +273,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
273
273
 
274
274
  **Response includes**: `pageId`, `version`, `bufferId`, `contentSize`, metadata
275
275
 
276
- **Usage**: Content is always stored in buffer with `contentType: "xhtml"`. Use `buffer_edit_xhtml` to modify (required for XHTML buffers), then `confluence_draft_create` for user review.
276
+ **Usage**: Content is stored in buffer with `contentType: "xhtml"` and returns `structure` with element IDs. Use `buffer_edit` with element IDs to modify, then `confluence_draft_create` for user review.
277
277
 
278
278
  ---
279
279
 
@@ -289,7 +289,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
289
289
 
290
290
  **Response includes**: `pageId`, `version`, `bufferId`, `contentSize`, metadata
291
291
 
292
- **Usage**: Content is always stored in buffer with `contentType: "xhtml"`. Use `buffer_edit_xhtml` to modify (required for XHTML buffers), then `confluence_draft_create` for user review.
292
+ **Usage**: Content is stored in buffer with `contentType: "xhtml"` and returns `structure` with element IDs. Use `buffer_edit` with element IDs to modify, then `confluence_draft_create` for user review.
293
293
 
294
294
  ---
295
295
 
@@ -428,7 +428,9 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
428
428
  |-----------|------|----------|-------------|
429
429
  | draftId | string | ✓ | Draft page ID |
430
430
 
431
- **Response includes**: `draftId`, `bufferId`, `title`, `spaceKey`, `version`, `url`, `contentPreview`
431
+ **Response includes**: `draftId`, `bufferId`, `structure` (element IDs), `title`, `spaceKey`, `version`, `url`, `contentPreview`
432
+
433
+ **Usage**: Content is stored in buffer with element IDs. Use `buffer_edit` with element IDs (e.g., `after=2`, `replace=5`) to modify, then `confluence_draft_save` to checkpoint.
432
434
 
433
435
  ---
434
436
 
@@ -444,11 +446,11 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
444
446
  | parentId | string | ✗ | Parent page ID |
445
447
  | labels | string[] | ✗ | Array of labels |
446
448
 
447
- **Response includes**: `draftId`, `bufferId`, `title`, `spaceKey`, `version`, `url` (clickable to preview)
449
+ **Response includes**: `draftId`, `bufferId`, `structure` (element IDs), `title`, `spaceKey`, `version`, `url` (clickable to preview), `contentSummary`
448
450
 
449
- **PlantUML**: Raw @startuml blocks are not supported. Use `buffer_edit_xhtml` with `insert-plantuml` operation.
451
+ **PlantUML**: Raw @startuml blocks are not supported. Use `buffer_edit` with `plantuml` parameter.
450
452
 
451
- **Workflow**: Create draft → Click URL to preview → Use `buffer_edit_xhtml` to modify (required for XHTML buffers) → Use `confluence_draft_save` to checkpoint
453
+ **Workflow**: Create draft → returns `structure` with element IDs → Click URL to preview → Use `buffer_edit` with element IDs (e.g., `after=2`) → Use `confluence_draft_save` to checkpoint
452
454
 
453
455
  ---
454
456
 
@@ -462,11 +464,11 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
462
464
  | bufferId | string | ✓ | Buffer ID with content to save |
463
465
  | title | string | ✗ | Optional new title |
464
466
 
465
- **PlantUML**: Raw @startuml blocks are not supported. Use `buffer_edit_xhtml` with `insert-plantuml` operation.
467
+ **PlantUML**: Raw @startuml blocks are not supported. Use `buffer_edit` with `plantuml` parameter.
466
468
 
467
469
  **Note**: Due to Confluence API limitations, drafts cannot be updated. This tool deletes the old draft and creates a new one with updated content.
468
470
 
469
- **Response includes**: `previousDraftId`, `newDraftId`, `bufferId`, `title`, `url` (new clickable URL)
471
+ **Response includes**: `previousDraftId`, `newDraftId`, `bufferId`, `structure` (element IDs), `title`, `url` (new clickable URL)
470
472
 
471
473
  ---
472
474
 
@@ -542,8 +544,8 @@ AND lastModified >= now("-30d")
542
544
 
543
545
  ### Workflow 3: Documentation Update
544
546
  1. `confluence_search_content` - Find existing page
545
- 2. `confluence_get_page` - Read current content (returns bufferId with `contentType: "xhtml"`)
546
- 3. `buffer_edit_xhtml` - Modify content locally (required for XHTML buffers)
547
+ 2. `confluence_get_page` - Read current content (returns bufferId with `structure` element IDs)
548
+ 3. `buffer_edit` - Modify content using element IDs (e.g., `after=2`, `replace=5`)
547
549
  4. `confluence_draft_create` - Create draft for user review
548
550
  5. User reviews draft at URL
549
551
  6. User publishes via Confluence UI (click "Publish" button)
@@ -559,9 +561,9 @@ AND lastModified >= now("-30d")
559
561
  6. `jira_link_issues` - Link related issues
560
562
 
561
563
  ### Workflow 5: Create Page via Draft
562
- 1. `confluence_draft_create` - Create draft + buffer (with `contentType: "xhtml"`), get preview URL
564
+ 1. `confluence_draft_create` - Create draft + buffer with `structure` (element IDs), get preview URL
563
565
  2. Click URL to preview draft in browser
564
- 3. `buffer_edit_xhtml` - Modify content locally (required for XHTML buffers)
566
+ 3. `buffer_edit` - Modify content using element IDs (e.g., `after=1`, `plantuml="..."`)
565
567
  4. `confluence_draft_save` - Checkpoint changes, get new URL
566
568
  5. Repeat steps 2-4 as needed
567
569
  6. User publishes via Confluence UI (click "Publish" button)
@@ -705,7 +707,7 @@ Large responses are buffered - use `buffer_get_chunk` or `buffer_grep` to access
705
707
  ---
706
708
 
707
709
  ### 11. tempo_get_user_info
708
- **Description**: Get current user info (workerKey, accountId, displayName)
710
+ **Description**: Get current user info (workerKey, username, accountId, displayName)
709
711
  **Use Cases**: Get workerKey for filtering worklogs, verify authentication
710
712
 
711
713
  | Parameter | Type | Required | Description |
@@ -732,31 +734,51 @@ More efficient than `jira_get_total_worklogs` for Tempo instances. Large respons
732
734
 
733
735
  ---
734
736
 
735
- ## Buffer Tools (9)
737
+ ## Buffer Tools (10)
736
738
 
737
739
  Buffer tools are used for local content management. All buffer operations are in-memory - write enforcement is on Jira/Confluence/Tempo tools.
738
740
 
739
- **XHTML Tools**: `buffer_edit_xhtml` and `buffer_validate_xhtml` provide structure-aware editing and validation for Confluence storage format content. XHTML validation is also automatically applied before any Confluence write operation.
741
+ **XHTML Editing**: `buffer_edit` uses element IDs for precise positioning in XHTML content. Each element gets a unique ID when loaded - use `buffer_get_structure` to see them. `buffer_validate_xhtml` validates Confluence storage format. XHTML validation is also automatically applied before any Confluence write operation.
740
742
 
741
743
  ### 1. buffer_create
742
- **Description**: Create a new buffer with initial content
744
+ **Description**: Create a new buffer with initial content. For XHTML, returns element structure with IDs.
743
745
  **Use Cases**: Draft new Confluence pages, prepare content before persisting
744
746
 
745
747
  | Parameter | Type | Required | Description |
746
748
  |-----------|------|----------|-------------|
747
749
  | content | string | ✓ | Initial content for the buffer |
750
+ | contentType | enum | ✓ | Content type: `"xhtml"` for Confluence, `"plain"` for text, `"json"` for data |
748
751
  | metadata | object | ✗ | Optional metadata to attach to the buffer |
749
752
 
750
- **Response includes**: `bufferId`, `totalSize`, `createdAt`, `expiresAt`, `metadata`, `message`
753
+ **Response for XHTML includes**: `bufferId`, `structure` (element IDs), `nextId`, `contentType`, `totalSize`
754
+
755
+ **Response for plain/json includes**: `bufferId`, `contentType`, `totalSize`, `createdAt`, `expiresAt`
756
+
757
+ **CDATA Detection**: For XHTML content, the tool detects if content is incorrectly wrapped in `<![CDATA[...]]>` and returns a clear error. CDATA should only be used inside `<ac:plain-text-body>` elements (for code blocks and PlantUML), never around the entire content.
751
758
 
752
- **Example workflow for new page**:
759
+ **Example workflow for new Confluence page**:
753
760
  ```typescript
754
- // 1. buffer_create({ content: "<h1>Title</h1><p></p>" }) -> returns bufferId
755
- // 2. buffer_edit({ bufferId, old_string: "<p></p>", new_string: "<p>Content</p>" })
761
+ // 1. buffer_create({ content: "<h1>Title</h1><p>Intro</p>", contentType: "xhtml" })
762
+ // -> returns bufferId, structure: [{id:1, type:"h1", text:"Title"}, {id:2, type:"p", text:"Intro"}]
763
+ // 2. buffer_edit({ bufferId, after: 1, content: "<p>New paragraph</p>" })
764
+ // -> inserts after h1, returns structure with new element id:3
756
765
  // 3. confluence_draft_create({ spaceKey, title, bufferId }) -> user reviews at URL
757
766
  // 4. User publishes via Confluence UI (click "Publish" button)
758
767
  ```
759
768
 
769
+ **Multi-diagram optimization**: Embed PlantUML macros directly in initial content:
770
+ ```typescript
771
+ // 1. plantuml_validate(...) for each diagram (can run in parallel)
772
+ // 2. buffer_create({ contentType: "xhtml", content: `
773
+ // <h1>Design</h1>
774
+ // <ac:structured-macro ac:name="plantuml" ac:schema-version="1" ac:macro-id="d1">
775
+ // <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
776
+ // <ac:plain-text-body><![CDATA[@startuml...@enduml]]></ac:plain-text-body>
777
+ // </ac:structured-macro>` })
778
+ // 3. confluence_draft_create({ spaceKey, title, bufferId })
779
+ // Saves tool calls vs placeholder-then-edit pattern. See help(topic="plantuml").
780
+ ```
781
+
760
782
  ---
761
783
 
762
784
  ### 2. buffer_get_chunk
@@ -773,7 +795,38 @@ Buffer tools are used for local content management. All buffer operations are in
773
795
 
774
796
  ---
775
797
 
776
- ### 3. buffer_list
798
+ ### 3. buffer_get_element
799
+ **Description**: Get the raw XHTML content of a specific element by ID. Use to inspect problematic elements when fixing XHTML parsing errors.
800
+ **Use Cases**: Debug XHTML validation errors, inspect element content before editing, targeted error recovery
801
+
802
+ | Parameter | Type | Required | Description |
803
+ |-----------|------|----------|-------------|
804
+ | bufferId | string | ✓ | Buffer ID containing XHTML content |
805
+ | elementId | number | ✓ | Element ID from buffer structure |
806
+
807
+ **Response includes**: `bufferId`, `elementId`, `elementType`, `lineCount`, `content`
808
+
809
+ **Example - Inspect problematic element after XHTML error:**
810
+ ```typescript
811
+ // Error message indicates element ID 12 has issues
812
+ buffer_get_element({
813
+ bufferId: "buf_xxx",
814
+ elementId: 12
815
+ })
816
+ // Returns: {
817
+ // bufferId: "buf_xxx",
818
+ // elementId: 12,
819
+ // elementType: "code",
820
+ // lineCount: 8,
821
+ // content: "<ac:structured-macro ac:name=\"code\">..."
822
+ // }
823
+ ```
824
+
825
+ **Tip**: When `confluence_draft_create` or `confluence_draft_save` fails with an XHTML error, the error response includes `suggestedActions` with a `buffer_get_element` call to inspect the problematic element.
826
+
827
+ ---
828
+
829
+ ### 4. buffer_list
777
830
  **Description**: List all active buffers with their metadata
778
831
  **Use Cases**: View active buffers, check expiration times
779
832
 
@@ -785,7 +838,7 @@ Buffer tools are used for local content management. All buffer operations are in
785
838
 
786
839
  ---
787
840
 
788
- ### 4. buffer_clear
841
+ ### 5. buffer_clear
789
842
  **Description**: Clear a specific buffer or all buffers
790
843
  **Use Cases**: Free up memory, clean up after processing
791
844
 
@@ -797,7 +850,7 @@ Buffer tools are used for local content management. All buffer operations are in
797
850
 
798
851
  ---
799
852
 
800
- ### 5. buffer_grep
853
+ ### 6. buffer_grep
801
854
  **Description**: Search buffered content for patterns (regex supported)
802
855
  **Use Cases**: Find specific content in large responses, locate text for editing
803
856
 
@@ -816,9 +869,33 @@ Buffer tools are used for local content management. All buffer operations are in
816
869
 
817
870
  ---
818
871
 
819
- ### 6. buffer_edit
820
- **Description**: Exact string replacement in buffered content
821
- **Use Cases**: Modify Jira/Tempo content, fix text in non-XHTML buffers
872
+ ### 7. buffer_edit
873
+ **Description**: Edit buffer content. For XHTML: use element IDs (single or batch). For plain/json: use string replacement.
874
+ **Use Cases**: Insert/replace/remove elements in Confluence pages, modify Jira/Tempo content
875
+
876
+ **XHTML Parameters (single operation):**
877
+
878
+ | Parameter | Type | Required | Description |
879
+ |-----------|------|----------|-------------|
880
+ | bufferId | string | ✓ | Buffer ID to modify |
881
+ | after | number | ✗ | Insert after element with this ID |
882
+ | before | number | ✗ | Insert before element with this ID |
883
+ | replace | number | ✗ | Replace element with this ID |
884
+ | remove | number | ✗ | Remove element with this ID |
885
+ | append | boolean | ✗ | Append at document end |
886
+ | content | string | ✗ | XHTML content to insert/replace |
887
+ | plantuml | string | ✗ | PlantUML code (auto-wrapped in macro, validated) |
888
+
889
+ **XHTML Batch Operations (multiple edits in one call):**
890
+
891
+ | Parameter | Type | Required | Description |
892
+ |-----------|------|----------|-------------|
893
+ | bufferId | string | ✓ | Buffer ID to modify |
894
+ | operations | array | ✓ | Array of `{after?, before?, replace?, append?, remove?, content?, plantuml?}` |
895
+
896
+ **Batch operations** are executed sequentially, stopping on first error. Much more efficient than multiple tool calls (parse once, serialize once).
897
+
898
+ **Plain/JSON Parameters (string replacement):**
822
899
 
823
900
  | Parameter | Type | Required | Description |
824
901
  |-----------|------|----------|-------------|
@@ -827,67 +904,99 @@ Buffer tools are used for local content management. All buffer operations are in
827
904
  | new_string | string | ✓ | Replacement text |
828
905
  | replace_all | boolean | ✗ | Replace all occurrences (default: false) |
829
906
 
830
- **⚠️ XHTML Buffers Blocked**: This tool is **blocked** for Confluence content (`contentType: "xhtml"`). Use `buffer_edit_xhtml` instead for XHTML buffers.
907
+ **Key Feature - Stable Element IDs**: Element IDs never change when content is inserted or deleted. After inserting between elements 2 and 3, element 3 keeps its ID - only the new element gets a new ID.
831
908
 
832
- **Note**: Fails if old_string is not unique (unless replace_all=true). Changes are in-memory only - call update API to persist.
909
+ **XHTML Response includes**: `success`, `operationsCompleted`, `structure`, `nextId`, `insertedIds`, `diagramTypes`
833
910
 
834
- **Response includes**: `success`, `replacements`, `oldSize`, `newSize`
911
+ **Plain/JSON Response includes**: `success`, `replacements`, `oldSize`, `newSize`
835
912
 
836
- ---
913
+ **Example - Insert after heading:**
914
+ ```typescript
915
+ buffer_edit({
916
+ bufferId: "buf_xxx",
917
+ after: 2, // Insert after element with ID 2
918
+ content: "<p>New paragraph</p>"
919
+ })
920
+ // Returns: { success: true, insertedIds: [5], structure: [...], nextId: 6 }
921
+ ```
837
922
 
838
- ### 7. buffer_edit_xhtml
839
- **Description**: Structure-aware XHTML editing for Confluence storage format
840
- **Use Cases**: Add table rows, insert PlantUML diagrams, update macros, manipulate page structure
923
+ **Example - Insert PlantUML diagram:**
924
+ ```typescript
925
+ buffer_edit({
926
+ bufferId: "buf_xxx",
927
+ after: 3,
928
+ plantuml: "@startuml\nA -> B: message\n@enduml"
929
+ })
930
+ // Automatically validates and wraps in Confluence macro
931
+ ```
841
932
 
842
- | Parameter | Type | Required | Description |
843
- |-----------|------|----------|-------------|
844
- | bufferId | string | ✓ | Buffer ID containing XHTML content |
845
- | operation | string | ✓ | Operation: insert, insert-plantuml, update, update-plantuml, remove, move, wrap |
846
- | selector | string | ✓ | CSS-like selector for target element(s) |
847
- | position | string | insert/move | Position: before, after, inside-start, inside-end |
848
- | content | string | insert/update/wrap | XHTML content for the operation |
849
- | plantuml | string | plantuml ops | Raw PlantUML code (auto-wrapped and validated) |
850
- | macroId | string | ✗ | Custom macro ID for PlantUML |
851
- | attributes | object | update | Attributes to set on element |
852
- | targetSelector | string | move | Target element for move operation |
853
- | matchIndex | number | ✗ | Operate on Nth match (0-based) |
854
- | matchAll | boolean | ✗ | Apply to all matches (default: false) |
855
- | validate | boolean | ✗ | Validate result (default: true) |
856
-
857
- **Selector Syntax**:
858
- - Tag name: `p`, `table`, `h2`
859
- - Namespaced: `ac:structured-macro`, `ri:page`
860
- - Attribute: `[ac:name="plantuml"]`, `ac:structured-macro[ac:name="code"]`
861
- - Descendant: `table tbody tr`
862
- - Direct child: `ul > li`
863
-
864
- **Example - Add table row**:
933
+ **Example - Batch operations (EFFICIENT for multiple diagrams):**
865
934
  ```typescript
866
- buffer_edit_xhtml({
935
+ buffer_edit({
867
936
  bufferId: "buf_xxx",
868
- operation: "insert",
869
- selector: "table tbody tr",
870
- matchIndex: -1, // Last row
871
- position: "after",
872
- content: "<tr><td>New Cell</td></tr>"
937
+ operations: [
938
+ { after: 6, plantuml: "@startuml\nA -> B\n@enduml" },
939
+ { after: 8, plantuml: "@startuml\nclass User\n@enduml" },
940
+ { after: 10, content: "<p>Summary paragraph</p>" },
941
+ { remove: 12 }
942
+ ]
873
943
  })
944
+ // Returns: { success: true, operationsCompleted: 4, insertedIds: [13, 14, 15], diagramTypes: ["sequence", "class"], structure: [...] }
945
+ // Benefits: parse once, serialize once, single tool call vs 4 separate calls
874
946
  ```
875
947
 
876
- **Example - Insert PlantUML diagram**:
948
+ **Example - Replace element:**
877
949
  ```typescript
878
- buffer_edit_xhtml({
950
+ buffer_edit({
879
951
  bufferId: "buf_xxx",
880
- operation: "insert-plantuml",
881
- selector: "h2",
882
- matchIndex: 0,
883
- position: "after",
884
- plantuml: "class User { +name: string }"
952
+ replace: 4,
953
+ content: "<p>Updated content</p>"
885
954
  })
886
955
  ```
887
956
 
957
+ **Example - Remove element:**
958
+ ```typescript
959
+ buffer_edit({
960
+ bufferId: "buf_xxx",
961
+ remove: 5
962
+ })
963
+ ```
964
+
965
+ ---
966
+
967
+ ### 8. buffer_get_structure
968
+ **Description**: Get current element structure for an XHTML buffer
969
+ **Use Cases**: View element IDs for editing, understand document structure
970
+
971
+ | Parameter | Type | Required | Description |
972
+ |-----------|------|----------|-------------|
973
+ | bufferId | string | ✓ | Buffer ID to get structure for |
974
+
975
+ **Response includes**: `bufferId`, `structure`, `nextId`
976
+
977
+ **Structure Format**:
978
+ ```typescript
979
+ structure: [
980
+ { id: 1, type: "h1", text: "Document Title" },
981
+ { id: 2, type: "h2", text: "Introduction" },
982
+ { id: 3, type: "p", text: "This section describes..." },
983
+ { id: 4, type: "plantuml", text: "Sequence diagram" },
984
+ { id: 5, type: "ul", children: 5 } // List with 5 items
985
+ ]
986
+ nextId: 6
987
+ ```
988
+
989
+ **Element Types**: `h1`-`h6`, `p`, `ul`, `ol`, `table`, `plantuml`, `ac:structured-macro`, etc.
990
+
991
+ **Example**:
992
+ ```typescript
993
+ buffer_get_structure({ bufferId: "buf_xxx" })
994
+ // Returns current element IDs for use with buffer_edit
995
+ ```
996
+
888
997
  ---
889
998
 
890
- ### 8. buffer_validate_xhtml
999
+ ### 9. buffer_validate_xhtml
891
1000
  **Description**: Validate buffered content as Confluence storage format (XHTML)
892
1001
  **Use Cases**: Check content validity before writing, debug validation errors
893
1002
 
@@ -907,7 +1016,7 @@ buffer_edit_xhtml({
907
1016
 
908
1017
  ---
909
1018
 
910
- ### 9. buffer_save_to_file
1019
+ ### 10. buffer_save_to_file
911
1020
  **Description**: Save buffer content to a file within the project directory
912
1021
  **Use Cases**: Export rendered PlantUML diagrams (PNG/EPS), save edited content locally
913
1022
 
@@ -1015,7 +1124,7 @@ Unified help system for all Jicon workflows and syntax guides. Always available
1015
1124
 
1016
1125
  | Parameter | Type | Required | Description |
1017
1126
  |-----------|------|----------|-------------|
1018
- | topic | string | ✗ | Topic for detailed help: jql, cql, storage, plantuml |
1127
+ | topic | string | ✗ | Topic for detailed help: jql, cql, storage, plantuml, buffers |
1019
1128
 
1020
1129
  **Default (no topic)**: Compact workflow guide with decision trees showing:
1021
1130
  - Confluence workflows (create page, update page, draft workflow, search)
@@ -1031,8 +1140,9 @@ Unified help system for all Jicon workflows and syntax guides. Always available
1031
1140
  |-------|-------------|
1032
1141
  | `jql` | JQL syntax guide - operators, functions, examples |
1033
1142
  | `cql` | CQL syntax guide - search operators, date functions |
1034
- | `storage` | Confluence storage format + structure editing (buffer_edit_xhtml) |
1143
+ | `storage` | Confluence storage format + structure editing (element IDs) |
1035
1144
  | `plantuml` | PlantUML syntax for Confluence diagrams |
1145
+ | `buffers` | Buffer management and element ID editing guide |
1036
1146
 
1037
1147
  **Examples**:
1038
1148
  ```typescript
@@ -1040,6 +1150,7 @@ help() // Get workflow overview and decision tree
1040
1150
  help(topic="jql") // JQL syntax guide
1041
1151
  help(topic="storage") // Basic Confluence formatting
1042
1152
  help(topic="plantuml") // PlantUML diagram syntax
1153
+ help(topic="buffers") // Buffer management guide
1043
1154
  ```
1044
1155
 
1045
1156
  **Tip**: Start with `help()` to understand the overall workflow, then use specific topics for syntax details.
@@ -1050,11 +1161,17 @@ help(topic="plantuml") // PlantUML diagram syntax
1050
1161
 
1051
1162
  Docker-based PlantUML validation and rendering. Requires Docker to be installed and running.
1052
1163
 
1053
- **⚠️ External Includes NOT Supported:**
1164
+ **Docker Lifecycle**:
1165
+ - Container starts **at MCP server startup** (not lazily on first use)
1166
+ - Does **NOT auto-restart** if container stops - restart MCP server to retry
1167
+ - Use `"disableDocker": true` in `.jicon.json` to skip PlantUML entirely
1168
+
1169
+ **Stdlib Includes (C4, AWS, Azure):**
1054
1170
  ```
1055
- !include https://raw.githubusercontent.com/... ← NOT SUPPORTED
1171
+ !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
1172
+ !include https://raw.githubusercontent.com/awslabs/aws-icons-for-plantuml/main/dist/AWSCommon.puml
1056
1173
  ```
1057
- Confluence's PlantUML plugin cannot fetch external URLs. Use native PlantUML syntax instead of C4 includes. See `help(topic="plantuml")` for examples.
1174
+ Include expansion is enabled by default. Whitelisted URLs: `plantuml-stdlib/*`, `plantuml/*`, `awslabs/aws-icons-for-plantuml/*`. See `help(topic="plantuml")` for examples.
1058
1175
 
1059
1176
  ### 1. plantuml_validate
1060
1177
  **Description**: Validate PlantUML diagram syntax using a real PlantUML server
@@ -1118,12 +1235,13 @@ buffer_save_to_file({
1118
1235
  |-----------|------|----------|-------------|
1119
1236
  | (none) | | | |
1120
1237
 
1121
- **Response includes**: `running`, `port`, `containerId`, `message`
1238
+ **Response includes**: `available`, `disabled`, `startupFailed`, `containerDied`, `error`, `containerId`, `port`, `baseUrl`, `message`
1122
1239
 
1123
- **Docker Lifecycle**:
1124
- - Container starts automatically on first `plantuml_validate` or `plantuml_render` call
1125
- - Uses dynamic port allocation (unique per MCP instance)
1126
- - Stops gracefully on MCP server shutdown
1240
+ **Status States**:
1241
+ - `available: true` - Container running and healthy
1242
+ - `disabled: true` - Disabled via `disableDocker: true` config
1243
+ - `startupFailed: true` - Docker failed at MCP startup (check logs)
1244
+ - `containerDied: true` - Container stopped after startup (restart MCP)
1127
1245
 
1128
1246
  ---
1129
1247
 
@@ -1161,17 +1279,17 @@ Tools that return large content (Confluence pages, Jira issues, Tempo worklogs)
1161
1279
  ### Buffer Workflows
1162
1280
 
1163
1281
  **Creating new Confluence pages (draft workflow):**
1164
- 1. `confluence_draft_create` → creates server draft + buffer, returns clickable preview URL
1282
+ 1. `confluence_draft_create` → creates server draft + buffer with `structure` (element IDs), returns clickable preview URL
1165
1283
  2. User clicks URL to review draft in Confluence UI (can edit there)
1166
- 3. If changes needed: `confluence_draft_open` → re-reads user's edits into buffer
1167
- 4. `buffer_edit_xhtml` → structure-aware editing (or `buffer_edit` for simple text)
1284
+ 3. If changes needed: `confluence_draft_open` → re-reads user's edits into buffer with updated structure
1285
+ 4. `buffer_edit` → edit using element IDs (e.g., `after=2`, `replace=5`, `plantuml="..."`)
1168
1286
  5. `confluence_draft_save` → checkpoint: deletes old draft, creates new with buffer content, returns new URL
1169
1287
  6. Repeat steps 2-5 until user approves
1170
1288
  7. User publishes via Confluence UI (click "Publish" button)
1171
1289
 
1172
1290
  **Editing existing Confluence pages (draft workflow):**
1173
- 1. `confluence_get_page` → page content is buffered, returns `bufferId`, `pageId`, and `version`
1174
- 2. `buffer_edit_xhtml` → structure-aware editing (tables, macros, layouts)
1291
+ 1. `confluence_get_page` → page content is buffered, returns `bufferId`, `pageId`, `version`, and `structure`
1292
+ 2. `buffer_edit` → edit using element IDs (e.g., `after=2`, `replace=5`, `plantuml="..."`)
1175
1293
  3. `confluence_draft_create` → creates draft with modified content for user review
1176
1294
  4. User reviews draft at URL
1177
1295
  5. If changes needed: repeat via `confluence_draft_open` → edit → `confluence_draft_save`
@@ -1184,68 +1302,72 @@ Tools that return large content (Confluence pages, Jira issues, Tempo worklogs)
1184
1302
 
1185
1303
  ### Buffer Content Types
1186
1304
 
1187
- **Buffer types enforce the correct editing tool:**
1305
+ **Buffer types determine editing mode:**
1188
1306
 
1189
- | Buffer Source | contentType | Editing Tool |
1307
+ | Buffer Source | contentType | Editing Mode |
1190
1308
  |---------------|-------------|--------------|
1191
- | Confluence pages/drafts | `xhtml` | `buffer_edit_xhtml` (required) |
1192
- | Jira issues | `json` | `buffer_edit` |
1193
- | Other content | `plain` | `buffer_edit` |
1309
+ | Confluence pages/drafts | `xhtml` | `buffer_edit` with element IDs (`after`, `before`, `replace`, `remove`) |
1310
+ | Jira issues | `json` | `buffer_edit` with string replacement (`old_string`, `new_string`) |
1311
+ | Other content | `plain` | `buffer_edit` with string replacement (`old_string`, `new_string`) |
1194
1312
 
1195
1313
  **XHTML Buffers (Confluence content):**
1196
1314
  - Confluence tools automatically set `contentType: "xhtml"` on buffers
1197
- - `buffer_edit` is **blocked** for XHTML buffers - use `buffer_edit_xhtml` instead
1198
- - This ensures PlantUML validation and proper structure-aware editing
1315
+ - Returns `structure` with element IDs for precise editing
1316
+ - Use `buffer_get_structure` to view current element IDs
1317
+ - Element IDs are **stable** - they never change when content is inserted/deleted
1199
1318
 
1200
1319
  ### XHTML Structure Editing
1201
1320
 
1202
- Use `buffer_edit_xhtml` for XML tree-aware editing of Confluence storage format content. This tool provides CSS-like selectors for targeting elements and supports PlantUML diagram insertion with automatic syntax validation.
1321
+ Use `buffer_edit` with element IDs for precise editing of Confluence storage format content. Each element gets a unique ID when loaded, which remains stable across edits.
1203
1322
 
1204
- **Operations:**
1323
+ **Operations (use exactly one):**
1205
1324
 
1206
- | Operation | Description |
1325
+ | Parameter | Description |
1207
1326
  |-----------|-------------|
1208
- | `insert` | Add content relative to selected element |
1209
- | `insert-plantuml` | Insert PlantUML diagram with validation and macro wrapping |
1210
- | `update` | Update element content and/or attributes |
1211
- | `update-plantuml` | Update existing PlantUML macro with validation |
1212
- | `remove` | Delete selected element(s) |
1213
- | `move` | Move element to new location |
1214
- | `wrap` | Wrap element with new parent |
1327
+ | `after=ID` | Insert content after element with ID |
1328
+ | `before=ID` | Insert content before element with ID |
1329
+ | `replace=ID` | Replace element with ID |
1330
+ | `remove=ID` | Delete element with ID |
1331
+ | `append=true` | Append at document end |
1215
1332
 
1216
- **Selector Syntax:**
1333
+ **Content Options (use exactly one for insert/replace):**
1217
1334
 
1218
- ```
1219
- p # Tag name
1220
- ac:structured-macro # Namespaced element
1221
- [ac:name="plantuml"] # Attribute selector
1222
- ac:structured-macro[ac:name="code"] # Combined tag + attribute
1223
- table tbody tr # Descendant selector
1224
- ul > li # Direct child selector
1335
+ | Parameter | Description |
1336
+ |-----------|-------------|
1337
+ | `content` | XHTML content to insert/replace |
1338
+ | `plantuml` | PlantUML code (auto-validated and wrapped in Confluence macro) |
1339
+
1340
+ **Element Structure Example:**
1341
+
1342
+ ```typescript
1343
+ // Structure returned by buffer_create or buffer_get_structure:
1344
+ structure: [
1345
+ { id: 1, type: "h1", text: "Document Title" },
1346
+ { id: 2, type: "h2", text: "Architecture" },
1347
+ { id: 3, type: "p", text: "This describes..." },
1348
+ { id: 4, type: "plantuml", text: "Sequence diagram" },
1349
+ { id: 5, type: "ul", children: 5 }
1350
+ ]
1351
+ nextId: 6
1225
1352
  ```
1226
1353
 
1227
- **Example - Add Table Row:**
1354
+ **Example - Insert paragraph after heading:**
1228
1355
 
1229
1356
  ```typescript
1230
- buffer_edit_xhtml({
1357
+ buffer_edit({
1231
1358
  bufferId: "buf_xxx",
1232
- operation: "insert",
1233
- selector: "table tbody tr",
1234
- matchIndex: -1, // Last row (use 0 for first)
1235
- position: "after",
1236
- content: "<tr><td>New Cell 1</td><td>New Cell 2</td></tr>"
1359
+ after: 2, // Insert after element ID 2 (h2)
1360
+ content: "<p>New paragraph here</p>"
1237
1361
  })
1362
+ // Returns: { success: true, insertedIds: [6], structure: [...] }
1238
1363
  ```
1239
1364
 
1240
1365
  **Example - Insert PlantUML Diagram:**
1241
1366
 
1242
1367
  ```typescript
1243
- buffer_edit_xhtml({
1368
+ buffer_edit({
1244
1369
  bufferId: "buf_xxx",
1245
- operation: "insert-plantuml",
1246
- selector: "h2",
1247
- matchIndex: 0,
1248
- position: "after",
1370
+ after: 3,
1249
1371
  plantuml: `
1250
1372
  class User {
1251
1373
  +id: string
@@ -1259,28 +1381,27 @@ buffer_edit_xhtml({
1259
1381
  // and generates complete Confluence PlantUML macro
1260
1382
  ```
1261
1383
 
1262
- **Position Values:**
1263
- - `before` - Insert before the selected element
1264
- - `after` - Insert after the selected element
1265
- - `inside-start` - Insert as first child of selected element
1266
- - `inside-end` - Insert as last child of selected element
1384
+ **Example - Replace element:**
1267
1385
 
1268
- **Match Control:**
1269
- - `matchIndex`: Operate on Nth match (0-based, use negative for reverse)
1270
- - `matchAll`: Apply operation to all matches
1386
+ ```typescript
1387
+ buffer_edit({
1388
+ bufferId: "buf_xxx",
1389
+ replace: 4, // Replace element ID 4 (the plantuml)
1390
+ plantuml: "@startuml\nA -> B: fixed\n@enduml"
1391
+ })
1392
+ ```
1271
1393
 
1272
- **Semantic Positions for PlantUML:**
1394
+ **Example - Remove element:**
1273
1395
 
1274
1396
  ```typescript
1275
- buffer_edit_xhtml({
1397
+ buffer_edit({
1276
1398
  bufferId: "buf_xxx",
1277
- operation: "insert-plantuml",
1278
- semanticPosition: "after-title", // No selector needed!
1279
- plantuml: "@startuml\nA -> B: message\n@enduml"
1399
+ remove: 5 // Remove element ID 5 (the list)
1280
1400
  })
1281
1401
  ```
1282
1402
 
1283
- Available: `after-title`, `after-heading`, `before-content`, `end`, `after-toc`
1403
+ **Key Feature - Stable IDs:**
1404
+ Element IDs never change when content is inserted or deleted. After inserting between IDs 2 and 3, element 3 keeps its ID - only the new element gets a new ID.
1284
1405
 
1285
1406
  ### XHTML Validation
1286
1407
 
@@ -1299,7 +1420,7 @@ buffer_validate_xhtml({
1299
1420
  - Required attributes on Confluence elements (ac:name, ri:space-key, etc.)
1300
1421
  - Valid layout section types
1301
1422
  - Known macro names (warnings for unknown macros)
1302
- - PlantUML syntax (if Docker service is running)
1423
+ - PlantUML syntax (requires Docker - returns error if unavailable)
1303
1424
 
1304
1425
  **Automatic Validation:**
1305
1426
  XHTML content is automatically validated before Confluence writes (`confluence_draft_create`, `confluence_draft_save`).