rhwp 0.9.0

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
use super::{cmd, cmd_json};

pub(super) fn extend(commands: &mut Vec<serde_json::Value>) {
    commands.extend([
        // ── 기계 계약(--json) 명령 ──
        cmd_json(
            "info",
            "문서 메타(포맷·버전·마지막 저장 제품·페이지/문단 수·폰트·제목) 표시",
            &["--json", "--font-plan"],
            &[
                "schemaVersion",
                "source",
                "format",
                "sizeBytes",
                "version",
                "sections",
                "pageCount",
                "paraCount",
                "fonts",
                "title",
                "lastSavedWith",
                "warnings",
            ],
        ),
        cmd_json(
            "word-count",
            "문서 분량(구역·문단·글자·어절·쪽 수) — IR 본문만 센다",
            &["--json"],
            &[
                "schemaVersion",
                "source",
                "sectionCount",
                "paragraphCount",
                "charCount",
                "wordCount",
                "pageCount",
            ],
        ),
        cmd_json(
            "bookmarks",
            "문서 책갈피 목록 — 코어 get_bookmarks_native",
            &["--json"],
            &[
                "schemaVersion",
                "source",
                "count",
                "bookmarks",
            ],
        ),
        cmd_json(
            "header-footer",
            "구역 머리말/꼬리말 한 건 조회 — 코어 get_header_footer_native",
            &["--json"],
            &[
                "schemaVersion",
                "source",
                "section",
                "isHeader",
                "applyTo",
                "exists",
            ],
        ),
        cmd_json(
            "headers-footers",
            "문서 머리말/꼬리말 목록 — 코어 get_header_footer_list_native",
            &["--json"],
            &[
                "schemaVersion",
                "source",
                "count",
                "headersFooters",
            ],
        ),
        cmd_json(
            "charts",
            "문서 차트 목록 — 코어 list_charts_native",
            &["--json"],
            &[
                "schemaVersion",
                "source",
                "count",
                "charts",
            ],
        ),
        cmd_json(
            "form-value",
            "양식 개체 값 조회 — 코어 get_form_value_native",
            &["--section", "--para", "--ctrl", "--json"],
            &[
                "schemaVersion",
                "source",
                "section",
                "paragraph",
                "ctrl",
                "ok",
                "formType",
                "name",
                "value",
                "text",
                "caption",
                "enabled",
            ],
        ),
        cmd_json(
            "export-text",
            "페이지별 텍스트 추출 (TXT 파일 또는 --json stdout)",
            &["-o", "-p", "--max-chars", "--json"],
            &[
                "schemaVersion",
                "source",
                "pageCount",
                "truncated",
                "omittedCount",
                "pages",
            ],
        ),
        cmd_json(
            "export-structure",
            "문서 개요/조문 계층을 JSON 트리로 추출",
            &["--mode", "-o", "--json"],
            &["schemaVersion", "source", "mode", "nodeCount", "structure"],
        ),
        // [#3633] 초소형 모델용 매크로 1호 — info+structure+발췌를 원콜로 묶는다.
        // [#3633 후속] v2: --sections(주소 보존 절 청크)·--pages(범위 발췌) 추가.
        cmd_json(
            "digest",
            "문서 요약 봉투(메타·개요·발췌·nextStep)를 한 번 호출로 출력",
            &["--sections", "--pages", "--max-chars", "--json"],
            &[
                "schemaVersion",
                "source",
                "format",
                "pageCount",
                "paraCount",
                "outline",
                "excerpt",
                "sections",
                "truncated",
                "nextStep",
            ],
        ),
        cmd_json(
            "export-ir-schema",
            "공개 IR 의 JSON Schema 산출 — 외부 바인딩 코드 생성의 단일 출처 (#3762)",
            &["--json", "--bare", "-o"],
            &["schemaVersion", "irSchemaVersion", "dialect", "definitionCount", "schema"],
        ),
        cmd_json(
            "run",
            "선언적 편집 계획 실행 — 정적 선검증·원자 실행·저널 (#3703). 선택 필드 \
             preconditions.inputSha256 을 실으면 실행 입구에서 입력 지문을 대조해 낡은 기준을 \
             거부한다 — 실행 0·디스크 무변경·preconditionFailed+nextCall·exit 3, --dry-run 도 \
             같은 판정 (#4378 R22). import_paragraph_block은 source{path,sha256}+request를 받는 단독 step이며 원본 SHA 불일치는 실행/저장 없이 exit 3이다. fill_template·repeat_and_fill_paragraph_block·repeat_and_fill_table_rows는 request를 받는 단독 step이며, dry-run도 동일 detached 준비를 수행한다 (#3587).",
            &["--json", "--plan-json", "--dry-run"],
            &[
                "schemaVersion",
                "planVersion",
                "input",
                "output",
                "outputFormat",
                "steps",
                "verify",
                "invalid",
                "preconditionFailed",
                "nextCall",
                "preview",
                "steps[].operationResult",
                "steps[].source",
                "steps[].workload",
                "inputSha256",
                "outputSha256",
            ],
        ),
        // [#4391] 작업 영수증 — run 계획의 제3자 재현·증명. 사용자 파일은 건드리지
        // 않는다(임시 산출만). attest = 영수증 발급, --expect-output-sha256 = 검증.
        cmd_json(
            "replay",
            "계획을 임시 산출로 재실행해 작업 영수증(입력·계획·산출 SHA-256)을 발급하고, --expect-output-sha256 로 타인의 작업 주장을 재현 검증한다 — 불일치는 exit 3 (#4391)",
            &["--json", "--plan-json", "--expect-output-sha256", "--capsule", "--parent", "--sign-key"],
            &[
                "schemaVersion",
                "mode",
                "input",
                "inputSha256",
                "planSha256",
                "outputSha256",
                "toolVersion",
                "steps",
                "reproduced",
                "expectedOutputSha256",
            ],
        ),
        cmd_json(
            "lineage",
            "작업 캡슐 해시 체인을 거슬러 연대기를 검증 — 부모 파일 무결·계보 불변식(부모 산출=자식 입력)·(--deep) 링크별 재현·(--keyring) 링크별 서명 귀속. 깨진 체인은 exit 3, brokenAt 명세 (#4401·#4509)",
            &["--json", "--deep", "--keyring", "--anchor-log"],
            &[
                "schemaVersion",
                "head",
                "depth",
                "valid",
                "brokenAt",
                "links",
            ],
        ),
        cmd_json(
            "keygen",
            "Ed25519 서명키 파일 발급 — 캡슐 귀속(4년 축)의 시작점. 비밀키가 담기므로 기존 파일 덮어쓰기 금지, 보관 책임은 소유자 (#4509)",
            &["--json", "--key-id", "--out"],
            &["schemaVersion", "keyId", "publicKey", "keyFile"],
        ),
        cmd_json(
            "verify-signature",
            "캡슐 분리 서명(<캡슐>.sig.json)을 파일 바이트·키 등록부와 대조 — verdict(valid|invalid|unknownKey|revoked|malformed)는 봉투 데이터, 유효 아님 = exit 3 (#4509)",
            &["--json", "--sig", "--keyring"],
            &[
                "schemaVersion",
                "capsule",
                "sigPath",
                "capsuleSha256",
                "capsuleShaMatches",
                "signatureOk",
                "keyId",
                "keyKnown",
                "revoked",
                "verdict",
            ],
        ),
        cmd_json(
            "harness",
            "검증 루프의 쓰는 쪽 — init(작업장 규약)·wrap(실산출+영수증+캡슐+자동 부모 연결+서명 한 방). 판정은 harness-status (#4537)",
            &["--json", "--plan", "--dir", "--sign-key", "--key-id"],
            &[
                "schemaVersion",
                "dir",
                "capsule",
                "output",
                "parent",
                "signed",
            ],
        ),
        cmd_json(
            "harness-status",
            "작업장 통합 판정 — 캡슐 체인 무결·(--keyring) 서명 집계·(--deep) 전수 재현을 한 봉투로. 깨짐 exit 3, brokenAt 이 원인 캡슐 (#4537)",
            &["--json", "--keyring", "--deep"],
            &[
                "schemaVersion",
                "dir",
                "capsules",
                "chainValid",
                "brokenAt",
                "signed",
                "reproduced",
                "verdict",
            ],
        ),
        cmd_json(
            "anchor",
            "투명성 로그(T7 방어) — add(append-only 등재, 깨진 로그 거부)·checkpoint(머클 루트)·verify(등재·자기 무결·머클 경로 판정, 아님 exit 3). 공표는 운영 절차 (#4543)",
            &["--json", "--log", "--checkpoint", "-o"],
            &[
                "schemaVersion",
                "log",
                "capsuleSha256",
                "seq",
                "upToSeq",
                "merkleRoot",
                "entries",
                "logChainOk",
                "logged",
                "inCheckpoint",
                "merklePath",
            ],
        ),
        cmd_json(
            "gate",
            "반입 정책 기계 판정 — admissionPolicy(연산자 eq·in·gte·lte 4종 고정, deny 기본, 미지 키 로드 거부)를 캡슐에 적용. 재료는 자기 신고가 아니라 재계산(계보·서명·앵커·--deep 재실행), 거부는 exit 3 + violations[] (#4545)",
            &["--json", "--policy", "--keyring", "--anchor-log", "--policy-keyring", "--deep"],
            &[
                "schemaVersion",
                "policy",
                "policyPath",
                "policySigned",
                "target",
                "targetSha256",
                "verdict",
                "evaluated",
                "violations",
            ],
        ),
        cmd_json(
            "bundle",
            "연합 교환 — export(계보 폐쇄집합+서명+머클 증명을 zip 하나로)·verify(컨테이너·폐쇄집합·계보·서명[도메인 키링만, 동봉 불신]·앵커 5단 오프라인 판정, 깨짐 exit 3) (#4549)",
            &["--json", "-o", "--anchor-log", "--checkpoint", "--domain", "--trust-domain"],
            &[
                "schemaVersion",
                "bundle",
                "head",
                "capsules",
                "signatures",
                "proofs",
                "trustDomain",
                "containerOk",
                "closureOk",
                "lineageValid",
                "signed",
                "anchored",
                "brokenAt",
                "verdict",
            ],
        ),
        cmd_json(
            "disclose",
            "선택적 공개 — redact(plan 문자열 잎을 salt 커밋으로 치환한 가림 캡슐+비밀 개봉 파일)·verify(부분 개봉 필드 대조, 불일치 exit 3)·restore(전체 개봉으로 바이트 완전 복원 — 원본 서명 그대로 valid) (#4551)",
            &["--json", "-o", "--opening-out", "--opening"],
            &[
                "schemaVersion",
                "capsule",
                "redacted",
                "opening",
                "committedFields",
                "originalCapsuleSha256",
                "verifiedFields",
                "mismatched",
                "unopened",
                "restored",
                "restoredSha256",
                "byteIdentical",
                "verdict",
            ],
        ),
        cmd_json(
            "settle",
            "정산 증빙 — propose(명세서·캡슐·게이트 봉투 3해시 고정 청구 발급, 4년 서명 선택)·verify(3해시 대조+게이트 verdict 재확인+서명·이중청구 opt-in 축, 실패 exit 3)·record(원장 append-only 기입, 이중 청구 전역 검사 exit 3) — 돈은 움직이지 않는다, 산출물은 제3자 검증 가능한 지불 근거뿐 (#4553)",
            &[
                "--json",
                "--workorder",
                "--capsule",
                "--gate-envelope",
                "-o",
                "--sign-key",
                "--keyring",
                "--ledger",
                "--sig",
                "--verdict",
            ],
            &[
                "schemaVersion",
                "claim",
                "workorderSha256",
                "capsuleSha256",
                "gateEnvelopeSha256",
                "signed",
                "workorderOk",
                "capsuleOk",
                "gateOk",
                "gateVerdict",
                "signerOk",
                "workorderSignerOk",
                "ledgerOk",
                "duplicate",
                "ledger",
                "seq",
                "claimSha256",
                "existingSeq",
                "verdict",
            ],
        ),
        cmd_json(
            "audit-report",
            "감사 보고 표준 — 캡슐 폴더의 재현(--deep)·계보·귀속(--keyring)·앵커(--anchor-log)·게이트(--policy) 수치를 기존 축 검증의 기계 합산으로 산출하고(kind agentLaborAuditReport) 보고서 자체를 4년 사이드카로 서명(--sign-key)한다 — \"감사 보고서를 감사할 수 있다\"가 표준의 요건 (#4558)",
            &["--json", "--deep", "--keyring", "--anchor-log", "--policy", "--sign-key", "-o"],
            &[
                "schemaVersion",
                "report",
                "capsules",
                "reproduction",
                "lineage",
                "attribution",
                "anchoring",
                "gate",
                "toolVersions",
                "signed",
            ],
        ),
        cmd_json(
            "recall-scope",
            "오염 리콜 범위 — 오염 캡슐(경로 또는 sha256)의 후손 폐쇄집합을 계보 걷기로 계산해 영향/미영향을 가르고, --ledger 를 주면 영향 캡슐의 정산 청구 좌표까지 짚는다(리콜의 회계 연결) (#4558)",
            &["--json", "--contaminated", "--among", "--ledger"],
            &[
                "schemaVersion",
                "contaminated",
                "affected",
                "unaffected",
                "claims",
            ],
        ),
        cmd_json(
            "conformance",
            "적합성 자가진단 L1~L5 — 영수증(1년)→감사가능+계보(2·3년)→귀속+앵커(4·5년)→게이트(6년)→원장(9년) 누적 요건을 기존 판정기 재사용으로 검사(신규 판정기 발명 0), 미달은 exit 3 이고 항목별 판정은 checks 가 말한다 (#4558)",
            &["--json", "--level", "--deep", "--keyring", "--anchor-log", "--policy", "--ledger"],
            &[
                "schemaVersion",
                "level",
                "capsules",
                "checks",
                "achieved",
                "verdict",
            ],
        ),
        cmd_json(
            "audit",
            "작업 캡슐(*.capsule.json) 폴더 전수 재실행·대조 — 에이전트 노동의 재현율 회계. 불일치 1건이라도 있으면 exit 3 (#4393)",
            &["--json"],
            &[
                "schemaVersion",
                "root",
                "total",
                "reproduced",
                "failed",
                "reproducedRate",
            ],
        ),
        // [#3719 §6-4] 계획서 문법의 단일 출처 — `run` 바로 뒤에 둔다. 계획을 실행하는
        // 명령과 계획을 쓰는 법을 알려주는 명령이 자기서술에서도 붙어 있어야 에이전트가
        // 하나를 보고 다른 하나를 놓치지 않는다.
        cmd_json(
            "export-plan-schema",
            "계획서(run) 문법의 JSON Schema 산출 — 계획 생성의 단일 출처 (#3719 §6-4)",
            &["--json", "--bare", "-o"],
            &[
                "schemaVersion",
                "planSchemaVersion",
                "dialect",
                "definitionCount",
                "schema",
            ],
        ),
        cmd_json(
            "capabilities",
            "본 자기서술 JSON 출력",
            &["--search"],
            &[
                "schemaVersion",
                "schemaRegistry",
                "tool",
                "version",
                "exitCodes",
                "commands",
                "batch",
            ],
        ),
        // [#3787 S1] 봉투 출처 지도 — 어느 필드가 문서(= 공격자 통제 가능)에서 오는지.
        cmd_json(
            "export-provenance-map",
            "명령별 문서 파생(신뢰 불가) 봉투 필드 지도 — 봉투의 untrustedContent/untrustedFields 표지의 원천",
            &["--json"],
            &[
                "schemaVersion",
                "tool",
                "version",
                "envelopeFlags",
                "pathSyntax",
                "policy",
                "commands",
            ],
        ),
        // [#3828 B2] capabilities·export-ir-schema·export-provenance-map·export-plan-schema
        // 를 한 봉투로 묶는다 — 처음 붙는 에이전트의 왕복 4회를 1회로.
        cmd_json(
            "export-agent-manifest",
            "capabilities+irSchema+provenanceMap+planSchema 를 한 번의 호출로 조립 — 누락 축이 생기면 missingAxes 로 명시 (#3828 B2)",
            &["--json", "--bare"],
            &["schemaVersion", "capabilities", "irSchema", "provenanceMap", "planSchema", "missingAxes"],
        ),
        cmd(
            "mcp-serve",
            "MCP 서버 (stdio JSON-RPC) — capabilities --mcp 도구 전부 + 세션 도구 실행 (#3140)",
        ),
    ]);
}