feat(docs): add insert-table primitive#617
Open
chrischall wants to merge 2 commits into
Open
Conversation
Closes openclaw#602. Surfaces the Docs API InsertTableRequest as a standalone CLI subcommand that bypasses the markdown writer (openclaw#592 / openclaw#608 / openclaw#609 are all markdown-table-only bugs; agents need a path that doesn't go through that converter for table-shaped deliverables). Usage: gog docs insert-table <docId> --rows N --cols M [--index N | --at-end] \ [--values-json [[...]]] [--tab=STRING] Internals: - Reuses the existing TableInserter.InsertNativeTable so the structural insert, the post-insert Get-to-find-cell-indices, and the per-cell text inserts all go through the same path the markdown writer uses. - --values-json takes a JSON 2D string array whose dimensions must match --rows x --cols exactly. Empty values-json fills the table with empty cells. - --index / --at-end semantics match the new insert-page-break command and docs write --append: omit either → resolve to end-of-doc via docsTargetEndIndexAndTabID; --at-end is the explicit form. Tests cover the parseTableValuesJSON helper (empty, populated, row mismatch, column mismatch, malformed JSON) plus a table-driven Run- level check for every flag-validation branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #602.
Summary
Surfaces the Docs API `InsertTableRequest` as a standalone CLI subcommand that bypasses the markdown writer. The markdown path can render tables, but it has had several distinct rendering bugs (#592, #608, #609) and structural off-by-ones (#607) — for agent-generated table-shaped deliverables (itineraries, schedules, comparisons) a direct primitive is the cleanest backbone.
Usage
```
gog docs insert-table --rows N --cols M [--index N | --at-end] \
[--values-json [[...]]] [--tab=STRING]
```
Internals
Tests
`go test ./internal/cmd/ -count=1` → ok 23.8s.