@mkterswingman/5mghost-wonder 0.0.9 → 0.0.10

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.
package/dist/cli.js CHANGED
@@ -9,6 +9,32 @@ import { createWonderTelemetryRuntime } from "./telemetry/runtime.js";
9
9
  import { createWonderAuthSdk } from "./auth/runtime.js";
10
10
  import { resolveTelemetryCommand, classifyUnhandledCliError, } from "./telemetry/policy.js";
11
11
  import { buildCompletionTelemetry } from "./telemetry/events.js";
12
+ // How long to wait for in-flight telemetry flushes before exiting. Long
13
+ // enough to cover the SDK's full network roundtrip in the typical case
14
+ // (~1s on a healthy connection), short enough to not block a stuck
15
+ // upload behind the SDK's own 10s timeout. Events that miss the
16
+ // deadline stay in the outbox and are picked up by the next
17
+ // `wonder` invocation's startup flush.
18
+ const TELEMETRY_DRAIN_MS = 5000;
19
+ async function drainTelemetry(rt) {
20
+ if (!rt)
21
+ return;
22
+ const flightTask = rt.flushTask;
23
+ if (!flightTask)
24
+ return;
25
+ let timer;
26
+ const deadline = new Promise((resolve) => {
27
+ timer = setTimeout(resolve, TELEMETRY_DRAIN_MS);
28
+ timer.unref?.();
29
+ });
30
+ try {
31
+ await Promise.race([flightTask.catch(() => undefined), deadline]);
32
+ }
33
+ finally {
34
+ if (timer)
35
+ clearTimeout(timer);
36
+ }
37
+ }
12
38
  // ── Global error handlers (catch errors outside async dispatch) ─────────────
13
39
  process.on("uncaughtException", (err) => {
14
40
  process.stderr.write(`Unhandled exception: ${String(err)}\n`);
@@ -51,6 +77,7 @@ try {
51
77
  // No arguments → show help, exit 0
52
78
  if (argv.length === 0) {
53
79
  const result = await runHelpCommand(io);
80
+ await drainTelemetry(telemetry);
54
81
  process.exit(result.exitCode);
55
82
  }
56
83
  const result = await dispatchWonderCommand(argv, context);
@@ -62,6 +89,7 @@ try {
62
89
  // Telemetry failure must never change the CLI exit code.
63
90
  }
64
91
  }
92
+ await drainTelemetry(telemetry);
65
93
  process.exit(result.exitCode);
66
94
  }
67
95
  catch (err) {
@@ -79,5 +107,6 @@ catch (err) {
79
107
  }
80
108
  }
81
109
  io.stderr(`Unhandled error: ${String(err)}`);
110
+ await drainTelemetry(telemetry);
82
111
  process.exit(1);
83
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mkterswingman/5mghost-wonder",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
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.9**.
10
+ This skill matches **wonder 0.0.10**.
11
11
 
12
- Once the CLI is installed in Step 1, run `wonder --version`. If the output does not equal `0.0.9`, 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.10`, 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.9**.
10
+ This skill matches **wonder 0.0.10**.
11
11
 
12
12
  ---
13
13
 
@@ -7,9 +7,9 @@ description: Use this skill when the user shares a URL containing "doc.weixin.qq
7
7
 
8
8
  ## Skill version
9
9
 
10
- This skill matches **wonder 0.0.9**.
10
+ This skill matches **wonder 0.0.10**.
11
11
 
12
- In the Session Initialization step below, after running `wonder --version`, compare the output to `0.0.9`. If they differ, the loaded skill text and the CLI on disk are out of sync. Stop, tell the user to run `/update-5mghost-wonder`, and then **start a fresh AI session** (`/exit` and re-enter, or open a new chat) before trying again. `wonder update` rewrites the skill files on disk, but skill text already loaded into the current session does not auto-refresh.
12
+ In the Session Initialization step below, after running `wonder --version`, compare the output to `0.0.10`. If they differ, the loaded skill text and the CLI on disk are out of sync. Stop, tell the user to run `/update-5mghost-wonder`, and then **start a fresh AI session** (`/exit` and re-enter, or open a new chat) before trying again. `wonder update` rewrites the skill files on disk, but skill text already loaded into the current session does not auto-refresh.
13
13
 
14
14
  ## Session Initialization (first use only per session)
15
15
 
@@ -19,7 +19,7 @@ The **first time** you encounter a WeCom document URL in a session, run these ch
19
19
  # 1. Check for updates
20
20
  wonder update
21
21
 
22
- # 2. Confirm the CLI version matches this skill's expected version (0.0.9)
22
+ # 2. Confirm the CLI version matches this skill's expected version (0.0.10)
23
23
  wonder --version
24
24
 
25
25
  # 3. Check WeCom cookie status