ai-stack-trace
v1.0.0
Published
AI-powered stack trace analyzer - paste errors, get solutions
Maintainers
Readme
ai-stack-trace
AI-powered stack trace analyzer. Paste errors, get solutions.
Install & Run
npx ai-stack-traceWhat It Does
- Parses stack traces from any language (JavaScript, Python, Java, etc.)
- Identifies the error type and root cause
- Provides step-by-step solutions
- Suggests prevention strategies
Usage
# Interactive - paste your error
npx ai-stack-trace
# From file
npx ai-stack-trace -f error.log
# Pipe from command
npm test 2>&1 | npx ai-stack-trace
# Include source context for better analysis
npx ai-stack-trace -f error.log -c src/index.js,src/utils.jsOptions
Options:
-f, --file <path> Read error from file
-c, --context <files> Include source files (comma-separated)
-l, --language <lang> Runtime hint (node, python, java)
--json Output as JSONExample
$ npx ai-stack-trace -f error.log
🔥 AI Stack Trace Analyzer
TypeError: Cannot read property 'map' of undefined
📍 5 stack frames detected
Top: renderList at src/components/List.jsx:24
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
**Error Summary**: Attempting to call .map() on undefined data
**Root Cause**: The `items` prop is undefined when the component
renders, likely because data hasn't loaded yet.
**Solution**:
1. Add a guard before mapping:
```jsx
{items?.map(item => <Item key={item.id} {...item} />)}- Or provide a default value:
const { items = [] } = props;
Prevention: Always initialize array state/props with empty arrays, not undefined. Use TypeScript for type safety.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
## Requirements
- Node.js 18+
- `OPENAI_API_KEY` environment variable
## License
MIT - Built by [LXGIC Studios](https://github.com/lxgicstudios)