From 4ed3930df045c8ebe52681140d9bc6039557fd80 Mon Sep 17 00:00:00 2001 From: AngelMsger Date: Mon, 18 May 2026 22:02:21 +0800 Subject: [PATCH] Add page version history, restore and watch commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements tier 2 of the practical-coverage roadmap. Version history — `page history` lists a page's versions; `page restore --version N` rolls a page back. Restore has no native v1 endpoint, so it fetches version N's body and republishes it as a new version via the existing buildUpdatePage machinery — non-destructive, the history is kept. `restore` supports `--dry-run`. Watchers — `page watch` / `page unwatch` subscribe or unsubscribe the authenticated user (the v1 user-watch endpoints act on the credentialed user, so no current-user resolution is needed); `page watch-status` reports whether you watch a page. `watch` / `unwatch` support `--dry-run`. Each write op exposes a build* helper shared with `DescribeWrite`, keeping the --dry-run preview in lock-step with the sent request. Regenerates the CLI reference and updates the embedded confluence Skill. Co-Authored-By: Claude Opus 4.7 --- CHANGELOG.md | 7 ++ docs/cli/README.md | 5 + docs/cli/index.html | 81 +++++++++++++ internal/apiclient/client.go | 6 + internal/apiclient/mapping.go | 37 +++++- internal/apiclient/models.go | 24 ++++ internal/apiclient/pages_write.go | 4 + internal/apiclient/versions.go | 85 ++++++++++++++ internal/apiclient/versions_test.go | 110 ++++++++++++++++++ internal/apiclient/watch.go | 53 +++++++++ internal/apiclient/watch_test.go | 91 +++++++++++++++ internal/app/app_test.go | 17 +++ internal/app/page.go | 2 + internal/app/page_history.go | 91 +++++++++++++++ internal/app/page_watch.go | 84 +++++++++++++ internal/app/writes_test.go | 92 +++++++++++++++ skills/confluence/SKILL.md | 18 ++- skills/confluence/references/writing-pages.md | 26 +++++ 18 files changed, 825 insertions(+), 8 deletions(-) create mode 100644 internal/apiclient/versions.go create mode 100644 internal/apiclient/versions_test.go create mode 100644 internal/apiclient/watch.go create mode 100644 internal/apiclient/watch_test.go create mode 100644 internal/app/page_history.go create mode 100644 internal/app/page_watch.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 57eb520..97842da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Page version history: `page history` lists a page's versions, and + `page restore --version N` rolls a page back by republishing that version's + body as a new version (non-destructive — the history is kept). `restore` + supports `--dry-run`. +- Page watch commands: `page watch` / `page unwatch` subscribe or unsubscribe + the authenticated user, and `page watch-status` reports whether you watch a + page. `watch` / `unwatch` support `--dry-run`. - Attachment write commands: `attachment upload` attaches a file to a page, `attachment update` replaces an attachment's content with a new version, and `attachment delete` removes one. Uploads use `multipart/form-data`; `--file -` diff --git a/docs/cli/README.md b/docs/cli/README.md index db4f738..1fefad3 100644 --- a/docs/cli/README.md +++ b/docs/cli/README.md @@ -70,8 +70,13 @@ is published at . | [`confluence-cli page delete`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-delete) | Delete a page (move it to the trash) | | [`confluence-cli page descendants`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-descendants) | List all descendant pages of a page | | [`confluence-cli page get`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-get) | Fetch a page and render its body | +| [`confluence-cli page history`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-history) | List a page's version history | | [`confluence-cli page move`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-move) | Move a page under a new parent and/or space | +| [`confluence-cli page restore`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-restore) | Restore a page to an earlier version | +| [`confluence-cli page unwatch`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-unwatch) | Stop watching a page | | [`confluence-cli page update`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-update) | Update a page's title and/or body | +| [`confluence-cli page watch`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-watch) | Watch a page (subscribe to its notifications) | +| [`confluence-cli page watch-status`](https://angelmsger.github.io/confluence-cli/cli/#confluence-cli-page-watch-status) | Report whether you watch a page | ## search diff --git a/docs/cli/index.html b/docs/cli/index.html index c0f1ea5..689e224 100644 --- a/docs/cli/index.html +++ b/docs/cli/index.html @@ -74,8 +74,13 @@ confluence-cli page delete confluence-cli page descendants confluence-cli page get + confluence-cli page history confluence-cli page move + confluence-cli page restore + confluence-cli page unwatch confluence-cli page update + confluence-cli page watch + confluence-cli page watch-status
search
@@ -606,6 +611,23 @@

Examples

  # render the whole page as Markdown
     
     
+    
+

confluence-cli page history

+

List a page's version history

+
confluence-cli page history <id|url> [flags]
+ +

Options

+ + + + + + +
FlagDefaultDescription
--allfalsefetch every page of results
--limit0page size (default from config)
+

Examples

  confluence-cli page history 123456
+  confluence-cli page history 123456 --all --format table
+
+

confluence-cli page move

Move a page under a new parent and/or space

@@ -627,6 +649,41 @@

Examples

  # reparent a page
   confluence-cli page move 123456 --target-space DOCS
+
+

confluence-cli page restore

+

Restore a page to an earlier version

+
confluence-cli page restore <id|url> --version <N> [flags]
+

Republish an earlier version's body as a new version. The restore is +non-destructive: the version history is left intact. Run `page history` +first to find the version number to restore.

+

Options

+ + + + + + + +
FlagDefaultDescription
--dry-runfalseprint the request without sending it
--messageversion comment for the restore
--version0the version number to restore
+

Examples

  confluence-cli page restore 123456 --version 3
+  confluence-cli page restore 123456 --version 3 --message "roll back bad edit"
+
+ +
+

confluence-cli page unwatch

+

Stop watching a page

+
confluence-cli page unwatch <id|url> [flags]
+ +

Options

+ + + + + +
FlagDefaultDescription
--dry-runfalseprint the request without sending it
+

Examples

  confluence-cli page unwatch 123456
+
+

confluence-cli page update

Update a page's title and/or body

@@ -655,6 +712,30 @@

Examples

  # retitle a page, keeping its body
     
+
+

confluence-cli page watch

+

Watch a page (subscribe to its notifications)

+
confluence-cli page watch <id|url> [flags]
+ +

Options

+ + + + + +
FlagDefaultDescription
--dry-runfalseprint the request without sending it
+

Examples

  confluence-cli page watch 123456
+
+ +
+

confluence-cli page watch-status

+

Report whether you watch a page

+
confluence-cli page watch-status <id|url>
+ + +

Examples

  confluence-cli page watch-status 123456
+
+