atli 0.7.0__tar.gz → 0.8.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 (58) hide show
  1. {atli-0.7.0 → atli-0.8.0}/PKG-INFO +1 -1
  2. {atli-0.7.0 → atli-0.8.0}/src/atli/__init__.py +1 -1
  3. {atli-0.7.0 → atli-0.8.0}/src/atli/confluence/client.py +2 -2
  4. {atli-0.7.0 → atli-0.8.0}/src/atli/confluence/commands.py +21 -8
  5. {atli-0.7.0 → atli-0.8.0}/src/atli/skills/atli-confluence/SKILL.md +9 -6
  6. atli-0.8.0/tests/test_confluence_gaps.py +204 -0
  7. {atli-0.7.0 → atli-0.8.0}/.gitignore +0 -0
  8. {atli-0.7.0 → atli-0.8.0}/CHANGELOG.md +0 -0
  9. {atli-0.7.0 → atli-0.8.0}/LICENSE +0 -0
  10. {atli-0.7.0 → atli-0.8.0}/README.md +0 -0
  11. {atli-0.7.0 → atli-0.8.0}/pyproject.toml +0 -0
  12. {atli-0.7.0 → atli-0.8.0}/src/atli/__main__.py +0 -0
  13. {atli-0.7.0 → atli-0.8.0}/src/atli/cli.py +0 -0
  14. {atli-0.7.0 → atli-0.8.0}/src/atli/client.py +0 -0
  15. {atli-0.7.0 → atli-0.8.0}/src/atli/commands_util.py +0 -0
  16. {atli-0.7.0 → atli-0.8.0}/src/atli/config.py +0 -0
  17. {atli-0.7.0 → atli-0.8.0}/src/atli/config_commands.py +0 -0
  18. {atli-0.7.0 → atli-0.8.0}/src/atli/confluence/__init__.py +0 -0
  19. {atli-0.7.0 → atli-0.8.0}/src/atli/confluence/markdown.py +0 -0
  20. {atli-0.7.0 → atli-0.8.0}/src/atli/jira/__init__.py +0 -0
  21. {atli-0.7.0 → atli-0.8.0}/src/atli/jira/agile.py +0 -0
  22. {atli-0.7.0 → atli-0.8.0}/src/atli/jira/agile_commands.py +0 -0
  23. {atli-0.7.0 → atli-0.8.0}/src/atli/jira/body.py +0 -0
  24. {atli-0.7.0 → atli-0.8.0}/src/atli/jira/client.py +0 -0
  25. {atli-0.7.0 → atli-0.8.0}/src/atli/jira/commands.py +0 -0
  26. {atli-0.7.0 → atli-0.8.0}/src/atli/jira/fields.py +0 -0
  27. {atli-0.7.0 → atli-0.8.0}/src/atli/jira/jql.py +0 -0
  28. {atli-0.7.0 → atli-0.8.0}/src/atli/output.py +0 -0
  29. {atli-0.7.0 → atli-0.8.0}/src/atli/skills/atli-jira/SKILL.md +0 -0
  30. {atli-0.7.0 → atli-0.8.0}/src/atli/skills/using-atli/SKILL.md +0 -0
  31. {atli-0.7.0 → atli-0.8.0}/src/atli/skills_commands.py +0 -0
  32. {atli-0.7.0 → atli-0.8.0}/tests/__init__.py +0 -0
  33. {atli-0.7.0 → atli-0.8.0}/tests/test_client.py +0 -0
  34. {atli-0.7.0 → atli-0.8.0}/tests/test_client_download.py +0 -0
  35. {atli-0.7.0 → atli-0.8.0}/tests/test_config.py +0 -0
  36. {atli-0.7.0 → atli-0.8.0}/tests/test_config_commands.py +0 -0
  37. {atli-0.7.0 → atli-0.8.0}/tests/test_confluence.py +0 -0
  38. {atli-0.7.0 → atli-0.8.0}/tests/test_confluence_attach.py +0 -0
  39. {atli-0.7.0 → atli-0.8.0}/tests/test_confluence_attachment_dl.py +0 -0
  40. {atli-0.7.0 → atli-0.8.0}/tests/test_confluence_labels.py +0 -0
  41. {atli-0.7.0 → atli-0.8.0}/tests/test_confluence_property.py +0 -0
  42. {atli-0.7.0 → atli-0.8.0}/tests/test_confluence_space.py +0 -0
  43. {atli-0.7.0 → atli-0.8.0}/tests/test_followup_fixes.py +0 -0
  44. {atli-0.7.0 → atli-0.8.0}/tests/test_integration.py +0 -0
  45. {atli-0.7.0 → atli-0.8.0}/tests/test_jira.py +0 -0
  46. {atli-0.7.0 → atli-0.8.0}/tests/test_jira_agile.py +0 -0
  47. {atli-0.7.0 → atli-0.8.0}/tests/test_jira_attachment_ops.py +0 -0
  48. {atli-0.7.0 → atli-0.8.0}/tests/test_jira_attachments.py +0 -0
  49. {atli-0.7.0 → atli-0.8.0}/tests/test_jira_bulk_meta.py +0 -0
  50. {atli-0.7.0 → atli-0.8.0}/tests/test_jira_fields.py +0 -0
  51. {atli-0.7.0 → atli-0.8.0}/tests/test_jira_helpers.py +0 -0
  52. {atli-0.7.0 → atli-0.8.0}/tests/test_jira_jql.py +0 -0
  53. {atli-0.7.0 → atli-0.8.0}/tests/test_jira_p3.py +0 -0
  54. {atli-0.7.0 → atli-0.8.0}/tests/test_markdown.py +0 -0
  55. {atli-0.7.0 → atli-0.8.0}/tests/test_review_findings.py +0 -0
  56. {atli-0.7.0 → atli-0.8.0}/tests/test_skills.py +0 -0
  57. {atli-0.7.0 → atli-0.8.0}/tests/test_sprint_move_search.py +0 -0
  58. {atli-0.7.0 → atli-0.8.0}/tests/test_stage5_features.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: atli
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: Lightweight CLI for self-hosted Jira and Confluence (Server / Data Center)
5
5
  Project-URL: Homepage, https://github.com/yuanyuan06/atli-kit
