Skip to content

feat(docs insert): add --markdown for positional formatted-markdown insertion#854

Merged
steipete merged 2 commits into
openclaw:mainfrom
sebsnyk:feat/docs-insert-markdown
Jun 19, 2026
Merged

feat(docs insert): add --markdown for positional formatted-markdown insertion#854
steipete merged 2 commits into
openclaw:mainfrom
sebsnyk:feat/docs-insert-markdown

Conversation

@sebsnyk

@sebsnyk sebsnyk commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What

Adds --markdown to gog docs insert, so a formatted markdown block (heading, fenced code block, list, table, image, inline styles) can be inserted at a position resolved by --index / --at / --occurrence, without deleting anything at the anchor.

Closes #851.

Why

docs insert already places content at an arbitrary position, but only as plain text — a heading or fenced code block inserted this way landed as literal, unformatted characters. The converted-markdown path already exists in the codebase and is already exposed on docs update --markdown (its non-replacing branch). So insert was the only positional command missing a capability the tool already has, which is a discoverability cliff: users reach for docs insert --markdown first, hit an unknown-flag error, and then have to learn that the converted path lives on update instead.

How

  • New --markdown bool on DocsInsertCmd.
  • When set, after the placement index is resolved, route through the existing insertPreparedDocsMarkdownAt helper and run the existing heading-link rewrite over the inserted range — mirroring the non-replacing branch of docs update --markdown. The shared converter (docsmarkdown.MarkdownToDocsRequests) is already parameterized on an arbitrary base index, so code-fence styling (Roboto Mono + grey shading) and everything else render identically to write --markdown.
  • --markdown is rejected together with --batch, since the markdown path issues its own documents.batchUpdate calls and cannot be queued into a persisted batch.
  • Plain (non---markdown) behavior is unchanged.

The split between the two commands stays clean: insert = place at a position, never delete; update --markdown --at / --replace-range = delete-and-replace.

Tests

  • TestDocsInsertCmd_MarkdownAtIndex — asserts a converted heading inserts at the resolved index with the converter's HEADING paragraph-style request (and that an explicit --index with no heading links issues no extra GET).
  • TestDocsInsertCmd_MarkdownRejectsBatch — asserts the --markdown + --batch guard.
  • Existing plain-insert tests unchanged and passing.

go build ./..., go vet ./internal/cmd/, and go test ./internal/cmd/ all pass. CHANGELOG and the generated docs insert command page + editing guide are updated.

sebsnyk and others added 2 commits June 19, 2026 17:28
…nsertion

`docs insert` placed content at a resolved index (--index/--at/--occurrence)
but only as plain text, so a heading or fenced code block landed unformatted.
The converted-markdown path already exists internally and is exposed on
`docs update --markdown`; this gives `insert` the same capability without
deleting anything at the anchor.

When --markdown is set, route through the existing insertPreparedDocsMarkdownAt
helper at the resolved index and run the heading-link rewrite over the inserted
range, mirroring the non-replacing branch of `docs update --markdown`. Reject
--markdown with --batch (the markdown path issues its own batchUpdate calls).

Closes openclaw#851

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 19, 2026, 1:06 PM ET / 17:06 UTC.

Summary
The branch adds a --markdown flag to gog docs insert, reuses the existing Docs markdown insertion helper with revision control, updates docs/changelog text, and adds focused unit tests.

Reproducibility: yes. for the missing capability: current main has no Markdown field on DocsInsertCmd and always uses a plain insert request. I did not run live CLI mutations because this is a read-only review.

Review metrics: 2 noteworthy metrics.

  • Touched surface: 6 files changed, 236 additions, 1 deletion. The diff spans command code, generated/user docs, changelog text, and tests, so review needs both behavior and documentation coverage.
  • Regression tests: 3 test functions added. The tests cover explicit-index conversion, anchor revision control, and rejection of markdown persisted batches.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #851
Summary: This PR is the open implementation candidate for the linked source-reproducible feature request.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted real Google Docs proof showing formatted markdown inserted at an index or anchor, preferably including at least a heading and fenced code block.
  • Keep private document IDs, account details, API keys, and non-public URLs redacted in posted proof.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Only unit/build/vet/test claims are present; the contributor should add redacted terminal output, a screenshot/video, logs, or a linked artifact showing gog docs insert --markdown against a real Google Doc, then update the PR body to trigger re-review or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] The PR still needs real Google Docs proof showing formatted insertion after the change; unit tests and claimed local commands do not prove headings, code styling, tables/images, tabs, and heading-link rewrites in the live Docs API path.

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused flag after maintainer review and redacted real-behavior proof, keeping the linked issue open until the candidate is merged or closed.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Needs human PR review because the external real-behavior proof gate is unmet and automation cannot provide proof from the contributor's Google Docs setup.

Security
Cleared: The diff adds a CLI flag, Docs API request reuse, docs, and tests without new dependencies, workflows, credential handling, or supply-chain execution paths.

