GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: v0.3.0 IR S4 — rhwp-py CLI + LangChain include_furniture + Sche… · DanMeon/rhwp-python@7f0a319

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • ci.yml
    • publish-schema.yml
  • CHANGELOG.md
  • README.md
  • docs/implementation/v0.3.0/stages
    • stage-4.md
  • pyproject.toml
  • python/rhwp
    • cli
      • __init__.py
      • __main__.py
      • _state.py
      • app.py
      • chunks.py
      • ir.py
    • integrations
      • langchain.pyi
      • langchain.py
  • tests
    • test_cli.py
    • test_langchain_loader_ir.py
  • uv.lock
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/ci.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272
tests/test_ir_formula.py tests/test_ir_footnote.py \
7373
tests/test_ir_list.py tests/test_ir_caption.py \
7474
tests/test_ir_toc.py tests/test_ir_field.py \
75+
tests/test_cli.py \
7576
tests/conftest.py tests/type_check_samples.py
7677
- name: Run pyright (intentional errors — expect 4)
7778
if: matrix.lint
@@ -128,12 +129,12 @@ jobs:
128129
- run: uv run maturin develop --release
129130
- name: Run pytest — extras-gated tests must auto-skip via importorskip
130131
# ^ 파일-레벨 importorskip 은 해당 파일 전체를 skip 1개로 카운트.
131-
# 현재 gated 파일: test_langchain_loader.py + test_langchain_loader_ir.py
132+
# v0.3.0 S4 기준 gated 파일: test_langchain_loader.py + test_langchain_loader_ir.py
132133
# (langchain-core), test_ir_schema_export.py (jsonschema),
133-
# test_async.py (aiofiles) → 총 4 파일
134+
# test_async.py (aiofiles), test_cli.py (typer) → 총 5 파일
134135
run: |
135136
uv run pytest tests/ -m "not slow" -v | tee pytest-output.txt
136-
if ! grep -qE '(^|[^0-9])4 skipped([^0-9]|$)' pytest-output.txt; then
137-
echo "::error::expected 4 extras-gated files to auto-skip via importorskip (langchain×2, jsonschema, aiofiles)"
137+
if ! grep -qE '(^|[^0-9])5 skipped([^0-9]|$)' pytest-output.txt; then
138+
echo "::error::expected 5 extras-gated files to auto-skip via importorskip (langchain×2, jsonschema, aiofiles, typer)"
138139
exit 1
139140
fi
Collapse file

‎.github/workflows/publish-schema.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/publish-schema.yml
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ on:
88
push:
99
branches: [main]
1010
paths:
11-
- 'python/rhwp/ir/schema/hwp_ir_v1.json'
11+
# ^ glob — v2 도입 시 hwp_ir_v2.json 만 변경되어도 자동 트리거
12+
- 'python/rhwp/ir/schema/hwp_ir_v*.json'
1213
- 'python/rhwp/ir/nodes.py'
1314
- 'python/rhwp/ir/schema.py'
1415
- '.github/workflows/publish-schema.yml'
@@ -54,11 +55,16 @@ jobs:
5455
runs-on: ubuntu-latest
5556
steps:
5657
- uses: actions/checkout@v6
57-
- name: Prepare pages directory — copy every versioned schema
58+
- name: Prepare pages directory — copy versioned schema + content-addressed alias
5859
# ^ 불변 경로 정책: repo 의 hwp_ir_v*.json 을 모두 각 버전 URL 로 배포.
5960
# v2 도입 시 python/rhwp/ir/schema/hwp_ir_v2.json 을 추가하기만 하면
6061
# 이 루프가 자동으로 v1/v2 양쪽 모두를 pages 아티팩트에 포함한다.
6162
# `actions/deploy-pages@v4` 의 replace-all 동작으로 v1 이 누락되는 것을 원천 차단.
63+
#
64+
# Content-addressed alias (v0.3.0 S4 추가, ir-expansion.md § 스키마 버저닝):
65+
# 같은 v1 URL 안에서 minor bump (1.0 → 1.1) 가 발생할 때마다 hash-tagged
66+
# immutable alias 를 alongside 발행. 구 hash 는 영구 보존되어 SchemaStore /
67+
# 외부 도구가 정확한 스냅샷을 reproducible 하게 참조 가능.
6268
run: |
6369
set -euo pipefail
6470
mkdir -p pages/schema/hwp_ir
@@ -69,7 +75,10 @@ jobs:
6975
ver="${name#hwp_ir_}" # v1, v2, ...
7076
mkdir -p "pages/schema/hwp_ir/$ver"
7177
cp "$f" "pages/schema/hwp_ir/$ver/schema.json"
72-
echo "Published $f -> pages/schema/hwp_ir/$ver/schema.json"
78+
sha=$(shasum -a 256 "$f" | awk '{print $1}')
79+
alias="pages/schema/hwp_ir/${name}-sha256-${sha}.json"
80+
cp "$f" "$alias"
81+
echo "Published $f -> $ver/schema.json + alias ${name}-sha256-${sha}.json"
7382
copied=$((copied + 1))
7483
done
7584
if [ "$copied" -eq 0 ]; then
Collapse file

