Skip to content

feat: block-level CLI ops + simplification#4

Merged
max4c merged 1 commit intomainfrom
feature/cli-block-ops-simplify
Mar 9, 2026
Merged

feat: block-level CLI ops + simplification#4
max4c merged 1 commit intomainfrom
feature/cli-block-ops-simplify

Conversation

@max4c
Copy link
Owner

@max4c max4c commented Mar 7, 2026

Summary

  • Add block command group with list, get, replace, update-text, insert, move, delete subcommands for granular markdown block editing
  • Add page format, page compact, page ensure-block-ids, page strip-block-ids subcommands
  • Add block ID persistence support in MarkdownBlockParser (parse/serialize <!-- block-id: ... --> comments)
  • Add install command and install script
  • Add comprehensive CLI test suite (1643 lines, covering block ops, page mutations, formatting)

Simplification

  • Deduplicated preview computation in PageCommand.Update.run() — preview was computed identically in both dryRun and non-dryRun branches (~30 lines removed)
  • Extracted lookupBlock helper from resolveWorkspacePageBlock to eliminate double document parsing in previewWorkspacePageBlockUpdate, previewWorkspacePageBlockTextUpdate, and previewWorkspacePageBlockMove
  • Hoisted loadWorkspacePage before output switch statements

Test plan

  • swift build succeeds
  • All 290 tests pass
  • Block operations, page formatting, and update commands verified through test suite

🤖 Generated with Claude Code

Add block command group (list, get, replace, update-text, insert, move, delete),
page format/compact/ensure-block-ids/strip-block-ids subcommands, block ID
persistence in MarkdownBlockParser, install command, and comprehensive CLI tests.

Simplification: deduplicate preview computation in Update.run() (removed ~30 lines
of copy-paste between dryRun branches), eliminate double document parsing in block
preview functions by extracting lookupBlock helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d823c1ab4c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +208 to +209
if lines.count > 1, lines.last == "" {
lines.removeLast()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve trailing empty paragraph blocks when parsing

PageBlockParser.parseBlocks unconditionally drops the last empty line, but serialized block-ID output uses a trailing empty line to represent a final empty paragraph block. For pages that end with an empty paragraph (including the default page create template # Title\n\n), this turns the last block into an orphan <!-- block-id: ... --> comment on the next parse, so the block disappears and its persisted selector can no longer be resolved.

Useful? React with 👍 / 👎.


init(markdown: String) {
let (metadata, content) = MarkdownBlockParser.parseMetadata(markdown)
self.persistsBlockIDs = content.contains("<!-- block-id:")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Derive ID persistence from valid block-id comments

BlockDocument enables includeBlockIDComments based on a raw substring check (content.contains("<!-- block-id:")), which treats arbitrary user comments as internal ID markers. If a note contains a non-UUID comment like <!-- block-id: draft -->, opening and saving it will unexpectedly inject generated block-id comments throughout the document even though no valid persisted IDs were present.

Useful? React with 👍 / 👎.

@max4c max4c merged commit d823c1a into main Mar 9, 2026
1 of 2 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.

1 participant