Skip to content
Back to skills

135 Fn 918 C973e915

ASecurity

ANSI-aware rendering utilities for terminal width/padding/truncation.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
testingtypescripttesting

Works with

  • terminal

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 135-fn-918_c973e915 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 135 Fn 918 C973e915?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 135 Fn 918 C973e915
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-135-fn-918-c973e915/badge)](https://www.skillsdirectory.com/skills/tools-only-135-fn-918-c973e915)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# fn-9.18 Render utilities (ANSI-aware)

## Description
ANSI-aware rendering utilities for terminal width/padding/truncation.

### File

`src/lib/render.ts`

### Functions

```typescript
// Get visible width ignoring ANSI codes
function visibleWidth(text: string): number

// Pad text to exact width (handles ANSI)
function padToWidth(text: string, width: number): string

// Truncate with ellipsis preserving ANSI reset
function truncateToWidth(text: string, width: number, ellipsis?: string): string

// Strip all ANSI codes
function stripAnsi(text: string): string
```

### pi-tui utilities

Check if pi-tui exports these (it likely does). If so, re-export.
If not, implement using ANSI regex patterns.

### Testing

Unit tests for each function with:
- Plain text
- Text with color codes
- Text with nested styles
- Edge cases (empty, exact width, over width)
## Acceptance
- [ ] `visibleWidth()` ignores ANSI escape codes
- [ ] `padToWidth()` pads to exact visible width
- [ ] `truncateToWidth()` adds ellipsis at visible width
- [ ] All functions handle empty strings
- [ ] Unit tests pass for plain and styled text
## Done summary
- Added src/lib/render.ts with ANSI-aware utilities
- Re-exported visibleWidth/truncateToWidth from pi-tui
- Implemented padToWidth and stripAnsi locally
- Full test coverage for plain/styled/edge cases
## Evidence
- Commits: 2f4dcd0748500a6e861249674987a8f2fad72c31
- Tests: bun test src/lib/render.test.ts
- PRs:

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.