@crypto512/jicon-mcp 1.1.1 → 1.2.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 (68) hide show
  1. package/PROMPT.md +214 -0
  2. package/README.md +54 -8
  3. package/TOOL_LIST.md +241 -58
  4. package/dist/confluence/client.d.ts +7 -2
  5. package/dist/confluence/client.d.ts.map +1 -1
  6. package/dist/confluence/client.js +28 -10
  7. package/dist/confluence/client.js.map +1 -1
  8. package/dist/confluence/tools.d.ts +64 -8
  9. package/dist/confluence/tools.d.ts.map +1 -1
  10. package/dist/confluence/tools.js +587 -33
  11. package/dist/confluence/tools.js.map +1 -1
  12. package/dist/permissions/tool-registry.d.ts +9 -9
  13. package/dist/permissions/tool-registry.d.ts.map +1 -1
  14. package/dist/permissions/tool-registry.js +10 -3
  15. package/dist/permissions/tool-registry.js.map +1 -1
  16. package/dist/permissions/write-home-validator.d.ts.map +1 -1
  17. package/dist/permissions/write-home-validator.js +23 -3
  18. package/dist/permissions/write-home-validator.js.map +1 -1
  19. package/dist/tempo/client.js +1 -1
  20. package/dist/tempo/client.js.map +1 -1
  21. package/dist/tempo/tools.js +1 -1
  22. package/dist/tempo/tools.js.map +1 -1
  23. package/dist/utils/buffer-tools.d.ts +10 -0
  24. package/dist/utils/buffer-tools.d.ts.map +1 -1
  25. package/dist/utils/buffer-tools.js +139 -28
  26. package/dist/utils/buffer-tools.js.map +1 -1
  27. package/dist/utils/content-buffer.d.ts +5 -1
  28. package/dist/utils/content-buffer.d.ts.map +1 -1
  29. package/dist/utils/content-buffer.js +6 -3
  30. package/dist/utils/content-buffer.js.map +1 -1
  31. package/dist/utils/jicon-help.d.ts +1 -1
  32. package/dist/utils/jicon-help.d.ts.map +1 -1
  33. package/dist/utils/jicon-help.js +78 -19
  34. package/dist/utils/jicon-help.js.map +1 -1
  35. package/dist/utils/plantuml/client.d.ts +15 -1
  36. package/dist/utils/plantuml/client.d.ts.map +1 -1
  37. package/dist/utils/plantuml/client.js +56 -3
  38. package/dist/utils/plantuml/client.js.map +1 -1
  39. package/dist/utils/plantuml/include-expander.d.ts +15 -0
  40. package/dist/utils/plantuml/include-expander.d.ts.map +1 -1
  41. package/dist/utils/plantuml/include-expander.js +47 -8
  42. package/dist/utils/plantuml/include-expander.js.map +1 -1
  43. package/dist/utils/plantuml/index.d.ts +1 -1
  44. package/dist/utils/plantuml/index.d.ts.map +1 -1
  45. package/dist/utils/plantuml/index.js +1 -1
  46. package/dist/utils/plantuml/index.js.map +1 -1
  47. package/dist/utils/plantuml/service.d.ts +1 -1
  48. package/dist/utils/plantuml/service.d.ts.map +1 -1
  49. package/dist/utils/plantuml/service.js +1 -1
  50. package/dist/utils/plantuml/service.js.map +1 -1
  51. package/dist/utils/plantuml/tools.d.ts.map +1 -1
  52. package/dist/utils/plantuml/tools.js +5 -2
  53. package/dist/utils/plantuml/tools.js.map +1 -1
  54. package/dist/utils/url-tools.d.ts +27 -1
  55. package/dist/utils/url-tools.d.ts.map +1 -1
  56. package/dist/utils/url-tools.js +142 -1
  57. package/dist/utils/url-tools.js.map +1 -1
  58. package/dist/utils/xhtml/index.d.ts +1 -1
  59. package/dist/utils/xhtml/index.d.ts.map +1 -1
  60. package/dist/utils/xhtml/index.js +1 -1
  61. package/dist/utils/xhtml/index.js.map +1 -1
  62. package/dist/utils/xhtml/plantuml.d.ts +24 -6
  63. package/dist/utils/xhtml/plantuml.d.ts.map +1 -1
  64. package/dist/utils/xhtml/plantuml.js +70 -12
  65. package/dist/utils/xhtml/plantuml.js.map +1 -1
  66. package/dist/utils/xhtml/validator.js +2 -2
  67. package/dist/utils/xhtml/validator.js.map +1 -1
  68. package/package.json +2 -2
package/TOOL_LIST.md CHANGED
@@ -5,13 +5,13 @@ This document provides a comprehensive reference of all available tools in the J
5
5
 
6
6
  ## Summary
7
7
 