6
6
  Project-URL: Repository, https://github.com/yuanyuan06/atli-kit
@@ -1,3 +1,3 @@
1
1
  """atli — Lightweight CLI for self-hosted Jira and Confluence."""
2
2
 
3
- __version__ = "0.7.0"
3
+ __version__ = "0.8.0"
@@ -34,11 +34,11 @@ class ConfluenceClient(AtlassianClient):
34
34
  def list_pages(self, space: str, limit: int = 25, start: int = 0) -> dict:
35
35
  return self.get(
36
36
  f"{self.API}/content",
37
- params={"spaceKey": space, "type": "page", "limit": limit, "start": start},
37
+ params={"spaceKey": space, "type": "page", "limit": limit, "start": start, "expand": "space"},
38
38
  )
39
39
 
40
40
  def search(self, cql: str, limit: int = 25) -> dict:
41
- return self.get(f"{self.API}/content/search", params={"cql": cql, "limit": limit})
41
+ return self.get(f"{self.API}/content/search", params={"cql": cql, "limit": limit, "expand": "space"})
42
42
 
43
43
  def search_pages(
44
44
  self,
@@ -161,15 +161,26 @@ def create(
161
161
 
162
162
 
163
163
  @conf.command("view")
164
- @click.option("--space", required=True, help="Space key")
165
- @click.option("--title", required=True, help="Page title")
164
+ @click.option("--space", default=None, help="Space key (required unless --id is used)")
165
+ @click.option("--title", default=None, help="Page title (required unless --id is used)")
166
+ @click.option("--id", "page_id", default=None, help="Page ID (alternative to --space + --title)")
166
167
  @click.option("--body", "show_body", is_flag=True, help="Print page body content")
167
168
  @click.pass_context
168
- def view(ctx: click.Context, space: str, title: str, show_body: bool) -> None:
169
- """Show a page by space + title."""
169
+ def view(ctx: click.Context, space: str | None, title: str | None, page_id: str | None, show_body: bool) -> None:
170
+ """Show a page by space + title or by ID."""
171
+ if page_id:
172
+ if space or title:
173
+ fail("--id cannot be used with --space or --title")
174
+ else:
175
+ if not space or not title:
176
+ fail("--space and --title are required when --id is not provided")
177
+
170
178
  client = _client(ctx)
171
179
  try:
172
- page = client.require_page(space, title)
180
+ if page_id:
181
+ page = client.get_page(page_id)
182
+ else:
183
+ page = client.require_page(space, title)
173
184
  except AtlassianAPIError as e:
174
185
  fail(str(e))
175
186
 
@@ -207,6 +218,7 @@ def view(ctx: click.Context, space: str, title: str, show_body: bool) -> None:
207
218
  help="Body format",
208
219
  )
209
220
  @click.option("--create-if-missing", is_flag=True, help="Create the page if it does not exist")
221
+ @click.option("--parent-id", default=None, help="Parent page ID (only when creating with --create-if-missing)")
210
222
  @click.pass_context
211
223
  def update(
212
224
  ctx: click.Context,
@@ -216,6 +228,7 @@ def update(
216
228
  content: str | None,
217
229
  representation: str,
218
230
  create_if_missing: bool,
231
+ parent_id: str | None,
219
232
  ) -> None:
220
233
  """Update an existing page (or create it with --create-if-missing)."""
221
234
  client = _client(ctx)
@@ -225,7 +238,7 @@ def update(
225
238
  )
226
239
  try:
227
240
  if create_if_missing:
228
- action, page = client.upsert_page(space, title, body, representation=representation)
241
+ action, page = client.upsert_page(space, title, body, representation=representation, parent_id=parent_id)
229
242
  else:
230
243
  existing = client.require_page(space, title)
231
244
  page = client.update_page(
@@ -271,8 +284,8 @@ def list_cmd(ctx: click.Context, space: str, limit: int) -> None:
271
284
  if ctx.obj["json"]:
272
285
  emit_json(result)
273
286
  return
274
- rows = [[p.get("id", ""), p.get("title", "")] for p in pages]
275
- emit_table(["ID", "Title"], rows, json_mode=False)
287
+ rows = [[p.get("id", ""), p.get("title", ""), p.get("space", {}).get("key", "")] for p in pages]
288
+ emit_table(["ID", "Title", "Space"], rows, json_mode=False)
276
289
 
277
290
 
278
291
  @conf.command("search")
@@ -11,8 +11,8 @@ Run `atli config show` first to confirm Confluence is configured (see using-atli
11
11
 
12
12
  ```
13
13
  atli conf create --space TEAM --title "..." (--file body | --content "...") [--format storage|wiki|markdown|markdown-macro] [--parent-id 123]
14
- atli conf view --space TEAM --title "..." [--body]
15
- atli conf update --space TEAM --title "..." (--file body | --content "...") [--create-if-missing] [--format storage|wiki|markdown|markdown-macro]
14
+ atli conf view (--space TEAM --title "..." | --id ID) [--body]
15
+ atli conf update --space TEAM --title "..." (--file body | --content "...") [--create-if-missing] [--format storage|wiki|markdown|markdown-macro] [--parent-id ID]
16
16
  atli conf delete (--id <id> | --space TEAM --title "...") [--yes]
17
17
  atli conf list --space TEAM
18
18
  atli conf search [QUERY] [--cql] [--space TEAM] [--label draft] [--title "..."] [--text "..."] [--limit N]
@@ -35,7 +35,11 @@ atli conf space view SPACE_KEY
35
35
  atli conf space create --key KEY --name "..." [--description "..."]
36
36
  atli conf space update SPACE_KEY [--name "..."] [--description "..."]
37
37
  atli conf space delete SPACE_KEY [--yes]
38
- atli conf children (--space TEAM --title "..." | --id ID) [--limit 100]
38
+ atli conf version list (--space TEAM --title "..." | --id ID) [--limit 50]
39
+ atli conf version view (--space TEAM --title "..." | --id ID) --number N
40
+ atli conf version restore (--space TEAM --title "..." | --id ID) --number N [--yes]
41
+ atli conf permissions (--space TEAM --title "..." | --id ID | --space-key KEY)
42
+ atli conf export --space TEAM [--limit 1000]
39
43
  ```
40
44
 
41
45
  ## The body format gotcha
@@ -142,14 +146,13 @@ CQL field reference:
142
146
 
143
147
  ## Limitations
144
148
 
145
- - **Cannot change parent page via update**: The `update` command does not accept `--parent-id`. The underlying `upsert_page()` only passes `parent_id` when creating a new page; updating an existing page never changes its parent. To move a page, use the Confluence web UI or the REST API directly.
146
- - **view only supports space + title**: Unlike `delete` (which supports both `--id` and `--space + --title`), `view` only supports `--space` and `--title`. There is no `--id` option for `view`.
147
149
  - **Pagination**: `list` defaults to 25 results and `search` defaults to 10 results (`--limit` controls page size). There is no built-in pagination helper; for large result sets, manage `start` manually via raw CQL.
150
+ - **Markdown macro rendering**: When using `--format markdown-macro`, the CLI wraps the content in a Confluence markdown macro. This requires the target wiki to have a Markdown macro plugin installed (often with Mermaid rendering support). The CLI does not verify plugin presence before publishing; test rendering in the wiki after creating the page.
148
151
 
149
152
  ## Constraints
150
153
 
151
154
  1. **When an operation is unsupported, explain why and provide evidence**
152
- - If `atli conf` does not support an operation (e.g. page permission changes, bulk label management, attachment uploads, page moves, space creation), **clearly tell the user the operation cannot be done via `atli conf`**, explain the specific reason (command does not exist, API limitation, outside CLI scope), and provide evidence (e.g. `atli conf --help` output, or reference the Atlassian REST API docs).
155
+ - If `atli conf` does not support an operation (e.g. page-level permission changes, bulk label management), **clearly tell the user the operation cannot be done via `atli conf`**, explain the specific reason (command does not exist, API limitation, outside CLI scope), and provide evidence (e.g. `atli conf --help` output, or reference the Atlassian REST API docs).
153
156
  - **Do not** unilaterally fall back to alternatives (e.g. raw `curl`, direct API calls, web UI actions). You may **suggest** alternatives, but must get user confirmation before executing.
154
157
 
155
158
  2. **Ask for confirmation when instructions are ambiguous**
@@ -0,0 +1,204 @@
1
+ """Tests for Confluence gaps (C1-C8) from docs/atli-confluence-gaps-2026-11-16.md."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ import pytest
8
+ import respx
9
+ from click.testing import CliRunner
10
+ from httpx import Response
11
+
12
+ from atli.cli import cli
13
+
14
+
15
+ @pytest.fixture
16
+ def both_envs(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
17
+ """Set HOME to tmp and inject config via env vars."""
18
+ monkeypatch.setenv("HOME", str(tmp_path))
19
+ monkeypatch.setenv("ATLI_CONFLUENCE_URL", "https://conf.example.com")
20
+ monkeypatch.setenv("ATLI_CONFLUENCE_TOKEN", "fake-token")
21
+ monkeypatch.setenv("ATLI_JIRA_URL", "https://jira.example.com")
22
+ monkeypatch.setenv("ATLI_JIRA_TOKEN", "fake-token")
23
+ return monkeypatch
24
+
25
+
26
+ # C1 — update --create-if-missing 缺 --parent-id
27
+ @respx.mock
28
+ def test_c1_update_create_if_missing_with_parent_id(both_envs):
29
+ """C1: update --create-if-missing should accept --parent-id and pass it to upsert_page."""
30
+ runner = CliRunner()
31
+
32
+ # Mock find_page: page does not exist (match any query params)
33
+ respx.get(url__regex=r"https://conf\.example\.com/rest/api/content\?.*").mock(
34
+ return_value=Response(200, json={"results": [], "size": 0})
35
+ )
36
+
37
+ # Mock create_page: capture the request
38
+ create_route = respx.post("https://conf.example.com/rest/api/content").mock(
39
+ return_value=Response(
40
+ 200,
41
+ json={
42
+ "id": "123",
43
+ "title": "New Page",
44
+ "space": {"key": "DEMO"},
45
+ "_links": {"webui": "/pages/123"},
46
+ },
47
+ )
48
+ )
49
+
50
+ result = runner.invoke(
51
+ cli,
52
+ [
53
+ "conf",
54
+ "update",
55
+ "--space",
56
+ "DEMO",
57
+ "--title",
58
+ "New Page",
59
+ "--content",
60
+ "<p>test</p>",
61
+ "--create-if-missing",
62
+ "--parent-id",
63
+ "456",
64
+ ],
65
+ )
66
+
67
+ assert result.exit_code == 0, result.output
68
+ assert create_route.called
69
+ # Verify that ancestors was passed with parent_id
70
+ req = create_route.calls.last.request
71
+ body = req.read().decode()
72
+ assert '"ancestors":[{"id":"456"}]' in body
73
+
74
+
75
+ # C2 — view 命令缺 --id 选项
76
+ @respx.mock
77
+ def test_c2_view_by_id(both_envs):
78
+ """C2: view should accept --id as an alternative to --space + --title."""
79
+ runner = CliRunner()
80
+
81
+ respx.get(url__regex=r"https://conf\.example\.com/rest/api/content/123\?.*").mock(
82
+ return_value=Response(
83
+ 200,
84
+ json={
85
+ "id": "123",
86
+ "title": "Page by ID",
87
+ "space": {"key": "DEMO"},
88
+ "version": {"number": 5},
89
+ "body": {"storage": {"value": "<p>content</p>"}},
90
+ "_links": {"webui": "/pages/123"},
91
+ },
92
+ )
93
+ )
94
+
95
+ result = runner.invoke(cli, ["conf", "view", "--id", "123"])
96
+
97
+ assert result.exit_code == 0, result.output
98
+ assert "123" in result.output
99
+ assert "Page by ID" in result.output
100
+
101
+
102
+ @respx.mock
103
+ def test_c2_view_id_conflicts_with_space_title(both_envs):
104
+ """C2: view should fail if --id is used together with --space or --title."""
105
+ runner = CliRunner()
106
+
107
+ result = runner.invoke(
108
+ cli, ["conf", "view", "--id", "123", "--space", "DEMO", "--title", "Page"]
109
+ )
110
+
111
+ assert result.exit_code == 1
112
+ assert "--id cannot be used with --space or --title" in result.output
113
+
114
+
115
+ @respx.mock
116
+ def test_c2_view_requires_space_and_title_without_id(both_envs):
117
+ """C2: view should fail if neither --id nor (--space + --title) is provided."""
118
+ runner = CliRunner()
119
+
120
+ # Only --space without --title
121
+ result = runner.invoke(cli, ["conf", "view", "--space", "DEMO"])
122
+ assert result.exit_code == 1
123
+ assert "--space and --title are required when --id is not provided" in result.output
124
+
125
+ # Only --title without --space
126
+ result = runner.invoke(cli, ["conf", "view", "--title", "Page"])
127
+ assert result.exit_code == 1
128
+ assert "--space and --title are required when --id is not provided" in result.output
129
+
130
+
131
+ # C3 — search/list 结果缺 space 字段
132
+ @respx.mock
133
+ def test_c3_list_pages_includes_expand_space(both_envs):
134
+ """C3: list_pages should pass expand=space and output should include Space column."""
135
+ runner = CliRunner()
136
+
137
+ list_route = respx.get(
138
+ url__regex=r"https://conf\.example\.com/rest/api/content\?.*spaceKey=DEMO.*"
139
+ ).mock(
140
+ return_value=Response(
141
+ 200,
142
+ json={
143
+ "results": [
144
+ {
145
+ "id": "101",
146
+ "title": "Page One",
147
+ "space": {"key": "DEMO"},
148
+ },
149
+ {
150
+ "id": "102",
151
+ "title": "Page Two",
152
+ "space": {"key": "DEMO"},
153
+ },
154
+ ],
155
+ "size": 2,
156
+ },
157
+ )
158
+ )
159
+
160
+ result = runner.invoke(cli, ["conf", "list", "--space", "DEMO", "--limit", "10"])
161
+
162
+ assert result.exit_code == 0, result.output
163
+ assert list_route.called
164
+ req = list_route.calls.last.request
165
+ # Verify expand=space is in the query params
166
+ assert "expand=space" in str(req.url)
167
+ # Verify Space column is in the output
168
+ assert "Space" in result.output
169
+ assert "DEMO" in result.output
170
+
171
+
172
+ @respx.mock
173
+ def test_c3_search_includes_expand_space(both_envs):
174
+ """C3: search should pass expand=space and output should include Space column."""
175
+ runner = CliRunner()
176
+
177
+ search_route = respx.get(
178
+ url__regex=r"https://conf\.example\.com/rest/api/content/search\?.*"
179
+ ).mock(
180
+ return_value=Response(
181
+ 200,
182
+ json={
183
+ "results": [
184
+ {
185
+ "id": "201",
186
+ "title": "Search Result",
187
+ "space": {"key": "PROJ"},
188
+ }
189
+ ],
190
+ "size": 1,
191
+ },
192
+ )
193
+ )
194
+
195
+ result = runner.invoke(cli, ["conf", "search", "test", "--limit", "5"])
196
+
197
+ assert result.exit_code == 0, result.output
198
+ assert search_route.called
199
+ req = search_route.calls.last.request
200
+ # Verify expand=space is in the query params
201
+ assert "expand=space" in str(req.url)
202
+ # Verify Space column is in the output (search already had this, but verify it still works)
203
+ assert "Space" in result.output
204
+ assert "PROJ" in result.output
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes