Flatten Markdown/HTML for human-readable paste + PowerShell/prompt cleanup, --agent preset, MCP server & hook#1
Merged
Conversation
Add a stripFences transform that removes code-block delimiter lines so output pastes into email/Slack as plain text with no fences: - Markdown fences (>=3 backticks or tildes, optional indent + info string), opening and closing, leaving the wrapped content intact. - PowerShell error underlines (the "+ ~~~~~" run under a bad token). On by default; --no-fences / keep-fences to disable. Wired through the pipeline, CLI flags, config validation, and library exports, with unit tests and README/CHANGELOG updates. https://claude.ai/code/session_01MmJKvYLG7wM3kyNGBv5Ydp
…ent, MCP server + hook Phase 1 (engine): - flattenMarkdown: headings, **bold**/*italic*/~~strike~~, inline `code`, list markers, [text](url) -> text (url); fenced + inline code kept VERBATIM via NUL sentinels (shielded from inline strip + typography). Opt-in (-m / --markdown). - htmlToText (--html), cleanPowerShell (--powershell/--ps: ~ underlines + "+ " gutter), stripPrompts (--prompts), reflowParagraphs (--reflow). - decodeInput: UTF-16 LE/BE + BOM detection so Windows input doesn't mojibake. - --agent preset: denoise for feeding output INTO a model (keep Markdown/Unicode). - Markdown/HTML/reflow/prompts/PowerShell enabled in --email / --plain presets. - Markdown pipe-table alignment rows (| :--: |) recognized by the table engine. Phase 2 (distribution): - socb-mcp: stdio MCP server exposing sanitize_text(text, preset?, options?) for Claude Desktop/Code and Codex. @modelcontextprotocol/sdk as an optional dep so the plain CLI path stays dependency-free. - Experimental Claude Code PreToolUse hook (hooks/socb-clean.mjs) that rewrites noisy Bash commands through `socb --agent`, preserving the original exit code. Tests: 186 pass (markdown/html/powershell/prompts/reflow/decode units; colon table alignment; CLI preset/override integration; MCP server over stdio; hook decision logic). Typecheck clean. Co-Authored-By: Claude Opus 4.8 (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.
Grows the original fence/underline strip into a comprehensive make-it-paste-ready feature set, plus agent integration.
Phase 1 — engine
-m/--markdown; on in--email/--plain): headings,**bold**/*italic*/~~strike~~, inline`code`, list markers,[text](url)→text (url), autolinks/images. Fenced and inline code are kept verbatim — shielded from both inline stripping and typography via a NUL-sentinel pass. Opt-in, so a baresocbnever mangles raw terminal output.--html): strip tags/script/style, decode entities.--powershell/--ps): drop~~~~underlines and the+continuation gutter, block-anchored so diffs are safe.--prompts) and paragraph reflow (--reflow, conservative).--agentpreset: denoise for feeding output into a model — strip ANSI/box/glyph noise but keep Markdown structure + Unicode.| :--: |) recognized by the table engine.Phase 2 — distribution
socb-mcp): stdio server exposingsanitize_text(text, preset?, options?)for Claude Desktop/Code and Codex.@modelcontextprotocol/sdkis an optional dependency, so the plain CLI path stays dependency-free.hooks/socb-clean.mjs): rewrites noisy Bash commands throughsocb --agentbefore output hits the model's context, preserving the original exit code. (PostToolUse can't rewrite output — verified against the hooks docs — so PreToolUseupdatedInputis the mechanism.)Tests
186 passing: unit tests for every new transform (incl. false-positive guards for
my_var_name,ls *.py, code-span protection, idempotence) + decode; CLI preset/override integration; MCP server driven over stdio via the SDK client; hook decision logic. Typecheck clean.🤖 Generated with Claude Code