Commit Graph

196 Commits

Author SHA1 Message Date
can1357 ffd838b256 fix(utils): detached deeper code after padded blanks 2026-08-16 02:03:17 +02:00
can1357 36465c4e1a fix(utils): preserved deeper lazy continuations 2026-08-16 02:03:17 +02:00
chan1103 dc0e2ebeed fix(utils): stop indented code interrupting paragraphs in marked lexer 2026-08-14 22:48:39 +09:00
roboomp 5a0b2d460d fix(utils): normalized aborts during retry backoff
Route both fetchWithRetry backoff paths through one abort-normalizing wait helper and cover response and network retry cancellation.

Fixes #8450
2026-08-14 00:02:14 +02:00
can1357 157690aeb6 Merge PR #8101: fix(utils): mask routed lines beneath edge labels (@roboomp)
# Conflicts:
#	packages/utils/test/mermaid-ascii.test.ts
2026-08-13 01:15:29 +02:00
can1357 9c311d7a7b Merge PR #8040: fix(tui,utils): remove O(N²) hot paths when streaming long tool-call args (@AmecoCoding) 2026-08-13 01:14:45 +02:00
roboomp eaa5f46d32 fix(mcp): resumed interrupted HTTP response streams
Implemented 2025-11-25 Streamable HTTP polling semantics for POST SSE responses: retain event IDs and retry intervals, wait as instructed, and reconnect with GET plus Last-Event-ID until the originating JSON-RPC response arrives.

Extended the shared SSE parser to expose valid id/retry fields and control-only events so reconnecting consumers do not need to reparse raw lines.

Fixes #8264
2026-08-11 18:21:12 +00:00
can1357 978db72a46 Merge PR #7120: fix(utils): retain one rolled log per process day (@wolfiesch) 2026-08-11 15:07:43 +02:00
Shawn Koh e658d9f7be fix: address Mermaid rendering review 2026-08-11 01:14:29 +08:00
Shawn Koh a42868f550 fix: make terminal state diagrams readable 2026-08-11 01:00:35 +08:00
Wolfie dca28eee66 fix(utils): retain one rolled log per process day 2026-08-09 23:19:52 -07:00
roboomp 5d92336e19 fix(utils): masked routed lines beneath edge labels
Added opaque label-space cells so Mermaid ASCII edge labels erase routed paths while preserving spaces during serialization.

Added horizontal and vertical regression coverage.

Fixes #8098
2026-08-09 19:03:32 +00:00
lee 9e87d432bd fix(tui,utils): remove O(N^2) hot paths when streaming long tool-call args
Long write/edit streams made the TUI stutter or freeze for seconds at a
time (ui.loop-blocked warnings, keystrokes starving while the single JS
thread rebuilt previews). Two compounding quadratic paths:

1. parseStreamingJsonThrottled re-parsed the entire accumulated args
   buffer on a FIXED 256-byte cadence. The comment claimed this bounded
   mid-stream work to O(N), but a constant growth gate still parses an
   N-byte buffer N/256 times at O(N) each: O(N^2) with a smaller
   constant. The gate now scales geometrically (max(256, len/32)), so
   parse points form a geometric progression: O(log N) parses, O(N log N)
   total, with mid-stream snapshots staying within ~3% of the stream.
   Small buffers keep the exact fixed cadence as before.

