feat: switched to native text sanitization, removed Bun.stripANSI
- Added `sanitizeText` function to pi-natives that strips ANSI escape sequences, removes control characters and lone surrogates, and normalizes line endings. - Moved `sanitizeText` function from `@oh-my-pi/pi-utils` to `@oh-my-pi/pi-natives` for better code organization and native performance. - Added line length clamping (4000 characters) to bash and Python execution output to prevent excessively long lines. - Replaced internal `#normalizeOutput` methods with `sanitizeText` utility function in bash and Python execution components. - Fixed bash interactive tool to gracefully handle malformed output chunks by normalizing them with `sanitizeText`. - Simplified documentation by removing WASM terminology from package descriptions and comments.
This commit is contained in:
@@ -8,16 +8,16 @@ This repo contains multiple packages, but **`packages/coding-agent/`** is the pr
|
||||
|
||||
### Package Structure
|
||||
|
||||
| Package | Description |
|
||||
| ----------------------- | ------------------------------------------------------ |
|
||||
| `packages/ai` | Multi-provider LLM client with streaming support |
|
||||
| `packages/agent` | Agent runtime with tool calling and state management |
|
||||
| `packages/coding-agent` | Main CLI application (primary focus) |
|
||||
| `packages/tui` | Terminal UI library with differential rendering |
|
||||
| `packages/natives` | WASM bindings for native text/image/grep operations |
|
||||
| `packages/stats` | Local observability dashboard (`omp stats`) |
|
||||
| `packages/utils` | Shared utilities (logger, streams, temp files) |
|
||||
| `crates/pi-natives` | Rust WASM crate for performance-critical text/grep ops |
|
||||
| Package | Description |
|
||||
| ----------------------- | ---------------------------------------------------- |
|
||||
| `packages/ai` | Multi-provider LLM client with streaming support |
|
||||
| `packages/agent` | Agent runtime with tool calling and state management |
|
||||
| `packages/coding-agent` | Main CLI application (primary focus) |
|
||||
| `packages/tui` | Terminal UI library with differential rendering |
|
||||
| `packages/natives` | bindings for native text/image/grep operations |
|
||||
| `packages/stats` | Local observability dashboard (`omp stats`) |
|
||||
| `packages/utils` | Shared utilities (logger, streams, temp files) |
|
||||
| `crates/pi-natives` | Rust crate for performance-critical text/grep ops |
|
||||
|
||||
## Code Quality
|
||||
|
||||
@@ -79,26 +79,6 @@ This repo contains multiple packages, but **`packages/coding-agent/`** is the pr
|
||||
const { promise, resolve, reject } = Promise.withResolvers<string>();
|
||||
```
|
||||
|
||||
## WASM Bindgen Resources
|
||||
|
||||
**Use `using` declarations** for wasm-bindgen objects — they implement `Symbol.dispose`:
|
||||
|
||||
```typescript
|
||||
// BAD: Manual try/finally with .free()
|
||||
const image = PhotonImage.new_from_byteslice(bytes);
|
||||
try {
|
||||
return image.get_bytes();
|
||||
} finally {
|
||||
image.free();
|
||||
}
|
||||
|
||||
// GOOD: Automatic cleanup via Symbol.dispose
|
||||
using image = PhotonImage.new_from_byteslice(bytes);
|
||||
return image.get_bytes();
|
||||
```
|
||||
|
||||
This applies to all wasm-bindgen generated classes (`CompiledPattern`, `PhotonImage`, etc.).
|
||||
|
||||
## Bun Over Node
|
||||
|
||||
This project uses Bun. Use Bun APIs where they provide a cleaner alternative; use `node:fs` for operations Bun doesn't cover.
|
||||
|
||||
Reference in New Issue
Block a user