fix: code audit round 2 — safety, hot-reload, error diagnostics#982
Merged
fix: code audit round 2 — safety, hot-reload, error diagnostics#982
Conversation
…d, error cause chain 1. pruneEmptyDirs: use path.relative() instead of startsWith() to prevent false boundary matches on overlapping directory names 2. evaluateWithArgs: add safe evaluate method that auto-serializes args via JSON.stringify, preventing injection by design 3. Hot-reload: detect mtime changes on user adapter files in daemon mode, invalidate module cache so edits take effect without restart 4. toEnvelope: preserve error cause chain in verbose mode for better production debugging
- pruneEmptyDirs: resolve() paths before relative() check - evaluateWithArgs: validate keys are valid JS identifiers - hot-reload: only bust ESM cache on reload, not first load - toEnvelope: move cause serialization into toEnvelope itself so all consumers (AI agents, MCP tools) get cause chain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses 4 items from the code audit:
startsWith()could match overlapping directory names (e.g.,/a-sitevs/a). Now usespath.relative()for correct boundary checking.evaluateWithArgssafe evaluate — NewIPage.evaluateWithArgs(js, args)method that auto-serializes args viaJSON.stringify()asconstdeclarations. Prevents injection by design. Available for adapters to adopt incrementally.~/.opencli/clis/adapter files and invalidates module cache. Edits take effect without daemon restart.renderErrornow preserveserr.causein verbose mode, so nested errors (browser → adapter → pipeline) show the full chain for debugging.Test plan
evaluateWithArgsworks with a sample adapter