lark-hirono 0.1.0

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.
Files changed (122) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +240 -0
  3. package/dist/bin/lark-hirono.d.ts +18 -0
  4. package/dist/bin/lark-hirono.d.ts.map +1 -0
  5. package/dist/bin/lark-hirono.js +76 -0
  6. package/dist/bin/lark-hirono.js.map +1 -0
  7. package/dist/src/cli.d.ts +66 -0
  8. package/dist/src/cli.d.ts.map +1 -0
  9. package/dist/src/cli.js +275 -0
  10. package/dist/src/cli.js.map +1 -0
  11. package/dist/src/commands/analyze.d.ts +8 -0
  12. package/dist/src/commands/analyze.d.ts.map +1 -0
  13. package/dist/src/commands/analyze.js +49 -0
  14. package/dist/src/commands/analyze.js.map +1 -0
  15. package/dist/src/commands/auth.d.ts +9 -0
  16. package/dist/src/commands/auth.d.ts.map +1 -0
  17. package/dist/src/commands/auth.js +43 -0
  18. package/dist/src/commands/auth.js.map +1 -0
  19. package/dist/src/commands/fetch.d.ts +9 -0
  20. package/dist/src/commands/fetch.d.ts.map +1 -0
  21. package/dist/src/commands/fetch.js +77 -0
  22. package/dist/src/commands/fetch.js.map +1 -0
  23. package/dist/src/commands/highlight.d.ts +9 -0
  24. package/dist/src/commands/highlight.d.ts.map +1 -0
  25. package/dist/src/commands/highlight.js +135 -0
  26. package/dist/src/commands/highlight.js.map +1 -0
  27. package/dist/src/commands/optimize.d.ts +11 -0
  28. package/dist/src/commands/optimize.d.ts.map +1 -0
  29. package/dist/src/commands/optimize.js +103 -0
  30. package/dist/src/commands/optimize.js.map +1 -0
  31. package/dist/src/commands/upload.d.ts +8 -0
  32. package/dist/src/commands/upload.d.ts.map +1 -0
  33. package/dist/src/commands/upload.js +87 -0
  34. package/dist/src/commands/upload.js.map +1 -0
  35. package/dist/src/commands/verify.d.ts +8 -0
  36. package/dist/src/commands/verify.d.ts.map +1 -0
  37. package/dist/src/commands/verify.js +65 -0
  38. package/dist/src/commands/verify.js.map +1 -0
  39. package/dist/src/config.d.ts +33 -0
  40. package/dist/src/config.d.ts.map +1 -0
  41. package/dist/src/config.js +75 -0
  42. package/dist/src/config.js.map +1 -0
  43. package/dist/src/core/analyze.d.ts +20 -0
  44. package/dist/src/core/analyze.d.ts.map +1 -0
  45. package/dist/src/core/analyze.js +112 -0
  46. package/dist/src/core/analyze.js.map +1 -0
  47. package/dist/src/core/chunked.d.ts +26 -0
  48. package/dist/src/core/chunked.d.ts.map +1 -0
  49. package/dist/src/core/chunked.js +108 -0
  50. package/dist/src/core/chunked.js.map +1 -0
  51. package/dist/src/core/headings.d.ts +18 -0
  52. package/dist/src/core/headings.d.ts.map +1 -0
  53. package/dist/src/core/headings.js +129 -0
  54. package/dist/src/core/headings.js.map +1 -0
  55. package/dist/src/core/highlight.d.ts +39 -0
  56. package/dist/src/core/highlight.d.ts.map +1 -0
  57. package/dist/src/core/highlight.js +207 -0
  58. package/dist/src/core/highlight.js.map +1 -0
  59. package/dist/src/core/lark-table.d.ts +10 -0
  60. package/dist/src/core/lark-table.d.ts.map +1 -0
  61. package/dist/src/core/lark-table.js +301 -0
  62. package/dist/src/core/lark-table.js.map +1 -0
  63. package/dist/src/core/narrative.d.ts +93 -0
  64. package/dist/src/core/narrative.d.ts.map +1 -0
  65. package/dist/src/core/narrative.js +417 -0
  66. package/dist/src/core/narrative.js.map +1 -0
  67. package/dist/src/core/normalize.d.ts +35 -0
  68. package/dist/src/core/normalize.d.ts.map +1 -0
  69. package/dist/src/core/normalize.js +276 -0
  70. package/dist/src/core/normalize.js.map +1 -0
  71. package/dist/src/core/preprocess.d.ts +35 -0
  72. package/dist/src/core/preprocess.d.ts.map +1 -0
  73. package/dist/src/core/preprocess.js +168 -0
  74. package/dist/src/core/preprocess.js.map +1 -0
  75. package/dist/src/image/images.d.ts +59 -0
  76. package/dist/src/image/images.d.ts.map +1 -0
  77. package/dist/src/image/images.js +225 -0
  78. package/dist/src/image/images.js.map +1 -0
  79. package/dist/src/index.d.ts +12 -0
  80. package/dist/src/index.d.ts.map +1 -0
  81. package/dist/src/index.js +12 -0
  82. package/dist/src/index.js.map +1 -0
  83. package/dist/src/logging.d.ts +5 -0
  84. package/dist/src/logging.d.ts.map +1 -0
  85. package/dist/src/logging.js +7 -0
  86. package/dist/src/logging.js.map +1 -0
  87. package/dist/src/patch/patch.d.ts +45 -0
  88. package/dist/src/patch/patch.d.ts.map +1 -0
  89. package/dist/src/patch/patch.js +220 -0
  90. package/dist/src/patch/patch.js.map +1 -0
  91. package/dist/src/pipeline.d.ts +31 -0
  92. package/dist/src/pipeline.d.ts.map +1 -0
  93. package/dist/src/pipeline.js +383 -0
  94. package/dist/src/pipeline.js.map +1 -0
  95. package/dist/src/verify/verify.d.ts +59 -0
  96. package/dist/src/verify/verify.d.ts.map +1 -0
  97. package/dist/src/verify/verify.js +260 -0
  98. package/dist/src/verify/verify.js.map +1 -0
  99. package/package.json +67 -0
  100. package/src/cli.ts +336 -0
  101. package/src/commands/analyze.ts +56 -0
  102. package/src/commands/auth.ts +46 -0
  103. package/src/commands/fetch.ts +81 -0
  104. package/src/commands/highlight.ts +146 -0
  105. package/src/commands/optimize.ts +108 -0
  106. package/src/commands/upload.ts +91 -0
  107. package/src/commands/verify.ts +68 -0
  108. package/src/config.ts +103 -0
  109. package/src/core/analyze.ts +139 -0
  110. package/src/core/chunked.ts +136 -0
  111. package/src/core/headings.ts +143 -0
  112. package/src/core/highlight.ts +253 -0
  113. package/src/core/lark-table.ts +312 -0
  114. package/src/core/narrative.ts +540 -0
  115. package/src/core/normalize.ts +309 -0
  116. package/src/core/preprocess.ts +220 -0
  117. package/src/image/images.ts +301 -0
  118. package/src/index.ts +11 -0
  119. package/src/logging.ts +5 -0
  120. package/src/patch/patch.ts +269 -0
  121. package/src/pipeline.ts +406 -0
  122. package/src/verify/verify.ts +323 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Charles
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,240 @@
1
+ # lark-hirono
2
+
3
+ Markdown → Styled Feishu (Lark) documents with heading numbering, table conversion, and narrative optimizations.
4
+
5
+ ## Features
6
+
7
+ - **Subcommand CLI** — `upload`, `optimize`, `fetch`, `analyze`, `highlight`, `verify`, `auth`
8
+ - **Document types** — Automatic analysis: `catalog_table`, `data_table`, `narrative`, `mixed`
9
+ - **Heading styling** — Blue number prefix + rainbow backgrounds per level
10
+ - **Chinese ordinals** — `一、二、` → `1. 2.` auto-convert
11
+ - **Table conversion** — Markdown tables → `<lark-table>` XML with proportional widths
12
+ - **Keyword highlighting** — LLM-assisted `{red:keyword}` for table titles
13
+ - **Narrative optimizations** — Callout injection, code block tagging, signpost bolding
14
+ - **Chunked upload** — Large docs (>200KB) split automatically
15
+ - **Verify** — Block-level structure validation
16
+
17
+ ## Install
18
+
19
+ ### CLI (npm)
20
+
21
+ Requires Node.js 20+ and the Feishu CLI dependency used by `lark-hirono`.
22
+ After the package is published to npm, install the latest release with:
23
+
24
+ ```bash
25
+ npm install -g lark-hirono@latest
26
+ ```
27
+
28
+ ### Install `lark-cli`
29
+
30
+ `lark-hirono` shells out to `lark-cli` for auth, document APIs, and uploads. Install it first if you do not already have it:
31
+
32
+ ```bash
33
+ mkdir -p /tmp/larkcli
34
+ cd /tmp/larkcli
35
+ npm init -y
36
+ npm install @larksuite/cli
37
+ node node_modules/@larksuite/cli/scripts/install.js
38
+ ```
39
+
40
+ ### Claude Code Skill
41
+
42
+ ```bash
43
+ npx skills add charles1614/lark-hirono
44
+ ```
45
+
46
+ Then use `/lark-hirono` in Claude Code. See [`skills/lark-hirono/SKILL.md`](skills/lark-hirono/SKILL.md) for action reference.
47
+
48
+ ### Local Development
49
+
50
+ ```bash
51
+ corepack enable
52
+ corepack prepare pnpm@10.18.3 --activate
53
+ pnpm install
54
+ ```
55
+
56
+ ### Authentication
57
+
58
+ Before using the CLI or skill, authenticate with Feishu:
59
+
60
+ ```bash
61
+ lark-cli auth login --domain docs
62
+ ```
63
+
64
+ ## Usage
65
+
66
+ ### Upload Local Markdown
67
+
68
+ ```bash
69
+ lark-hirono upload input.md --title "My Document" --verify
70
+ ```
71
+
72
+ ### Optimize Existing Document
73
+
74
+ Create optimized sibling (recommended):
75
+ ```bash
76
+ lark-hirono optimize --doc GzlQwunV9iQAqmkQqOBcZzugnjf --new --verify
77
+ ```
78
+
79
+ Update in-place (not recommended due to Feishu export corruption):
80
+ ```bash
81
+ lark-hirono optimize --doc GzlQwunV9iQAqmkQqOBcZzugnjf --verify
82
+ ```
83
+
84
+ ### Fetch Document as Markdown
85
+
86
+ ```bash
87
+ lark-hirono fetch --doc GzlQwunV9iQAqmkQqOBcZzugnjf --output out.md
88
+ ```
89
+
90
+ ### Analyze Document Type
91
+
92
+ ```bash
93
+ lark-hirono analyze input.md
94
+ # Output: {"document_type": "narrative", "headings": 15, "tables": "0/0"}
95
+ ```
96
+
97
+ ### Verify Existing Document
98
+
99
+ ```bash
100
+ lark-hirono verify --doc GzlQwunV9iQAqmkQqOBcZzugnjf
101
+ ```
102
+
103
+ ## Commands
104
+
105
+ | Command | Description |
106
+ |---------|-------------|
107
+ | `upload <file.md>` | Create new styled Feishu document |
108
+ | `optimize --doc <id>` | Optimize existing document |
109
+ | `fetch --doc <id>` | Retrieve document as markdown |
110
+ | `analyze <file.md>` | Analyze document structure |
111
+ | `highlight <subcommand>` | Extract/apply keyword highlights |
112
+ | `verify --doc <id>` | Validate document structure |
113
+ | `auth <subcommand>` | Feishu authentication |
114
+
115
+ ### Common Flags
116
+
117
+ | Flag | Description |
118
+ |------|-------------|
119
+ | `--doc <id>` | Feishu document ID |
120
+ | `--new` | Create sibling doc instead of updating |
121
+ | `--input <file>` | Local markdown source |
122
+ | `--title <title>` | Document title |
123
+ | `--wiki-space <id>` | Target wiki space |
124
+ | `--wiki-node <token>` | Target parent node |
125
+ | `--bg-mode light\|dark` | Heading background palette |
126
+ | `--verify` | Validate after upload/optimize |
127
+ | `--no-highlight` | Skip keyword highlighting |
128
+ | `--dry-run` | Output to stdout, no API calls |
129
+ | `-v, --verbose` | Detailed logging |
130
+
131
+ ## Pipeline
132
+
133
+ ```
134
+ Upload: Read → Normalize → Analyze → Preprocess → Split → Highlight
135
+ → LarkTable → Upload → Patch → Verify
136
+
137
+ Optimize: Fetch → Normalize → Analyze → Narrative → Preprocess → Split
138
+ → LarkTable → Create → Patch → Verify
139
+ ```
140
+
141
+ ### Key Steps
142
+
143
+ 1. **Normalize** — HTML (`<p>`, `<ul>`, `<li>`, `<strong>`, `<a>`) → clean Markdown
144
+ 2. **Analyze** — Classify document type based on table count and heading density
145
+ 3. **Narrative** — For narrative docs: callout injection, code block tagging, signpost bolding
146
+ 4. **Preprocess** — Heading numbering, strip title, blue prefix + rainbow backgrounds
147
+ 5. **Split** — Oversized sections (>40KB) into chunks for API limits
148
+ 6. **Highlight** — Apply `{red:keyword}` from LLM-selected keywords (table docs only)
149
+ 7. **LarkTable** — Markdown tables → `<lark-table>` XML
150
+ 8. **Upload/Create** — Chunked doc creation via `lark-cli`
151
+ 9. **Patch** — Block-level PATCH for heading backgrounds
152
+ 10. **Verify** — Structure validation (block-level, not markdown export)
153
+
154
+ ## Narrative Optimizations
155
+
156
+ For `documentType === "narrative"` (≥3 headings, no tables):
157
+
158
+ - **Opening callout** — Inject `[!callout icon=bulb]` with first paragraph as description
159
+ - **Code block tagging** — Detect `bash`, `nginx`, `yaml`, `python` from content patterns
160
+ - **Blockquote conversion** — TL;DR and summary phrases → callout format
161
+ - **Signpost bolding** — Emphasize transition phrases (`具体来说`, `值得注意的是`)
162
+ - **Chatbot tail stripping** — Remove LLM artifact text from end of fetched docs
163
+
164
+ ## Config File
165
+
166
+ `lark-hirono.json` in current directory or ancestors:
167
+
168
+ ```json
169
+ {
170
+ "wikiSpace": "7620053427331681234",
171
+ "wikiNode": "UNtHwabqNiqc8ZkzvLscWNnwnYd",
172
+ "bgMode": "light",
173
+ "highlight": true
174
+ }
175
+ ```
176
+
177
+ Priority: CLI flags → config file → built-in defaults.
178
+
179
+ ## Tests
180
+
181
+ ```bash
182
+ npm test # 92 checks, all local file-based
183
+ ```
184
+
185
+ ## Architecture
186
+
187
+ ```
188
+ src/
189
+ ├── pipeline.ts # Master orchestration
190
+ ├── cli.ts # Lark CLI wrapper (auth, API calls)
191
+ ├── config.ts # Config file resolution
192
+ ├── commands/ # CLI subcommands
193
+ │ ├── upload.ts
194
+ │ ├── optimize.ts
195
+ │ ├── fetch.ts
196
+ │ ├── analyze.ts
197
+ │ ├── highlight.ts
198
+ │ ├── verify.ts
199
+ │ └── auth.ts
200
+ ├── core/
201
+ │ ├── analyze.ts # Document classification
202
+ │ ├── normalize.ts # HTML→Markdown cleanup
203
+ │ ├── preprocess.ts # Heading numbering, strip-title
204
+ │ ├── narrative.ts # Narrative doc optimizations
205
+ │ ├── headings.ts # Chinese ordinal conversion
206
+ │ ├── lark-table.ts # Table → XML conversion
207
+ │ ├── chunked.ts # Large doc splitting
208
+ │ └── highlight.ts # Keyword highlighting
209
+ ├── patch/
210
+ │ └── patch.ts # Heading background PATCH
211
+ ├── image/
212
+ │ └── images.ts # Image upload
213
+ └── verify/
214
+ └── verify.ts # Structure validation
215
+ ```
216
+
217
+ ## Limitations
218
+
219
+ ### Feishu Markdown Export Corruption
220
+
221
+ `lark-cli docs +fetch` does not faithfully round-trip markdown:
222
+ - Plain text blocks exported as `##` headings
223
+ - Consecutive paragraph lines merged (blank lines lost)
224
+ - Code block language tags stripped (`bash` → `plaintext`)
225
+ - Callout format simplified (blank lines removed)
226
+
227
+ **Mitigation:** Verify uses block-level structure (accurate), not markdown export (corrupted).
228
+
229
+ ### LLM Content Emphasis Not Automated
230
+
231
+ The optimization guide requires LLM judgment for:
232
+ - `{red:关键结论}` — identifying key conclusions
233
+ - `{green:技术术语}` — identifying technical terms
234
+ - Insight callouts — content understanding
235
+
236
+ These are **not automated** in the pipeline. Use the skill layer (`skills/lark-hirono/SKILL.md`) for LLM-assisted content optimization.
237
+
238
+ ## License
239
+
240
+ MIT
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * lark-hirono CLI — Markdown to styled Feishu documents.
4
+ *
5
+ * Usage:
6
+ * lark-hirono <command> [options]
7
+ *
8
+ * Commands:
9
+ * upload Create new Feishu document from local markdown
10
+ * optimize Update existing Feishu document with pipeline transforms
11
+ * fetch Retrieve Feishu document as markdown
12
+ * analyze Analyze markdown document structure
13
+ * highlight Extract/apply keyword highlights
14
+ * verify Fetch and verify an existing document
15
+ * auth Feishu authentication (passthrough to lark-cli)
16
+ */
17
+ export {};
18
+ //# sourceMappingURL=lark-hirono.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lark-hirono.d.ts","sourceRoot":"","sources":["../../bin/lark-hirono.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * lark-hirono CLI — Markdown to styled Feishu documents.
4
+ *
5
+ * Usage:
6
+ * lark-hirono <command> [options]
7
+ *
8
+ * Commands:
9
+ * upload Create new Feishu document from local markdown
10
+ * optimize Update existing Feishu document with pipeline transforms
11
+ * fetch Retrieve Feishu document as markdown
12
+ * analyze Analyze markdown document structure
13
+ * highlight Extract/apply keyword highlights
14
+ * verify Fetch and verify an existing document
15
+ * auth Feishu authentication (passthrough to lark-cli)
16
+ */
17
+ import * as upload from "../src/commands/upload.js";
18
+ import * as optimize from "../src/commands/optimize.js";
19
+ import * as fetch from "../src/commands/fetch.js";
20
+ import * as analyze from "../src/commands/analyze.js";
21
+ import * as highlight from "../src/commands/highlight.js";
22
+ import * as verify from "../src/commands/verify.js";
23
+ import * as auth from "../src/commands/auth.js";
24
+ const COMMANDS = {
25
+ upload,
26
+ optimize,
27
+ fetch,
28
+ analyze,
29
+ highlight,
30
+ verify,
31
+ auth,
32
+ };
33
+ function showHelp() {
34
+ console.log(`
35
+ lark-hirono — Markdown to styled Feishu documents
36
+
37
+ Usage:
38
+ lark-hirono <command> [options]
39
+
40
+ Commands:
41
+ upload <input.md> Create new styled Feishu document from local markdown
42
+ optimize --doc <id> Update existing document with pipeline transforms
43
+ fetch --doc <id> Retrieve Feishu document as markdown
44
+ analyze <input.md> Analyze markdown document structure
45
+ highlight <subcommand> Extract/apply keyword highlights
46
+ verify --doc <id> Fetch and verify an existing document
47
+ auth <subcommand> Feishu authentication (passthrough to lark-cli)
48
+
49
+ Options:
50
+ -h, --help Show help for a command
51
+ -v, --verbose Verbose logging
52
+
53
+ Run "lark-hirono <command> --help" for more information.
54
+ `);
55
+ }
56
+ async function main() {
57
+ const args = process.argv.slice(2);
58
+ if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
59
+ showHelp();
60
+ process.exit(0);
61
+ }
62
+ const [cmd, ...rest] = args;
63
+ if (!Object.hasOwn(COMMANDS, cmd)) {
64
+ console.error(`Unknown command: ${cmd}`);
65
+ console.error("Run 'lark-hirono --help' for available commands.");
66
+ process.exit(1);
67
+ }
68
+ const command = COMMANDS[cmd];
69
+ const exitCode = await command.run(rest);
70
+ process.exit(exitCode);
71
+ }
72
+ main().catch((err) => {
73
+ console.error(`Fatal error: ${err.message}`);
74
+ process.exit(1);
75
+ });
76
+ //# sourceMappingURL=lark-hirono.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lark-hirono.js","sourceRoot":"","sources":["../../bin/lark-hirono.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,6BAA6B,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,SAAS,MAAM,8BAA8B,CAAC;AAC1D,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAEhD,MAAM,QAAQ,GAAG;IACf,MAAM;IACN,QAAQ;IACR,KAAK;IACL,OAAO;IACP,SAAS;IACT,MAAM;IACN,IAAI;CACI,CAAC;AAIX,SAAS,QAAQ;IACf,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;CAoBb,CAAC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAClE,QAAQ,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAE5B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG,EAAE,CAAC,CAAC;QACzC,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAkB,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Lark CLI wrapper — thin subprocess interface to `lark-cli`.
3
+ *
4
+ * Auth is handled entirely by the CLI (`lark-cli auth login`).
5
+ * This module only calls the CLI binary and parses JSON output.
6
+ */
7
+ export declare function findLarkCli(): string;
8
+ export interface AuthStatus {
9
+ appId: string;
10
+ brand: string;
11
+ identity: string;
12
+ tokenStatus: "valid" | "needs_refresh" | "expired";
13
+ userOpenId: string;
14
+ userName: string;
15
+ expiresAt: string;
16
+ refreshExpiresAt: string;
17
+ scope: string;
18
+ }
19
+ export interface ApiResult {
20
+ code: number;
21
+ msg: string;
22
+ data?: Record<string, unknown>;
23
+ [key: string]: unknown;
24
+ }
25
+ export interface CliOptions {
26
+ cliPath?: string;
27
+ timeout?: number;
28
+ retries?: number;
29
+ }
30
+ export declare class LarkCli {
31
+ private cli;
32
+ private timeout;
33
+ private retries;
34
+ constructor(opts?: CliOptions);
35
+ /** Run lark-cli and return parsed JSON. */
36
+ private run;
37
+ /** Get current auth status. Throws if not logged in. */
38
+ status(): AuthStatus;
39
+ /** Generic GET request. */
40
+ get(path: string, params?: Record<string, unknown>): ApiResult | null;
41
+ /** Generic PATCH request. */
42
+ patch(path: string, data: Record<string, unknown>): ApiResult | null;
43
+ /** Update a section by title using replace_range mode. */
44
+ updateSection(docId: string, sectionTitle: string, markdown: string): boolean;
45
+ appendDoc(docId: string, markdown: string): boolean;
46
+ /** Generic POST request. */
47
+ post(path: string, data?: Record<string, unknown>): ApiResult | null;
48
+ /** Create a doc via the CLI's built-in shortcut. */
49
+ createDoc(title: string, markdown: string, wikiSpace?: string, wikiNode?: string): {
50
+ doc_id: string;
51
+ url: string;
52
+ } | null;
53
+ /** Get all blocks in a document. Paginates with small page_size to avoid ENOBUFS. */
54
+ getBlocks(docId: string): Record<string, unknown>[];
55
+ /** Delete a range of children from a block (batch_delete). Used for cleanup. */
56
+ deleteBlockChildrenTail(docId: string, parentBlockId: string, startIndex: number, endIndex: number): boolean;
57
+ /** Insert block children at a given index. */
58
+ createBlockChildren(docId: string, parentBlockId: string, children: Record<string, unknown>[], index: number): boolean;
59
+ /** PATCH a block with arbitrary payload. */
60
+ patchBlock(docId: string, blockId: string, payload: Record<string, unknown>): boolean;
61
+ /** Replace doc content with new markdown. */
62
+ updateDoc(docId: string, markdown: string): boolean;
63
+ /** Fetch doc content as markdown. Parses JSON stdout from lark-cli. */
64
+ fetchDoc(docId: string): string | null;
65
+ }
66
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH,wBAAgB,WAAW,IAAI,MAAM,CAapC;AAID,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,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