Skip to main content
Glama
prjxp β€” ProjectEXpert

prjxp β€” ProjectEXpert

README.md
# prjxp

[![prjxp MCP server](https://glama.ai/mcp/servers/carstenSpraener/prjxp/badges/score.svg)](https://glama.ai/mcp/servers/carstenSpraener/prjxp)

An AI toolset to provide an expert for a Software Project

_More detailed architectural documentation is in the [arc42 README.md](doc/arc42/README.md)_

## Disclaimer:

$$\{ \langle M \rangle \mid \mathcal{P}(L(M)) = \text{true} \} \text{ is undecidable.}$$

## πŸ— Modules Overview

### πŸ“¦ Chunk-Norris

![Gemini_Generated_Image_ufkk1aufkk1aufkk.jpg](doc/images/Gemini_Generated_Image_ufkk1aufkk1aufkk.jpg)

**Chunk-Norris** is a high-performance chunking framework designed to decompose
text into structured `PxChunks`. It is built with extensibility at its core,
allowing you to add specialized chunking logic without modifying the core
library.

#### Data Output: JSONL

Chunk-Norris processes documents and outputs the resulting chunks in **JSONL (
JSON Lines)** format. This ensures:

* **Streamability:** Large documents can be processed and read line-by-line.
* **Compatibility:** Each line is a valid JSON object (`PxChunk`), making it
  easy to pipe the output into other tools or databases.

#### Extensibility

**Language Packs** are the primary way to add a programming language: a `LanguagePack`
bundles everything prjxp needs for one language β€” the chunking side (files β†’ `PxChunk`s)
and the retrieval side (a `GoldenRetriever`). Built-in packs (Java, TypeScript,
Visual Basic) are Spring beans inside the engine modules; **external packs are plugin
JARs** that are loaded at startup from `./language-packs` into isolating class loaders
and become visible to chunking, retrieval and the grep language filter alike. The
`lp-csharp` module is the reference implementation: a C# pack shipped as a standalone
plugin JAR (own class loader, private ANTLR runtime, no host classes bundled).

For finer-grained chunking extensions, Chunk-Norris also leverages the classic
**Java ServiceLoader mechanism**:

1. **Implement the Broker:** Inherit from `AnnotationBasedChunkerBrokerImpl` to
   define your custom loading logic.
2. **Annotate Methods:** Within your code, mark the actual chunking methods with
   the `@Chunker` annotation.
3. **Register the Service:** Add your factory class to the service
   configuration file in `META-INF/services/de.spraener.chuno.ChunkerBroker`.
4. **Automatic Integration:** Once the JAR is present, Chunk-Norris
   automatically discovers and integrates your new capabilities.

πŸ‘‰ Full plugin contract: [doc/LanguagePack_Plugin_Guide.md](doc/LanguagePack_Plugin_Guide.md)

#### Intelligent Selection Logic

You don't need to manually select a chunker. Chunk-Norris automatically
identifies the best tool for the job:

* It scans all registered `ChunkerFactories` at runtime.
* For any given file type, it selects the Chunker that declares the **highest
  Priority** for that specific format.

---

### πŸ“¦ Tibed

![Gemini_Generated_Image_hcv7uahcv7uahcv7.jpg](doc/images/Gemini_Generated_Image_hcv7uahcv7uahcv7.jpg)
**Tibed** is a batch-oriented embedding engine that serves as the bridge between
raw chunks and searchable vectors.

* **Input:** It consumes the **JSONL** output generated by Chunk-Norris.
* **Metadata Persistence:** Tibed processes each entry as a `PxChunk`. All
  attributes and metadata associated with the chunks are automatically mapped
  and stored within **Lucene**.
* **Compatibility:** By preserving the structured metadata, Tibed ensures that
  the data remains fully compatible with the retrieval logic of *
  *Golden-Retriever**.

### πŸ“¦ Golden-Retriever

![Gemini_Generated_Image_pfnodopfnodopfno.jpg](doc/images/Gemini_Generated_Image_pfnodopfnodopfno.jpg)

**Golden-Retriever** serves as the core RAG (Retrieval-Augmented Generation)
engine. Unlike simple vector-search tools, it implements a sophisticated
enrichment and filtering pipeline to ensure high-quality context for the LLM.

#### Specialized JavaCodeRetriever

Retrievers are provided **per language** through Language Packs (Java, TypeScript,
Visual Basic built-in; C# via the `lp-csharp` plugin). At its heart, the module
features a specialized `JavaCodeRetriever` designed for
technical analysis:

* **Context Enrichment:** When a `PxChunk` with the mime-type `text/x-java-code`
  is matched, the retriever reconstructs an abstract description of the affected
  class.
* **Data Synthesis:** It merges retrieved chunks with additional data from the
  database into a meaningful **Context Enrichment**, while intelligently
  deduplicating overlapping information.

#### Forest of Trees & Veto System

To handle complex queries where multiple vector hits might refer to different
parts of a system, Golden-Retriever manages a **"Forest of Trees"**:

* **Tree Management:** Since multiple hits can result in several distinct
  logical structures (trees), the module manages them collectively as a forest.
* **Granular Enrichment:** For each individual tree, a specific Context
  Enrichment is generated.
* **Veto Mechanism:** To maintain high data quality, each enrichment is passed
  through a **Veto System**. This allows specialized filters to reject "noise"
  or irrelevant trees before they reach the LLM, ensuring only precise and
  relevant information is used for final generation.

### πŸ“¦ prjxp-common

![Gemini_Generated_Image_1yo3qp1yo3qp1yo3.jpg](doc/images/Gemini_Generated_Image_1yo3qp1yo3qp1yo3.jpg)
The **prjxp-common** module provides the foundational data structures and
utilities shared across the entire ecosystem. Its primary purpose is to maintain
data integrity and structural relationships between chunks.

#### The PxChunk Core

The central entity is the `PxChunk`, which is much more than a simple text
fragment. It is designed for structural reconstruction:

* **Logical Identity:** Chunks belonging to the same logical unit (e.g., a
  single long method) share the same **ID**. This allows **Golden-Retriever** to
  perfectly reconstruct the original source code, even if it was split across
  multiple entries.
* **Hierarchical Metadata:** By utilizing metadata fields like `parent`, the
  system can reconstruct complex tree structures from flat database hits.
* **Vector References:** Each `PxChunk` can store a `reference` (e.g., Fully
  Qualified Class Name and method signature). This provides the vectorization
  process with the necessary context regarding where the chunk logically belongs
  in the codebase.

#### Structural Utilities

The module includes essential utilities to handle the lifecycle of these chunks:

* **Decomposition:** Tools to split long text blocks into a sequence of
  `PxChunks` while maintaining their logical links.
* **Recomposition:** Logic to merge a list of `PxChunks` with the same ID back
  into a coherent, original text block.

### πŸ“¦ mcp-server

The runtime: a Spring AI **MCP server** (streamable HTTP) exposing the three-level
search ladder (`vectorSearch`, `grep`, `readFile`, `readBySignature`, …) plus a REST
API and a web UI. In **hub mode** it hosts the whole pipeline in-process (chunk-norris
+ tibed as beans) and serves any number of projects from one shared, project-stamped
Lucene index.

### πŸ“¦ lucene-store

The file-based **Lucene** index: vector (KNN) + full-text + index search in one
place, exposed as a Spring auto-configuration. Single-writer, project-scoped queries.

### πŸ“¦ docpipe

The documentation pipeline: `.dp/documents.json` jobs β†’ Handlebars prompt templates
(resolvers: `gr` enrichment, `source-dump`, `groovy`, `mcp-project`, …) β†’ LLM β†’ output
files. The LLM can call the prjxp MCP tools over HTTP while generating.

### πŸ“¦ lp-csharp *(standalone)*

The **C# Language Pack** plugin: a standalone Gradle project (not part of the root
build) that bundles a C# parser (ANTLR), a structural chunker and a retriever as a
loadable plugin JAR. It depends on `prjxp-common` from the local Maven repository and
is loaded by the host into its own class loader at startup.

---

## πŸš€ Deployment

prjxp ships as a single Docker image. Embeddings run against an external
OpenAI-compatible endpoint (LM Studio, OpenAI, AOAI, Ollama, TEI, …) β€” the
application never runs neural inference itself.

Prebuilt multi-arch images (`linux/amd64`, `linux/arm64`) are published to the
GitHub Container Registry on every release tag (`v*`):

```bash
docker compose pull && docker compose up -d
```

Pin a release with `PRJXP_VERSION=v0.9.0` in `.env` (default: `latest`). Without
registry access the compose file still supports local builds via
`docker compose build`.

Two deployment modes are available:

### Single Project β€” one container per project

The `./prjxp` control script manages the full pipeline (chunk β†’ embed β†’ hub)
for one project:

```bash
./prjxp /path/to/your-project mcp    # chunk + embed + hub β€” serves the MCP server on :7007
```

πŸ‘‰ Full setup: [doc/Docker_Setup_Guide.md](doc/Docker_Setup_Guide.md)

### Multi-Project Hub β€” one container, many projects

A long-running hub serves **any number of projects added at runtime**.
Drop a tar archive into the import directory β€” it is extracted, registered,
chunked and embedded automatically (in-process):

```bash
docker compose up -d hub                        # starts the hub on :7008
tar czf import/my-project.tar my-project/       # triggers the import
```

Alternatively, mount a directory of live projects and drop a `prjxp.yaml` marker
into any project β€” it is embedded in place (no tar needed) and refreshed with
`POST /prjxp/projects/{name}/reindex`. A `.prjxp-exclude` marker file has the
opposite effect: it makes the hub ignore that directory (and its whole subtree)
entirely β€” handy for pruning huge non-project folders (e.g. old VCS branches)
out of the recursive scan. **Tip:** mount the narrowest possible directory as
`./import` β€” a broad mount (e.g. an entire projects drive) forces every poll to
recursively walk *all* sibling repos, which can make discovery take minutes or
longer; `prjxp.hub.scan-max-depth` caps this as a safety net.

Projects appear in the web UI (`http://localhost:7008/`) with their lifecycle
status β€” `importing β†’ chunking β†’ embedding β†’ ready` β€” and are only searchable
once ready. Remove a project with `DELETE /prjxp/projects/{name}`.

πŸ‘‰ Details: [doc/Docker_Setup_Guide.md β€” Multi-Project Hub](doc/Docker_Setup_Guide.md#multi-project-hub-one-container-many-projects)

---

## 🀠 Fun Fact: The Documentation Paradox

You might notice that **prjxp** has absolutely zero manual Javadoc. This is a
deliberate architectural decision.

> "Chunk Norris doesn't need documentation. Chunk Norris **is** the source of
> it!"

**Chunk-Norris now documents itself.** By utilizing its own specialized
`JavaCodeRetriever` and enrichment pipeline, the framework generates its own
technical documentation. It doesn't just process code; it understands its own
soul.

![Gemini_Generated_Image_5ur0bs5ur0bs5ur0.jpg](doc/images/Gemini_Generated_Image_5ur0bs5ur0bs5ur0.jpg)
**Documentation is a generation task, not a manual one.**

---

## πŸ”Œ MCP Tool Integration for docpipe (HTTP Transport)

Starting with **LangChain4j MCP 1.21.0-beta31**, docpipe's LLM can use the prjxp MCP
server over **Streamable HTTP** to query embedded project information during documentation
generation. The LLM autonomously calls tools like `vectorSearch`, `grep`, `readFile`, and
`readBySignature` β€” all transparently inside the existing `String chat(String)` contract.

**Configuration:**
```yaml
prjxp:
  mcp-servers:
    - name: "prjxp-search"
      type: "http"
      url: "${PRJXP_MCP_URL:http://localhost:7007/mcp}"
      defaultProject: "prjxp"
```

**Prompt template usage:**
```handlebars
{{mcp-project project="prjxp"}}

Erstelle eine Architektur-Dokumentation. Nutze die Suchwerkzeuge, um
Informationen ΓΌber die Module und ihre AbhΓ€ngigkeiten zu finden.
```

The `McPEnablingKIChatDecorator` wraps the LLM in a LangChain4j `AiServices` agent with
MCP tools. A system prompt tells the LLM about available tools and the active project name.
The `mcp-project` Handlebars helper injects explicit project context into prompt templates.

---

## πŸŒ‰ MCP Proxy β€” stdio β†’ streamable-http Bridge

Some AI agents (e.g. **Kiro**) require **HTTPS** for streamable-http transport and
reject self-signed certificates. The **mcp-proxy** module solves this by running as a
plain Java process that bridges **stdio** (what the agent expects) to **streamable-http**
(what the mcp-server provides).

### Architecture

```
Agent (stdio) ──stdin/stdout──> java -jar mcp-proxy-all.jar ──HTTP──> http://localhost:7007/mcp
```

The proxy is a **transparent JSON-RPC relay**: it reads newline-delimited messages from
stdin, forwards them as HTTP POST to the upstream MCP server, and relays responses back
to stdout. All logs go to stderr only.

### Usage

```bash
java -jar mcp-proxy/build/libs/mcp-proxy-all.jar \
  --server-url http://localhost:7007/mcp \
  [--timeout-seconds 300]
```

### Agent Configuration (Kiro example)

```json
{
  "mcpServers": {
    "prjxp": {
      "command": "java",
      "args": [
        "-jar", "/path/to/mcp-proxy-all.jar",
        "--server-url", "http://localhost:7007/mcp"
      ]
    }
  }
}
```

### Build

```bash
./gradlew :mcp-proxy:shadowJar   # produces mcp-proxy-all.jar
```

The proxy is a **plain Java** application β€” no Spring Boot, no web server.
Startup time < 200 ms, JAR size ~2–3 MB.

---
_This README was generated with Gemini – based on code documented by
Chunk-Norris._