8
- **Total Tools**: 64
8
+ **Total Tools**: 69
9
9
  - **Jira Tools**: 18 (13 read + 5 write)
10
- - **Confluence Tools**: 17 (11 read + 6 write)
10
+ - **Confluence Tools**: 21 (13 read + 8 write)
11
11
  - **Tempo Tools**: 12 (9 read + 3 write)
12
12
  - **Buffer Tools**: 10
13
13
  - **Workload Tools**: 2
14
- - **URL Tools**: 1
14
+ - **URL Tools**: 2
15
15
  - **Jicon Help Tools**: 1
16
16
  - **PlantUML Tools**: 3
17
17
 
@@ -247,7 +247,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
247
247
 
248
248
  ---
249
249
 
250
- ## Confluence Tools (17)
250
+ ## Confluence Tools (21)
251
251
 
252
252
  ### 1. confluence_search_content
253
253
  **Description**: Search Confluence content using CQL. Auto-fetches all results (up to 5000).
@@ -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 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.
276
+ **Usage**: Content is stored in buffer with `contentType: "xhtml"` and returns `structure` with element IDs. Use `buffer_edit(bufferId, after=ID, content/plantuml/fromBufferId)` to add content, then `confluence_draft_create(pageId, bufferId)` for user review.
277
277
 
278
278
  ---
279
279
 
@@ -289,18 +289,60 @@ 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 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.
292
+ **Usage**: Content is stored in buffer with `contentType: "xhtml"` and returns `structure` with element IDs. Use `buffer_edit(bufferId, after=ID, content/plantuml/fromBufferId)` to add content, then `confluence_draft_create(pageId, bufferId)` for user review.
293
+
294
+ ---
295
+
296
+ ### 4. confluence_edit (RECOMMENDED)
297
+ **Description**: Smart page/draft loader - auto-resolves URLs, pageIds, draftIds, or SPACE/Title
298
+ **Use Cases**: Edit any Confluence content with a single tool, handle URL input from users
299
+
300
+ | Parameter | Type | Required | Description |
301
+ |-----------|------|----------|-------------|
302
+ | input | string | ✓ | URL, pageId, "draft:ID", or "SPACE/Title" |
303
+
304
+ **Input formats supported**:
305
+ | Input | Behavior |
306
+ |-------|----------|
307
+ | `https://confluence.example.com/pages/viewpage.action?pageId=123` | Parse URL, load page |
308
+ | `https://confluence.example.com/pages/resumedraft.action?draftId=456` | Parse URL, try draft (fallback to page) |
309
+ | `https://confluence.example.com/display/DOCS/Page+Title` | Parse URL, find by space/title |
310
+ | `123456` (numeric) | Load page directly by ID |
311
+ | `draft:123456` | Try draft; if 404 (published), find page by title |
312
+ | `DOCS/API Guide` | Find page by space key and title |
313
+
314
+ **Response includes**: `bufferId`, `structure`, `pageId` or `draftId`, `spaceKey`, `title`
315
+
316
+ **Smart behavior**:
317
+ - URLs are parsed automatically to extract pageId or draftId
318
+ - Draft IDs: tries to load draft; if 404 (user published), finds page by title
319
+ - Returns bufferId + structure for editing
320
+
321
+ **Workflow**:
322
+ ```
323
+ 1. confluence_edit("URL or SPACE/Title") → bufferId, structure, pageId
324
+ 2. buffer_edit(bufferId, after=ID, content/plantuml/fromBufferId) → add content
325
+ 3. confluence_draft_create(pageId=..., bufferId=...) → draft for review (links to original page)
326
+ 4. User publishes via Confluence UI (updates original page)
327
+ 5. For more edits: confluence_edit(same input) → auto-resolves
328
+ ```
329
+
330
+ **TIP**: If you created content in a separate buffer, use `fromBufferId` to merge it:
331
+ ```
332
+ buffer_edit(bufferId=pageBuffer, after=5, fromBufferId=newContentBuffer)
333
+ ```
293
334
 
294
335
  ---
295
336
 
296
337
  > **Note**: All page content changes go through the draft workflow.
297
338
  > AI creates/edits drafts; user publishes manually via Confluence UI:
298
- > - New pages: `confluence_draft_create` → user review → user publishes
299
- > - Existing pages: `confluence_get_page` edit → `confluence_draft_create` → user review → user publishes
339
+ > - **Edit existing**: `confluence_edit(input)` → `buffer_edit(bufferId, after=ID, content/plantuml/fromBufferId)` `confluence_draft_create(pageId, bufferId)` → user publishes
340
+ > - **Create new**: `confluence_draft_create(spaceKey, title, content)` → user review → user publishes
341
+ > - **After publish**: Draft ID becomes invalid; use `confluence_edit("SPACE/Title")` to edit again
300
342
 
301
343
  ---
302
344
 
303
- ### 4. confluence_delete_page
345
+ ### 5. confluence_delete_page
304
346
  **Description**: Delete a Confluence page
