rhwp 0.9.1

HWP/HWPX document engine for Rust applications, WebAssembly, and CLI automation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
use super::{cmd, cmd_gated, cmd_json};

pub(super) fn extend(commands: &mut Vec<serde_json::Value>) {
    commands.extend([
        // ── 내보내기/변환 ──
        cmd_json(
            "export-svg",
            "문서를 페이지별 SVG로 렌더하고 --json 매니페스트 출력",
            &["-o", "-p", "--json", "--compat", "--backend"],
            &[
                "schemaVersion",
                "source",
                "format",
                "backend",
                "outputDir",
                "pageCount",
                "renderedCount",
                "pages",
            ],
        ),
        {
            let mut command = cmd_gated(
                "export-png",
                "문서를 페이지별 PNG로 렌더하고 --json 매니페스트 출력 (native-skia)",
                cfg!(feature = "native-skia"),
            );
            command["json"] = serde_json::json!(true);
            command["flags"] = serde_json::json!([
                "--page", "-p", "--output", "-o", "--font-path", "--profile", "--compat",
                "--font-environment", "--dpi", "--scale", "--json", "--metadata-only",
                "--render-tree-output"
            ]);
            command["recordFields"] = serde_json::json!([
                "schemaVersion", "source", "backend", "comparisonProfile", "layoutGeneration",
                "outputDir", "pageCount", "renderedCount", "pages"
            ]);
            command
        },
        {
            let mut command = cmd_gated(
                "export-kitty",
                "문서를 Kitty graphics stdout 또는 페이지별 파일로 출력 (native-skia)",
                cfg!(feature = "native-skia"),
            );
            command["flags"] = serde_json::json!([
                "--page", "-p", "--output", "-o", "--width", "--font-path", "--profile", "--compat"
            ]);
            command
        },
        {
            let mut command = cmd_gated(
                "export-sixel",
                "문서를 Sixel stdout 또는 페이지별 파일로 출력 (native-skia)",
                cfg!(feature = "native-skia"),
            );
            command["flags"] = serde_json::json!([
                "--page", "-p", "--output", "-o", "--width", "--font-path", "--profile", "--compat"
            ]);
            command
        },
        cmd_json(
            "export-pdf",
            "문서를 PDF로 렌더 (svg|direct backend, --json 매니페스트)",
            &[
                "-o",
                "-p",
                "--backend",
                "--profile",
                "--font-path",
                "--json",
                "--compat",
            ],
            &[
                "schemaVersion",
                "source",
                "format",
                "backend",
                "output",
                "bytes",
                "pageCount",
                "renderedCount",
            ],
        ),
        cmd_json(
            "export-markdown",
            "페이지별 텍스트를 Markdown으로 추출 (--json 매니페스트)",
            &["-o", "-p", "--json"],
            &[
                "schemaVersion",
                "source",
                "format",
                "outputDir",
                "pageCount",
                "renderedCount",
                "imageCount",
                "pages",
            ],
        ),
        cmd_json(
            "export-hwpx",
            "HWP→HWPX 변환 저장 (--verify 게이트 exit 3/4, --json 봉투)",
            &["--verify", "--verify-pages", "--json"],
            &[
                "schemaVersion",
                "source",
                "output",
                "format",
                "bytes",
                "verify",
                "verifyPages",
            ],
        ),
        {
            let mut command = cmd_json(
                "import-pdf",
                "PDF 전체/선택 쪽을 HWPX 또는 HWP로 가져오기 (pdf-import feature)",
                &["--source-pages", "--layout", "--json", "--table-inference", "--resource-profile", "--resource-limits"],
                &["schemaVersion", "source", "output", "format", "bytes", "pageCount", "diagnostics", "resourceProfile", "execution"],
            );
            command["requiresFeature"] = serde_json::json!("pdf-import");
            command["available"] = serde_json::json!(rhwp::pdf_support::pdf_import_support().enabled);
            command["resourceProfiles"] = serde_json::json!(["standard", "constrained"]);
            command
        },
        cmd_json(
            "export-hml",
            "HML 원본을 HWPML 2.91 XML로 저장 (--json 봉투)",
            &["-o", "--json"],
            &["schemaVersion", "source", "output", "format", "bytes"],
        ),
        cmd_json(
            "export-doclang",
            "문서를 DocLang v0.6 XML로 내보내기 (--json 봉투)",
            &["-o", "--assets-dir", "--json"],
            &[
                "schemaVersion",
                "source",
                "output",
                "format",
                "doclangVersion",
                "bytes",
                "assetsDir",
                "assetCount",
                "lossCount",
            ],
        ),
        cmd_json(
            "export-capabilities-schema",
            "capabilities 자기서술 자체의 JSON Schema 산출 — 명령 표면 코드 생성의 단일 출처 (#3776)",
            &["--json", "--bare", "-o"],
            &[
                "schemaVersion",
                "capabilitiesSchemaVersion",
                "dialect",
                "definitionCount",
                "schema",
                "mcpSchema",
            ],
        ),
        // [#3907 O1] 자기서술 4축(IR 스키마·capabilities·MCP 도구·출처 지도)에서
        // 실행 시점에 기계 유도하는 JSON-LD 온톨로지 — 손 나열 상수 0.
        cmd_json(
            "export-ontology",
            "자기서술에서 기계 유도한 JSON-LD 온톨로지 산출 — IR 클래스·속성, 명령/MCP 행위, 신뢰 술어 (#3907 O1)",
            &["--json", "--bare", "-o"],
            &[
                "schemaVersion",
                "ontology",
                "classCount",
                "propertyCount",
                "actionCount",
            ],
        ),
        cmd_json(
            "export-tables",
            "표를 병합·중첩 구조를 보존한 격자 JSON으로 추출",
            &["-o", "--json"],
            &["schemaVersion", "source", "tableCount", "tables"],
        ),
        // [#3719 §6-7] 데이터 보고서 자동화의 입출구 — 표 ↔ CSV.
        cmd_json(
            "table-to-csv",
            "본문 최상위 표를 병합 격자를 채운 RFC 4180 CSV 로 내보내기",
            &["--table", "-o", "--bom", "--json"],
            &[
                "schemaVersion",
                "source",
                "tableCount",
                "tables",
                "bom",
                "output",
                "outputFormat",
            ],
        ),
        cmd_json(
            "csv-to-table",
            "CSV 로 기존 표 N 의 셀 덮어쓰기 — 표 크기 불변, 행·열 불일치는 invalid+exit 2",
            &["--csv", "--table", "-o", "--dry-run", "--verify", "--json"],
            &[
                "schemaVersion",
                "source",
                "csv",
                "table",
                "rowCount",
                "colCount",
                "changedCount",
                "changed",
                "invalid",
                "dryRun",
                "changedPages",
                "output",
                "outputFormat",
                "verify",
            ],
        ),
        // [#4100 B1] 차트 숫자 데이터의 입출구 — 표 CSV 와 같은 왕복 규약.
        cmd_json(
            "chart-to-csv",
            "차트 숫자 데이터를 RFC 4180 CSV 로 내보내기 (행=카테고리·분산형 X, 열=계열)",
            &["--chart", "-o", "--bom", "--json"],
            &[
                "schemaVersion",
                "source",
                "chartCount",
                "charts",
                "bom",
                "output",
                "outputFormat",
            ],
        ),
        cmd_json(
            "csv-to-chart",
            "CSV 로 기존 차트 N 의 값 덮어쓰기 — 기본은 계열·값 개수 불변, 불일치는 invalid+exit 2. \
             --structure 면 CSV 가 목표 상태: 행·열 증감(꼬리 기준)·계열명·라벨 변경도 쓴다 \
             (원형 계열 수 1 고정·주식형 계열 수 고정·마지막 1점/1계열 삭제는 거부). \
             편집은 OOXML 두 표현(zip 파트·중첩 CFB)에 함께 쓴다",
            &["--csv", "--chart", "-o", "--structure", "--dry-run", "--verify", "--json"],
            &[
                "schemaVersion",
                "source",
                "csv",
                "chart",
                "changedCount",
                "changed",
                "invalid",
                "wrote",
                "dryRun",
                "changedPages",
                "output",
                "outputFormat",
                "verify",
            ],
        ),
        cmd_json(
            "extract-pages",
            "쪽 범위만 남겨 저장 (--json 봉투; 발췌·부분 제출·결함 이분법)",
            &["--from", "--to", "--json"],
            &[
                "schemaVersion",
                "source",
                "output",
                "from",
                "to",
                "pagesBefore",
                "pagesAfter",
                "paragraphsKept",
                "paragraphsRemoved",
            ],
        ),
        cmd_json(
            "search",
            "문서 검색 결과를 구역·문단·페이지·문자 오프셋 주소와 함께 출력",
            &[
                "--json",
                "--ignore-case",
                "--limit",
                "--max-matches",
                "--context",
            ],
            &[
                "schemaVersion",
                "source",
                "query",
                "caseSensitive",
                "matchCount",
                "totalMatchCount",
                "truncated",
                "omittedCount",
                "matches",
            ],
        ),
        // [#3719 §6-10] 행정문서 구조화의 공통 프리미티브 — 값과 주소를 한 몸으로 낸다.
        cmd_json(
            "extract-data",
            "날짜·금액·수량을 구역·문단·페이지·문자 오프셋 주소와 함께 추출",
            &["--json", "--kind", "--limit"],
            &[
                "schemaVersion",
                "source",
                "kind",
                "itemCount",
                "totalItemCount",
                "truncated",
                "counts",
                "items",
            ],
        ),
        cmd_json(
            "fields",
            "누름틀/필드를 이름·안내문·현재값·위치와 함께 조사",
            &["--json"],
            &["schemaVersion", "source", "fieldCount", "fields"],
        ),
        // [#3828] 새 판정 로직이 아니라 info/export-structure/export-tables/fields의
        // 조합 — 처음 보는 문서를 사람/에이전트가 한 번에 파악하는 결정론적 요약.
        cmd_json(
            "explain",
            "문서를 결정론적 규칙 문장으로 요약(형식·쪽수·문단·표·누름틀·각주/미주·암호 여부)",
            &["--json"],
            &[
                "schemaVersion",
                "source",
                "format",
                "pageCount",
                "paragraphCount",
                "tables",
                "fields",
                "footnoteCount",
                "endnoteCount",
                "encrypted",
                "summary",
            ],
        ),
        // [#gym] 어포던스 라우터 — explain(문서가 무엇인지)·capabilities(도구 일반)와
        // 구별되는 세 번째 축: 이 문서로 무엇을 할 수 있는지. 기존 조회 개수에서 유도.
        cmd_json(
            "explore",
            "이 문서로 할 수 있는 rhwp 행동을 순위 매긴 메뉴로 라우팅(표·누름틀·구조·차트·보안·요약)",
            &["--json"],
            &[
                "schemaVersion",
                "source",
                "format",
                "pageCount",
                "encrypted",
                "affordanceCount",
                "menu",
                "note",
            ],
        ),
        // [#3787 S2/S3/S4] 문서를 읽기만 하는 보안 검사 명령군. 세 하위 명령의 플래그와
        // 봉투 필드는 합집합으로 광고해 capabilities 자체가 어느 축도 숨기지 않게 한다.
        cmd_json(
            "inspect",
            "은닉 텍스트·프롬프트 주입·유니코드 기만을 조사하는 읽기 전용 보안 검사 명령군",
            &[
                "--json",
                "--threshold-pt",
                "--include-offpage",
                "--min-confidence",
                "--include-fields",
                "--kind",
            ],
            &[
                "schemaVersion",
                "source",
                "thresholdPt",
                "includeOffPage",
                "hiddenText",
                "hiddenCharCount",
                "minConfidence",
                "includeFields",
                "scanScopes",
                "injectionSignals",
                "signalCount",
                "highestConfidence",
                "kindFilter",
                "scannedChars",
                "findings",
                "findingCount",
                "severityCounts",
                "kindCounts",
                "clean",
                "untrustedContent",
                "untrustedFields",
            ],
        ),
        // [프롬프트 주입 방패] inspect injection + 출처 표지 + nonce 격벽을 하나로 묶어
        // 어떤 문서든 본문을 프롬프트에 안전하게 넣을 수 있는 형태로 낸다.
        cmd_json(
            "armor",
            "문서 본문을 nonce 격벽으로 감싸고 주입 신호를 신고한다 — LLM 에 넣기 전 프롬프트 주입 방패",
            &["--json"],
            &[
                "schemaVersion",
                "source",
                "pageCount",
                "scanScopes",
                "safety",
                "armoredText",
                "injectionSignals",
                "signalCount",
                "clean",
                "untrustedContent",
                "untrustedFields",
            ],
        ),
        cmd(
            "export-render-tree",
            "페이지별 render tree bbox JSON 덤프",
        ),
        cmd_json(
            "convert",
            "HWPX/배포용→편집 가능 HWP5 변환 (--verify 게이트 exit 3/4, --json 봉투)",
            &["--verify", "--verify-pages", "--json"],
            &[
                "schemaVersion",
                "source",
                "output",
                "format",
                "bytes",
                "wasDistribution",
                "verify",
                "verifyPages",
            ],
        ),
        cmd_json(
            "build-from-ingest",
            "ingest JSON과 로컬 이미지에서 HWPX 생성 (--json 봉투)",
            &["-o", "--output", "--media-dir", "--json", "--max-image-bytes", "--max-total-image-bytes", "--max-image-pixels", "--max-total-image-pixels", "--max-image-instances"],
            &[
                "schemaVersion",
                "source",
                "output",
                "format",
                "bytes",
                "questionCount",
                "paragraphCount",
            ],
        ),
        cmd_json(
            "scaffold",
            "구조화된 명세(JSON)에서 유효한 HWPX 문서 생성 — 문서를 *만드는* 생성 축 (--json 봉투)",
            &["-o", "--output", "--format", "--json"],
            &[
                "schemaVersion",
                "source",
                "output",
                "format",
                "bytes",
                "blockCount",
                "paragraphCount",
                "tableCount",
            ],
        ),
        cmd_json(
            "thumbnail",
            "내장 썸네일(PrvImage) 추출 (--json 봉투)",
            &["-o", "--base64", "--data-uri", "--json"],
            &[
                "schemaVersion",
                "source",
                "format",
                "mime",
                "width",
                "height",
                "bytes",
                "output",
            ],
        ),
        // ── 편집 (#3329 Stage 3) ──
        cmd_json(
            "edit",
            "문서 편집 — fill-fields: 누름틀 채우기 / replace-text: 일괄 치환(--occurrence k번째만, 0부터, 생략 시 전체) / set-cell: 표 셀 기록 / insert-text-in-cell: 표 셀 문단 삽입 / delete-text-in-cell: 표 셀 문단 삭제 / insert-text: 문단 좌표 삽입 / delete-text: 문단 좌표 삭제 / insert-paragraph: 빈 문단 삽입 / delete-paragraph: 문단 삭제 / merge-paragraph: 문단 병합 / insert-page-break: 쪽 나눔 / insert-column-break: 단 나눔 / insert-table: 본문 표 생성 / insert-row: 표 행 삽입 / insert-col: 표 열 삽입 / delete-row: 표 행 삭제 / delete-col: 표 열 삭제 / merge-cells: 표 셀 병합 / split-cell: 병합 셀 분할 / split-table: 표 나누기 / fit-table: 표 폭 맞춤 / resize-table: 표 크기 조절 / merge-table: 다음 표와 붙이기 / merge-paragraph-in-cell: 표 셀 문단 병합 / set-column-widths: 표 열 폭 설정 / insert-footnote: 각주 삽입 / insert-endnote: 미주 삽입 / delete-footnote: 각주 삭제 / add-bookmark: 책갈피 추가 / delete-bookmark: 책갈피 삭제 / rename-bookmark: 책갈피 이름 변경 / delete-header-footer: 머리말/꼬리말 삭제 / insert-header-footer-text: 머리말/꼬리말 텍스트 삽입 / set-header-footer-text: 머리말/꼬리말 문단 텍스트 교체 / delete-hf-text: 머리말/꼬리말 텍스트 삭제 / split-paragraph-in-hf: 머리말/꼬리말 문단 분할 / merge-paragraph-in-hf: 머리말/꼬리말 문단 병합 / split-paragraph-in-cell: 표 셀 문단 분할 / delete-control: 컨트롤 삭제 / delete-table: 표 삭제 / insert-header-footer: 머리말/꼬리말 생성 / insert-image: 도장·서명 그림 삽입 / redact: 개인정보 마스킹 / sanitize: 메타데이터 제거",
            &[
                "--data",
                "--find",
                "--replace",
                "--ignore-case",
                "--table",
                "--row",
                "--col",
                "--below",
                "--right",
                "--vertical",
                "--forward",
                "--line",
                "--end-row",
                "--end-col",
                "--rows",
                "--cols",
                "--widths",
                "--count",
                "--cell-para",
                "--cell",
                "--start",
                "--end",
                "--bold",
                "--font-size",
                "--color",
                "--text",
                "--props",
                "--style",
                "--script",
                // [#4990] insert-text 축. search 주소와 같은 0 기준 구역·문단·문자 오프셋.
                "--section",
                "--para",
                "--offset",
                "--ctrl",
                "--name",
                "--header",
                "--footer",
                "--apply-to",
                "--field-type",
                "--type",
                "--same-width",
                "--mixed-width",
                "--spacing",
                "--hide-header",
                "--hide-footer",
                "--hide-master",
                "--hide-border",
                "--hide-fill",
                "--hide-page-num",
                // 같은 항목의 summary 가 이미 이름을 대고 있고 MCP 도구
                // hwp_set_checkbox 가 이 플래그를 고정 배선한다 — 목록에만 없었다.
                "--occurrence",
                "--keep-style",
                // [#3719 §6-5] insert-image 축. 길이 인자는 전부 HWPUNIT(1/7200 inch).
                "--image",
                "--page",
                "--x",
                "--y",
                "--width",
                "--height",
                "--shape",
                "--wrap",
                "--treat-as-char",
                // [#3719 §6-11] redact/sanitize 축. 선언 누락은 매니페스트만 읽는
                // 에이전트에게 "그 기능이 없는 것"과 같다.
                "--kind",
                "--mask",
                "--in-place",
                "--keep-preview",
                "-o",
                "--dry-run",
                // [redact-noraw] --dry-run 봉투의 findings[].raw 유출을 막는 옵션.
                "--no-raw",
                // [#3702] 모든 편집 축이 받는 저장 직후 자기검증.
                "--verify",
                "--json",
            ],
            &[
                "schemaVersion",
                "source",
                "dryRun",
                "filledCount",
                "filled",
                "notFound",
                "replacedCount",
                "table",
                "row",
                "col",
                "below",
                "right",
                "endRow",
                "endCol",
                "rows",
                "cols",
                "widths",
                "count",
                "columnCount",
                "columnType",
                "sameWidth",
                "spacing",
                "oldText",
                "newText",
                "keepStyle",
                "overflow",
                "cellPara",
                "innerPara",
                "props",
                "bold",
                "fontSize",
                "color",
                // [#4990] insert-text 봉투 축.
                "section",
                "paragraph",
                "offset",
                "ctrl",
                "name",
                "isHeader",
                "applyTo",
                "text",
                "insertedChars",
                "script",
                "fontSize",
                "color",
                "script",
                "fontSize",
                "color",
                // [#3719 §6-5] insert-image 봉투 축.
                "image",
                "page",
                "x",
                "y",
                "width",
                "height",
                "binDataId",
                "kinds",
                "mask",
                "inPlace",
                "findingCount",
                "findings",
                "redactedCount",
                "keepPreview",
                "removedCount",
                "removed",
                "changedPages",
                "output",
                "outputFormat",
                "verify",
            ],
        ),
        // ── 배치 ──
        cmd_json(
            "batch",
            "stdin 파일 목록을 한 프로세스에서 파일 간 병렬 처리, NDJSON 스트림 출력 (fill 축만 stdin 대신 --form 서식 + --data 행 파일로 메일머지)",
            // --query 는 search 축의 필수 인자다(없으면 exit 2). --out-dir 는 convert·fill
            // 공용, --verify-pages 는 convert 전용, --form·--name-field·--dry-run 은 fill
            // 전용이다. 모두 같은 top-level batch 명령의 인자이므로 축 단위 batch.flags 와
            // 함께 명령 항목에도 선언한다.
            &[
                "--json",
                "--threads",
                "--mode",
                "--query",
                "--out-dir",
                "--verify",
                "--verify-pages",
                "--form",
                "--name-field",
                "--dry-run",
                // extract-data 축 전용. batch.flags 에만 넣고 여기 빠뜨리면
                // 같은 매니페스트가 서로 다른 말을 하게 된다
                // (capabilities_declared_flags_are_real_cli_flags 가 잡는다).
                "--kind",
                "--limit",
            ],
            &[
                "schemaVersion",
                "source",
                "error",
                "exitClass",
                "row",
                "output",
                "filledCount",
                "notFound",
            ],
        ),
        // [#3918 승격 3호] 코퍼스 발견 — batch 가 전제하는 "경로 목록"의 원천.
        cmd_json(
            "scan",
            "디렉터리 재귀 발견·분류 — 확장자↔매직 대조(extMismatch), --probe 파싱 시도(암호·쪽수), batch stdin 목록의 원천",
            &["--probe", "--max-depth", "--limit", "--json"],
            &["schemaVersion", "roots", "files", "summary"],
        ),
        // 무기화 문서 구조 위협 탐지 — 읽기 전용 안전 에어락(컨테이너·레코드 구조 층).
        cmd_json(
            "threat-scan",
            "무기화 문서 구조 위협 탐지 — 파싱 전에 컨테이너·레코드 구조를 훑어 실행체 내장·OLE 패키지·손상 레코드·매크로/스크립트·원격 외부참조 신호를 열거한다. 휴리스틱 판정이며 안티바이러스가 아니다(신호이지 증거·보증이 아님). rhwp 의 실질 방어는 메모리 안전+DoS 하드닝이고 이 스캔은 그 위의 가시성이다.",
            &["--json"],
            &[
                "schemaVersion",
                "source",
                "format",
                "scanScopes",
                "findings",
                "findingCount",
                "highestSeverity",
                "clean",
                "truncated",
                "notes",
            ],
        ),
        // ── 진단 ──
        cmd("dump", "문서 조판부호 구조 덤프"),
        cmd_json(
            "dump-pages",
            "페이지네이션 항목 덤프 (--json: 조판 진단 기계 계약)",
            &["-p", "--respect-vpos-reset", "--json", "--compat"],
            &[
                "schemaVersion",
                "source",
                "pageCount",
                "pageFilter",
                "respectVposReset",
                "pages",
            ],
        ),
        cmd(
            "dump-extents",
            "레이아웃 트리 항목별 실제 extent 덤프 (쪽 밖 배치 조사용)",
        ),
        cmd("dump-note-shape", "각주/미주 모양 덤프"),
        cmd("dump-endnote-lines", "미주 줄 배치 덤프"),
        cmd("dump-records", "저수준 레코드 스트림 덤프"),
        cmd("diag", "문서 구조 진단(번호/글머리표/개요)"),
        cmd_json(
            "ir-diff",
            "두 문서의 IR 차이를 JSON으로 비교",
            &["-s", "-p", "--json"],
            // 실제 봉투는 a/b 다 (ir-diff 방출부, cli_commands.md 의 문서화된 모양도 동일).
            // 자기서술만 sourceA/sourceB 로 어긋나 있었다 — 매니페스트로 파서를 만드는
            // 에이전트는 비교 대상 경로를 통째로 못 읽는다.
            &[
                "schemaVersion",
                "a",
                "b",
                "identical",
                "diffCount",
                "categories",
                "pageCountA",
                "pageCountB",
            ],
        ),
        // [#4113 / #3918 승격 2호] 독립 사후검증 게이트 — 기대 조건 집합 대조.
        cmd_json(
            "verify",
            "기대 조건(--expect-pages/min-pages/max-pages/min-chars/min-tables/table-count/contains/not-contains/field/format) 대조 — 전부 만족 exit 0, 불일치는 봉투 후 exit 3",
            &[
                "--expect-pages",
                "--expect-min-pages",
                "--expect-max-pages",
                "--expect-min-chars",
                "--expect-min-tables",
                "--expect-table-count",
                "--expect-contains",
                "--expect-not-contains",
                "--expect-field",
                "--expect-format",
                "--json",
            ],
            &[
                "schemaVersion",
                "source",
                "expectations",
                "passCount",
                "failCount",
                "verdict",
            ],
        ),
        cmd_json(
            "render-diff",
            "왕복/두 파일 렌더 기하 차이 검증 — --json 회귀 검출은 exit 3 (--batch 는 NDJSON)",
            &["--json", "--batch", "--via", "-p", "--max-disp", "-o"],
            &[
                "schemaVersion",
                "mode",
                "sourceA",
                "sourceB",
                "via",
                "pageFilter",
                "threshold",
                "pageCountA",
                "pageCountB",
                "pageCountMismatch",
                "maxDisp",
                "worstPage",
                "overPages",
                "structPages",
                "hardStructPages",
                "status",
                "regression",
                "pages",
            ],
        ),
        cmd_json(
            "layout-anomaly",
            "렌더 한 장의 기하 이상탐지(overflow/off-canvas/overlap/text-overlap/stored-line-escape/empty_page) — render-diff(변위)와 다른 질문. overflow=본문 여백, off-canvas=페이지 상자·y<0, text-overlap=텍스트 런 bbox 교차, stored-line-escape=저장 줄을 재현한 줄의 글자가 남의 저장 줄 baseline 에 앉음. 기본 exit 0, --strict 만 확정 신호를 exit 3. --batch 는 NDJSON",
            &[
                "--json",
                "--batch",
                "-p",
                "--strict",
                "--types",
                "--overflow-tolerance",
                "--overlap-tolerance",
                "--stored-line-tolerance",
            ],
            &[
                "schemaVersion",
                "mode",
                "source",
                "pageCount",
                "pageFilter",
                "overflowTolerancePx",
                "overlapTolerancePx",
                "storedLineTolerancePx",
                "types",
                "strict",
                "overflowCount",
                "offCanvasCount",
                "overlapCount",
                "textOverlapCount",
                "storedLineEscapeCount",
                "emptyPageCount",
                "hasSignal",
                "pages",
            ],
        ),
        cmd("hwpx-roundtrip", "HWPX 왕복 무손실 게이트"),
        cmd("hwp5-roundtrip", "HWP5 왕복 무손실 게이트"),
        cmd("measure-width", "텍스트 폭 측정 프로브"),
        cmd("core-pages", "코어 페이지 수 프로브"),
        cmd("bench", "성능 벤치마크"),
        cmd("hwp5-inventory", "HWP5 레코드 인벤토리"),
        cmd("hwp5-inventory-diff", "HWP5 인벤토리 비교"),
        cmd(
            "hwp5-contract-analyze",
            "HWPX→HWP5 저장 계약 분석",
        ),
        cmd("hwp5-contract-probe", "HWP5 저장 계약 프로브"),
        cmd("hwp5-ctrl-data-trace", "CTRL_DATA 추적"),
        cmd("hwp5-table-probe", "표 저장 프로브"),
        cmd(
            "hwp5-mel-personnel-probe",
            "특정 샘플 재현 프로브",
        ),
        cmd(
            "hwp5-borderfill-diagonal-probe",
            "테두리 대각선 프로브",
        ),
        cmd(
            "hwp5-first-para-control-probe",
            "첫 문단 컨트롤 프로브",
        ),
        cmd("hwp5-anchor-trace", "앵커 추적"),
        cmd("hwp5-char-shape-audit", "CHAR_SHAPE provenance audit"),
        cmd("hwp5-cell-header-probe", "셀 헤더 프로브"),
        // ── 내부 개발용 ──
        cmd("test-shape", "도형 왕복 테스트"),
        cmd("test-caption", "고정 fixture 캡션 라운드트립 검증"),
        cmd("test-field", "누름틀 왕복 테스트"),
        cmd("gen-table", "표 샘플 생성"),
        cmd("gen-pua", "PUA 샘플 생성"),
    ]);
}