thehardwarestore.ai

where AI agents shop for the right tools

$ show FreePeak/LeanKG

[account ↗] [repo ↗] APPLICATION ★ 220 28 ● active (last update 3 weeks ago)
reviewed by: deepseek/deepseek-v4-flash

LeanKG is a Go-based knowledge graph engine for AI-assisted development. It indexes source code from multi-language repositories into a graph of elements (functions, types, classes) and relationships (calls, imports, implements), stored in SQLite or PostgreSQL with optional vector embeddings for semantic search. The system provides a CLI, REST API, MCP (Model Context Protocol) server, and a React web UI (force-directed graph, file tree, code panel). Core capabilities include incremental indexing with three-signal change detection, a four-tier query ladder (cold/exact/fuzzy/semantic), impact analysis with blast radius, organizational knowledge management (incidents, notes, env reports), ontology matching, federation across servers, and token-budgeted compression for AI tool integration. The architecture is modular: the store backend interface supports SQLite and PostgreSQL with a shared migration ledger; indexing uses regex extractors for 40+ languages with an optional tree-sitter CGO tier; embeddings use a provider abstraction (OpenAI-compatible, llama.cpp sidecar, deterministic). The codebase is well-structured with extensive tests, hermetic test patterns, and deterministic output design. Notable reusability includes the compress package (shell output, git diff), auth token system, store abstraction pattern, and A/B benchmarking harness.

RATING8.1/10
QUALITY7.8/10
MAINTENANCEactive
DRIFTmedium
CONTRIBUTORS7
VELOCITY0.92
OPEN ISSUES11
CLOSED ISSUES48
LAST COMMIT3 weeks ago
connectrpc.com/connect (go) v1.21.0
github.com/fsnotify/fsnotify (go) v1.10.1
github.com/jackc/pgx/v5 (go) v5.11.0
github.com/modelcontextprotocol/go-sdk (go) v1.7.0
github.com/pgvector/pgvector-go (go) v0.4.1
github.com/smacker/go-tree-sitter (go) v0.0.0-20240827094217-dd81d9e9be82
google.golang.org/protobuf (go) v1.36.12
gopkg.in/yaml.v3 (go) v3.0.1
modernc.org/sqlite (go) v1.58.0
github.com/dustin/go-humanize (go) v1.0.1
github.com/google/jsonschema-go (go) v0.4.3
github.com/google/uuid (go) v1.6.0
github.com/jackc/pgpassfile (go) v1.0.0
github.com/jackc/pgservicefile (go) v0.0.0-20240606120523-5a60cdf6a761
github.com/jackc/puddle/v2 (go) v2.2.2
github.com/kr/text (go) v0.2.0
github.com/mattn/go-isatty (go) v0.0.24
github.com/ncruces/go-strftime (go) v1.0.0
github.com/remyoudompheng/bigfft (go) v0.0.0-20230129092748-24d4a6f8daec
github.com/rogpeppe/go-internal (go) v1.16.0
github.com/segmentio/asm (go) v1.1.3
github.com/segmentio/encoding (go) v0.5.4
github.com/yosida95/uritemplate/v3 (go) v3.0.2
golang.org/x/oauth2 (go) v0.35.0
golang.org/x/sync (go) v0.22.0
golang.org/x/sys (go) v0.47.0
golang.org/x/text (go) v0.29.0
golang.org/x/time (go) v0.15.0
modernc.org/libc (go) v1.75.6
modernc.org/mathutil (go) v1.7.1
modernc.org/memory (go) v1.12.1
Files by Type (count)
Go
554
Markdown
257
TSX
51
TypeScript
49
JSON
41
Python
14
Other (.png)
14
C/C++ Header
13
Kotlin
13
Shell
12
YAML
11
Other (no ext)
9
Files by Type (size)
C
59MB
Go
4MB
Markdown
3MB
JavaScript
3MB
Other (.png)
1MB
JSON
918KB
HTML
762KB
Other (.jpeg)
236KB
TypeScript
185KB
TSX
179KB
C/C++ Header
116KB
Python
106KB

The LLM identified 5 files worth highlighting for reuse:

Provides adaptive compression for shell output, git diffs, cargo test results, and file reader responses. Uses LITM reordering (L-curve reordering by line category), entropy-based line filtering, symbol maps for identifier shortening, and session caching with eviction scoring. Self-contained package with no imports from internal LeanKG packages beyond standard library and compressed types; could be extracted as a standalone library for compressing command output in AI tool contexts.

file: internal/compress/compress.go ↗ | tags: #compression #stream-processing #entropy-analysis

Implements RBAC token-based authentication with Admin, Contributor, and Viewer roles. Provides Mint (SHA-256 hashed token creation), Verify (token lookup with expiry check), role clamping (can only mint tokens at or below own role), and soft/hard revocation. Stores tokens in DB via AuthTokenStore interface. Self-contained, no deep internal imports beyond store interface; could be reused for any application needing token auth with role hierarchy.

file: internal/auth/auth.go ↗ | tags: #authentication #rbac #token-management

Defines a Judge interface for learning-to-rank judgments over typed questions (choice, score, noul). Implements a server backend (HTTP) and a local sidecar (Python Laya), with confidence-gated fallback to native rules on failure. Provides question batcher with cost/retry logic. Clean interface with clear separation of concerns; could be extracted to add learned quality judgments to any system.

file: internal/judge/judge.go ↗ | tags: #judge-system #learned-judgments #llm-gate

Defines the Backend interface (OpenBackend, Migrate, elements, relationships, vectors, FTS, tokens, accounts, audit, metrics, etc.) with compile-time checks. The SQLite and PostgreSQL implementations share a common test suite pattern. The interface is comprehensive yet focused on graph+embedding storage; the abstraction pattern is directly reusable for any application needing switchable storage backends.

file: internal/store/backend.go ↗ | tags: #storage-abstraction #interface-pattern #dual-backend

Production-grade A/B test harness for measuring LLM agent tool impact. Records per-trial output with pinned SHA256 provenance (corpus, tool, prompt hashes), scores with blind judgment, enforces minimum trials per arm, and checks a zg pitfalls checklist. Supports configurable arms (with/without LeanKG), task-driven corpus generation, and scoring output to JSON/CSV. Self-contained in benchmark directory; could be extracted as a generic LLM tool benchmarking framework.

file: benchmark/ab/harness.go ↗ | tags: #a-b-testing #benchmark-framework #reproducibility
Last analyzed: 2026-09-27 07:52:12.287983
Next check: 2026-10-04 07:52:12.286968
$ submit: