Files
plugins/packages/workbuddy/package.json
T
yetone 8528698e3a workbuddy 0.2.33: the free window reads routing traces a line at a time, numbered day files too (#1077)
freeWindowRows read each routing day whole: readFileSync, gunzipSync into
one string, then split("\n"). A busy day's .gz unzipped to 520 MB, and the
read took Bun past 1.1 GB on easonlao's 2 GB host, where the kernel killed
the plugin host every minute or two and every request in flight with it.

- routingLines streams the file (createReadStream, piped through
  createGunzip for a .gz), holding a chunk and one line, never the file.
  A line over 4 MiB is passed over (the longest in the 520 MB day was
  88 KiB). A .gz that fails part way keeps the lines before the fault, as
  magpie's own gzRoutes does; a .gz of several members is read through.
- Today's plain file is read on from the offset past its last newline
  when it has grown (same inode, bigger), so a usage read no longer
  re-reads the day after every request; a half-written last line waits
  for the next read. One that shrank or kept its size is read whole.
- freeWindowRouting lists a day's numbered files (YYYY-MM-DD.N.jsonl and
  .gz, magpie 5d93f6b3), which were missed, so a day past 256 MB read
  short.
- Two usage reads at once share one read of a trace.
- readRoutingRefusals, routingRefusalRows and freeWindowRows are async;
  the one caller, the usage handler, already awaits.

Run (WSL magpie-desktop, Bun 1.4.2, HOME=$(mktemp -d); mote's load was
over 18):
- bun test freewindow.test.mjs: 59 pass.
- packages/workbuddy bun test: 376 pass, 0 fail.
- bun scripts/check.mjs workbuddy: ok.

Broken by hand: the new memory test against origin/main's index.mjs, in
its own child process on a .gz of 256 MB unzipped: RSS grew 848 MB, red
(bar 160 MB); green on this change.

Not tried: the reporter's real 47.6 MB trace or a 2 GB host; Windows and
macOS (the read is node:fs/zlib streams only). Each CN estimated window
still reads a trace on its own, once per trace change.

Reported-by: easonlao
2026-11-13 15:05:03 +08:00

27 lines
669 B
JSON

{
"name": "@magpie-community/opencode-workbuddy-auth",
"version": "0.2.33",
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
"type": "module",
"main": "./opencode.mjs",
"exports": { ".": "./opencode2.mjs" },
"files": [
"index.mjs",
"opencode.mjs",
"opencode2.mjs",
"README.md"
],
"keywords": [
"opencode",
"opencode-plugin",
"workbuddy",
"codebuddy"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/magpie-community/plugins.git",
"directory": "packages/workbuddy"
}
}