‎CHANGELOG.md‎

Copy file name to clipboardExpand all lines: CHANGELOG.md
+69-1Lines changed: 69 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,73 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.3.0] — 2026-04-28
11+
12+
MINOR release — Phase 2 두 축 동시 GA. v0.2.0 의 Document IR v1.0 위에 HWP 고유 의미 요소 8 종을 추가하고 (SchemaVersion 1.1), 동시에 Python 고유 가치 (IR/LangChain 청크/스키마 export) 를 shell 에서 직접 소비할 수 있는 `rhwp-py` CLI 를 재도입한다. 모든 v0.2.0 공개 API 보존 — 추가만 있고 기존 코드는 그대로 동작.
13+
14+
상류 `edwardkim/rhwp` 커밋 핀은 v0.2.0 그대로 (`bea635b`) — IR 확장은 상류가 이미 노출하는 first-class struct/enum (Picture, Equation, Footnote/Endnote, Caption, Field/FieldType, Header/Footer, ParaShape) 의 매핑을 채우는 작업이며 상류 변경 없이 가능했다.
15+
16+
### Added — Document IR v1.1 (8 신규 블록 + Furniture 채움)
17+
18+
- `PictureBlock` (S1) — 이미지. `image: ImageRef | None` (URI 스킴 `bin://<bin_data_id>` 기본), `caption: CaptionBlock | None` (S3 부터), `description: str | None` (HWP alt-text). `Document.bytes_for_image(picture)` 헬퍼로 raw bytes 해석.
19+
- `FormulaBlock` (S2) — 수식. `script: str` (HWP equation script raw) + `script_kind: Literal["hwp_eq", "latex", "mathml"]` + `text_alt: str | None` (RAG 폴백 평문 근사). LaTeX/MathML 자동 변환은 v0.3.0 미제공 (공개 변환기 부재).
20+
- `FootnoteBlock` / `EndnoteBlock` (S2) — 각주 / 미주. `blocks: list[Block]` 재귀, `marker_prov` (본문 인용 위치) 와 `prov` (각주 본문 위치) 분리. 각주/미주 본문은 `furniture.footnotes` / `endnotes` 로 라우팅 — body 검색 오염 회피.
21+
- `ListItemBlock` (S3) — 목록 항목. `level + marker + enumerated` 평면 모델 (group container 미도입, HWP 상류가 list group 미지원). `marker` 는 v0.3.0 placeholder (`"•"` / `"1."` / `"-"`) — 정확 marker (`"가."`, `"(a)"`) 는 v0.4.0+.
22+
- `CaptionBlock` (S3) — 캡션. `blocks: list[Block]` 재귀 + `direction: Literal["top", "bottom", "left", "right"]`. 부모 컨테인먼트 — `PictureBlock.caption` / `TableBlock.caption_block` 으로 1:1 부착 (ref-id 미도입). v0.2.0 `TableBlock.caption: str` 보존 + `caption_block` 옵셔널 추가.
23+
- `TocBlock` + `TocEntryBlock` (S3) — 목차. `entries: list[TocEntryBlock]` (TocEntryBlock 은 leaf type, Block 유니온 멤버 아님). v0.3.0 entries 는 빈 placeholder — 항목 추출은 v0.4.0+ (heading hierarchy + bookmark resolver 필요).
24+
- `FieldBlock` + `FieldKind` (S3) — 필드. 닫힌 `Literal` 14 종 (`date`/`crossref`/`hyperlink`/...) + `"unknown"` 안전판 + `field_type_code: int | None` (forward-compat). `FieldType::Formula` 는 `"calc"` (Equation 의 `"formula"` 와 이름 충돌 회피).
25+
- `Furniture` 채움 (S1+S2) — `page_headers` / `page_footers` (master_pages + Control::Header/Footer 매핑) / `footnotes` / `endnotes` 모두 실제 본문 출고. `iter_blocks(scope="furniture")` 순서: page_headers → page_footers → footnotes → endnotes (v0.2.0 furniture 순서 계약 확장).
26+
27+
### Added — `rhwp-py` CLI 재도입
28+
29+
v0.2.0 에서 폐기됐던 CLI 를 별도 이름 (`rhwp-py`) 으로 재도입. 상류 Rust `rhwp` 바이너리와 PATH 충돌 회피 + Python 고유 가치 (IR / LangChain) 에 집중 — 기능 중복 0.
30+
31+
- 신규 entry point: `rhwp-py = "rhwp.cli:app"` (typer 지연 로드, 미설치 시 친절 에러 + exit 2).
32+
- 서브커맨드: `parse` (요약 정보) / `version` / `schema` (in-package JSON Schema) / `ir` (전체 IR JSON) / `blocks` (블록 스트림 NDJSON / JSON / text) / `chunks` (LangChain RecursiveCharacterTextSplitter 결과).
33+
- `blocks` 의 `--kind` enum 11 종 (`paragraph` / `table` + 8 신규 + `all`) — IR 확장 GA 와 동기.
34+
- `chunks --include-furniture` — `HwpLoader(mode="ir-blocks", include_furniture=True)` 와 동일 정책.
35+
- 글로벌 옵션 `--quiet/-q` — stderr progress 메시지 가드.
36+
- 새 extras: `[cli]` (typer 만), `[cli-chunks]` (typer + langchain-text-splitters).
37+
- 업스트림 바이너리와의 역할 분담: 구조 추출은 `rhwp-py`, 시각 출력 (SVG/PDF) / 메타데이터 덤프 (`info`/`dump`) / 라운드트립 진단 (`diag`/`ir-diff`) 은 상류 `rhwp` — overlap 0.
38+
39+
### Added — LangChain `HwpLoader.include_furniture`
40+
41+
- `HwpLoader(mode="ir-blocks", include_furniture=True)` — body 다음에 furniture (page_headers / page_footers / footnotes / endnotes) 도 LangChain Document 로 yield. 각 furniture Document 는 `metadata.scope="furniture"` 로 표시되어 RAG 가 body / furniture 분리 색인 가능.
42+
- 기본 `include_furniture=False` — v0.2.0 시절 동작 (body 만) 보존.
43+
- `mode="single"` / `"paragraph"` 에서는 `include_furniture` 무시 — text 추출은 항상 body 만.
44+
45+
### Added — Schema GA + content-addressed alias
46+
47+
- SchemaVersion `"1.0"` → `"1.1"` (in-place v1 URL — major 안의 minor 추가).
48+
- `_KNOWN_KINDS` 11 known kinds (10 known + UnknownBlock) — `Block` Annotated Union 11 멤버. callable Discriminator 는 O(1) lookup.
49+
- JSON Schema in-place 갱신 — `python/rhwp/ir/schema/hwp_ir_v1.json` (1,261 lines, 20 `$defs`).
50+
- Content-addressed alias `hwp_ir_v1-sha256-<hash>.json` — `publish-schema.yml` 가 매 deploy 시 hash-tagged immutable copy 를 alongside 발행. 구 hash 는 영구 보존 (SchemaStore / 외부 도구 reproducibility).
51+
- `_harden_unknown_variant` 가 `_KNOWN_KINDS` SSOT 를 사용 — `TocEntryBlock.kind="toc_entry"` 같은 leaf-only kind 가 not.enum 에 포함되어 라운드트립 깨지는 케이스 회피.
52+
53+
### Documentation
54+
55+
- `docs/roadmap/v0.3.0/ir-expansion.md` — IR 확장 spec (8 결정 사항 + research 인용).
56+
- `docs/roadmap/v0.3.0/cli.md` — `rhwp-py` 재도입 spec (이름 선정 + overlap=0 + extras 정책).
57+
- `docs/design/v0.3.0/ir-expansion-research.md` / `cli-design-research.md` — 결정 증거.
58+
- `docs/implementation/v0.3.0/stages/stage-{1..4}.md` — 단계별 구현 로그 (S1: Picture+Furniture, S2: Formula+Footnote/Endnote, S3: ListItem+Caption+Toc+Field, S4: Schema GA + CLI + LangChain include_furniture + 문서).
59+
- `README.md` — v0.3.0 신규 블록 + `rhwp-py` CLI 섹션 추가, content-addressed alias 안내.
60+
61+
### Tests
62+
63+
- 5 신규 IR 테스트 파일 (S1 picture+furniture, S2 formula+footnote, S3 list+caption+toc+field) + 1 CLI 테스트 파일 → 405 (S3) → S4 추가.
64+
- `tests/test_cli.py` — typer.testing.CliRunner 기반 smoke + 통합 (parse/version/schema/ir/blocks/chunks 전 서브커맨드 + exit code 1/2 검증 + langchain-text-splitters 미설치 monkeypatch).
65+
- `tests/test_langchain_loader_ir.py` 확장 — `include_furniture` 옵션 4 테스트.
66+
- CI `test-without-extras` skip count 4 → 5 (typer 추가).
67+
68+
### Deferred to v0.4.0+
69+
70+
- `ListItemBlock` 정확 marker (`"가."`, `"(a)"`) — `Numbering.level_formats` lookup.
71+
- `TocBlock.entries` 채움 + `target_section_idx` resolver + `is_stale` 검출.
72+
- `FieldBlock.cached_value` 추출 (paragraph text inline `field_ranges` 매핑 필요).
73+
- `InlineRun.href` 자동 채움 (Hyperlink/Bookmark Field 와 cross-link).
74+
- `PictureBlock` `embedded` / `external_dir` 임베딩 모드 (`Document.to_ir(image_mode=...)` 옵션).
75+
- `RevisionMark` (변경 이력) — 상류 미지원 (영구 비목표 후보).
76+
1077
## [0.2.0] — 2026-04-25
1178

