confluence-ai 0.1.0__tar.gz

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 (29) hide show
  1. confluence_ai-0.1.0/PKG-INFO +217 -0
  2. confluence_ai-0.1.0/README.md +177 -0
  3. confluence_ai-0.1.0/pyproject.toml +60 -0
  4. confluence_ai-0.1.0/setup.cfg +4 -0
  5. confluence_ai-0.1.0/src/confluence_ai/__init__.py +85 -0
  6. confluence_ai-0.1.0/src/confluence_ai/cli.py +574 -0
  7. confluence_ai-0.1.0/src/confluence_ai/client.py +286 -0
  8. confluence_ai-0.1.0/src/confluence_ai/describer.py +159 -0
  9. confluence_ai-0.1.0/src/confluence_ai/downloader.py +325 -0
  10. confluence_ai-0.1.0/src/confluence_ai/exceptions.py +153 -0
  11. confluence_ai-0.1.0/src/confluence_ai/export.py +476 -0
  12. confluence_ai-0.1.0/src/confluence_ai/json_renderer.py +72 -0
  13. confluence_ai-0.1.0/src/confluence_ai/models.py +233 -0
  14. confluence_ai-0.1.0/src/confluence_ai/output_renderer.py +124 -0
  15. confluence_ai-0.1.0/src/confluence_ai/parser.py +710 -0
  16. confluence_ai-0.1.0/src/confluence_ai/providers/__init__.py +143 -0
  17. confluence_ai-0.1.0/src/confluence_ai/providers/anthropic_describer.py +189 -0
  18. confluence_ai-0.1.0/src/confluence_ai/providers/bedrock_describer.py +197 -0
  19. confluence_ai-0.1.0/src/confluence_ai/providers/openai_describer.py +186 -0
  20. confluence_ai-0.1.0/src/confluence_ai/publish.py +251 -0
  21. confluence_ai-0.1.0/src/confluence_ai/py.typed +0 -0
  22. confluence_ai-0.1.0/src/confluence_ai/renderer.py +419 -0
  23. confluence_ai-0.1.0/src/confluence_ai/url_parser.py +41 -0
  24. confluence_ai-0.1.0/src/confluence_ai.egg-info/PKG-INFO +217 -0
  25. confluence_ai-0.1.0/src/confluence_ai.egg-info/SOURCES.txt +27 -0
  26. confluence_ai-0.1.0/src/confluence_ai.egg-info/dependency_links.txt +1 -0
  27. confluence_ai-0.1.0/src/confluence_ai.egg-info/entry_points.txt +2 -0
  28. confluence_ai-0.1.0/src/confluence_ai.egg-info/requires.txt +25 -0
  29. confluence_ai-0.1.0/src/confluence_ai.egg-info/top_level.txt +1 -0