2. write.ts formatStreamingContent normalized + split('\n') the WHOLE
   accumulated content on every 30Hz reveal tick (renderCall also ran a
   full-payload normalize first): O(N) per tick, O(N^2) per stream, per
   concurrent writer. The collapsed tail-window path now tracks the
   newline count incrementally (append-only resume keyed on the
   component's persistent render-state object via WeakMap) and extracts
   only the tail window with a backward scan: O(delta + preview lines)
   per tick, byte-identical output to the split-based reference. The
   expanded (Ctrl+O) path is unchanged in output and skips its
   split+join round-trip.

Tests: geometric-gate bounds + freshness + small-buffer cadence in
parse-streaming-json-throttled.test.ts; append-growth/reference-
window/CRLF/trailing-newline/restart battery in
write-streaming-incremental.test.ts. Full write/tool-render battery
(56 tests) and ai streaming-args tests (117 tests) pass.
2026-08-08 22:32:26 +01:00
can1357 34af136c6a test(utils): dropped flaky concurrent logger rotation test
- The two-child fs.watch/poll choreography deadlocked under parallel test load
  (runner killed a dangling probe); the PID-namespace pruning test still covers
  the multiprocess audit/rotation file contract.
2026-08-07 23:38:26 +02:00
can1357 3a8591a8af test: hardened two ci-flaky timing tests
- mnemopi provider parity 'diagnose, validate, graph' does ~6.7s of real
  work under bun --parallel=8 on loaded runners; raised its per-test
  timeout to 30s (default 5s flaked twice in three CI runs).
- utils LRUCache updateAgeOnGet drove a 30ms TTL with real 20ms sleeps
  (10ms margin); now drives performance.now() via a mocked clock, so the
  contract is asserted deterministically with no wall-clock wait.
2026-08-06 14:48:57 +02:00
can1357 6e40e3e9fd fix(utils/marked): closed lists at an end-of-input blank run
- A blank run at EOF now breaks the list without consuming the blank,
  matching real marked: '- item\n\n' lexes as a tight list plus a space
  token instead of a loose list whose raw includes the blank.
- Completes the 17.2.10 mid-document fix; same-marker continuation and
  indented item content across blanks are unaffected.
- Added list/blank boundary token-shape tests (verified against marked
  v15) since the tui incremental tests compare the lexer to itself.
2026-08-06 14:40:13 +02:00
can1357 6c84c3e8fc Merge PR #7691: fix(utils): support PowerShell as custom shellPath (@metaphorics) 2026-08-05 21:50:25 +02:00
can1357 e9888367d1 refactor: migrated packages to internal utility modules and removed external dependencies
- Implemented in-house, zero-dependency utility modules in `pi-utils` covering DOM manipulation, markdown parsing, templating, browser automation helpers, and terminal buffers.
- Migrated packages across the repository to consume the new internal utilities and `omptype` schema validators instead of external dependencies.
- Removed multiple external runtime and development dependencies including Zod, Marked, LRU cache, Turndown, and Puppeteer browser packages.
2026-08-05 13:39:09 +02:00
metaphorics b86f788ae7 fix(utils): support PowerShell as custom shellPath 2026-08-05 10:24:35 +00:00
brymko 56931915f1 feat(coding-agent): added fatal session recovery hints
Registered live session resume commands with postmortem handling so a
fatal rejection or exception identifies every recoverable agent before
cleanup. Escaped terminal control characters in recovery output.
2026-08-05 14:31:03 +08:00
metaphorics 7262d9762e fix(ai): honor account reset windows and statusless concurrency caps
Account-reset hint evaluated before short retry hints; account-scoped caps rotate on status 403 or undefined (Devin statusless trailer); statusless concurrency caps marked transient; transient same-model retries use the concurrency backoff.

Refuted: quota-worded concurrency caps were already excluded from rotation before the usage-limit text match.
(cherry picked from commit f2b9a18d715ddbcb6ae703670f2212da36bb2826)
2026-08-05 02:32:35 +02:00
metaphorics 9d51aabce9 fix(ai): address PR review feedback (#6958)
(cherry picked from commit 19327455a482ffdf8dfebcfb47b12fe0d4c888da)
2026-08-05 02:32:35 +02:00
can1357 84fc295f0c Merge PR #7586: refactor: centralize version comparison in pi-utils (@metaphorics) 2026-08-05 01:11:56 +02:00
can1357 e76d998c01 Merge PR #7498: fix(utils): honor current PATH in cached lookups (@usr-bin-roygbiv) 2026-08-05 01:11:56 +02:00
metaphorics 3802d2dd80 chore(ts): enforce noImplicitOverride 2026-08-05 02:49:01 +09:00
metaphorics 954894f1d4 refactor: centralize version comparison in pi-utils 2026-08-05 02:48:59 +09:00
can1357 455493dfad feat: introduced native file lock bindings for cross-process advisory locking
- Added native `FileLock` bindings supporting cross-process advisory locking on Linux, Unix, and Windows.
- Replaced directory-based file locking and custom stale-lock reclamation with OS-backed native locks.
- Updated TypeScript declarations, native bindings, and package documentation for the new API.
- Added comprehensive unit tests and fixtures validating single-owner constraints and process death handoff.
2026-08-03 16:09:09 +02:00
can1357 9fb082bf14 refactor(utils): consolidated file locking into pi-utils file-lock
- Moved the coding-agent lock-directory primitive to @oh-my-pi/pi-utils/file-lock
  and migrated settings, MCP config-writer, and security store imports.
- Replaced the stats aggregator's parallel ~200-line token/breaker lock protocol
  with the shared primitive: dead owners reclaimed immediately, live-but-wedged
  owners after STATS_SYNC_LOCK_STALE_MS, unstamped acquisitions after the new
  acquireStaleMs grace (10s).
- Shared primitive now treats EPERM kill probes as live owners.
- Rewrote the stats lock-reclamation regressions against the shared protocol
  and moved the file-lock contract test into pi-utils.
2026-08-03 15:25:03 +02:00
usr-bin-roygbiv 71a4c69369 test(utils): reproduce stale PATH lookup cache 2026-08-03 12:45:43 +00:00
can1357 5039b33a11 test(utils): skipped torn log lines in logger poll loop
- waitForLogEntry raced winston's async flush and JSON.parsed a
  partially written line, failing the error-serialization tests on
  loaded CI runners; unparseable lines now wait for the next poll.
2026-08-03 06:52:11 +02:00
can1357 f1c7eda7de Merge PR #7205: perf(cli): keep root help off runtime graph (@eggpeat)
# Conflicts:
#	packages/coding-agent/src/cli-commands.ts
#	packages/coding-agent/src/cli/args.ts
2026-08-02 20:59:12 +02:00
roboomp a6521f07ed fix(auth): guarded config-value resolvers against case-insensitive env hijack
On Windows process.env/Bun.env lookups are case-insensitive, so the
"env var name, else literal" resolvers turned a literal /login key like
`public` (OpenCode Zen's free key) into the built-in PUBLIC=C:\Users\Public,
sending `Authorization: Bearer C:\Users\Public` and 401ing every request.

Added `$envExact` in pi-utils, which trusts an env lookup only when an
exact-case key is enumerated (the only case-preserving signal on Windows;
the getter and hasOwnProperty/getOwnPropertyDescriptor traps are all
case-insensitive there). Wired it into all three resolvers:
resolve-config-value.ts, model-registry.ts, and auth-storage.ts.

Fixes #7361
2026-08-02 06:53:18 +00:00
can1357 dda859b60f fix(ci): hardened logger probe timeouts and silenced async trait lint
- Raised probe-spawning logger tests to 30s timeouts; bun's 5s default
  SIGTERMed probe children (exit 143) on shared-core CI runners, matching
  the precedent documented in logger-contract.test.ts.
- Allowed clippy::unused_async_trait_impl on KillCommand::execute with an
  unknown_lints guard for the pinned CI nightly that predates the lint.
2026-08-01 22:34:39 +02:00
can1357 72c66c87c1 fix(xdg): adopted legacy secret-placeholder.key and marketplaces.json at XDG paths 2026-08-01 20:46:25 +02:00
can1357 f13f9b1228 fix(utils): recognize underscore Bun test entrypoints 2026-08-01 20:14:39 +02:00
can1357 5b2aefe584 Merge PR #7263: fix(tui): prevent test env from suppressing interactive launch (@roboomp)
# Conflicts:
#	packages/utils/test/env.test.ts
2026-08-01 20:14:08 +02:00
roboomp 9f9c9758a1 fix(tui): prevented test env from suppressing interactive launch
Scoped test-runtime detection to explicit runner markers and Bun test entrypoints, so application NODE_ENV/BUN_ENV values no longer make ProcessTerminal headless.

Added subprocess regression coverage and propagated the private marker to test children.

Fixes #7261
2026-08-01 11:39:57 +00:00
pi3123 96a206440c Add unit tests for getDbBusyTimeoutMs 2026-07-31 20:04:30 -07:00
Brent a572fcb9be fix(cli): preserve help metadata contracts 2026-07-31 22:01:19 +00:00
Brent 9df3067930 perf(cli): keep root help off runtime graph 2026-07-31 21:28:41 +00:00
can1357 8db0228f4d fix(ci): unblocked release run on formatting and chunk watchdog
- Reformatted the logger burst test per biome (the type-check job gates on
  check:tools, which failed on the previous hotfix's formatting).
- Raised the native/unit bucket's chunk watchdog to 1200 s: the mupdf PDF
  extraction chunk runs ~7 min per attempt on burstable runners under a
  full fan-out and the 600 s default SIGKILLed both tries in release run
  30519992654; the watchdog targets wedged children, not slow chunks.
2026-07-30 08:59:03 +02:00
can1357 053dbfa605 fix(ci): stopped mtime prune from gutting extracted bazel repos
- The hosted disk-cache prune swept ~/.cache/omp-bazel-repo file-by-file;
  extracted repository contents keep upstream-archive mtimes (months old),
  so a restored archive lost most of rules_rust while bazel still trusted
  the entry's recorded_inputs — both darwin release legs failed with
  'BUILD file not found' in release run 30519253683. Prune only the
  action disk cache, whose files carry bazel-written mtimes.
- Gave the logger burst-order contract an explicit 30 s budget: two probe
  children measure ~4.4 s unloaded and bun's 5 s default test timeout
  SIGTERMed them (exit 143) on shared-core runners.
2026-07-30 08:33:27 +02:00
can1357 a4773c0baa refactor(typescript-edit-benchmark): updated mutation plans
- Update benchmark fixtures archive file.
- Adjust mutation plan block sizes and counts in generator script.
- Remove postmortem quit test.
2026-07-30 07:57:55 +02:00
can1357 38ebd30337 chore: update stale tests 2026-07-30 07:49:43 +02:00
can1357 f925f9f38a test(utils): cover quit without stdout drain
(cherry picked from commit 59a8002411726d8686c187a6d031a1f54577093b)
2026-07-29 23:08:32 +02:00
usr-bin-roygbiv 574f400b0f fix(utils): pin logger rotation entrypoint
(cherry picked from commit 6dc31019848a20053e66df947c48e087cce8566a)
2026-07-29 23:08:28 +02:00
usr-bin-roygbiv 08b280d550 perf(utils): avoid Winston runtime dispatch
(cherry picked from commit e5aeff8153551c8c4a5cb6a47c7ed00cba32000f)
2026-07-29 23:08:27 +02:00
usr-bin-roygbiv 54e3a9f156 test(utils): define lean logger contract
(cherry picked from commit 4ded69a293827e0dfbc3333f3da2944c97d71016)
2026-07-29 23:08:27 +02:00
can1357 532e4c318c fix(utils): filter NODE_ENV dotenv files and keep escaped quotes in dotenv values
- filterChildShellEnv now also filters Bun-autoloaded .env.{NODE_ENV||development}
  entries, closing the .env.production/.env.development leak into child shells.
- parseEnvLine skips backslash-escaped quotes when locating the closing
  delimiter, restoring baseline/Bun-literal handling of values like JSON="{\"a\":1}"
  that the new parser truncated.
- Adds a parseEnvFile regression test for escaped quotes.
2026-07-28 10:58:59 +02:00
can1357 0a5727670f Merge PR #6814: fix(cli): stop forwarding project dotenv to shells (@roboomp) 2026-07-28 10:58:59 +02:00