Skip to content

Add wrap-unwrap extension#27655

Open
chrismessina wants to merge 2 commits intoraycast:mainfrom
chrismessina:sync/wrap-unwrap
Open

Add wrap-unwrap extension#27655
chrismessina wants to merge 2 commits intoraycast:mainfrom
chrismessina:sync/wrap-unwrap

Conversation

@chrismessina
Copy link
Copy Markdown
Contributor

Description

Adds Wrap Unwrap, a new extension with two no-view commands for Markdown-aware text reflow:

  • Wrap Text — wrap selected (or clipboard) text at a configurable column width. The classifier is prefix-aware: blockquote markers (> ) and list-item markers (- , hang indent) count toward the line budget so wrapped output stays within the chosen column width including its prefix.
  • Unwrap Text — reflow wrapped text into continuous paragraphs while preserving Markdown structure: ATX/setext headings, fenced and indented code, blockquotes (with nesting), bullet/ordered/task lists, pipe tables, HTML blocks, reference link definitions, and hard breaks. Optional soft-hyphen stripping (inter- + estinginteresting) and blank-line preservation.

Shared preferences follow the Change Case extension's conventions: Preferred Source (selection vs clipboard, with fallback), Primary Action (paste vs copy), Hide HUD, Pop to Root.

The extension also exposes a cross-extension provider interface (LitoMore convention) using only built-in Raycast SDK primitives — other extensions can launch wrap/unwrap with a launchContext.text and a callbackLaunchOptions to receive the result.

Source repo: https://github.com/chrismessina/raycast-wrap-unwrap

Screencast

See metadata/screenshot-01.png (2000×1250) included in this PR.

Checklist

Markdown-aware text reflow with two no-view commands:
- Wrap Text: wrap lines at a configurable column width, prefix-aware
  for blockquotes and list items.
- Unwrap Text: reflow wrapped text into continuous paragraphs, preserving
  Markdown structure (code fences, lists, blockquotes, tables, links,
  hyphenation, hard breaks).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@raycastbot raycastbot added new extension Label for PRs with new extensions platform: macOS labels May 4, 2026
@raycastbot
Copy link
Copy Markdown
Collaborator

Congratulations on your new Raycast extension! 🚀

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days.

Once the PR is approved and merged, the extension will be available on our Store.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 4, 2026

Greptile Summary

This PR introduces the Wrap Unwrap extension with two no-view commands — Wrap Text and Unwrap Text — that perform Markdown-aware text reflow. The implementation is thorough: a shared classifier handles all major CommonMark block types (fenced/indented code, blockquotes, lists, tables, headings, HTML blocks, hard breaks), inline token protection prevents splitting inside code spans and links during greedy fill, and a cross-extension callback interface follows the LitoMore convention. The test suite covers edge cases well (hard breaks, soft-hyphen stripping, oversized tokens, CRLF normalisation).

Confidence Score: 5/5

This is a brand-new, self-contained extension with no changes to existing extensions; it is safe to merge.

All changed files are net-new additions for a single extension. The core reflow logic is well-tested, the Raycast API surface is used correctly (auto-generated preference types, no unused dependencies, correct no-view mode), and the ESLint/CHANGELOG/manifest conventions are all followed. No logic errors or correctness issues were found in the wrapping, unwrapping, or classification paths.

No files require special attention.

Important Files Changed

Filename Overview
extensions/wrap-unwrap/package.json Well-formed Raycast extension manifest: $schema present, correct textfield type for width preference (no number type in preferences API), getPreferenceValues uses auto-generated types, no unused dependencies.
extensions/wrap-unwrap/src/lib/pipeline.ts Shared plumbing for both commands: content sourcing, size guard, cross-extension callback delivery, error reporting. Logic is sound; readContent fans out clipboard and selection reads concurrently; deliver correctly short-circuits to callback when callbackLaunchOptions is present.
extensions/wrap-unwrap/src/lib/classify.ts Line classifier that handles all major Markdown block types. The two-pass architecture (setext/table/hard-break passes after the main scan) is well-structured. Minor: applySetextPass can promote an hr-classified --- line to heading-setext when it follows prose — correct per CommonMark precedence but implicit.
extensions/wrap-unwrap/src/lib/wrap.ts Greedy word-fill wrapping with correct prefix-aware budgets for blockquotes and list items. Hard-break markers are stripped before fill and re-appended to the last output line.
extensions/wrap-unwrap/src/lib/unwrap.ts Group-based reflow: hard-break-terminated groups are correctly prevented from absorbing continuations via the endHardBreak guard, and the trailing-space/backslash suffix is preserved through rec.content.
extensions/wrap-unwrap/src/lib/inline.ts Module-level global regexes used exclusively with String.prototype.replace(), which resets lastIndex to 0 before each replacement pass — no stale-index hazard across calls.
extensions/wrap-unwrap/eslint.config.mjs Correct ESLint v9 flat-config format using defineConfig from eslint/config with the Raycast preset.
extensions/wrap-unwrap/CHANGELOG.md Uses {PR_MERGE_DATE} placeholder correctly; changelog exists and covers all added functionality.

Reviews (2): Last reviewed commit: "fix(wrap-unwrap): address review feedbac..." | Re-trigger Greptile

Comment thread extensions/wrap-unwrap/package.json
Comment thread extensions/wrap-unwrap/src/lib/wrap.ts
- Drop unused @raycast/utils dependency
- Hoist samePrefixStack from unwrap.ts to classify.ts; reuse in wrap.ts
  so both transforms apply the same depth + spaceAfter check on
  blockquote prefix continuity

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chrismessina
Copy link
Copy Markdown
Contributor Author

@greptile could you take another look?

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

Labels

new extension Label for PRs with new extensions platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants