|
1 | 1 | # Hwping Spec |
2 | 2 |
|
3 | | -This file is the canonical statement of what Hwping is supposed to be. |
| 3 | +This file is the canonical durable statement of what Hwping is supposed to be. |
4 | 4 |
|
5 | | -## Identity |
| 5 | +It is not the implementation-status report or milestone tracker. Current state lives in `STATUS.md`; accepted future sequencing lives in `PLANS.md`. |
| 6 | + |
| 7 | +## Project Identity |
6 | 8 |
|
7 | 9 | - Project: Hwping |
8 | 10 | - Canonical repo: `https://github.com/LPFchan/Hwping` |
9 | 11 | - Project id: `hwping` |
10 | 12 | - Operator: `LPFchan` |
11 | 13 | - Last updated: `2026-04-09` |
12 | | -- Related decisions: `DEC-20260409-001` |
| 14 | +- Key decisions: `DEC-20260409-001`, `DEC-20260409-002`, `DEC-20260409-003`, `DEC-20260409-004`, `DEC-20260409-005` |
| 15 | + |
| 16 | +## What Hwping Is |
| 17 | + |
| 18 | +Hwping is a native macOS-focused HWP reader product and downstream fork of upstream `rhwp`. |
| 19 | + |
| 20 | +It is meant to let macOS users open `.hwp` and `.hwpx` documents from familiar Apple-platform surfaces, read them comfortably, preview them in Finder, automate simple read-only workflows, and export or print them without turning the shared document engine into app code. |
| 21 | + |
| 22 | +## Product Principles |
| 23 | + |
| 24 | +### v1 Is A Reader |
| 25 | + |
| 26 | +- Prioritize opening, reading, navigation, search, printing, PDF export, Quick Look, and automation. |
| 27 | +- Favor Preview-like document viewing and TextEdit-like macOS document-app conventions. |
| 28 | +- Keep full editing, annotations, collaboration, cloud sync, and complex authoring workflows out of the v1 promise. |
| 29 | + |
| 30 | +### Keep Engine And Product Separate |
| 31 | + |
| 32 | +- Rust owns the upstream-aligned HWP/HWPX parser, model, layout, renderer, serializer, and CLI behavior. |
| 33 | +- Downstream facade and FFI layers own the app-facing capability boundary. |
| 34 | +- Swift and Apple-platform targets own document lifecycle, windows, menus, Finder integration, Quick Look, App Intents, Shortcuts, and app UI. |
| 35 | +- AppKit, SwiftUI, PDFKit, Quick Look, Finder, App Intents, and Shortcuts behavior must not leak into `crates/rhwp/`. |
| 36 | + |
| 37 | +### Share One Capability Boundary |
| 38 | + |
| 39 | +The main app, Quick Look Preview extension, Quick Look Thumbnail extension, Shortcuts/App Intents, smoke targets, and future automation should reuse one document-loading and rendering capability boundary instead of each surface inventing its own engine path. |
| 40 | + |
| 41 | +## Intended System Shape |
| 42 | + |
| 43 | +```text |
| 44 | +user document (.hwp / .hwpx) |
| 45 | + -> Hwping.app (NSDocument-based) |
| 46 | + -> Quick Look Preview extension |
| 47 | + -> Quick Look Thumbnail extension |
| 48 | + -> App Intents / Shortcuts |
| 49 | +
|
| 50 | +each surface |
| 51 | + -> Apple-platform call layer |
| 52 | + -> hwping-ffi |
| 53 | + -> hwping-core |
| 54 | + -> rhwp |
| 55 | + -> parser / model / layout / renderer / serializer |
| 56 | +``` |
| 57 | + |
| 58 | +## Core Surfaces |
| 59 | + |
| 60 | +### `crates/rhwp/` |
| 61 | + |
| 62 | +Upstream-aligned shared engine area. |
| 63 | + |
| 64 | +Owns: |
13 | 65 |
|
14 | | -## Product Thesis |
| 66 | +- HWP and HWPX parsing |
| 67 | +- document model |
| 68 | +- layout and pagination |
| 69 | +- foundational SVG, PDF, bitmap, or preview-ready rendering paths |
| 70 | +- serialization |
| 71 | +- platform-independent CLI and debugging paths |
15 | 72 |
|
16 | | -Hwping is a macOS-focused downstream fork and product workspace built on top of upstream `rhwp`. It exists to ship a native HWP reader stack for Apple platforms while keeping the shared HWP and HWPX engine as upstream-aligned and syncable as possible. |
| 73 | +Default rule: treat changes here as upstreamable unless there is a concrete recorded reason for a local compatibility patch. |
17 | 74 |
|
18 | | -## Primary User And Context |
| 75 | +### `crates/hwping-core/` |
19 | 76 |
|
20 | | -- Primary operator: Hwping maintainer and collaborators |
21 | | -- Primary environment: a Cargo workspace with downstream Rust, FFI, and Apple-platform targets |
22 | | -- Primary problem being solved: deliver reliable HWP and HWPX reading workflows on macOS without letting the fork drift into an unsyncable multi-product repository |
23 | | -- Why this matters: reading correctness, product focus, and upstream sync cost all depend on keeping shared engine work and Apple-platform product work sharply separated |
| 77 | +App-facing Rust facade. |
24 | 78 |
|
25 | | -## Primary Workspace Object |
| 79 | +Expected operation families: |
26 | 80 |
|
27 | | -The primary user-facing object is an HWP or HWPX document rendered through an upstream-aligned engine and delivered through native macOS surfaces. |
| 81 | +- open a document from bytes or path |
| 82 | +- report document info, page count, page size, and first-page metadata |
| 83 | +- render preview-ready PDF or page images |
| 84 | +- render first-page thumbnail data |
| 85 | +- extract text and search for a query |
| 86 | +- export PDF |
| 87 | +- normalize product-facing errors |
28 | 88 |
|
29 | | -## Canonical Interaction Model |
| 89 | +### `crates/hwping-ffi/` |
30 | 90 |
|
31 | | -1. A user opens an HWP or HWPX document from the app, Finder, or a Quick Look surface. |
32 | | -2. Hwping parses and renders the document through `crates/rhwp/`. |
33 | | -3. Downstream facade and FFI layers expose metadata, page data, and rendered output to Apple-platform callers. |
34 | | -4. The app or extension presents reading, preview, search, export, and system integration workflows. |
35 | | -5. Maintainers preserve shared-core correctness and review upstream changes through `upstream-intake/`. |
| 91 | +Swift-facing ABI boundary. |
36 | 92 |
|
37 | | -## Core Capabilities |
| 93 | +Owns conversion of strings, paths, bytes, handles, errors, metadata structs, preview bytes, ownership, and lifetime rules. |
38 | 94 |
|
39 | | -- Capability: upstream-aligned HWP and HWPX parsing and rendering |
40 | | - - Why it exists: Hwping needs accurate document understanding and output while staying cheap to sync with upstream `rhwp` |
41 | | - - What must remain true: shared-core fixes should stay upstreamable or at least upstream-shaped unless a concrete Hwping-only reason exists |
42 | | -- Capability: downstream macOS product boundary |
43 | | - - Why it exists: Hwping needs app, FFI, Quick Look, and Apple integration without contaminating the engine core |
44 | | - - What must remain true: Apple-platform behavior stays outside `crates/rhwp/` |
45 | | -- Capability: disciplined repo operations and upstream intake |
46 | | - - Why it exists: a downstream fork needs explicit truth, plans, decisions, worklogs, and recurring upstream review |
47 | | - - What must remain true: root truth docs, provenance records, and `upstream-intake/` remain canonical |
| 95 | +### `apps/` And `extensions/` |
48 | 96 |
|
49 | | -## Invariants |
| 97 | +Downstream Apple-platform product targets. |
50 | 98 |
|
51 | | -- `crates/rhwp/` is the upstream-aligned engine area. |
52 | | -- Apple-platform code lives in downstream layers such as `crates/hwping-core/`, `crates/hwping-ffi/`, `apps/`, and `extensions/`. |
53 | | -- Root `SPEC.md`, `STATUS.md`, and `PLANS.md` hold canonical project truth, current state, and accepted future direction. |
54 | | -- `upstream-intake/` is the canonical recurring upstream-review module. |
55 | | -- `mydocs/` stores shared technical, troubleshooting, and manual material that supports but does not replace the root truth docs. |
56 | | -- Hwping-specific accepted direction and architecture decisions live in root docs and `DEC-*` records, not in a separate `mydocs/hwping/` subtree. |
| 99 | +Intended targets: |
| 100 | + |
| 101 | +- main `NSDocument`-based Hwping app |
| 102 | +- Quick Look Preview extension |
| 103 | +- Quick Look Thumbnail extension |
| 104 | +- smoke and integration targets needed to validate the app boundary |
| 105 | + |
| 106 | +## Native Reader Experience |
| 107 | + |
| 108 | +The target app should behave like a normal macOS document app: |
| 109 | + |
| 110 | +- Finder double-click opens a document in Hwping. |
| 111 | +- Recent documents, windows, tabs, state restoration, printing, and standard app menus behave consistently with macOS expectations. |
| 112 | +- Space bar Quick Look preview works without launching the full app UI. |
| 113 | +- Finder thumbnails are fast enough not to make ordinary folder browsing feel broken. |
| 114 | +- Search, page movement, zooming, fit behavior, printing, and PDF export use one command model across menus, shortcuts, toolbar actions, intents, and automation when practical. |
| 115 | + |
| 116 | +## Viewing Strategy |
| 117 | + |
| 118 | +The accepted v1 direction favors a PDF-backed viewing path: |
| 119 | + |
| 120 | +```text |
| 121 | +.hwp / .hwpx |
| 122 | + -> rhwp parsing and layout |
| 123 | + -> preview-ready PDF generation |
| 124 | + -> native PDF-backed viewing or preview surface |
| 125 | +``` |
| 126 | + |
| 127 | +This path should get Hwping to native scrolling, zooming, printing, and Preview-like behavior faster than a custom page view. It must not prevent a direct page renderer later if text selection, accessibility, overlays, search quality, or navigation demands it. |
| 128 | + |
| 129 | +## Error, Cache, And Quality Expectations |
| 130 | + |
| 131 | +User-visible errors should stay short and actionable, grouped around cases like open failure, corrupted document, unsupported feature, font substitution difference, render failure, permission failure, or file-access failure. |
| 132 | + |
| 133 | +Likely cache targets include preview PDF, first-page thumbnail, page size, page count, document metadata, and render options. Cache invalidation should be able to account for file identity, file size, modification time, render parameters, and engine version. |
| 134 | + |
| 135 | +Quality expectations: |
| 136 | + |
| 137 | +- Ordinary documents should show a first useful reading surface quickly. |
| 138 | +- Quick Look and thumbnail paths should have tighter budgets than the full app. |
| 139 | +- App-shell menus, buttons, search UI, zoom, opening, and page movement should be keyboard-accessible and VoiceOver-friendly. |
| 140 | +- Document-content accessibility can improve after v1, but app-shell accessibility is part of the baseline product quality. |
| 141 | + |
| 142 | +## Repository Operating Contract |
| 143 | + |
| 144 | +Hwping uses the repo-template model, with Hwping-specific rules in `REPO.md`. |
| 145 | + |
| 146 | +- `SPEC.md`, `STATUS.md`, and `PLANS.md` hold canonical truth, current state, and accepted future direction. |
| 147 | +- `records/decisions/` holds durable decisions. |
| 148 | +- `records/agent-worklogs/` holds useful execution history. |
| 149 | +- `research/` holds reusable exploration. |
| 150 | +- `upstream-intake/` holds recurring upstream-review artifacts. |
| 151 | +- `mydocs/tech/`, `mydocs/troubleshootings/`, and `mydocs/manual/` hold deeper shared technical, investigation, and manual material. |
| 152 | + |
| 153 | +Do not recreate a dedicated `mydocs/hwping/` tree. |
57 | 154 |
|
58 | 155 | ## Non-Goals |
59 | 156 |
|
60 | | -- web demo hosting |
| 157 | +- full editing for v1 |
| 158 | +- annotations and collaboration for v1 |
| 159 | +- cloud sync for v1 |
| 160 | +- an iOS release alongside the first macOS app |
| 161 | +- web demo hosting in the main Hwping tree |
61 | 162 | - npm package distribution for old web or editor surfaces |
62 | 163 | - VS Code extension distribution |
63 | | -- legacy browser-only infrastructure |
64 | | - |
65 | | -## Main Surfaces |
66 | | - |
67 | | -- Surface: `crates/rhwp/` |
68 | | - - Purpose: upstream-aligned parser, model, renderer, serializer, and CLI engine |
69 | | - - Notes: treat engine changes as upstreamable by default |
70 | | -- Surface: `crates/hwping-core/`, `crates/hwping-ffi/`, `apps/`, and `extensions/` |
71 | | - - Purpose: downstream product and Apple-platform integration surfaces |
72 | | - - Notes: keep these boundaries clean and product-owned |
73 | | -- Surface: `SPEC.md`, `STATUS.md`, `PLANS.md`, `INBOX.md`, `research/`, `records/`, and `upstream-intake/` |
74 | | - - Purpose: canonical repo operating surfaces |
75 | | - - Notes: keep truth, intake, research, decisions, logs, and upstream review distinct |
76 | | -- Surface: `mydocs/` |
77 | | - - Purpose: shared technical notes, troubleshooting references, and manuals |
78 | | - - Notes: use these docs for depth, not as a substitute for root truth docs or decision records |
| 164 | +- legacy browser-only infrastructure kept only for history |
79 | 165 |
|
80 | 166 | ## Success Criteria |
81 | 167 |
|
82 | | -- Hwping ships a native macOS reader stack without reabsorbing removed upstream product surfaces. |
83 | | -- Shared engine work remains cheap to sync with upstream `rhwp`. |
84 | | -- Maintainers can answer what Hwping is, what is true now, what is accepted next, what was decided, and what happened by reading the repo itself. |
| 168 | +Hwping succeeds when: |
| 169 | + |
| 170 | +- a macOS user can open an HWP/HWPX document, preview it, navigate it, search it, print it, export it, and automate basic read-only tasks through native-feeling surfaces |
| 171 | +- shared engine correctness keeps improving without product code contaminating upstream-aligned code |
| 172 | +- upstream `rhwp` changes can be reviewed and adapted deliberately |
| 173 | +- maintainers can recover current truth, accepted direction, key decisions, research, execution history, and upstream-intake outcomes from the repo itself |
0 commit comments