1279
MINOR release — Phase 2 착수. RAG / LLM 파이프라인이 직접 소비하는 구조화 Document IR v1 (Pydantic V2 + JSON Schema Draft 2020-12) 을 도입. 기존 `Document` / `HwpLoader` API 는 변경 없음 (backward-compatible). 상류 `edwardkim/rhwp` 커밋 핀을 `bea635b` (main HEAD) 로 갱신 — v0.1.0 의 `1636213` 이후 upstream 변경은 docs (매뉴얼 현행화 / README 동기화 / 자기검열) 만으로 코드 동작 변화 없음. BMP→PNG 재인코딩 fix (#240) 는 여전히 upstream `origin/devel` 에만 있으며 본 release pin 에 미포함 — BMP 임베딩 HWP 의 SVG/PDF 렌더링 이슈는 upstream main 머지를 대기.
@@ -134,7 +201,8 @@ The `rhwp` Rust core is consumed via git submodule pinned to upstream commit `16
134201
- Local `maturin build --release` wheel (3.0 MB) verified end-to-end in a clean venv: install → import → `rhwp.parse` → `HwpLoader` load. (Note: the v0.1.0 sdist exceeded PyPI's 100 MB limit and did not upload; fixed in [0.1.1](#011--2026-04-23).)
135202
- GitHub Actions workflow (`publish.yml`) builds Linux (x86_64 + aarch64) / macOS (x86_64 + aarch64) / Windows wheels + sdist on release publish, then uploads via PyPI Trusted Publisher (OIDC).
136203

137-
[Unreleased]: https://github.com/DanMeon/rhwp-python/compare/v0.2.0...HEAD
204+
[Unreleased]: https://github.com/DanMeon/rhwp-python/compare/v0.3.0...HEAD
205+
[0.3.0]: https://github.com/DanMeon/rhwp-python/releases/tag/v0.3.0
138206
[0.2.0]: https://github.com/DanMeon/rhwp-python/releases/tag/v0.2.0
139207
[0.1.1]: https://github.com/DanMeon/rhwp-python/releases/tag/v0.1.1
140208
[0.1.0]: https://github.com/DanMeon/rhwp-python/releases/tag/v0.1.0
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+28-8Lines changed: 28 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,34 @@ docs = HwpLoader("report.hwp", mode="ir-blocks").load()
122122
# para_idx / (표의 경우) rows / cols / text / caption 포함
123123
```
124124

125-
**JSON Schema** — `rhwp.ir.schema.export_schema()` 로 Draft 2020-12 스키마 생성,
126-
`load_schema()` 로 in-package 동봉 JSON 로드 (네트워크 불필요). `$id` 공개 URL:
127-
`https://danmeon.github.io/rhwp-python/schema/hwp_ir/v1/schema.json` — 불변 경로
128-
정책 (v1 영구). 외부 도구는 이 URL 또는 `*.hwp_ir.json` 파일명 convention 사용 가능.
129-
130-
미구현 블록 타입 (Picture / Formula / Footnote / ListItem / Caption / TocEntry /
131-
Field) 은 `UnknownBlock` catch-all 로 forward-compat — v0.3.0 에서 추가되어도
132-
v0.2.0 소비자가 깨지지 않는다.
125+
**JSON Schema** — `rhwp.ir.schema.export_schema()` / `load_schema()`. 공개 `$id`:
126+
`https://danmeon.github.io/rhwp-python/schema/hwp_ir/v1/schema.json` (불변 경로).
127+
v0.3.0+ 는 같은 디렉토리에 content-addressed alias `hwp_ir_v1-sha256-<hash>.json`
128+
도 alongside 발행 (reproducible 참조).
129+
130+
### v0.3.0 신규
131+
132+
Picture / Formula / Footnote / Endnote / ListItem / Caption / Toc / Field 8 종
133+
블록 + `furniture.page_headers/footers/footnotes/endnotes` 채움. SchemaVersion
134+
`1.1` GA. 머리글/꼬리말/각주/미주도 LangChain Document 로 색인하려면
135+
`HwpLoader("report.hwp", mode="ir-blocks", include_furniture=True)` (furniture
136+
Document 는 `metadata.scope="furniture"` — body 와 분리 검색 가능). 변경 상세는
137+
[CHANGELOG](CHANGELOG.md#030--2026-04-28).
138+
139+
## rhwp-py CLI (v0.3.0+)
140+
141+
```bash
142+
pip install "rhwp-python[cli]" # parse / version / schema / ir / blocks
143+
pip install "rhwp-python[cli-chunks]" # + chunks (langchain text splitter)
144+
145+
rhwp-py parse report.hwp
146+
rhwp-py blocks report.hwp --kind table --format ndjson | jq '.rows'
147+
rhwp-py chunks report.hwp --size 1000 --format ndjson
148+
```
149+
150+
`rhwp-py` 는 구조 추출 (IR / 블록 / 청크 / 스키마) 전담 — 시각 출력 (SVG/PDF) /
151+
메타데이터 덤프는 상류 `rhwp` Rust 바이너리. 자세한 사용은 `rhwp-py --help`
152+
또는 [cli.md](docs/roadmap/v0.3.0/cli.md) 참조.
133153

134154
## 성능
135155

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.