1---2name: oma-hwp3description: Convert HWP / HWPX / HWPML files to Markdown using kordoc. Extracts text, headings, tables, lists, images, footnotes, and hyperlinks. Use for Korean word processor files (Hangul), government documents, and AI-ready data preparation.4---5
6# HWP Skill - HWP / HWPX / HWPML to Markdown Conversion
7
8## Scheduling
9
10### Goal
11Convert Korean HWP-family documents into readable Markdown or structured JSON while preserving document structure for LLM context, RAG, government-document review, or enterprise document processing.
12
13### Intent signature
14- User asks to convert, parse, read, extract, or transform `.hwp`, `.hwpx`, or `.hwpml`.
15- User mentions Korean word processor files, Hangul documents, government forms, or "한글 파일".
16- User needs headings, tables, nested tables, lists, images, footnotes, or hyperlinks extracted from HWP-family files.
17
18### When to use
19- Converting Korean HWP documents (`.hwp`, `.hwpx`, `.hwpml`) to Markdown
20- Preparing Korean government/enterprise documents for LLM context or RAG
21- Extracting structured content (tables, headings, lists, images) from HWP
22- User says "convert this HWP", "parse hwpx", "HWP to markdown", "한글 파일"
23
24### When NOT to use
25- PDF files -> use `oma-pdf` (OCR + Tagged PDF specialization)
26- XLSX / DOCX files -> out of scope; run `bunx kordoc` directly if needed (note: `oma-docs` is the documentation-drift skill, not a converter)
27- Generating or editing HWP documents -> out of scope (kordoc itself supports `generate` / `fill` / `seal` / `patch` / `redact` / `lint` / `validate` / `render` subcommands; run `bunx kordoc@latest <subcommand>` directly if needed)
28- Already-text files -> use Read tool directly
29
30### Expected inputs
31- `input_path`: `.hwp`, `.hwpx`, or `.hwpml` file path
32- `output_path` or `output_dir`: optional explicit output target
33- `format`: optional output format — `markdown` (default), `json` (structured AST), or `chunks` (RAG-oriented structural chunk JSON with heading breadcrumbs and standalone table chunks)
34- `page_range`: optional page or section range
35- `kordoc_version`: optional pinned kordoc version
36
37### Expected outputs
38- Markdown output next to the input file or in the requested directory
39- Optional JSON or RAG-chunks output when requested
40- Post-processed Markdown with flattened GFM tables and stripped Private Use Area glyphs by default
41- A short report with output path, detected source format, and conversion issues
42
43### Dependencies
44- `bun` and `bunx`
45- `bunx kordoc@latest` or configured pinned kordoc version
46- `resources/flatten-tables.ts` for Markdown cleanup
47- Local filesystem access to input and output paths
48
49### Control-flow features
50- Branches by file extension, output target, format, page range, encryption/DRM state, and post-processing requirements
51- Calls external CLI tools through `bunx` and `bun run`
52- Reads local HWP-family files and writes local Markdown or JSON output
53- Routes non-HWP inputs to other skills instead of stretching this skill's scope
54
55## Structural Flow
56
57### Entry
581. Confirm the input path exists.
592. Confirm the extension is `.hwp`, `.hwpx`, or `.hwpml`.
603. Resolve output path or directory and default filename.
614. Check that `bun` is available.
62
63### Scenes
641. **PREPARE**: Validate path, extension, size, output target, and requested format.
652. **ACQUIRE**: Detect source format and runtime availability.
663. **ACT**: Run `kordoc` with explicit output target and requested options.
674. **VERIFY**: Post-process Markdown and inspect structure for headings, tables, lists, images, and footnotes.
685. **FINALIZE**: Report output path, source format, and any conversion limitations.
69
70### Transitions
71- If the input is `.pdf`, stop and route to `oma-pdf`.
72- If the input is `.xlsx` or `.docx`, explain that this skill does not advertise those formats.
73- If `bun` is unavailable, stop and ask the user to install Bun.
74- If Markdown is produced, run `resources/flatten-tables.ts` unless the caller explicitly needs HTML tables or PUA glyphs preserved.
75- If output is empty or garbled, consult `resources/troubleshooting.md`.
76
77### Failure and recovery
78| Failure | Recovery |
79|---------|----------|
80| `bun` or `bunx` unavailable | Ask user to install Bun |
81| Unsupported or mismatched format | Check extension and magic bytes, then route or stop |
82| Encrypted or DRM-locked document | Report limitation and request an accessible copy when needed |
83| Empty Markdown output | Treat as possible scanned-image content and recommend OCR outside this skill |
84| Complex merged tables | Accept flattened Markdown or HTML fallback as best effort |
85| Stale kordoc cache | Use `bunx kordoc@latest` or configured pinned version |
86| `Cannot find module "turndown"` from `flatten-tables.ts` | Run `bun install` in this skill's `resources/` directory (its `node_modules` is gitignored and absent on fresh clones) |
87
88### Exit
89- Success: output file exists and structure is readable after post-processing.
90- Partial success: output exists with explicitly reported table, glyph, encryption, or fidelity limitations.
91- Failure: no reliable output is produced and the blocking cause is reported.
92
93## Logical Operations
94
95### Actions
96| Action | SSL primitive | Evidence |
97|--------|---------------|----------|
98| Validate file path and extension | `VALIDATE` | Input preflight in execution protocol |
99| Check runtime availability | `VALIDATE` | `bun --version` |
100| Select output target and format | `SELECT` | Output behavior and config |
101| Run converter | `CALL_TOOL` | `bunx kordoc@latest` |
102| Write output artifact | `WRITE` | Markdown or JSON output |
103| Flatten tables and strip PUA glyphs | `CALL_TOOL` | `resources/flatten-tables.ts` |
104| Inspect extraction quality | `VALIDATE` | Verification step |
105| Report result | `NOTIFY` | Final user-facing summary |
106
107### Tools and instruments
108- `kordoc`: primary HWP-family conversion CLI
109- `flatten-tables.ts`: post-processing for GFM tables and Hancom PUA cleanup
110- `bun` / `bunx`: runtime and CLI executor
111
112### Canonical command path
113```bash
114bunx kordoc@latest "{input_path}" -o "{output_path}"
115# fresh clone: run `bun install` in {skill_dir}/resources/ first (node_modules is gitignored)
116bun "{skill_dir}/resources/flatten-tables.ts" "{output_path}"
117# {skill_dir} = this skill's directory: .agents/skills/oma-hwp (project mode) or ~/.agents/skills/oma-hwp (global mode)
118```
119
120For batch conversion, use an explicit output directory:
121```bash
122bunx kordoc@latest "{input_pattern}" -d "{output_dir}"
123```
124
125### Resource scope
126| Scope | Resource target |
127|-------|-----------------|
128| `LOCAL_FS` | Input HWP-family files and generated outputs |
129| `PROCESS` | `bunx kordoc` and `bun run` subprocesses |
130| `MEMORY` | Format decisions, validation notes, and final report |
131
132### Preconditions
133- Input file exists and is readable.
134- Output location is writable or can be created.
135- `bun` is installed.
136- `kordoc` can parse the document or fail with a reportable error.
137
138### Effects and side effects
139- Creates Markdown or JSON output files.
140- May flatten merged-cell tables, trading cell fidelity for Markdown compatibility.
141- Strips Private Use Area characters by default because they render as blanks without Hancom fonts.
142- Does not intentionally modify the source HWP-family document.
143
144### Guardrails
1451. Always pass `@latest` or an explicit pinned version to avoid stale `bunx` cache.
1462. Always pass an explicit output target when the user expects a file.
1473. Do not add custom security defenses around kordoc's ZIP, XML, SSRF, or XSS defenses.
1484. Report missing tables, garbled text, empty output, encrypted segments, and best-effort DRM extraction.
1495. Keep full CLI details in `resources/execution-protocol.md` and troubleshooting branches in `resources/troubleshooting.md`.
150
151### Supported Formats
152| Format | Extension | Notes |
153|--------|-----------|-------|
154| HWP 5.x binary | `.hwp` | Full support (incl. DRM-locked via kordoc's rhwp-algorithm port) |
155| HWPX | `.hwpx` | Full support incl. nested tables, merged cells |
156| HWPML | `.hwp` (XML variant) | Auto-detected by signature |
157
158> kordoc also parses PDF / XLSX / DOCX and offers document-authoring subcommands (`generate`, `fill`, `seal`, `patch`, `redact`, `lint`, `validate`, `render`). All of those are intentionally outside this skill's scope; see "When NOT to use". Conversion-quality flags (`--dedupe-headers`, `--keep-empty-cols`, `--inline-images`) and the `chunks` format are documented in `resources/execution-protocol.md`.
159
160## References
161- Execution protocol: `resources/execution-protocol.md`
162- Troubleshooting: `resources/troubleshooting.md`
163- Configuration: read the `hwp:` section of `.agents/oma-config.yaml` first, then fall back to `config/hwp-config.yaml` for any key it does not set (`supported_formats` lives only in the skill config). User overrides belong in `.agents/oma-config.yaml`, since `oma update` overwrites the skill config.
164- Upstream: https://github.com/chrisryugj/kordoc
165- Related: `../oma-pdf/SKILL.md` (use for `.pdf` inputs)