Commit Graph

4 Commits

Author SHA1 Message Date
Wolfgang Schoenberger 3a2ab8ad7d test: restore full env state in document-conversion cache tests
Snapshot and restore PI_CODING_AGENT_DIR, OMP_PROFILE, PI_PROFILE, and
XDG_CACHE_HOME instead of relying on setAgentDir(originalAgentDir), which
cannot restore previously-unset or profile-derived env state. Reset the
profile snapshot and rebuild dirs from env in cleanup to prevent
suite-order pollution.

Also reject empty cached content in parseCacheEntry() to harden the
cache contract against corrupted/empty entries.
2026-06-24 03:08:48 -07:00
Wolfgang Schoenberger ef97b63313 refactor(coding-agent): harden document conversion cache temp handling
- Add random UUID suffix to cache temp filenames to avoid same-pid/same-ms collisions
- Export pruneMarkitConversionCache and cover orphaned .tmp sweeping with a regression test
2026-06-22 17:44:04 -07:00
Wolfgang Schoenberger e09ff9af88 refactor(coding-agent): address cache review feedback
- fold coding-agent package version into the cache key so releases that
  change markit converter output auto-invalidate stale entries
- sweep orphaned `.tmp` files during prune (crash between write and
  rename previously leaked, invisible to the size cap)
- make prune fire-and-forget after rename so a cache miss returns once
  the entry is on disk instead of waiting on a readdir + N×stat sweep
- document the FIFO-by-mtime eviction policy on-record
- use Bun.file()/Bun.write() for payload I/O per repo conventions
2026-06-22 16:54:13 -07:00
Wolfgang Schoenberger 2cb892ef1f feat(coding-agent): cache successful document conversions
Repeated reads of unchanged PDFs, Office documents, and EPUBs re-ran the
full markit conversion every time. Add a transparent, content-addressed
cache for successful conversions keyed by SHA-256(content) + normalized
extension, so repeat reads reuse converted markdown instead of
reconverting.

- packages/utils: XDG-aware getDocumentConversionCacheDir() helper
- coding-agent: markit-cache module (bounded 256 MiB, oldest-first prune,
  best-effort writes that never fail conversion) layered over the central
  convertFileWithMarkit/convertBufferWithMarkit wrappers
- imageDir conversions stay uncached (cache:"skipped") to preserve PDF
  image extraction side effects; failed/empty/aborted conversions are
  never cached
- abort-safe: file byte reads run under untilAborted; cache I/O rechecks
  the signal
2026-06-22 16:54:13 -07:00