305
347
  **Use Cases**: Remove outdated content
306
348
 
@@ -310,7 +352,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
310
352
 
311
353
  ---
312
354
 
313
- ### 5. confluence_list_spaces
355
+ ### 6. confluence_list_spaces
314
356
  **Description**: List all accessible Confluence spaces
315
357
  **Use Cases**: Discover available spaces, get space keys
316
358
 
@@ -322,7 +364,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
322
364
 
323
365
  ---
324
366
 
325
- ### 6. confluence_get_space
367
+ ### 7. confluence_get_space
326
368
  **Description**: Get detailed information about a space
327
369
  **Use Cases**: View space details, get homepage
328
370
 
@@ -333,7 +375,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
333
375
 
334
376
  ---
335
377
 
336
- ### 7. confluence_get_page_children
378
+ ### 8. confluence_get_page_children
337
379
  **Description**: Get all child pages of a page
338
380
  **Use Cases**: Navigate page hierarchy, list subpages
339
381
 
@@ -346,7 +388,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
346
388
 
347
389
  ---
348
390
 
349
- ### 8. confluence_add_comment
391
+ ### 9. confluence_add_comment
350
392
  **Description**: Add a comment to a Confluence page
351
393
  **Use Cases**: Provide feedback, ask questions
352
394
 
@@ -357,7 +399,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
357
399
 
358
400
  ---
359
401
 
360
- ### 9. confluence_get_comments
402
+ ### 10. confluence_get_comments
361
403
  **Description**: Get all comments on a Confluence page
362
404
  **Use Cases**: Read feedback, review discussions
363
405
 
@@ -369,7 +411,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
369
411
 
370
412
  ---
371
413
 
372
- ### 10. confluence_upload_attachment
414
+ ### 11. confluence_upload_attachment
373
415
  **Description**: Upload an attachment to a Confluence page
374
416
  **Use Cases**: Attach documents, upload images
375
417
 
@@ -381,7 +423,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
381
423
 
382
424
  ---
383
425
 
384
- ### 11. confluence_list_attachments
426
+ ### 12. confluence_list_attachments
385
427
  **Description**: List all attachments on a Confluence page
386
428
  **Use Cases**: View uploaded files, check attachments
387
429
 
@@ -393,7 +435,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
393
435
 
394
436
  ---
395
437
 
396
- ### 12. confluence_get_current_user_space
438
+ ### 13. confluence_get_current_user_space
397
439
  **Description**: Get the current user's personal Confluence space
398
440
  **Use Cases**: Verify personal space before write operations, check space key for write-home restriction
399
441
 
@@ -407,7 +449,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
407
449
 
408
450
  ---
409
451
 
410
- ### 13. confluence_draft_list
452
+ ### 14. confluence_draft_list
411
453
  **Description**: List user's draft pages
412
454
  **Use Cases**: View pending drafts, find drafts to continue editing
413
455
 
@@ -420,7 +462,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
420
462
 
421
463
  ---
422
464
 
423
- ### 14. confluence_draft_open
465
+ ### 15. confluence_draft_open
424
466
  **Description**: Load existing draft into buffer for editing
425
467
  **Use Cases**: Continue editing a draft, prepare draft for publishing
426
468
 
@@ -430,31 +472,58 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
430
472
 
431
473
  **Response includes**: `draftId`, `bufferId`, `structure` (element IDs), `title`, `spaceKey`, `version`, `url`, `contentPreview`
432
474
 
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.
475
+ **Usage**: Content is stored in buffer with element IDs. Use `buffer_edit(bufferId, after=ID, content/plantuml/fromBufferId)` to modify, then `confluence_draft_save` to checkpoint.
434
476
 
435
477
  ---
436
478
 
437
- ### 15. confluence_draft_create
438
- **Description**: Create a new server-side draft with local buffer
439
- **Use Cases**: Start new page as draft, iterative content development
479
+ ### 16. confluence_draft_create
480
+ **Description**: Create a draft for user review - either a new page or as an edit to an existing page
481
+ **Use Cases**: Start new page as draft, edit existing page through draft workflow
440
482
 
441
- | Parameter | Type | Required | Description |
442
- |-----------|------|----------|-------------|
443
- | spaceKey | string | ✓ | Space key |
444
- | title | string | ✓ | Draft title |
445
- | content | string | ✓ | Initial content (storage format) |
446
- | parentId | string | ✗ | Parent page ID |
447
- | labels | string[] | ✗ | Array of labels |
483
+ **Two Modes:**
448
484
 
