Skip to main content
Glama

headcleaner

フォルダーをスキャンし、すべてのドキュメントを Markdown(フロントマター付き)、OKF v0.2(フロントマター付き)、またはその両方に変換します — omp スタイルのアニメーション TUI 付き。

headcleaner convert ~/Documents/inbox --format both --output ~/Documents/inbox.clean

headcleaner は、指定したディレクトリをスキャンし、各ドキュメントを拡張子で識別し、適切な抽出エンジン(Office 形式には OfficeCLI、PDF には pdfplumber、HTML には BeautifulSoup など)を実行して、クリーンで正規化された出力 — Markdown と OKF の並列、またはどちらか一方 — を生成する Python CLI です。

  • 出力形式: --format md(Markdown)、--format okf(OKF v0.2 バンドル)、--format both(デフォルト)

  • エンジン対応: 標準で 7 形式(XLSX、DOCX、PPTX、PDF、HTML、HTM、TXT)— 16 形式対応の v1.0 ロードマップは docs/FORMAT_MATRIX.md を参照

  • TUI: omp に着想を得たアニメーションターミナル(ボックス描画パネル、ネオンパレット、パワーラインセパレータ)

  • リンター: headcleaner lint は変換された Markdown / OKF をフォーマットの問題についてレビューします

  • メッセージ単位の PST: メールごとに 1 つの OKF コンセプトを生成(readpst 経由)し、レビュー/承認をファイル単位で行えます

  • office_oxide バックエンド: Office 形式向けの Pure-Rust の Python バインディング(OfficeCLI より約 100 倍高速)

  • ヒューリスティッククリーナップ: headcleaner convert --clean は any2md に着想を得た 12 段階のクリーンアップパイプラインを実行します

  • all2md フォールバック: all2md がインストールされている場合、追加の 38 形式(Jupyter、LaTeX、reST、sourcecode など)を自動処理します

  • headcleaner mcp: headcleaner を MCP サーバーとして実行し、14 個の okf_* ツールをあらゆる MCP エージェントホスト(Claude Code、Cursor など)に公開します — インストール: uv pip install \"headcleaner[mcp]\"

  • 診断: headcleaner doctor は Python、PATH、OfficeCLI、出力権限、@slug レジストリをチェックし、GO/NO-GO の判定を出力します

  • アダプタープラグイン: サードパーティパッケージは headcleaner_plugin エントリーポイントグループを通じて形式を登録します

  • zsv CSV: zsv が PATH にある場合、世界最速の SIMD CSV パーサー(標準ライブラリの約 10〜100 倍)を利用

  • 信頼のアテステーション: headcleaner attest は Merkle ルート + ed25519 署名を構築し、verify がそれを検証します

  • ローカルブラウズ: headcleaner serve <bundle> はブラウズと検索のための FastAPI UI を公開します

  • 誠実なデフォルト: OKF の信頼フィールドは unverified / human:pending で埋められ、決して捏造されません

インストール

# 1. The Office engine — single binary, no Office install needed
npm install -g @officecli/officecli

# 2. The CLI itself (Python ≥3.12, uv-managed)
uv tool install headcleaner

# Or for development:
git clone <this repo>
cd headcleaner-cli
uv sync
uv run headcleaner --help

他のインストール方法(curl | bash、pip、brew、Windows PowerShell)については、docs/INSTALL.md を参照してください。

クイックスタート

headcleaner ~/Documents/inbox --format both --output ./clean

これにより次が生成されます:

clean/
├── manifest.json                  # run summary: per-file status, engine, sha256
├── REPORT.md                      # count, average time, and error rate by engine
├── _md/                           # plain Markdown (one file per source)
│   ├── notes.docx.md
│   ├── q3.pdf.md
│   └── ...
└── okf/                           # OKF v0.2 bundle (one concept per source)
    ├── index.md                   # auto-generated directory index
    ├── notes.md                   # OKF concept: type=Document
    ├── q3.pdf.md
    └── ...

CLI リファレンス

headcleaner convert <INPUT_DIR> [OPTIONS]

Options:
  -f, --format {md,okf,both}   Output format(s) [default: both]
  -o, --output DIR             Output directory [default: ./out]
  --ocr                        Enable Tesseract OCR for scanned PDFs
  --officecli-timeout <secs>   Timeout per OfficeCLI subprocess call (default: 60)
  --include, -i GLOB           Include glob (may be repeated)
  --exclude, -e GLOB           Exclude glob (may be repeated)
  --jobs, -j N                Parallel worker processes (default: 1 = sequential)
  --no-cache                  Re-convert every file (skip the SHA-256 cache)
  --no-continue-on-error       Stop on the first failure
  --obsidian-compat            Add Obsidian-friendly flat fields to OKF frontmatter
  --clean                       Run the 12-stage heuristic cleanup pipeline (any2md-inspired) on each body
  --tui / --no-tui             Force / disable the animated TUI (default: auto-detect TTY)
  --no-okf-index               Skip OKF directory index.md generation