@@ -0,0 +1,217 @@
1
+ Metadata-Version: 2.4
2
+ Name: confluence-ai
3
+ Version: 0.1.0
4
+ Summary: General-purpose AI-powered Confluence toolkit — export, publish, and describe pages
5
+ Author: Confluence AI Contributors
6
+ License: MIT
7
+ Keywords: confluence,markdown,export,publish,ai,gliffy
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Documentation
16
+ Classifier: Topic :: Text Processing :: Markup
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: click>=8.1.0
21
+ Requires-Dist: atlassian-python-api>=3.41.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: requests>=2.31.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
26
+ Requires-Dist: hypothesis>=6.90.0; extra == "dev"
27
+ Requires-Dist: pytest-mock; extra == "dev"
28
+ Provides-Extra: anthropic
29
+ Requires-Dist: anthropic>=0.30.0; extra == "anthropic"
30
+ Provides-Extra: openai
31
+ Requires-Dist: openai>=1.0.0; extra == "openai"
32
+ Provides-Extra: bedrock
33
+ Requires-Dist: boto3>=1.28.0; extra == "bedrock"
34
+ Requires-Dist: botocore[crt]>=1.28.0; extra == "bedrock"
35
+ Provides-Extra: all
36
+ Requires-Dist: anthropic>=0.30.0; extra == "all"
37
+ Requires-Dist: openai>=1.0.0; extra == "all"
38
+ Requires-Dist: boto3>=1.28.0; extra == "all"
39
+ Requires-Dist: botocore[crt]>=1.28.0; extra == "all"
40
+
41
+ # confluence-ai
42
+
43
+ General-purpose AI-powered Confluence toolkit — export, publish, and describe pages.
44
+
45
+ ## Library Usage
46
+
47
+ ### Export a Page
48
+
49
+ ```python
50
+ from confluence_ai import export_page, ImageDescriberConfig
51
+
52
+ # Export with AI-powered image descriptions
53
+ result = export_page(
54
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/123456/My-Page",
55
+ "./output",
56
+ email="user@acme.com",
57
+ api_token="your-api-token",
58
+ ai_config=ImageDescriberConfig(
59
+ provider="bedrock",
60
+ model="us.anthropic.claude-sonnet-4-20250514-v1:0",
61
+ ),
62
+ )
63
+ print(f"Exported to: {result.markdown_path}")
64
+ print(f"Images: {result.images_downloaded}, Descriptions: {result.descriptions_generated}")
65
+
66
+ # Export without AI descriptions
67
+ result = export_page(
68
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/123456/My-Page",
69
+ "./output",
70
+ email="user@acme.com",
71
+ api_token="your-api-token",
72
+ )
73
+ ```
74
+
75
+ ### Publish a Page
76
+
77
+ ```python
78
+ from confluence_ai import publish_page
79
+
80
+ url = publish_page(
81
+ "<h1>Report</h1><p>Analysis results...</p>",
82
+ email="user@acme.com",
83
+ api_token="your-api-token",
84
+ base_url="https://acme.atlassian.net/wiki",
85
+ space_key="ENG",
86
+ title="Gap Analysis Report - 2024-01-15",
87
+ parent_page_id="123456",
88
+ )
89
+ print(f"Published: {url}")
90
+ ```
91
+
92
+ ### Export as JSON
93
+
94
+ ```python
95
+ from confluence_ai import export_page
96
+
97
+ result = export_page(
98
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/123456/My-Page",
99
+ "./output",
100
+ email="user@acme.com",
101
+ api_token="your-api-token",
102
+ output_format="json",
103
+ )
104
+ ```
105
+
106
+ ## Extension Points
107
+
108
+ ### Custom Image Describer
109
+
110
+ Subclass `ImageDescriber` and register it to use your own vision model:
111
+
112
+ ```python
113
+ from confluence_ai import ImageDescriber, ImageDescriberConfig, ImageContext, register_describer
114
+
115
+ class LocalLlavaDescriber(ImageDescriber):
116
+ """Image describer using a local LLaVA model."""
117
+
118
+ def describe(self, image_path: str, context: ImageContext) -> str:
119
+ # Call your local model here
120
+ return f"Description of {context.filename}"
121
+
122
+ # Register the custom provider
123
+ register_describer("local-llava", LocalLlavaDescriber)
124
+
125
+ # Use it via the standard factory
126
+ from confluence_ai import create_describer
127
+
128
+ describer = create_describer(ImageDescriberConfig(provider="local-llava", model="llava-1.5"))
129
+ description = describer.describe("diagram.png", ImageContext(is_gliffy=True))
130
+ ```
131
+
132
+ ### Custom Output Renderer
133
+
134
+ Subclass `OutputRenderer` to export pages in formats beyond Markdown and JSON:
135
+
136
+ ```python
137
+ from confluence_ai import OutputRenderer, register_renderer
138
+ from confluence_ai.models import ContentNode, PageMetadata
139
+
140
+ class ReStructuredTextRenderer(OutputRenderer):
141
+ """Render Confluence pages as reStructuredText."""
142
+
143
+ def render(
144
+ self,
145
+ nodes: list[ContentNode],
146
+ metadata: PageMetadata,
147
+ descriptions: dict[str, str] | None = None,
148
+ ) -> str:
149
+ # Convert nodes to RST format
150
+ lines = [metadata.page_title, "=" * len(metadata.page_title), ""]
151
+ # ... render nodes ...
152
+ return "\n".join(lines)
153
+
154
+ # Register and use
155
+ register_renderer("rst", ReStructuredTextRenderer)
156
+
157
+ from confluence_ai import export_page
158
+
159
+ result = export_page(
160
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/123456/My-Page",
161
+ "./output",
162
+ email="user@acme.com",
163
+ api_token="your-api-token",
164
+ output_format="rst",
165
+ )
166
+ ```
167
+
168
+ ## CLI Usage
169
+
170
+ ### confluence-export
171
+
172
+ ```bash
173
+ # Basic export (no AI descriptions)
174
+ confluence-export \
175
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/12345/My-Page" \
176
+ ./output \
177
+ --email user@example.com \
178
+ --api-token YOUR_API_TOKEN \
179
+ --no-ai
180
+
181
+ # Export with AI image descriptions
182
+ confluence-export \
183
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/12345/My-Page" \
184
+ ./output \
185
+ --email user@example.com \
186
+ --api-token YOUR_API_TOKEN \
187
+ --ai-provider anthropic \
188
+ --ai-api-key YOUR_ANTHROPIC_KEY
189
+ ```
190
+
191
+ | Option | Env Variable | Description |
192
+ |---|---|---|
193
+ | `--email` | `CONFLUENCE_EMAIL` | Confluence account email |
194
+ | `--api-token` | `CONFLUENCE_API_TOKEN` | Confluence Cloud API token |
195
+ | `--ai-provider` | `CONFLUENCE_EXPORT_AI_PROVIDER` | AI provider: `anthropic`, `openai`, or `bedrock` |
196
+ | `--ai-model` | `CONFLUENCE_EXPORT_AI_MODEL` | AI model name |
197
+ | `--ai-api-key` | `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` | AI provider API key |
198
+ | `--no-ai` | — | Skip AI image description generation |
199
+ | `--verbose` | — | Enable DEBUG-level logging |
200
+
201
+ ## Installation
202
+
203
+ ```bash
204
+ pip install confluence-ai
205
+
206
+ # With AI provider support
207
+ pip install "confluence-ai[bedrock]" # Amazon Bedrock (Claude)
208
+ pip install "confluence-ai[openai]" # OpenAI GPT-4o
209
+ pip install "confluence-ai[anthropic]" # Anthropic Claude (direct API)
210
+ pip install "confluence-ai[all]" # All providers
211
+ ```
212
+
213
+ Requires Python 3.10+.
214
+
215
+ ## License
216
+
217
+ MIT
@@ -0,0 +1,177 @@
1
+ # confluence-ai
2
+
3
+ General-purpose AI-powered Confluence toolkit — export, publish, and describe pages.
4
+
5
+ ## Library Usage
6
+
7
+ ### Export a Page
8
+
9
+ ```python
10
+ from confluence_ai import export_page, ImageDescriberConfig
11
+
12
+ # Export with AI-powered image descriptions
13
+ result = export_page(
14
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/123456/My-Page",
15
+ "./output",
16
+ email="user@acme.com",
17
+ api_token="your-api-token",
18
+ ai_config=ImageDescriberConfig(
19
+ provider="bedrock",
20
+ model="us.anthropic.claude-sonnet-4-20250514-v1:0",
21
+ ),
22
+ )
23
+ print(f"Exported to: {result.markdown_path}")
24
+ print(f"Images: {result.images_downloaded}, Descriptions: {result.descriptions_generated}")
25
+
26
+ # Export without AI descriptions
27
+ result = export_page(
28
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/123456/My-Page",
29
+ "./output",
30
+ email="user@acme.com",
31
+ api_token="your-api-token",
32
+ )
33
+ ```
34
+
35
+ ### Publish a Page
36
+
37
+ ```python
38
+ from confluence_ai import publish_page
39
+
40
+ url = publish_page(
41
+ "<h1>Report</h1><p>Analysis results...</p>",
42
+ email="user@acme.com",
43
+ api_token="your-api-token",
44
+ base_url="https://acme.atlassian.net/wiki",
45
+ space_key="ENG",
46
+ title="Gap Analysis Report - 2024-01-15",
47
+ parent_page_id="123456",
48
+ )
49
+ print(f"Published: {url}")
50
+ ```
51
+
52
+ ### Export as JSON
53
+
54
+ ```python
55
+ from confluence_ai import export_page
56
+
57
+ result = export_page(
58
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/123456/My-Page",
59
+ "./output",
60
+ email="user@acme.com",
61
+ api_token="your-api-token",
62
+ output_format="json",
63
+ )
64
+ ```
65
+
66
+ ## Extension Points
67
+
68
+ ### Custom Image Describer
69
+
70
+ Subclass `ImageDescriber` and register it to use your own vision model:
71
+
72
+ ```python
73
+ from confluence_ai import ImageDescriber, ImageDescriberConfig, ImageContext, register_describer
74
+
75
+ class LocalLlavaDescriber(ImageDescriber):
76
+ """Image describer using a local LLaVA model."""
77
+
78
+ def describe(self, image_path: str, context: ImageContext) -> str:
79
+ # Call your local model here
80
+ return f"Description of {context.filename}"
81
+
82
+ # Register the custom provider
83
+ register_describer("local-llava", LocalLlavaDescriber)
84
+
85
+ # Use it via the standard factory
86
+ from confluence_ai import create_describer
87
+
88
+ describer = create_describer(ImageDescriberConfig(provider="local-llava", model="llava-1.5"))
89
+ description = describer.describe("diagram.png", ImageContext(is_gliffy=True))
90
+ ```
91
+
92
+ ### Custom Output Renderer
93
+
94
+ Subclass `OutputRenderer` to export pages in formats beyond Markdown and JSON:
95
+
96
+ ```python
97
+ from confluence_ai import OutputRenderer, register_renderer
98
+ from confluence_ai.models import ContentNode, PageMetadata
99
+
100
+ class ReStructuredTextRenderer(OutputRenderer):
101
+ """Render Confluence pages as reStructuredText."""
102
+
103
+ def render(
104
+ self,
105
+ nodes: list[ContentNode],
106
+ metadata: PageMetadata,
107
+ descriptions: dict[str, str] | None = None,
108
+ ) -> str:
109
+ # Convert nodes to RST format
110
+ lines = [metadata.page_title, "=" * len(metadata.page_title), ""]
111
+ # ... render nodes ...
112
+ return "\n".join(lines)
113
+
114
+ # Register and use
115
+ register_renderer("rst", ReStructuredTextRenderer)
116
+
117
+ from confluence_ai import export_page
118
+
119
+ result = export_page(
120
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/123456/My-Page",
121
+ "./output",
122
+ email="user@acme.com",
123
+ api_token="your-api-token",
124
+ output_format="rst",
125
+ )
126
+ ```
127
+
128
+ ## CLI Usage
129
+
130
+ ### confluence-export
131
+
132
+ ```bash
133
+ # Basic export (no AI descriptions)
134
+ confluence-export \
135
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/12345/My-Page" \
136
+ ./output \
137
+ --email user@example.com \
138
+ --api-token YOUR_API_TOKEN \
139
+ --no-ai
140
+
141
+ # Export with AI image descriptions
142
+ confluence-export \
143
+ "https://acme.atlassian.net/wiki/spaces/ENG/pages/12345/My-Page" \
144
+ ./output \
145
+ --email user@example.com \
146
+ --api-token YOUR_API_TOKEN \
147
+ --ai-provider anthropic \
148
+ --ai-api-key YOUR_ANTHROPIC_KEY
149
+ ```
150
+
151
+ | Option | Env Variable | Description |
152
+ |---|---|---|
153
+ | `--email` | `CONFLUENCE_EMAIL` | Confluence account email |
154
+ | `--api-token` | `CONFLUENCE_API_TOKEN` | Confluence Cloud API token |
155
+ | `--ai-provider` | `CONFLUENCE_EXPORT_AI_PROVIDER` | AI provider: `anthropic`, `openai`, or `bedrock` |
156
+ | `--ai-model` | `CONFLUENCE_EXPORT_AI_MODEL` | AI model name |
157
+ | `--ai-api-key` | `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` | AI provider API key |
158
+ | `--no-ai` | — | Skip AI image description generation |
159
+ | `--verbose` | — | Enable DEBUG-level logging |
160
+
161
+ ## Installation
162
+
163
+ ```bash
164
+ pip install confluence-ai
165
+
166
+ # With AI provider support
167
+ pip install "confluence-ai[bedrock]" # Amazon Bedrock (Claude)
168
+ pip install "confluence-ai[openai]" # OpenAI GPT-4o
169
+ pip install "confluence-ai[anthropic]" # Anthropic Claude (direct API)
170
+ pip install "confluence-ai[all]" # All providers
171
+ ```
172
+
173
+ Requires Python 3.10+.
174
+
175
+ ## License
176
+
177
+ MIT
@@ -0,0 +1,60 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "confluence-ai"
7
+ version = "0.1.0"
8
+ description = "General-purpose AI-powered Confluence toolkit — export, publish, and describe pages"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ {name = "Confluence AI Contributors"},
14
+ ]
15
+ keywords = ["confluence", "markdown", "export", "publish", "ai", "gliffy"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Documentation",
25
+ "Topic :: Text Processing :: Markup",
26
+ "Typing :: Typed",
27
+ ]
28
+ dependencies = [
29
+ "click>=8.1.0",
30
+ "atlassian-python-api>=3.41.0",
31
+ "pyyaml>=6.0",
32
+ "requests>=2.31.0",
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ dev = [
37
+ "pytest>=7.4.0",
38
+ "hypothesis>=6.90.0",
39
+ "pytest-mock",
40
+ ]
41
+ anthropic = ["anthropic>=0.30.0"]
42
+ openai = ["openai>=1.0.0"]
43
+ bedrock = ["boto3>=1.28.0", "botocore[crt]>=1.28.0"]
44
+ all = ["anthropic>=0.30.0", "openai>=1.0.0", "boto3>=1.28.0", "botocore[crt]>=1.28.0"]
45
+
46
+ [project.scripts]
47
+ confluence-export = "confluence_ai.cli:main"
48
+
49
+ [tool.setuptools.packages.find]
50
+ where = ["src"]
51
+
52
+ [tool.setuptools.package-data]
53
+ confluence_ai = ["py.typed"]
54
+
55
+ [tool.pytest.ini_options]
56
+ testpaths = ["tests"]
57
+ pythonpath = ["src"]
58
+
59
+ [tool.hypothesis]
60
+ database_backend = "directory"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,85 @@
1
+ """AI-powered Confluence toolkit — export, publish, and describe pages.
2
+
3
+ Programmatic API for Confluence Cloud: read pages, resolve user mentions,
4
+ download attachments, describe images via multimodal AI, render to
5
+ Markdown or JSON (or custom formats), and publish HTML back to Confluence.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ __version__ = "0.1.0"
11
+
12
+ # --- Core classes ---
13
+ from confluence_ai.client import ConfluenceClient
14
+ from confluence_ai.describer import ImageDescriber
15
+ from confluence_ai.downloader import AssetDownloader
16
+ from confluence_ai.output_renderer import OutputRenderer, register_renderer
17
+ from confluence_ai.parser import StorageFormatParser
18
+ from confluence_ai.renderer import MarkdownRenderer
19
+ from confluence_ai.url_parser import URLParser
20
+
21
+ # --- Factory & registry functions ---
22
+ from confluence_ai.providers import create_describer, register_describer
23
+
24
+ # --- Convenience functions ---
25
+ from confluence_ai.export import export_page
26
+ from confluence_ai.publish import publish_page
27
+
28
+ # --- Config & result models ---
29
+ from confluence_ai.models import (
30
+ ExportResult,
31
+ ImageContext,
32
+ ImageDescriberConfig,
33
+ PageMetadata,
34
+ )
35
+
36
+ # --- Exceptions ---
37
+ from confluence_ai.exceptions import (
38
+ AuthenticationError,
39
+ ConfluenceConnectionError,
40
+ DownloadError,
41
+ ExporterError,
42
+ FileSystemError,
43
+ ImageDescriptionError,
44
+ InvalidURLError,
45
+ PageNotFoundError,
46
+ ParseError,
47
+ )
48
+
49
+ # Importing this ensures the built-in JSON renderer registers itself.
50
+ from confluence_ai import json_renderer # noqa: F401
51
+
52
+ __all__ = [
53
+ # Version
54
+ "__version__",
55
+ # Core classes
56
+ "ConfluenceClient",
57
+ "StorageFormatParser",
58
+ "MarkdownRenderer",
59
+ "AssetDownloader",
60
+ "ImageDescriber",
61
+ "URLParser",
62
+ "OutputRenderer",
63
+ # Factory & registry
64
+ "create_describer",
65
+ "register_describer",
66
+ "register_renderer",
67
+ # Convenience functions
68
+ "export_page",
69
+ "publish_page",
70
+ # Models
71
+ "ImageDescriberConfig",
72
+ "ImageContext",
73
+ "PageMetadata",
74
+ "ExportResult",
75
+ # Exceptions
76
+ "ExporterError",
77
+ "InvalidURLError",
78
+ "AuthenticationError",
79
+ "ConfluenceConnectionError",
80
+ "PageNotFoundError",
81
+ "ParseError",
82
+ "DownloadError",
83
+ "ImageDescriptionError",
84
+ "FileSystemError",
85
+ ]