449
- **Response includes**: `draftId`, `bufferId`, `structure` (element IDs), `title`, `spaceKey`, `version`, `url` (clickable to preview), `contentSummary`
485
+ 1. **NEW PAGE**: Create a standalone draft
486
+ | Parameter | Type | Required | Description |
487
+ |-----------|------|----------|-------------|
488
+ | spaceKey | string | ✓ | Space key |
489
+ | title | string | ✓ | Draft title |
490
+ | content/bufferId | string | ✓ | Content (storage format) or buffer ID |
491
+ | parentId | string | ✗ | Parent page ID |
492
+ | labels | string[] | ✗ | Array of labels |
493
+
494
+ 2. **EDIT EXISTING PAGE**: Create a draft to edit an existing page
495
+ | Parameter | Type | Required | Description |
496
+ |-----------|------|----------|-------------|
497
+ | pageId | string | ✓ | Existing page ID to edit |
498
+ | bufferId | string | ✓ | Buffer ID from `confluence_get_page(pageId)` or `confluence_edit(pageId)` |
499
+ | title | string | ✗ | Optional new title (defaults to original) |
500
+
501
+ **Important**: When `pageId` is provided, `bufferId` must originate from that page (validated). Space, title, and parent are auto-populated from the original page.
502
+
503
+ **Response includes**: `draftId`, `bufferId`, `structure` (element IDs), `title`, `spaceKey`, `version`, `url` (clickable to preview), `contentSummary`, `editingExistingPage` (when editing)
450
504
 
451
505
  **PlantUML**: Raw @startuml blocks are not supported. Use `buffer_edit` with `plantuml` parameter.
452
506
 
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
507
+ **Workflow for editing existing page**:
508
+ ```
509
+ 1. confluence_get_page(pageId) → bufferId, structure
510
+ 2. buffer_edit(bufferId, ...) → modify content
511
+ 3. confluence_draft_create(pageId=..., bufferId=...) → draft for review
512
+ 4. User reviews and publishes in Confluence UI (updates original page)
513
+ ```
514
+
515
+ **Workflow for new page**:
516
+ ```
517
+ 1. confluence_draft_create(spaceKey, title, content) → draftId, bufferId, url
518
+ 2. User clicks URL to preview
519
+ 3. buffer_edit(bufferId, ...) → modify if needed
520
+ 4. confluence_draft_save(draftId, bufferId) → checkpoint
521
+ 5. User publishes via Confluence UI
522
+ ```
454
523
 
455
524
  ---
456
525
 
457
- ### 16. confluence_draft_save
526
+ ### 17. confluence_draft_save
458
527
  **Description**: Save buffer content to draft (delete + recreate pattern)
459
528
  **Use Cases**: Checkpoint work, persist edits before publishing
460
529
 
@@ -472,7 +541,7 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
472
541
 
473
542
  ---
474
543
 
475
- ### 17. confluence_draft_delete
544
+ ### 18. confluence_draft_delete
476
545
  **Description**: Permanently delete a draft
477
546
  **Use Cases**: Clean up abandoned drafts, remove unwanted content
478
547
 
@@ -484,6 +553,54 @@ Large responses are automatically buffered - use `buffer_get_chunk` or `buffer_g
484
553
 
485
554
  ---
486
555
 
556
+ ### 19. confluence_review_list
557
+ **Description**: List all "[jicon-mcp REVIEW]" drafts for cleanup or management
558
+ **Use Cases**: Find abandoned review drafts, manage multiple review workflows, clean up after publishing
559
+
560
+ | Parameter | Type | Required | Description |
561
+ |-----------|------|----------|-------------|
562
+ | spaceKey | string | ✗ | Filter by space key |
563
+
564
+ **Response includes**: `reviewDrafts` array with `reviewDraftId`, `title`, `originalTitle`, `originalPageId`, `spaceKey`, `spaceName`, `createdDate`, `editUrl`; `total`, `message`
565
+
566
+ **Note**: Review drafts are created when using `confluence_draft_create` with a `pageId` parameter to edit an existing page. They are linked to the original page via a label.
567
+
568
+ ---
569
+
570
+ ### 20. confluence_review_publish
571
+ **Description**: Publish a review draft to apply changes to the original page
572
+ **Use Cases**: Apply reviewed changes to the original page, complete the review workflow
573
+
574
+ | Parameter | Type | Required | Description |
575
+ |-----------|------|----------|-------------|
576
+ | reviewDraftId | string | ✓ | ID of the [jicon-mcp REVIEW] draft to publish |
577
+
578
+ **Workflow**:
579
+ 1. Validates the draft is a "[jicon-mcp REVIEW]" draft with proper label
580
+ 2. Copies the draft content to the original page (creates new version)
581
+ 3. Deletes the review draft
582
+
583
+ **Response includes**: `success`, `originalPageId`, `originalTitle`, `newVersion`, `reviewDraftDeleted`, `viewUrl`, `message`
584
+
585
+ ---
586
+
587
+ ### 21. confluence_review_discard
588
+ **Description**: Discard a review draft without applying changes to the original page
589
+ **Use Cases**: Cancel a review, abandon changes, clean up unwanted review drafts
590
+
591
+ | Parameter | Type | Required | Description |
592
+ |-----------|------|----------|-------------|
593
+ | reviewDraftId | string | ✓ | ID of the [jicon-mcp REVIEW] draft to discard |
594
+
595
+ **Workflow**:
596
+ 1. Validates the draft is a "[jicon-mcp REVIEW]" draft
597
+ 2. Deletes the review draft permanently
598
+ 3. Original page remains unchanged
599
+
600
+ **Response includes**: `success`, `discarded`, `reviewDraftId`, `originalTitle`, `message`
601
+
602
+ ---
603
+
487
604
  ## Query Language Reference
488
605
 
489
606
  ### JQL (Jira Query Language) Examples
@@ -766,17 +883,16 @@ Buffer tools are used for local content management. All buffer operations are in
766
883
  // 4. User publishes via Confluence UI (click "Publish" button)
767
884
  ```
768
885
 
769
- **Multi-diagram optimization**: Embed PlantUML macros directly in initial content:
886
+ **Multi-diagram workflow**: Use batch operations with plantuml parameter:
770
887
  ```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>` })
888
+ // 1. buffer_create({ contentType: "xhtml", content: "<h1>Design</h1><p>Introduction</p>" })
889
+ // 2. buffer_edit({ bufferId, operations: [
890
+ // { after: 1, plantuml: "@startuml\nA -> B\n@enduml" },
891
+ // { after: 2, plantuml: "@startuml\nclass User\n@enduml" }
892
+ // ]})
893
+ // -> All PlantUML validated in batch before any changes, rolled back on error
778
894
  // 3. confluence_draft_create({ spaceKey, title, bufferId })
779
- // Saves tool calls vs placeholder-then-edit pattern. See help(topic="plantuml").
895
+ // NOTE: Embedding PlantUML macros directly in content is NOT allowed - use plantuml parameter.
780
896
  ```
781
897
 
782
898
  ---
@@ -871,7 +987,7 @@ buffer_get_element({
871
987
 
872
988
  ### 7. buffer_edit
873
989
  **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
990
+ **Use Cases**: Insert/replace/remove elements in Confluence pages, modify Jira/Tempo content, compose content from multiple buffers
875
991
 
876
992
  **XHTML Parameters (single operation):**
877
993
 
@@ -883,15 +999,18 @@ buffer_get_element({
883
999
  | replace | number | ✗ | Replace element with this ID |
884
1000
  | remove | number | ✗ | Remove element with this ID |
885
1001
  | append | boolean | ✗ | Append at document end |
886
- | content | string | ✗ | XHTML content to insert/replace |
887
- | plantuml | string | ✗ | PlantUML code (auto-wrapped in macro, validated) |
1002
+ | content | string | ✗ | XHTML content to insert/replace (**NO PlantUML macros allowed**) |
1003
+ | plantuml | string | ✗ | PlantUML code (**REQUIRED** for diagrams - auto-validated and wrapped) |
1004
+ | fromBufferId | string | ✗ | Insert content from another buffer (useful for composing content) |
1005
+
1006
+ **IMPORTANT**: The `content` parameter **rejects** PlantUML macros. All PlantUML must use the `plantuml` parameter for mandatory validation.
888
1007
 
889
1008
  **XHTML Batch Operations (multiple edits in one call):**
890
1009
 
891
1010
  | Parameter | Type | Required | Description |
892
1011
  |-----------|------|----------|-------------|
893
1012
  | bufferId | string | ✓ | Buffer ID to modify |
894
- | operations | array | ✓ | Array of `{after?, before?, replace?, append?, remove?, content?, plantuml?}` |
1013
+ | operations | array | ✓ | Array of `{after?, before?, replace?, append?, remove?, content?, plantuml?, fromBufferId?}` |
895
1014
 
896
1015
  **Batch operations** are executed sequentially, stopping on first error. Much more efficient than multiple tool calls (parse once, serialize once).
897
1016
 
@@ -920,14 +1039,15 @@ buffer_edit({
920
1039
  // Returns: { success: true, insertedIds: [5], structure: [...], nextId: 6 }
921
1040
  ```
922
1041
 
923
- **Example - Insert PlantUML diagram:**
1042
+ **Example - Insert PlantUML diagram (REQUIRED method):**
924
1043
  ```typescript
925
1044
  buffer_edit({
926
1045
  bufferId: "buf_xxx",
927
1046
  after: 3,
928
1047
  plantuml: "@startuml\nA -> B: message\n@enduml"
929
1048
  })
930
- // Automatically validates and wraps in Confluence macro
1049
+ // Automatically validates syntax, rejects invalid code, and wraps in Confluence macro
1050
+ // NOTE: Using content parameter with PlantUML macros will be REJECTED
931
1051
  ```
932
1052
 
933
1053
  **Example - Batch operations (EFFICIENT for multiple diagrams):**