その他のコマンド: headcleaner doctor [--output-dir DIR] インストールと権限の診断を実行します headcleaner templates サポートされている形式を一覧表示します headcleaner agents エンジンのインストール状態を表示します headcleaner watch IN [--webhook-url URL] ファイル変更時に再変換します(停止するには Ctrl+C) headcleaner lint 変換された Markdown / OKF をフォーマットの問題についてレビューします headcleaner lint --fix 安全な問題を .fixed/ に自動修復します headcleaner serve OKF バンドル用のローカル HTTP ブラウザ headcleaner notion-import <EXPORT.zip> Notion ワークスペースエクスポートを逆変換します headcleaner attest Merkle ルートとオプションの ed25519 署名を計算します headcleaner verify バンドルに対するアテステーションを検証します

## Why OKF?

OKF (Open Knowledge Format, v0.2) is just **markdown + YAML frontmatter in a directory hierarchy**. That means:

- Every concept is a single `.md` file you can `cat`, `grep`, edit in any text editor
- Bundles live in git — pull requests, diffs, blame all work
- Obsidian, Notion, MkDocs, Hugo, Jekyll all consume OKF natively
- Required frontmatter key is just `type` — anything beyond that is producer freedom

See [docs/OKF_NOTES.md](docs/OKF_NOTES.md) for the OKF v0.2 specifics this CLI emits.

## Trust stance (honest defaults)

We never auto-claim review. Every emitted OKF concept gets:

- `status: unverified`
- `verified: human:pending`
- `generated: human:<user>@<host>` (OKF §7 actor convention)
- `stale_after: <today + 180d>`
- `sources: [{uri: file://..., sha256: ...}]`

A human can grep `human:pending` later to find concepts needing review. See [docs/OKF_NOTES.md](docs/OKF_NOTES.md) for the full contract.

## Supported formats

See [docs/FORMAT_MATRIX.md](docs/FORMAT_MATRIX.md) for the full engine × library table. At a glance:

| Format | Engine | Library |
|---|---|---|
| `.docx`, `.xlsx`, `.pptx` | OfficeCLI binary | (native DOM) |
| `.pdf` | pdfplumber (text-layer), pytesseract if `--ocr` | pdfplumber / pytesseract |
| `.html`, `.htm` | BeautifulSoup | beautifulsoup4 |
| `.txt` | chardet + read | chardet |
| `.md`, `.markdown` | pass-through + frontmatter inject | stdlib |
| `.csv`, `.tsv` | Sniffer dialect + GFM table (zsv SIMD when installed) | stdlib `csv` (or `zsv` binary) |
| `.json` | pretty-print + fenced block | stdlib `json` |
| `.eml` | headers + text/html body + attachments | stdlib `email` |
| `.epub` | per-chapter HTML → MD | ebooklib (+ bs4 fallback) |
| `.rtf` | control-word stripping | striprtf (+ regex fallback) |
| `.odt`, `.ods`, `.odp` | paragraph/row extraction + GFM tables | odfpy (+ raw-XML fallback) |
| `.msg` | Outlook headers + body + attachments | extract-msg |
| `.pst` | **per-message** (one OKF concept per email) | readpst (libpst) + libpff-python fallback |
| `.docx`, `.xlsx`, `.pptx` | **office_oxide** (primary, ~100x faster), OfficeCLI binary (fallback) | office_oxide 0.1.8 (PyO3) |
| `.ipynb`, `.latex`, `.rst`, sourcecode, `.enex`, `.chm`, etc. (38 formats) | all2md (when installed) | all2md 1.12 |
| `.doc`, `.xls`, `.ppt` | clear error path | needs `libreoffice --convert-to` first |

## Live mode

