hwpx-kit-cli 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hwpx_kit_cli-0.1.1/.claude-plugin/marketplace.json +11 -0
- hwpx_kit_cli-0.1.1/.claude-plugin/plugin.json +9 -0
- hwpx_kit_cli-0.1.1/.gitignore +15 -0
- hwpx_kit_cli-0.1.1/CLAUDE.md +77 -0
- hwpx_kit_cli-0.1.1/LICENSE +209 -0
- hwpx_kit_cli-0.1.1/PKG-INFO +190 -0
- hwpx_kit_cli-0.1.1/README.md +167 -0
- hwpx_kit_cli-0.1.1/commands/hwpx.md +31 -0
- hwpx_kit_cli-0.1.1/install.ps1 +58 -0
- hwpx_kit_cli-0.1.1/install.sh +29 -0
- hwpx_kit_cli-0.1.1/pyproject.toml +44 -0
- hwpx_kit_cli-0.1.1/sample-values.json +1 -0
- hwpx_kit_cli-0.1.1/scripts/build_skill_package.py +208 -0
- hwpx_kit_cli-0.1.1/scripts/check_stdout_purity.py +15 -0
- hwpx_kit_cli-0.1.1/scripts/make_sample.py +36 -0
- hwpx_kit_cli-0.1.1/skills/doc-create/SKILL.md +78 -0
- hwpx_kit_cli-0.1.1/skills/format-convert/SKILL.md +43 -0
- hwpx_kit_cli-0.1.1/skills/gongmun-format/SKILL.md +54 -0
- hwpx_kit_cli-0.1.1/skills/hwpx-form/SKILL.md +214 -0
- hwpx_kit_cli-0.1.1/skills/office-export/SKILL.md +57 -0
- hwpx_kit_cli-0.1.1/skills/table-calc/SKILL.md +44 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/__init__.py +1 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/adapter/__init__.py +0 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/adapter/base.py +43 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/adapter/hwpx_engine.py +545 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/adapter/kordoc_engine.py +79 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/adapter/office_readers.py +46 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/cli.py +259 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/__init__.py +0 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/analyze.py +126 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/convert.py +52 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/export.py +44 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/fill.py +91 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/fmt.py +29 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/generate.py +12 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/outline.py +13 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/page_break.py +17 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/read.py +42 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/render.py +11 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/row_height.py +39 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/table_clear.py +22 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/table_copy.py +24 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/table_map_cmd.py +18 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/table_new.py +29 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/table_set.py +49 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/commands/validate.py +12 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/format.py +94 -0
- hwpx_kit_cli-0.1.1/src/hwpx_kit/output.py +48 -0
- hwpx_kit_cli-0.1.1/templates/Default_Template.hwpx +0 -0
- hwpx_kit_cli-0.1.1/tests/__init__.py +0 -0
- hwpx_kit_cli-0.1.1/tests/conftest.py +61 -0
- hwpx_kit_cli-0.1.1/tests/fixtures/real/legacy-sample.hwp +0 -0
- hwpx_kit_cli-0.1.1/tests/fixtures/real/seoul-attachment.hwpx +0 -0
- hwpx_kit_cli-0.1.1/tests/fixtures/real/seoul-body.hwpx +0 -0
- hwpx_kit_cli-0.1.1/tests/fixtures/real/seoul-report-brief.hwpx +0 -0
- hwpx_kit_cli-0.1.1/tests/fixtures/real/seoul-report-cover.hwpx +0 -0
- hwpx_kit_cli-0.1.1/tests/test_adapter.py +54 -0
- hwpx_kit_cli-0.1.1/tests/test_analyze.py +177 -0
- hwpx_kit_cli-0.1.1/tests/test_cli.py +62 -0
- hwpx_kit_cli-0.1.1/tests/test_convert.py +78 -0
- hwpx_kit_cli-0.1.1/tests/test_export.py +80 -0
- hwpx_kit_cli-0.1.1/tests/test_fill.py +248 -0
- hwpx_kit_cli-0.1.1/tests/test_format.py +146 -0
- hwpx_kit_cli-0.1.1/tests/test_integration.py +60 -0
- hwpx_kit_cli-0.1.1/tests/test_kordoc.py +65 -0
- hwpx_kit_cli-0.1.1/tests/test_office_readers.py +83 -0
- hwpx_kit_cli-0.1.1/tests/test_output.py +35 -0
- hwpx_kit_cli-0.1.1/tests/test_page_break.py +77 -0
- hwpx_kit_cli-0.1.1/tests/test_read_validate.py +27 -0
- hwpx_kit_cli-0.1.1/tests/test_real_forms.py +123 -0
- hwpx_kit_cli-0.1.1/tests/test_row_height.py +80 -0
- hwpx_kit_cli-0.1.1/tests/test_skill_package.py +47 -0
- hwpx_kit_cli-0.1.1/tests/test_stdout_purity.py +27 -0
- hwpx_kit_cli-0.1.1/tests/test_table_clear.py +74 -0
- hwpx_kit_cli-0.1.1/tests/test_table_copy.py +93 -0
- hwpx_kit_cli-0.1.1/tests/test_table_map_new.py +128 -0
- hwpx_kit_cli-0.1.1/tests/test_table_set.py +96 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# hwpx-kit — 개발 컨텍스트
|
|
2
|
+
|
|
3
|
+
한글(HWPX/HWP) 문서 자동화 — Claude Code 플러그인(스킬 모음) + CLI.
|
|
4
|
+
"이 양식에 채워줘" 한마디로 서식 무손상 hwpx가 나오는 것이 목표.
|
|
5
|
+
|
|
6
|
+
> 내부 작업 노트(전략·검증 이력·백로그)는 `private/PROJECT-NOTES.md` (gitignore 구역).
|
|
7
|
+
> 세션 시작 시 그 파일을 먼저 읽을 것.
|
|
8
|
+
|
|
9
|
+
## 🔴 보안 — 최우선 규칙
|
|
10
|
+
|
|
11
|
+
**사용자(기관)가 제공한 문서 파일은 .env급 비밀이다.**
|
|
12
|
+
|
|
13
|
+
- `incoming/`, `private/` = 기밀 구역 (gitignore 됨). 이 안의 파일과 **모든 파생물**(render SVG, fill 결과, read 추출 텍스트)은 절대 git 커밋·외부 업로드 금지
|
|
14
|
+
- 코드·테스트에 사용자 문서 속 문장 하드코딩 금지 — 파일에서 동적 추출할 것 (`tests/test_real_forms.py` 참고)
|
|
15
|
+
- 레포 픽스처(`tests/fixtures/real/`)에는 **공개 출처 서식만** (현재: 서울시 정보소통광장 공개 서식 + 합성 legacy-sample.hwp)
|
|
16
|
+
|
|
17
|
+
## 아키텍처
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
skills/*/SKILL.md → Claude Code 플러그인 스킬들 (.claude-plugin/plugin.json이 컨테이너)
|
|
21
|
+
├─ hwpx-form → 양식 채우기 코어 워크플로
|
|
22
|
+
├─ doc-create → 백지 시작 라우터 (양식 유무 확인)
|
|
23
|
+
├─ format-convert → 금액한글화·날짜요일·만나이 (CLI fmt 호출 — 암산 금지 원칙)
|
|
24
|
+
├─ gongmun-format → 행안부 공문 규약 (지식 스킬)
|
|
25
|
+
├─ table-calc → 표 증감·비율·합계 (지식 + fill 착지)
|
|
26
|
+
└─ office-export → hwpx→docx(변환)·pptx/xlsx(재구성, officecli 선택 의존)
|
|
27
|
+
|
|
28
|
+
CLI (cli.py) — JSON 봉투, 종료코드 0/1/2
|
|
29
|
+
└─ commands/ (analyze·fill·read·validate·convert·export·render·generate·fmt·row-height·table-clear·table-set·table-copy·table-map·table-new·page-break·outline)
|
|
30
|
+
├─ format.py ← 순수함수 (금액한글화·요일·만나이) — 엔진 임포트 금지, fmt는 파일 인수 없음(FILE_NOT_FOUND 가드 우회)
|
|
31
|
+
└─ adapter/ ← 명령 계층은 어댑터 인터페이스만 사용 (엔진 직접 import 금지)
|
|
32
|
+
├─ hwpx_engine.py → python-hwpx (hwpx 분석·채우기·검증·표 조작, 순수 Python)
|
|
33
|
+
├─ office_readers.py → PDF·DOCX·XLSX 읽기 (pypdf/python-docx/openpyxl, Node 불필요)
|
|
34
|
+
├─ kordoc_engine.py → kordoc 3.18.0 고정 — 조건부 옵션: 한글 없는 환경의 구형 .hwp 읽기 + render + generate (Node 필요)
|
|
35
|
+
└─ (convert.py·export.py) → pyhwpx/한글 COM (.hwp→.hwpx / .hwpx→docx, Windows+한글 필요)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- 배포: 레포 루트가 자기-마켓플레이스 (`.claude-plugin/marketplace.json`). 로컬 개발 반영은 `claude plugin update hwpx-kit@hwpx-kit-market`. 오프라인 zip은 `scripts/build_skill_package.py`
|
|
39
|
+
- MCP 서버(`mcp/`)는 공개 레포에서 제외(gitignore) — 로컬에만 유지, GUI 단계 대비. 환경변수: `HWPX_KIT_CLI` / `HWPX_KIT_CLI_ARGS` / `HWPX_KIT_CWD`. 테스트: `cd mcp && npm test`
|
|
40
|
+
- kordoc는 MIT, 보험 포크: github.com/6aneffy/kordoc (업스트림 소멸 대비)
|
|
41
|
+
- python-hwpx는 어댑터로 격리 — 문제 시 엔진 교체 가능하게 유지
|
|
42
|
+
|
|
43
|
+
## fill_key 계약 (analyze가 주고 fill이 소비)
|
|
44
|
+
|
|
45
|
+
| 키 | 대상 | 비고 |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `clickhere:<이름>` | 누름틀 | 실서식으로 검증됨 |
|
|
48
|
+
| `marker:<키>` | `{{키}}` 마커 | 자체 정규식(한글 키 지원) — 엔진 것은 ASCII 전용이라 쓰면 안 됨 |
|
|
49
|
+
| `table:<라벨>` | 라벨 오른쪽 셀 | `#N`으로 중복 라벨 N번째 출현 지정, `> right > right` 방향 체인 가능. prefilled(기본값 찬 칸)도 덮어씀. 라벨은 공백 정규화(개행 든 병합 라벨 OK) |
|
|
50
|
+
| `text:<원문>` | 예시 텍스트 교체 | 런 단위 → 실패 시 문단 전체 일치 폴백. 서식 보존 |
|
|
51
|
+
| `delete:<문단원문>` | 양식 지시블록 삭제 | "(예시)", "←해당시" 류. blank-first 후 remove |
|
|
52
|
+
| `bold:<원문>` / `underline:<원문>` | 글자 서식 적용 (값 "") | 런 단위 — 원문을 품은 런 전체에 적용. 부분 강조는 원문이 런 경계와 일치해야 정밀 |
|
|
53
|
+
|
|
54
|
+
## 절대 규칙 (설계 불변)
|
|
55
|
+
|
|
56
|
+
1. **fill은 원본 절대 수정 금지** — `--out` 사본만. 원본 경로로 저장 시 ValueError
|
|
57
|
+
2. **`--json` 모드 stdout = JSON 한 줄만** — python-hwpx가 stdout에 print하므로 모든 엔진 호출은 `quiet_engine()`으로 감쌀 것. CLI는 stdout/stderr를 UTF-8로 강제(Windows cp949 문제)
|
|
58
|
+
3. **lxml 요소 프록시에 `id()` 쓰지 말 것** — GC 후 id 재사용으로 비결정 버그 남 (`test_press_form_title_text_replacement_roundtrip`이 재발 감지)
|
|
59
|
+
4. `skills/*/SKILL.md`(또는 templates/) 수정하면 **plugin.json 버전 범프 → 커밋·push → `claude plugin marketplace update hwpx-kit-market` → `claude plugin update hwpx-kit@hwpx-kit-market`** (버전 동일하면 업데이트 스킵됨, marketplace update 없이는 새 버전을 못 봄) — 마켓플레이스가 GitHub(6aneffy/hwpx-kit) 기준이라 push가 곧 배포다. git 추적 파일만 설치되므로 기밀 유출 불가. 🔴 레포 루트를 **로컬 경로**로 마켓플레이스 등록 금지 — 로컬 경로 설치는 gitignore 무시 통째 복사라 기밀까지 캐시에 복제된다 (실사고 1회). 구 단일 스킬 폴더(`~/.claude/skills/hwpx-kit/`)가 다시 생기면 이중 트리거되니 지울 것
|
|
60
|
+
|
|
61
|
+
## 엔진 특성 (알아두면 삽질 안 함)
|
|
62
|
+
|
|
63
|
+
- 표 채우기는 어댑터 자체 구현(`fill_at_label`) — 엔진 `fill_by_path`는 라벨 속 `>`(예: `<총괄>`)를 경로 구분자로 오파싱해서 안 씀. 엔진 내부 열거(`_find_label_candidates`)를 직접 사용하니 엔진 교체 시 재구현 지점
|
|
64
|
+
- 표 셀 문단의 `p.remove()`는 예외 없이 무효될 수 있음 → 삭제는 blank-first
|
|
65
|
+
- kordoc render는 한컴 저장본(조판 캐시)만 정밀 — 우리가 만든 파일은 `--reflow` 합성 렌더로 자동 폴백되는데 **겹침 등 부정확. 대략 확인용일 뿐, 정확한 검증은 한글로 여는 것**
|
|
66
|
+
- 한글 COM(convert/export) 함정 3가지: ① SaveAs의 워드 형식 문자열은 `"OOXML"` — "DOCX"/"MSWORD"는 False 반환하며 조용히 실패 ② visible=False에서 경고 팝업 뜨면 무한대기 — `set_message_box_mode(AUTO_ANSWER_MODE)` 필수 (convert.py 상수) ③ **좀비 Hwp 프로세스가 남아 있으면 다음 COM 세션이 그냥 멈춤** — hang 시 `Stop-Process -Name Hwp -Force` 먼저
|
|
67
|
+
- python-hwpx에는 표 행 추가/삭제 API 없음 (`add_table`/`merge_table_cells`뿐) — 행 개수 변경은 사용자가 한글에서, 높이 정돈은 `row-height`, 내용 비우기는 `table-clear`, 좌표 기입은 `table-set`
|
|
68
|
+
- **셀 비우기는 서식을 잃지 않는다** (실험 확인): `set_cell_text('')`가 텍스트만 지우고 빈 런의 글자모양(charPr) 참조는 유지 → 재기입 시 원래 서식 물려받음. table-clear가 안전한 근거
|
|
69
|
+
- 병합 셀은 엔진 표 맵에서 같은 텍스트가 격자 전체에 복제되어 보임 — 어댑터 table_map()이 셀별 `is_anchor`를 덧붙이고, 라벨 후보·#N 열거는 anchor만 센다 (복제를 세면 #N 오염 + 같은 논리 셀 이중 기입으로 값 유실)
|
|
70
|
+
- analyze의 마커 탐지는 본문 문단만 훑음 — 표 셀 안 {{마커}}는 못 잡음 (fill은 됨) ← 개선 후보
|
|
71
|
+
|
|
72
|
+
## 개발 환경
|
|
73
|
+
|
|
74
|
+
- Python 3.11 venv (`.venv`), `uv sync` / `uv run pytest`
|
|
75
|
+
- 실행: `uv run hwpx-kit <명령>` 또는 전역 `hwpx-kit`
|
|
76
|
+
- 작업 방식: feature 브랜치 → 테스트 통과 → main 머지. TDD
|
|
77
|
+
- 커밋 게이트로 쓰는 테스트 명령은 파이프로 자르지 말 것 (종료코드 삼킴). 한글 COM 왕복 테스트는 간헐 플레이크 — 실패 시 한 번 재실행으로 판별
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
Copyright 2026 6aneffy (tkdgus990809@gmail.com)
|
|
207
|
+
|
|
208
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
209
|
+
you may not use this file except in compliance with the License.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hwpx-kit-cli
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: 한글(HWPX) 문서 자동화 CLI — Korean HWPX document automation for AI agents: analyze, fill, read, validate, table ops
|
|
5
|
+
Project-URL: Homepage, https://github.com/6aneffy/hwpx-kit
|
|
6
|
+
Project-URL: Repository, https://github.com/6aneffy/hwpx-kit
|
|
7
|
+
Project-URL: Issues, https://github.com/6aneffy/hwpx-kit/issues
|
|
8
|
+
Author-email: 6aneffy <tkdgus990809@gmail.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: claude-code,document-automation,hangul,hwp,hwpx,korean
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Office/Business :: Office Suites
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Requires-Dist: openpyxl>=3.1.5
|
|
17
|
+
Requires-Dist: pypdf>=6.14.2
|
|
18
|
+
Requires-Dist: python-docx>=1.2.0
|
|
19
|
+
Requires-Dist: python-hwpx<3,>=2.24
|
|
20
|
+
Provides-Extra: convert
|
|
21
|
+
Requires-Dist: pyhwpx; (sys_platform == 'win32') and extra == 'convert'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
<div align="center">
|
|
25
|
+
|
|
26
|
+
# hwpx-kit
|
|
27
|
+
|
|
28
|
+
**한글(HWPX) 문서 자동화 — Claude Code 플러그인 & CLI**
|
|
29
|
+
|
|
30
|
+
*"이 양식에 채워줘" 한마디로, 서식 무손상 한글 문서가 나옵니다.*
|
|
31
|
+
|
|
32
|
+
[](LICENSE)
|
|
33
|
+
[](https://www.python.org/)
|
|
34
|
+
[](https://claude.com/claude-code)
|
|
35
|
+
[](tests/)
|
|
36
|
+
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 무엇이 되나
|
|
42
|
+
|
|
43
|
+
한글(HWP/HWPX)은 한국 공공·기업 문서의 표준이지만, AI가 다룰 수 있는 도구가 사실상 없었습니다.
|
|
44
|
+
hwpx-kit은 **AI 에이전트가 한글 문서를 읽고, 채우고, 고치고, 새로 만들 수 있게** 하는 도구 모음입니다.
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
👤 "이 양식에 채워줘" → 서식(폰트·표·조판) 무손상으로 값만 채운 사본
|
|
48
|
+
👤 "이 기획서를 ○○사업용으로 바꿔줘" → 기존 문서를 양식 삼아 내용 전면 교체
|
|
49
|
+
👤 "한글로 새 기획서 만들어줘" → 내장 템플릿으로 표지·장·표 갖춘 문서 생성
|
|
50
|
+
👤 "예산 앞에 장 하나 추가하고 표 넣어줘" → 장 헤더 복제·새 표 생성·쪽나눔까지
|
|
51
|
+
👤 "금액 한글로 병기해줘" → 금12,340원(금일만이천삼백사십원) — 계산 착오 0
|
|
52
|
+
👤 "이거 워드로도 줘" / "PPT로 만들어줘" → docx 변환 / 발표자료 재구성
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
모든 채우기는 **원본을 절대 수정하지 않고** 사본에만 씁니다. 실제 공공기관 서식
|
|
56
|
+
(보도자료·신청서·계획서·회의록·공고문)으로 왕복 검증했습니다.
|
|
57
|
+
|
|
58
|
+
| | hwpx-kit 없이 | hwpx-kit으로 |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| 양식 채우기 | 한글 열고 칸마다 복붙, 서식 깨지면 수작업 복구 | 파일 주고 한마디 — 서식 무손상 사본 |
|
|
61
|
+
| 새 기획서 | 백지에서 표지·표·조판 직접 | 내장 템플릿에 내용만 — 몇 분 완주 |
|
|
62
|
+
| 금액 병기 | 손으로 한글 표기 (오타 위험) | 결정론 계산 — `금12,340원(금일만이천삼백사십원)` |
|
|
63
|
+
| AI에게 한글 파일 | 못 읽음 · PDF 변환 우회 | hwpx·hwp 직접 읽기/쓰기 |
|
|
64
|
+
|
|
65
|
+
**이런 분들을 위해 만들었습니다**: 공공기관·학교의 서식 담당자, 사업계획서를 반복 작성하는
|
|
66
|
+
창업자·연구자, 한글 문서를 AI 워크플로에 넣고 싶은 개발자.
|
|
67
|
+
|
|
68
|
+
## 30초 설치
|
|
69
|
+
|
|
70
|
+
Claude Code에서:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
/plugin marketplace add 6aneffy/hwpx-kit
|
|
74
|
+
/plugin install hwpx-kit@hwpx-kit-market
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
이게 전부입니다. CLI 런타임은 첫 사용 때 스킬이 알아서 설치를 진행합니다
|
|
78
|
+
(PC에 Python 3.10+만 있으면 됩니다).
|
|
79
|
+
|
|
80
|
+
<details>
|
|
81
|
+
<summary>수동 설치</summary>
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install git+https://github.com/6aneffy/hwpx-kit.git
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
# Windows 일괄 (CLI + 플러그인 등록)
|
|
89
|
+
irm https://raw.githubusercontent.com/6aneffy/hwpx-kit/main/install.ps1 | iex
|
|
90
|
+
```
|
|
91
|
+
</details>
|
|
92
|
+
|
|
93
|
+
## 스킬 (Claude Code 플러그인)
|
|
94
|
+
|
|
95
|
+
| 스킬 | 트리거 | 역할 |
|
|
96
|
+
|------|--------|------|
|
|
97
|
+
| **hwpx-form** | "이 양식에 채워줘" | 분석→채우기→검증 코어 워크플로. 표 조작·강조·워드 출력 포함 |
|
|
98
|
+
| **doc-create** | "기획서 만들어줘" (파일 없이) | 백지 생성 라우터 — 내장 템플릿(표지·장 헤더·표 골격) 기반 |
|
|
99
|
+
| **format-convert** | "금액 한글로", "요일 붙여줘" | 금액 병기·날짜 요일·만나이 — 결정론 계산 (LLM 암산 금지) |
|
|
100
|
+
| **gongmun-format** | "공문 형식으로" | 행안부 공문 규약 — 글머리 위계(□○-※\*), 표기, 텍스트 정리 |
|
|
101
|
+
| **table-calc** | "증감 채워줘" | 보고서 표 증감(△·%p)·비율·합계 계산과 관습 표기 |
|
|
102
|
+
| **office-export** | "워드로", "PPT로" | docx 변환(한글 COM) / pptx·xlsx 재구성 |
|
|
103
|
+
|
|
104
|
+
스킬은 사용자에게 **필수 정보를 먼저 묻고**(선택지 UI), 초안을 확정받은 뒤 작업합니다.
|
|
105
|
+
말하지 않은 값을 지어내지 않습니다.
|
|
106
|
+
|
|
107
|
+
## CLI
|
|
108
|
+
|
|
109
|
+
모든 명령은 `--json`으로 한 줄 JSON 봉투(`ok`/`data`/`warnings`/`error`)를 반환합니다.
|
|
110
|
+
종료 코드: `0` 성공 · `1` 오류 · `2` 부분 성공.
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# 읽기·분석
|
|
114
|
+
hwpx-kit analyze 양식.hwpx --json # 채울 수 있는 필드 탐지 (fill_key 반환)
|
|
115
|
+
hwpx-kit read 문서 --format md # 본문 추출 — hwpx·PDF·DOCX·XLSX 내장 지원
|
|
116
|
+
hwpx-kit outline 문서.hwpx --json # 문단·표 배치 지도 (삽입 앵커 탐색)
|
|
117
|
+
hwpx-kit table-map 문서.hwpx --table 3 --json # 표 셀 좌표·병합 상태
|
|
118
|
+
hwpx-kit validate 문서.hwpx --json # 구조 검증
|
|
119
|
+
|
|
120
|
+
# 채우기·편집 (원본 불변 — 항상 --out 사본)
|
|
121
|
+
hwpx-kit fill 양식.hwpx --data 값.json --out 결과.hwpx
|
|
122
|
+
hwpx-kit table-set 문서.hwpx --table 3 --data 셀.json --out 결과.hwpx # 좌표 셀 쓰기
|
|
123
|
+
hwpx-kit table-clear 문서.hwpx --table 3 --rows 1-20 --out 결과.hwpx # 셀 내용 비우기
|
|
124
|
+
hwpx-kit table-copy 문서.hwpx --table 1 --after-table 4 --out 결과.hwpx # 표 통째 복제 (서식·병합 유지)
|
|
125
|
+
hwpx-kit table-new 문서.hwpx --rows 6 --cols 4 --like-table 3 --after-text "앵커" --out 결과.hwpx
|
|
126
|
+
hwpx-kit row-height 문서.hwpx --table 3 --like 1 --rows 2-5 --out 결과.hwpx # 행 높이 정돈
|
|
127
|
+
hwpx-kit page-break 문서.hwpx --table 5 --out 결과.hwpx # 쪽나눔 (새 장 시작)
|
|
128
|
+
|
|
129
|
+
# 변환·생성
|
|
130
|
+
hwpx-kit fmt --amount 12340 --json # 금12,340원(금일만이천삼백사십원)
|
|
131
|
+
hwpx-kit fmt --date 20260101 --json # 2026.1.1.(목)
|
|
132
|
+
hwpx-kit convert 문서.hwp --json # .hwp → .hwpx (Windows + 한글)
|
|
133
|
+
hwpx-kit export 문서.hwpx --to docx --json # 워드로 내보내기 (Windows + 한글)
|
|
134
|
+
hwpx-kit generate 초안.md --out 새문서.hwpx # Markdown → 공문서 (kordoc)
|
|
135
|
+
hwpx-kit render 문서.hwpx --out p.svg # SVG 미리보기 (kordoc)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## fill_key 계약
|
|
139
|
+
|
|
140
|
+
`analyze`가 주는 키를 그대로 데이터 JSON의 키로 씁니다.
|
|
141
|
+
|
|
142
|
+
| 키 | 대상 | 예시 |
|
|
143
|
+
|----|------|------|
|
|
144
|
+
| `clickhere:<이름>` | 누름틀 필드 | `"clickhere:신청자": "김철수"` |
|
|
145
|
+
| `marker:<키>` | `{{키}}` 마커 | `"marker:출장기간": "7/14~7/16"` |
|
|
146
|
+
| `table:<라벨>` | 라벨 오른쪽 셀 | `"table:성명": "김철수"` |
|
|
147
|
+
| `table:<라벨>#N` | 같은 라벨 N번째 | `"table:담당 부서#2": "운영과"` |
|
|
148
|
+
| `table:<라벨> > <방향>` | 방향 체인 | `"table:과 장 > right > right": "010-…"` |
|
|
149
|
+
| `text:<원문>` | 문장 교체 (서식 보존) | `"text:○○○ 사업": "청년 AI교육 사업"` |
|
|
150
|
+
| `delete:<문단원문>` | 안내문 삭제 | `"delete:(예시입니다)": ""` |
|
|
151
|
+
| `bold:` / `underline:<원문>` | 굵게·밑줄 | `"bold:핵심 성과": ""` |
|
|
152
|
+
|
|
153
|
+
## 요구 사항
|
|
154
|
+
|
|
155
|
+
| 기능 | 필요한 것 |
|
|
156
|
+
|------|-----------|
|
|
157
|
+
| 분석·채우기·검증·표 조작·표기 변환·PDF/DOCX/XLSX 읽기 | **Python 3.10+ 만** (순수 파이썬) |
|
|
158
|
+
| `.hwp` 변환, 워드(docx) 내보내기 | Windows + 한글(한컴오피스) |
|
|
159
|
+
| 한글 없는 환경(Mac 등)의 구형 `.hwp` 읽기, MD→HWPX, SVG | [kordoc](https://github.com/chrisryugj/kordoc) (Node 18+, 선택) |
|
|
160
|
+
|
|
161
|
+
## 아키텍처
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
Claude Code 스킬 6종 ──→ hwpx-kit CLI (19 명령, JSON 봉투)
|
|
165
|
+
└─ adapter/ ← 엔진 격리 계층
|
|
166
|
+
├─ python-hwpx hwpx 분석·채우기·표 조작
|
|
167
|
+
├─ pypdf·python-docx·openpyxl 타 포맷 읽기
|
|
168
|
+
├─ pyhwpx(COM) .hwp 변환·docx 내보내기
|
|
169
|
+
└─ kordoc 구형 .hwp·생성·렌더 (선택)
|
|
170
|
+
templates/ 기본 계획서 템플릿 (표지·장 헤더·표 골격, 마커 내장)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
설계 불변 원칙: **① 원본 절대 수정 금지 ② `--json` stdout은 봉투 한 줄만
|
|
174
|
+
③ 서식은 항상 보존** (셀을 비워도 글자모양이 유지되어 재기입 시 원래 서식을 물려받음).
|
|
175
|
+
|
|
176
|
+
> 🚧 같은 코어를 MCP 서버로 노출하는 버전도 제작 중입니다 (Claude Desktop 등 MCP 클라이언트용).
|
|
177
|
+
|
|
178
|
+
## 검증
|
|
179
|
+
|
|
180
|
+
- 자동 테스트 145개 (pytest)
|
|
181
|
+
- 실서식 수렴 테스트: 보도자료·신청서·계획서·회의록·공고문 5계열,
|
|
182
|
+
실제 공공기관 문서 30여 종으로 analyze→fill→validate 왕복
|
|
183
|
+
- 실사용 시나리오 테스트 3회 (백지 생성 12분 완주, 장·표 동적 추가, 보도자료 변환)
|
|
184
|
+
|
|
185
|
+
## 라이선스
|
|
186
|
+
|
|
187
|
+
[Apache-2.0](LICENSE) · © 2026 [6aneffy](https://github.com/6aneffy)
|
|
188
|
+
|
|
189
|
+
이슈·PR 환영합니다. 특히 실제 기관 양식에서의 analyze/fill 실패 사례 제보가 가장 값집니다
|
|
190
|
+
(단, **기관 내부 문서를 이슈에 첨부하지 마세요** — 재현 가능한 합성 예시로 부탁드립니다).
|