@@ -962,6 +1082,31 @@ buffer_edit({
962
1082
  })
963
1083
  ```
964
1084
 
1085
+ **Example - Insert content from another buffer (buffer composition):**
1086
+ ```typescript
1087
+ // EDITING EXISTING PAGES: When you have created content in a separate buffer
1088
+ // and want to insert it into the page's buffer:
1089
+
1090
+ // 1. Load existing page
1091
+ confluence_edit("https://confluence.example.com/pages/viewpage.action?pageId=123")
1092
+ // -> returns bufferId_A (page content), pageId
1093
+
1094
+ // 2. Create new content in a separate buffer
1095
+ buffer_create({ content: "<p>New content to add</p>", contentType: "xhtml" })
1096
+ // -> returns bufferId_B
1097
+
1098
+ // 3. Insert bufferId_B's content into bufferId_A
1099
+ buffer_edit({
1100
+ bufferId: "buf_A",
1101
+ after: 5, // Insert after element 5 in the page
1102
+ fromBufferId: "buf_B" // Takes content from this buffer
1103
+ })
1104
+
1105
+ // 4. Create draft linked to original page
1106
+ confluence_draft_create({ pageId: "123", bufferId: "buf_A" })
1107
+ // -> Works! bufferId_A originated from pageId 123
1108
+ ```
1109
+
965
1110
  ---
966
1111
 
967
1112
  ### 8. buffer_get_structure
@@ -1081,9 +1226,9 @@ Utility tools for time calculations. Always available with any Jira, Confluence,
1081
1226
 
1082
1227
  ---
1083
1228
 
1084
- ## URL Tools (1)
1229
+ ## URL Tools (2)
1085
1230
 
1086
- Utility tools for URL construction. Always available with any Jira, Confluence, or Tempo action.
1231
+ Utility tools for URL construction and parsing. Always available with any Jira, Confluence, or Tempo action.
1087
1232
 
1088
1233
  ### 1. fullurl
1089
1234
  **Description**: Convert Jira issue keys, Confluence page IDs, or relative paths into full URLs
@@ -1114,6 +1259,35 @@ fullurl("/display/DOCS/Home") // → https://confluence.example.com/display/DOCS
1114
1259
 
1115
1260
  ---
1116
1261
 
1262
+ ### 2. parseurl
1263
+ **Description**: Parse a Jira or Confluence URL to extract identifiers (pageId, issueKey, draftId, etc.)
1264
+ **Use Cases**: Extract IDs from URLs users share, prepare input for other tools
1265
+
1266
+ | Parameter | Type | Required | Description |
1267
+ |-----------|------|----------|-------------|
1268
+ | url | string | ✓ | Full URL to parse (Jira or Confluence) |
1269
+
1270
+ **Supported URL formats**:
1271
+ | URL Pattern | Extracted Fields |
1272
+ |-------------|------------------|
1273
+ | `https://jira.example.com/browse/PROJ-123` | `{type: "jira_issue", issueKey: "PROJ-123"}` |
1274
+ | `https://confluence.example.com/pages/viewpage.action?pageId=123` | `{type: "confluence_page", pageId: "123"}` |
1275
+ | `https://confluence.example.com/pages/resumedraft.action?draftId=456` | `{type: "confluence_draft", draftId: "456"}` |
1276
+ | `https://confluence.example.com/display/SPACE/Page+Title` | `{type: "confluence_space_path", spaceKey: "SPACE", title: "Page Title"}` |
1277
+ | `https://confluence.example.com/spaces/SPACE/pages/123/Title` | `{type: "confluence_page", pageId: "123", spaceKey: "SPACE", title: "Title"}` |
1278
+
1279
+ **Response includes**: `url`, `type`, and extracted fields (`issueKey`, `pageId`, `draftId`, `spaceKey`, `title`)
1280
+
1281
+ **Workflow**:
1282
+ ```
1283
+ 1. parseurl(url) → extract identifier
1284
+ 2. Use extracted ID with appropriate tool (jira_get_issue, confluence_get_page, confluence_edit, etc.)
1285
+ ```
1286
+
1287
+ **Tip**: `confluence_edit` can accept URLs directly and parses them internally, so you can often skip `parseurl` for Confluence workflows.
1288
+
1289
+ ---
1290
+
1117
1291
  ## Jicon Help Tools (1)
1118
1292
 
1119
1293
  Unified help system for all Jicon workflows and syntax guides. Always available with any Jira, Confluence, or Tempo action.
@@ -1272,7 +1446,7 @@ Tools that return large content (Confluence pages, Jira issues, Tempo worklogs)
1272
1446
  - `tempo_get_worklogs`, `tempo_get_team_worklogs`
1273
1447
 
1274
1448
  **Buffer Management:**