```bash
headcleaner watch ~/inbox --output ~/out --webhook-url https://hooks.slack.com/...

~/inbox 配下でファイルが変更されると、変換を自動的に再実行します。 再実行のたびにマニフェストを Webhook URL に POST します(オプション)。 停止するには Ctrl+C を押します。

Obsidian ボールト同期

headcleaner convert ~/inbox --format okf \
    --output ~/Documents/MyVault/Concepts \
    --obsidian-compat

OKF フロントマターに、Obsidian のプロパティパネルでコンセプトが正しく表示されるように、Obsidian 対応のフラットフィールド(sourcesha256generated_byverified_bystale_on)を追加します。元の OKF フィールドはラウンドトリップのためにそのまま保持されます。

レビュー(人間による承認)

自動変換では verified: human:pending が設定されます。headcleaner review TUI はバンドル内のすべての保留中コンセプトを順に表示し、人間がそれぞれを次のいずれかに切り替えられます:

  • approvedverified: human:reviewedstatus: verifiedreviewed_atreviewed_byreviewed_via

  • rejectedverified: human:rejectedstatus: rejected、 任意の rejection_reasons[]

  • skipped → コンセプトを pending のままにします

headcleaner review ./out/okf
# Textual TUI: a=approve, r=reject, s=skip, n=next, p=prev, q=quit

Textual が利用できない場合(例: ヘッドレス CI)、プレーンモードの REPL が自動的にフォールバックします。

配布

  • PyPI: pip install headcleaner(uv でビルド、タグプッシュ時に OIDC トラステッドパブリッシングで公開)

  • Homebrew: brew install headcleaner(Formula は packaging/homebrew/ にあり)

  • Docker: docker pull ghcr.io/local/headcleaner(tesseract を含むマルチステージイメージ)

  • Windows: winget install headcleanerscoop install headcleanerchoco install headcleaner

  • 静的バイナリ: pip install pyinstaller && pyinstaller packaging/pyinstaller/headcleaner.spec

完全なリリースチェックリストは RELEASE.md にあります。

CLI サーフェス

headcleaner view <bundle>(ターミナルで閲覧するには --tui を追加)は、OKF バンドルを単一の自己完結型 HTML グラフとしてレンダリングします(バックエンド不要、任意のブラウザで開けます)。全オプションは docs/VIEWER.md を参照してください。

headcleaner convert         IN_DIR [flags]    # walk + convert
headcleaner watch           IN_DIR [flags]    # live mode + webhooks
headcleaner review          BUNDLE            # human sign-off TUI/REPL
headcleaner attest          BUNDLE [--private-key PEM]   # Merkle root + optional ed25519 sig
headcleaner verify          BUNDLE [--public-key PEM]    # verify an attestation
headcleaner serve           BUNDLE [--host] [--port]    # local HTTP browser for the bundle
headcleaner glob            DIR               # interactive include REPL (Textual)
headcleaner notion-import   EXPORT.zip OUT    # reverse a Notion workspace export
headcleaner lint            DIR [--fix]       # OKF + MD rule checks
headcleaner doctor          [--output-dir]    # dependency and permission preflight
headcleaner agents          [stdout]          # emit AGENTS.md
headcleaner templates                        # list supported formats

ドキュメント

ドキュメント

目的

README.md

このファイル — インストール、クイックスタート、CLI リファレンス

docs/INSTALL.md

すべてのインストール方法(curl、pip、brew、PowerShell、uv、Docker)

docs/USAGE.md

実際の例を用いた詳細な使用ガイド

docs/ARCHITECTURE.md

パイプラインの全体像と拡張ポイント

docs/FORMAT_MATRIX.md

サポートされるすべての形式 × エンジン × ライブラリ

docs/OKF_NOTES.md

この CLI が出力する OKF v0.2 契約 + 信頼ポリシー

docs/SCHEMA.md

OKF フロントマターの JSON Schema とエディタ/CI 統合

docs/PLUGINS.md

サードパーティアダプターのエントリーポイントプロトコル

docs/TROUBLESHOOTING.md

一般的なエラーとその修正

docs/FAQ.md

よくある質問

docs/CONTRIBUTING.md

新しい形式 / エンジン / エミッターを追加する方法

docs/CHANGELOG.md

リリース履歴

docs/ENHANCEMENTS.md

44 以上の実装済み拡張 + 将来のアイデア

vscode-extension/README.md

HeadCleaner VS Code 拡張機能(Concept Explorer + Trust Inspector)

トラブルシューティング

officecli not foundnpm install -g @officecli/officecli でインストールしてください。確認には headcleaner agents を実行します。

テキストを抽出できない PDF — その PDF は画像のみです。--ocr を付けて再実行してください(pytesseract + PATH 上の Tesseract バイナリが必要です)。

隠しファイルはスキップされます — 意図的な動作です。. で始まるファイルはウォーカーによって除外されます。

ルートの OKF index.md がない場合 — バンドルに 1 以上のコンセプトがあると自動生成されます。無効にするには --no-okf-index を使用します。

詳細docs/TROUBLESHOOTING.md を参照してください。

開発

git clone <this repo>
cd headcleaner-cli
uv sync
uv run pytest                # 314 tests, ~14s
uv run headcleaner convert ./tests/fixtures --format both --output ./out

アーキテクチャ

src/headcleaner/
├── walk.py         # recursive folder walker
├── router.py       # extension → engine dispatch
├── normalize.py    # CanonicalDoc + OKF/MD frontmatter builders
├── lint.py         # post-conversion linter (OKF + Markdown)
├── run.py          # pipeline orchestrator
├── cli.py          # Click CLI (headcleaner command)
├── tui.py          # Textual TUI (omp-style)
├── engines/
│   ├── base.py     # Adapter ABC
│   ├── officecli.py
│   ├── pdf.py
│   ├── html.py
│   └── txt.py
└── emit/
    ├── markdown.py
    ├── okf.py
    ├── okf_index.py
    └── manifest.py

新しい形式を追加するには: engines/ にモジュールを配置し、router.py でアダプターを登録し、docs/FORMAT_MATRIX.md に行を追加します。完全な拡張ガイドは docs/CONTRIBUTING.md を参照してください。

ライセンス

Apache-2.0

-
license - not tested
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Markdown in, any format out. PDFs merged, split, watermarked. Runs on our own doc engines.

  • Markdown utilities MCP.

  • MCP server for AgentDocs (agentdocs.eu): read, search, write, comment on & share Markdown docs.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jamesdsizemore/headcleaner-cli'

If you have feedback or need assistance with the MCP directory API, please join our Discord server