code_dweller
v1.0.2
Published
An agent that lives in codebase and catches errors with reasons and gives solutions based on the codebase architecture
Readme
code_dweller
code_dweller is an agentic AI SDK designed to identify and resolve production runtime errors in real-time. Think of it as a virtual SRE (Site Reliability Engineer) that monitors your application, triages bugs, and suggests fixes so you can keep your focus on building features.
🚀 Getting Started
Prerequisites
- Node.js: version 20.0.0 or higher.
- API Key: Required for initializing the Dweller agent.
Installation
npm install code_dweller🛠️ Configuration
The agent requires specific context files to understand your codebase. You must create a .dweller/ directory in your project root with the following files:
Required Project Structure
| File Path | Purpose | Content Requirement |
| :-------------------------- | :----------------- | :------------------------------------------------------ |
| ./dweller/architecture.md | System Design | High-level architectural patterns used in the codebase. |
| ./dweller/map.md | File Index | Full directory tree and file paths relative to root. |
| ./dweller/errors.md | Knowledge Base | Documentation of known edge cases or historical bugs. |
[!CAUTION] > Important: Without these three files, the agent will lack the context necessary to navigate your codebase and may enter an infinite loop.
💻 Usage
1. Initialize the Client
import { Dweller } from "code_dweller";
const client = new Dweller("YOUR_API_KEY");2. Identify Errors
Wrap your critical logic in try-catch blocks and pass the telemetry to the agent.
try {
// Your application logic
} catch (error) {
const files = [
{
filename: "./dweller/architecture.md",
description: "Architectural patterns and system flow.",
},
{
filename: "./dweller/map.md",
description: "Project file structure and relative paths.",
},
{
filename: "./dweller/errors.md",
description: "Common causes of bugs in this codebase.",
},
];
await client.IdentifyError(
"Error at payments.service.ts: High Severity", // error_message
error, // error_value
files, // files array
{ allowCodeRead: true } // options
);
}📋 Parameter Reference
IdentifyError Arguments
| Parameter | Type | Description |
| :-------------- | :------- | :--------------------------------------------------------------------------- |
| error_message | string | A llm friendly error information (e.g., "Failed to process Stripe webhook"). |
| error_value | any | The raw error object captured in the catch block. |
| files | array | An array of objects pointing to your .dweller configuration files. |
| options | object | Additional configuration for agent code access behaviour. |
Mapping your codebase
In your map.md, ensure you provide clear paths relative to the root. For example:
my-project/
├── controllers/
│ ├── main_controller.js
│ └── auth_controller.js
└── services/
└── payments.service.jsLLM-Optimized Setup
To get the best results, your .dweller/ files should be optimized for LLM tokenization.
Quick Scaffold
Run this in your terminal to create the folder and empty files:
mkdir .dweller && touch .dweller/architecture.md .dweller/map.md .dweller/errors.md
---
## 📄 License
MIT
---