1275
- - **TTL**: Buffers expire after 10 minutes by default; edited buffers reset to 1 day TTL
1449
+ - **TTL**: Buffers expire after 1 hour by default; edited buffers reset to 1 day TTL
1276
1450
  - **List Buffers**: Use `buffer_list` to see active buffers
1277
1451
  - **Clear Buffers**: Use `buffer_clear` to free memory
1278
1452
 
@@ -1282,19 +1456,26 @@ Tools that return large content (Confluence pages, Jira issues, Tempo worklogs)
1282
1456
  1. `confluence_draft_create` → creates server draft + buffer with `structure` (element IDs), returns clickable preview URL
1283
1457
  2. User clicks URL to review draft in Confluence UI (can edit there)
1284
1458
  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="..."`)
1459
+ 4. `buffer_edit(bufferId, after=ID, content/plantuml/fromBufferId)` → edit using element IDs
1286
1460
  5. `confluence_draft_save` → checkpoint: deletes old draft, creates new with buffer content, returns new URL
1287
1461
  6. Repeat steps 2-5 until user approves
1288
1462
  7. User publishes via Confluence UI (click "Publish" button)
1289
1463
 
1290
1464
  **Editing existing Confluence pages (draft workflow):**
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="..."`)
1293
- 3. `confluence_draft_create` → creates draft with modified content for user review
1465
+ 1. `confluence_edit(URL or pageId)` → page content is buffered, returns `bufferId`, `pageId`, `version`, and `structure`
1466
+ 2. `buffer_edit(bufferId, after=ID, content/plantuml/fromBufferId)` → edit using element IDs
1467
+ 3. `confluence_draft_create(pageId, bufferId)` → creates draft linked to original page for user review
1294
1468
  4. User reviews draft at URL
1295
1469
  5. If changes needed: repeat via `confluence_draft_open` → edit → `confluence_draft_save`
1296
1470
  6. User publishes via Confluence UI (click "Publish" button)
1297
1471
 
1472
+ **Buffer composition (when content created separately):**
1473
+ If you created content in a separate buffer and need to insert it into a page:
1474
+ 1. `confluence_edit(pageId)` → `bufferId_A` (page buffer with structure)
1475
+ 2. `buffer_create(content, contentType="xhtml")` → `bufferId_B` (new content)
1476
+ 3. `buffer_edit(bufferId=bufferId_A, after=5, fromBufferId=bufferId_B)` → merges B into A
1477
+ 4. `confluence_draft_create(pageId, bufferId=bufferId_A)` → works because bufferId_A originated from pageId
1478
+
1298
1479
  **Saving buffer content to files:**
1299
1480
  - `buffer_save_to_file(bufferId, outputPath)` - Save buffer content to a local file
1300
1481
  - Security: Files can only be saved within project directory (must contain `.jicon.json`)
@@ -1334,8 +1515,10 @@ Use `buffer_edit` with element IDs for precise editing of Confluence storage for
1334
1515
 
1335
1516
  | Parameter | Description |
1336
1517
  |-----------|-------------|
1337
- | `content` | XHTML content to insert/replace |
1338
- | `plantuml` | PlantUML code (auto-validated and wrapped in Confluence macro) |
1518
+ | `content` | XHTML content to insert/replace (**REJECTS PlantUML macros**) |
1519
+ | `plantuml` | PlantUML code (**REQUIRED for diagrams** - auto-validated and wrapped in Confluence macro) |
1520
+
1521
+ **MANDATORY**: All PlantUML diagrams MUST use the `plantuml` parameter. The `content` parameter will reject any PlantUML macros to ensure validation.
1339
1522
 
1340
1523
  **Element Structure Example:**
1341
1524
 
@@ -43,7 +43,7 @@ export declare class ConfluenceClient {
43
43
  /**
44
44
  * Delete a draft page permanently
45
45
  * Drafts are not sent to trash - they are permanently deleted
46
- * Requires draft=true query parameter
46
+ * Data Center REST API v1 requires status=draft query parameter
47
47
  */
48
48
  deleteDraft(draftId: string): Promise<void>;
49
49
  /**
@@ -60,6 +60,11 @@ export declare class ConfluenceClient {
60
60
  * This returns drafts for the authenticated user (drafts are private to their creator).
61
61
  */
62
62
  listUserDrafts(spaceKey?: string, limit?: number): Promise<ConfluenceSearchResult>;
63
+ /**
64
+ * Find a draft by label
65
+ * Used to find existing review drafts linked to original pages
66
+ */
67
+ findDraftByLabel(label: string): Promise<ConfluencePage | null>;
63
68
  listSpaces(type?: "global" | "personal"): Promise<{
64
69
  results: ConfluenceSpace[];
65
70
  total: number;
@@ -79,7 +84,7 @@ export declare class ConfluenceClient {
79
84
  results: ConfluenceAttachment[];
80
85
  total: number;
81
86
  }>;
82
- private addLabels;
87
+ addLabels(pageId: string, labels: string[], isDraft?: boolean): Promise<void>;
83
88
  getCurrentUser(): Promise<{
84
89
  userKey: string;
85
90
  username: string;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/confluence/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAUpB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,OA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ors = [{ id: pageData.parentId }];
150
150
  }
151
151
  const page = await this.http.post("/rest/api/content?status=draft", body);
152
- // Add labels if provided
152
+ // Add labels if provided (must use isDraft=true for draft status parameter)
153
153
  if (pageData.labels && pageData.labels.length > 0) {
154
- await this.addLabels(page.id, pageData.labels);
154
+ await this.addLabels(page.id, pageData.labels, true);
155
155
  }
156
156
  return page;
157
157
  }
@@ -170,10 +170,10 @@ export class ConfluenceClient {
170
170
  /**
171
171
  * Delete a draft page permanently
172
172
  * Drafts are not sent to trash - they are permanently deleted
173
- * Requires draft=true query parameter
173
+ * Data Center REST API v1 requires status=draft query parameter
174
174
  */
175
175
  async deleteDraft(draftId) {
176
- await this.http.delete(`/rest/api/content/${draftId}?draft=true`);
176
+ await this.http.delete(`/rest/api/content/${draftId}?status=draft`);
177
177
  }
178
178
  /**
179
179
  * List user's draft pages
@@ -193,7 +193,7 @@ export class ConfluenceClient {
193
193
  params.append("status", "draft");
194
194
  params.append("type", "page");
195
195
  params.append("limit", String(limit));
196
- params.append("expand", DEFAULT_SEARCH_EXPAND.join(","));
196
+ params.append("expand", [...DEFAULT_SEARCH_EXPAND, "metadata.labels"].join(","));
197
197
  if (spaceKey) {
198
198
  params.append("spaceKey", spaceKey);
199
199
  }
@@ -201,6 +201,20 @@ export class ConfluenceClient {
201
201
  // The response format is compatible with ConfluenceSearchResult
202
202
  return this.http.get(`/rest/api/content?${params.toString()}`);
203
203
  }
204
+ /**
205
+ * Find a draft by label
206
+ * Used to find existing review drafts linked to original pages
207
+ */
208
+ async findDraftByLabel(label) {
209
+ // List all user's drafts with labels expanded
210
+ const drafts = await this.listUserDrafts(undefined, 500);
211
+ // Find draft with matching label
212
+ const matchingDraft = drafts.results.find((draft) => {
213
+ const labels = draft.metadata?.labels?.results || [];
214
+ return labels.some((l) => l.name === label);
215
+ });
216
+ return matchingDraft || null;
217
+ }
204
218
  // Space operations
205
219
  async listSpaces(type) {
206
220
  // Fetch all spaces (auto-paginate internally)
@@ -322,9 +336,13 @@ export class ConfluenceClient {
322
336
  return { results: allAttachments, total: allAttachments.length };
323
337
  }
324
338
  // Labels
325
- async addLabels(pageId, labels) {
339
+ async addLabels(pageId, labels, isDraft = false) {
326
340
  const labelObjects = labels.map((name) => ({ prefix: "global", name }));
327
- await this.http.post(`/rest/api/content/${pageId}/label`, labelObjects);
341
+ // Data Center REST API v1 requires status=draft query parameter for draft operations
342
+ const endpoint = isDraft
343
+ ? `/rest/api/content/${pageId}/label?status=draft`
344
+ : `/rest/api/content/${pageId}/label`;
345
+ await this.http.post(endpoint, labelObjects);
328
346
  }
329
347
  // User operations
330
348
  async getCurrentUser() {
@@ -338,7 +356,7 @@ export class ConfluenceClient {
338
356
  }
339
357
  async getCurrentUserSpace() {
340
358
  const user = await this.getCurrentUser();
341
- // Personal space key convention: ~username (e.g., ~jdoe or ~john.doe)
359
+ // Personal space key convention: ~username (e.g., ~amorgan or ~alex.morgan)
342
360
  const personalSpaceKey = `~${user.username}`;
343
361
  try {
344
362
  return await this.getSpace(personalSpaceKey);
@@ -358,10 +376,10 @@ export class ConfluenceClient {
358
376
  // Case-insensitive match
359
377
  if (keyLower === `~${usernameLower}`)
360
378
  return true;
361
- // Personal space key contains username (e.g., ~fabien.thomas contains fabien)
379
+ // Personal space key contains username (e.g., ~alex.morgan contains alex)
362
380
  if (keyLower.startsWith("~") && keyLower.includes(usernameLower))
363
381
  return true;
364
- // Space name contains display name (e.g., "Fabien THOMAS" space)
382
+ // Space name contains display name (e.g., "Alex Morgan" space)
365
383
  if (nameLower.includes(displayNameLower))
366
384
  return true;
367
385
  return false;