Review details

Best possible solution:

Land the focused flag after maintainer review and redacted real-behavior proof, keeping the linked issue open until the candidate is merged or closed.

Do we have a high-confidence way to reproduce the issue?

Yes for the missing capability: current main has no Markdown field on DocsInsertCmd and always uses a plain insert request. I did not run live CLI mutations because this is a read-only review.

Is this the best way to solve the issue?

Yes, the proposed approach is the narrow maintainable path: it reuses the existing Docs markdown converter and insertion helper instead of adding a parallel renderer. The remaining merge gate is live behavior proof, not a different implementation shape.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d2e0bd74809d.

Label changes

Label changes:

  • add P3: This is a low-risk ergonomics and parity feature for an existing Docs command surface.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Only unit/build/vet/test claims are present; the contributor should add redacted terminal output, a screenshot/video, logs, or a linked artifact showing gog docs insert --markdown against a real Google Doc, then update the PR body to trigger re-review or ask a maintainer to comment @clawsweeper re-review.

Label justifications:

  • P3: This is a low-risk ergonomics and parity feature for an existing Docs command surface.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Only unit/build/vet/test claims are present; the contributor should add redacted terminal output, a screenshot/video, logs, or a linked artifact showing gog docs insert --markdown against a real Google Doc, then update the PR body to trigger re-review or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

What I checked:

  • Repository policy read: AGENTS.md was read fully; its PR review-mode guidance applied by staying on main and inspecting the PR with gh pr view/gh pr diff only. (AGENTS.md:1, d2e0bd74809d)
  • Current insert command lacks markdown mode: On current main, DocsInsertCmd defines placement, file, tab, and batch fields but no markdown flag; its mutation path submits a plain docsedit.BuildInsertRequest. (internal/cmd/docs_edit.go:883, d2e0bd74809d)
  • Existing positional markdown path: The sibling docs update --markdown non-replacing branch already inserts converted markdown at a resolved index and rewrites heading links over the inserted range. (internal/cmd/docs_edit.go:732, d2e0bd74809d)
  • Reusable helper is index-aware: insertPreparedDocsMarkdownAt parses markdown, uses the caller-supplied insert/base index, submits Docs formatting requests, and handles tables/images with the supplied tab ID. (internal/cmd/docs_mutation.go:279, d2e0bd74809d)
  • PR implementation scope: The PR diff adds the Markdown field, rejects --markdown with --batch, routes markdown inserts through the shared helper, and adds revision-controlled markdown insertion after anchor resolution. (internal/cmd/docs_edit.go:888, f0a0acef796c)
  • Regression tests in branch: The PR adds tests for explicit-index markdown conversion, anchor-based revision control, fenced-code styling, and the --markdown/--batch guard. (internal/cmd/docs_insert_markdown_test.go:17, f0a0acef796c)

Likely related people:

  • steipete: Authored most recent docs placement/markdown refactors in the central files and also added the PR branch revision-control follow-up. (role: recent area contributor; confidence: high; commits: 107b9fbbadc0, e527d5d4105c, f0a0acef796c; files: internal/cmd/docs_edit.go, internal/cmd/docs_mutation.go)
  • rel: Authored the merged docs update --markdown feature that is the closest existing positional markdown command surface reused by this PR. (role: adjacent feature author; confidence: medium; commits: c182ced42920; files: internal/cmd/docs_edit.go, internal/cmd/docs_mutation.go)
  • sebsnyk: Has prior merged Docs markdown/live-test work relevant to formatted Docs mutations, beyond being the proposer of this PR. (role: adjacent contributor; confidence: medium; commits: 58b866e9ac55, c172741709aa; files: internal/cmd/docs_edit.go, scripts/live-tests/structure.sh)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. labels Jun 19, 2026
@steipete
steipete merged commit ab9a331 into openclaw:main Jun 19, 2026
5 checks passed
@steipete

Copy link
Copy Markdown
Collaborator

Landed as ab9a331.

Verification:

  • go test ./internal/cmd ./internal/docsedit ./internal/docsmarkdown
  • make ci
  • Codex autoreview on the final branch diff: clean, no actionable findings.
  • Exact-head live Google Docs proof: created a disposable document, inserted a literal anchor, then ran docs insert --markdown --at ANCHOR with a heading, fenced code block, and list. docs raw readback showed HEADING_2, Roboto Mono with the expected code color, native bullet list IDs, and the original anchor still present after the inserted block. The disposable document was moved to trash afterward.
  • Required CI at head f0a0ace: test, image, worker, Windows, and Darwin CGO all passed.

Caveat: live proof covered anchor placement plus heading/code/list formatting; table, image, and tab variants continue through the pre-existing shared Markdown insertion helper and were covered by existing/unit paths rather than separate live mutations here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(docs insert): add --markdown for positional formatted-markdown insertion (parity with docs update --markdown)

2 participants