Agent Office 0.2.0 (QingJ01, #551): a real 3D office, the workbench, and the earlier review's fixes. The session scanner now reads growing JSONL logs incrementally. It keeps a saved offset with 128 guard bytes, carries UTF-8 and partial JSON across ticks, applies a record complete at EOF once, and resets on truncation, inode or birthtime change and same-size rewrites. Readers update per kind (Claude response usage replaced, Grok sidecar daily totals replaced, metadata refreshed apart from logs).
Run at the reviewed head 3bf522f, merged on main 622f950, on mote under HOME=$(mktemp -d):
- agent-office bun test: 163 pass, 0 fail. Full bun test: 4310 pass, 9 skip, 0 fail. check.mjs agent-office and stamp-page --check: exit 0.
- 100MB log: append scan ~50ms -> 0.04-0.2ms (4x100MB: ~240ms -> 0.13-0.29ms). Through office.hooks: first scan 82ms, then 0.11-0.24ms per append.
- Fuzz with real Claude, Codex and Grok logs in random appends vs a fresh scanner: 0 mismatches.
- Broken by hand: 9 mutations of the cursor and readers go red. Gaps left as follow-ups: the inode check alone, ExtendedTail, the Codex title cursor and summary.json re-reads. Also follow-up: the first scan of an image-heavy log (336ms vs 42ms, framePart).
The package is new on npm: the owner publishes 0.2.0 by hand the first time.
17 lines
928 B
JavaScript
17 lines
928 B
JavaScript
// Stamp local static URLs after changing browser files. magpie's page
|
|
// entry is revalidated; content-addressed dependencies cannot mix an old
|
|
// stylesheet or renderer with a new index after a same-version update.
|
|
import {createHash} from 'node:crypto'
|
|
import {readFileSync,writeFileSync} from 'node:fs'
|
|
import {join} from 'node:path'
|
|
const page=join(import.meta.dir,'../page'),file=join(page,'index.html')
|
|
const html=readFileSync(file,'utf8')
|
|
const next=html.replace(/(\b(?:src|href)=")([^"?]+\.(?:js|css))(?:\?v=[a-f0-9]+)?(")/g,(all,start,name,end)=>{
|
|
if(name.startsWith('_magpie/'))return all
|
|
const hash=createHash('sha256').update(readFileSync(join(page,name))).digest('hex').slice(0,12)
|
|
return start+name+'?v='+hash+end
|
|
})
|
|
if(process.argv.includes('--check')) {
|
|
if(next!==html){console.error('Page asset stamps are stale: bun scripts/stamp-page.mjs');process.exit(1)}
|
|
} else if(next!==html)writeFileSync(file,next)
|