Skip to content

feat(docs): add insert-page-break primitive#614

Merged
steipete merged 4 commits into
openclaw:mainfrom
chrischall:feat/604-docs-insert-page-break
May 20, 2026
Merged

feat(docs): add insert-page-break primitive#614
steipete merged 4 commits into
openclaw:mainfrom
chrischall:feat/604-docs-insert-page-break

Conversation

@chrischall
Copy link
Copy Markdown
Contributor

Closes #604.

Summary

Surfaces the Docs API `InsertPageBreakRequest` as a standalone CLI subcommand. Markdown has no native page-break construct that the markdown writer can translate, and `docs format` only restyles existing content — so this is the first structural-element insert primitive on the docs side.

Usage

```
gog docs insert-page-break [--index N | --at-end] [--tab=STRING]
```

Aliases: `page-break`, `pb`.

Form Behaviour
insert-page-break <id> Insert at end-of-doc (default; uses docsTargetEndIndexAndTabID + docsAppendIndex, same helpers as docs write --append)
insert-page-break <id> --at-end Explicit end-of-doc
insert-page-break <id> --index N Insert at body index N (>=1)
… --tab=Name Works with both forms; tab resolved by title or ID

--at-end and --index are mutually exclusive. --index < 1 is rejected (index 0 is reserved, matching the existing docs insert guard).

Tests

  • TestDocsInsertPageBreakCmd_ExplicitIndex — verifies single InsertPageBreakRequest with the given index and no extra GET.
  • TestDocsInsertPageBreakCmd_DefaultsToEndOfDoc — omitted flags → one GET + insert at endIndex - 1.
  • TestDocsInsertPageBreakCmd_AtEndFlag — explicit --at-end behaves identically.
  • TestDocsInsertPageBreakCmd_AtEndAndIndexRejected — mutual exclusion guard.
  • TestDocsInsertPageBreakCmd_NegativeIndexRejected--index=-1 rejected with the same message as docs insert.
  • TestDocsInsertPageBreakCmd_WithTab — tabs resolution + Location.TabId populated.

go test ./internal/cmd/ -count=1 → ok 23.5s.

Notes

This PR contains 2 commits — the feature, plus a follow-up gofmt re-alignment of the DocsCmd struct tags after adding the new field. Happy to squash on merge.

chrischall and others added 4 commits May 20, 2026 21:16
Closes openclaw#604.

Surfaces the Docs API InsertPageBreakRequest as a standalone CLI
subcommand. Markdown has no native page-break construct that the
markdown writer can translate, and docs format only restyles existing
content, so this is the first structural-element insert primitive on
the docs side.

Usage:
  gog docs insert-page-break <docId> [--index N | --at-end] [--tab=STRING]

Behaviour:
- Omitted --index and --at-end both insert at end-of-doc (matches the
  existing docs write --append default; uses the same
  docsTargetEndIndexAndTabID + docsAppendIndex helpers).
- --index N (>=1) inserts at the explicit body index; --at-end is
  explicit form of the default. The two are mutually exclusive.
- --tab supports both --index and --at-end paths.

Aliases: `page-break`, `pb`.

Tests cover explicit index, --at-end, default end-of-doc, --tab,
mutual exclusion of --at-end + --index, and the negative-index guard.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Realigned by gofmt after adding the InsertPageBreak field.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@steipete steipete force-pushed the feat/604-docs-insert-page-break branch from a8c5754 to 4021e5c Compare May 20, 2026 20:22
@steipete steipete merged commit 9d61f2e into openclaw:main May 20, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(docs): insert-page-break primitive

2 participants