@loghead/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +201 -0
  2. package/bin/loghead +0 -0
  3. package/package.json +32 -0
package/README.md ADDED
@@ -0,0 +1,201 @@
1
+ # Loggerhead
2
+
3
+ Loggerhead is a smart log aggregation tool and MCP server. It collects logs from various sources like your Terminal, Docker containers, or Browser, stores them in a database, and makes them searchable for AI assistants (like Claude, Cursor, or Windsurf).
4
+
5
+ Think of it as a "long-term memory" for your development logs that your AI coding agent can read.
6
+
7
+ ## Prerequisites
8
+
9
+ Before you start, make sure you have:
10
+
11
+ 1. **Local Ollama**: [Download here](https://ollama.com/download).
12
+ - Ensure it is running (`ollama serve`) and accessible at `http://localhost:11434`.
13
+ - Pull the embedding model: `ollama pull qwen3-embedding:0.6b` (or similar).
14
+ 2. **The Loggerhead Executable**: You can download the latest release or build it yourself (see below).
15
+
16
+ _(Note: [Deno](https://docs.deno.com/runtime/fundamentals/installation/) is only required if you want to build the project from source.)_
17
+
18
+ ## Setup Guide
19
+
20
+ Follow these steps to get Loggerhead running on your machine.
21
+
22
+ ### 1. Install the Tool
23
+
24
+ Download the `loggerhead` binary from the releases page and move it to a directory in your PATH (e.g., `/usr/local/bin`).
25
+
26
+ **Verify installation:**
27
+
28
+ ```bash
29
+ loggerhead --help
30
+ ```
31
+
32
+ ### 2. Initialize the Database
33
+
34
+ Run this command to set up the database tables (SQLite):
35
+
36
+ ```bash
37
+ loggerhead init
38
+ ```
39
+
40
+ ## How to Use
41
+
42
+ ### 1. Start the MCP Server
43
+
44
+ This is the bridge that allows your AI editor to talk to Loggerhead.
45
+
46
+ ```bash
47
+ loggerhead start
48
+ ```
49
+
50
+ You will see instructions on how to connect your specific AI tool (Claude, Cursor, VS Code, Windsurf) in the output.
51
+
52
+ **Example for Claude Desktop Config:**
53
+
54
+ ```json
55
+ "loggerhead": {
56
+ "command": "loggerhead",
57
+ "args": ["stdio"]
58
+ }
59
+ ```
60
+
61
+ ### 2. Create a Project
62
+
63
+ Organize your logs into projects.
64
+
65
+ ```bash
66
+ loggerhead projects add "My Awesome App"
67
+ ```
68
+
69
+ ### 3. Add a Log Stream
70
+
71
+ A "stream" is a specific source of logs (e.g., your terminal output, or a specific Docker container). You need the Project ID from the previous step (use `loggerhead projects list` to see it).
72
+
73
+ **Example: Creating a stream for Docker logs**
74
+
75
+ ```bash
76
+ loggerhead streams add docker --project <PROJECT_ID> --name "Backend API" --container my-api-container
77
+ ```
78
+
79
+ **Example: Creating a generic terminal stream**
80
+
81
+ ```bash
82
+ loggerhead streams add terminal --project <PROJECT_ID> --name "Build Logs"
83
+ ```
84
+
85
+ ### 4. Ingest Logs
86
+
87
+ Now, feed logs into the stream you created. You need the Stream ID (use `loggerhead streams list --project <PROJECT_ID>` to find it).
88
+
89
+ **From Standard Input (Manual):**
90
+ You can pipe any command's output into Loggerhead:
91
+
92
+ ```bash
93
+ echo "Something happened" | loggerhead ingest --stream <STREAM_ID>
94
+ ```
95
+
96
+ Or run a script and capture its output:
97
+
98
+ ```bash
99
+ deno run my_script.ts | loggerhead ingest --stream <STREAM_ID>
100
+ ```
101
+
102
+ ### 5. Query Logs (The AI Part)
103
+
104
+ Your AI assistant can now "call" tools to search these logs. It can ask things like:
105
+
106
+ - "Show me the recent errors in the Backend API stream."
107
+ - "Find logs related to 'database connection failure'."
108
+
109
+ You can also check logs manually:
110
+
111
+ ```bash
112
+ loggerhead log list --stream <STREAM_ID>
113
+ ```
114
+
115
+ ## Building from Source
116
+
117
+ If you want to build the `loggerhead` executable yourself (e.g., to contribute or modify it):
118
+
119
+ 1. Install **Deno** (see Prerequisites).
120
+ 2. Compile the tool into a single executable file in the `build` directory:
121
+
122
+ ```bash
123
+ mkdir -p build
124
+ deno compile --allow-net --allow-read --allow-env --allow-run --allow-write --output build/loggerhead src/main.ts
125
+ ```
126
+
127
+ 3. This will generate the `loggerhead` binary in your `build/` directory. You can add it to your PATH (see Setup Guide) or move it manually:
128
+
129
+ ```bash
130
+ sudo mv build/loggerhead /usr/local/bin/
131
+ ```
132
+
133
+ ## Architecture Overview
134
+
135
+ - **Language:** TypeScript (Deno)
136
+ - **Database:** SQLite with `sqlite-vec` via `@sqliteai/sqlite-wasm` for storing log embeddings.
137
+ - **AI:** Local Ollama running `qwen3-embedding` to understand the semantic meaning of logs.
138
+ - **Protocol:** Model Context Protocol (MCP) for integration with AI agents.
139
+
140
+ ## Sample Apps
141
+
142
+ We provide sample applications in the `sample_apps` directory to help you test Loggerhead's capabilities.
143
+
144
+ ### 1. CLI Calculator
145
+
146
+ A simple script that generates random logs and simulates a crash.
147
+
148
+ **How to test:**
149
+
150
+ 1. Create a project and a stream:
151
+ ```bash
152
+ loggerhead projects add "Calculator App"
153
+ # Copy Project ID
154
+ loggerhead streams add terminal --project <PROJECT_ID> --name "CLI Output"
155
+ # Copy Stream ID
156
+ ```
157
+ 2. Run the calculator and pipe logs to Loggerhead:
158
+ ```bash
159
+ deno run sample_apps/cli_calculator/main.ts | loggerhead ingest --stream <STREAM_ID>
160
+ ```
161
+ 3. Ask your AI Agent: "Why did the calculator app crash?"
162
+
163
+ ### 2. Docker App
164
+
165
+ A Python worker process running in Docker that logs tasks and simulates occasional warnings.
166
+
167
+ **How to test:**
168
+
169
+ 1. Create a stream for Docker:
170
+ ```bash
171
+ # Use existing Project ID
172
+ loggerhead streams add docker --project <PROJECT_ID> --name "Worker Node" --container worker-app
173
+ # Note the container name "worker-app" matches the --name in docker run below
174
+ # Copy Stream ID
175
+ ```
176
+ 2. Build and run the container:
177
+ ```bash
178
+ cd sample_apps/docker_app
179
+ docker build -t docker-app .
180
+ docker run --name worker-app -d docker-app
181
+ ```
182
+ 3. Attach Loggerhead to the container logs:
183
+ ```bash
184
+ loggerhead attach --stream <STREAM_ID> --container worker-app
185
+ ```
186
+ 4. Ask your AI Agent: "What tasks is the worker processing?" or "Are there any performance warnings?"
187
+
188
+ ### 3. Browser App
189
+
190
+ A simple HTML/JS Calculator that logs actions to the browser console. This is designed to be used with a Browser Extension (coming soon) or manual copy-paste testing.
191
+
192
+ **How to test:**
193
+
194
+ 1. Open `sample_apps/browser_app/index.html` in your browser.
195
+ 2. Open Developer Tools (Console).
196
+ 3. Perform some calculations (try dividing by zero!).
197
+ 4. (Manual) Copy the console logs and save them to a file `logs.txt`.
198
+ 5. Ingest the file:
199
+ ```bash
200
+ cat logs.txt | loggerhead ingest --stream <STREAM_ID>
201
+ ```
package/bin/loghead ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@loghead/core",
3
+ "version": "0.1.0",
4
+ "description": "Smart log aggregation tool and MCP server",
5
+ "bin": {
6
+ "loghead": "./bin/loghead"
7
+ },
8
+ "files": [
9
+ "bin"
10
+ ],
11
+ "os": [
12
+ "darwin"
13
+ ],
14
+ "cpu": [
15
+ "arm64"
16
+ ],
17
+ "scripts": {
18
+ "postinstall": "echo 'Note: This package contains a prebuilt binary for macOS ARM64.'"
19
+ },
20
+ "author": "Onvo AI",
21
+ "license": "MIT",
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/onvo-ai/loggerhead.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/onvo-ai/loggerhead/issues"
31
+ }
32
+ }