@mkterswingman/5mghost-wonder 0.0.17 → 0.0.19

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.
@@ -159,6 +159,11 @@ export async function runBrowserNoExportRead(options) {
159
159
  evidence.push("opendoc-response");
160
160
  if (extracted?.text)
161
161
  evidence.push("initial-attributed-text");
162
+ if ((extracted?.tables.length ?? 0) > 0)
163
+ evidence.push("table-control-characters");
164
+ if ((extracted?.tables ?? []).some((table) => table.rows.some((row) => row.some((cell) => (cell.colSpan ?? 1) > 1)))) {
165
+ evidence.push("horizontal-colspan-inference");
166
+ }
162
167
  if (extracted?.structureHints)
163
168
  evidence.push("structure-hints");
164
169
  const images = options.saveDir && extracted?.imageUrls
@@ -182,6 +187,7 @@ export async function runBrowserNoExportRead(options) {
182
187
  textLength: extracted?.text.length,
183
188
  imageUrls: extracted?.imageUrls,
184
189
  images,
190
+ tables: extracted?.tables,
185
191
  structureHints: extracted?.structureHints,
186
192
  extraction: extracted?.text ? "opendoc-initial-attributed-text" : "none",
187
193
  evidence,
@@ -189,7 +195,7 @@ export async function runBrowserNoExportRead(options) {
189
195
  "No readable opendoc initialAttributedText was captured.",
190
196
  ],
191
197
  missing: [
192
- "table merge ranges",
198
+ "vertical table merge ranges",
193
199
  ...(images.some((image) => image.status === "downloaded") ? [] : ["image original resources"]),
194
200
  "image anchors",
195
201
  "floating vs fixed image classification",
@@ -314,6 +320,7 @@ export function extractTextFromOpendoc(body) {
314
320
  if (!text)
315
321
  return null;
316
322
  const imageUrls = extractImageUrls(decodedText);
323
+ const tables = extractTablesFromDecodedText(decodedText);
317
324
  const structureHints = analyzeOpendocStructure({
318
325
  opendocBody: body,
319
326
  htmlData: typeof payload.htmlData === "string" ? payload.htmlData : "",
@@ -325,15 +332,55 @@ export function extractTextFromOpendoc(body) {
325
332
  padType: payload.clientVars?.padType ?? payload.padType,
326
333
  text,
327
334
  imageUrls,
335
+ tables,
328
336
  structureHints,
329
337
  warnings: [
330
338
  "No-export text is decoded from opendoc initialAttributedText; rich styles are not reconstructed yet.",
339
+ ...(tables.some((table) => table.rows.some((row) => row.some((cell) => (cell.colSpan ?? 1) > 1)))
340
+ ? ["Horizontal table colSpan is inferred from row cell counts; vertical rowSpan is not reconstructed yet."]
341
+ : []),
331
342
  ...(imageUrls.length > 0
332
343
  ? ["Image resource URLs were detected, but image anchors and fixed/floating placement are not reconstructed yet."]
333
344
  : []),
334
345
  ],
335
346
  };
336
347
  }
348
+ function extractTablesFromDecodedText(decodedText) {
349
+ const tables = [];
350
+ const tablePattern = /\x1a([\s\S]*?)\x1b/g;
351
+ for (const match of decodedText.matchAll(tablePattern)) {
352
+ const body = match[1] ?? "";
353
+ const rows = body
354
+ .split("\x06")
355
+ .map((row) => row
356
+ .split("\x07")
357
+ .map((cell) => normalizeTableCellText(cell))
358
+ .filter((text) => text.length > 0)
359
+ .map((text) => ({ text })))
360
+ .filter((row) => row.length > 0);
361
+ inferHorizontalColSpans(rows);
362
+ if (rows.length > 0)
363
+ tables.push({ rows });
364
+ }
365
+ return tables;
366
+ }
367
+ function inferHorizontalColSpans(rows) {
368
+ const maxColumnCount = Math.max(0, ...rows.map((row) => row.length));
369
+ if (maxColumnCount <= 1)
370
+ return;
371
+ for (const row of rows) {
372
+ if (row.length !== 1)
373
+ continue;
374
+ row[0].colSpan = maxColumnCount;
375
+ }
376
+ }
377
+ function normalizeTableCellText(value) {
378
+ return value
379
+ .replace(/\r/g, "")
380
+ .replace(/[\u0000-\u0006\u0008-\u001f\u007f-\u009f]+/g, "")
381
+ .replace(/[^\S\r\n]+/g, " ")
382
+ .trim();
383
+ }
337
384
  function analyzeOpendocStructure(input) {
338
385
  return {
339
386
  opendoc: summarizeStructureSignals(input.opendocBody),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mkterswingman/5mghost-wonder",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "企微文档读取 CLI — WeCom document reader",
5
5
  "type": "module",
6
6
  "engines": {
@@ -7,9 +7,9 @@ description: Use this skill when the user wants to install or set up wonder, say
7
7
 
8
8
  ## Skill version
9
9
 
10
- This skill matches **wonder 0.0.17**.
10
+ This skill matches **wonder 0.0.19**.
11
11
 
12
- Once the CLI is installed in Step 1, run `wonder --version`. If the output does not equal `0.0.17`, the CLI on disk has drifted from the skill text loaded in this session. Ask the user to run `/update-5mghost-wonder`, then **start a fresh AI session** (`/exit` and re-enter, or open a new chat) — skill text already loaded into a running session does not refresh after `wonder update`, even though the file on disk has been replaced.
12
+ Once the CLI is installed in Step 1, run `wonder --version`. If the output does not equal `0.0.19`, the CLI on disk has drifted from the skill text loaded in this session. Ask the user to run `/update-5mghost-wonder`, then **start a fresh AI session** (`/exit` and re-enter, or open a new chat) — skill text already loaded into a running session does not refresh after `wonder update`, even though the file on disk has been replaced.
13
13
 
14
14
  After a successful first install, also remind the user to start a fresh AI session before invoking `/use-5mghost-wonder` for the first time. The skill files were just written to disk; the current session never loaded them.
15
15
 
@@ -7,7 +7,7 @@ description: Use this skill when the user wants to update or upgrade wonder, say
7
7
 
8
8
  ## Skill version
9
9
 
10
- This skill matches **wonder 0.0.17**.
10
+ This skill matches **wonder 0.0.19**.
11
11
 
12
12
  ---
13
13
 
@@ -10,10 +10,10 @@ the referenced workflow files needed for the current task.
10
10
 
11
11
  ## Version Gate
12
12
 
13
- This skill matches **wonder 0.0.17**.
13
+ This skill matches **wonder 0.0.19**.
14
14
 
15
15
  On first use in a session, follow `references/session-init.md`. If the installed
16
- CLI version differs from `0.0.17`, stop and ask the user to run
16
+ CLI version differs from `0.0.19`, stop and ask the user to run
17
17
  `/update-5mghost-wonder`, then start a fresh AI session.
18
18
 
19
19
  ## Hard Rules
@@ -37,10 +37,12 @@ wonder browser read <url> --save /tmp/wonder-browser-read
37
37
  ```
38
38
 
39
39
  This currently attempts text extraction from the browser `opendoc`
40
- `initialAttributedText`, downloads detected image resources when `--save` is
40
+ `initialAttributedText`, decodes simple table cells from WeCom table control
41
+ characters, infers horizontal `colSpan` when a single-cell row spans the
42
+ table's max row width, downloads detected image resources when `--save` is
41
43
  present, and returns safe `structureHints` for `htmlData`,
42
44
  `initialAttributedText`, and the full `opendoc` body. Treat it as `partial`
43
- unless it also proves actual table cells, merge ranges, and image anchors.
45
+ unless it also proves vertical merge ranges and image anchors.
44
46
 
45
47
  3. If the read is insufficient, run the evidence probe:
46
48
 
@@ -61,11 +63,13 @@ Use `--headed` only when login/debug visibility is needed.
61
63
  - WebSocket messages if they expose structured document operations
62
64
  - screenshots only as a fallback or visual cross-check
63
65
  6. For tables, specifically look for:
66
+ - `tables[].rows[].text` for simple table cell content
67
+ - `tables[].rows[].colSpan` for inferred horizontal merged cells
64
68
  - `structureHints.*.hasTableSignals` and `hasMergeSignals`
65
69
  - `structureHints.htmlData.hasTableMarkup`
66
70
  - cell coordinates
67
71
  - displayed text
68
- - merge ranges
72
+ - vertical merge ranges / `rowSpan`
69
73
  - row/column sizes if available
70
74
  - fixed cell images
71
75
  - floating images with position, size, and anchor
@@ -86,6 +90,14 @@ Return a concise result:
86
90
  "mergeRangesAvailable": true,
87
91
  "imagesAvailable": true,
88
92
  "imageAnchorsAvailable": true,
93
+ "tables": [
94
+ {
95
+ "rows": [
96
+ [{ "text": "A1B1", "colSpan": 2 }],
97
+ [{ "text": "A2" }, { "text": "B2" }]
98
+ ]
99
+ }
100
+ ],
89
101
  "structureHints": {
90
102
  "htmlData": {
91
103
  "hasTableMarkup": true,
@@ -41,7 +41,8 @@ The goal is lossless structured data. Verify each field independently:
41
41
 
42
42
  - text
43
43
  - table cell coordinates
44
- - merge ranges
44
+ - horizontal `colSpan`
45
+ - vertical merge ranges / `rowSpan`
45
46
  - image original resources or URLs
46
47
  - image anchors, positions, and sizes
47
48
  - floating vs fixed cell images