diff --git a/.gitignore b/.gitignore index 1d16974..2c7a209 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,15 @@ replay_pid* # jcstress / jqwik test outputs (generated in repo root) /.jqwik-database + +# Benchmark/experiment scratch output dirs (not part of the build) +src/siteGusto/ +src/siteMistral3/ +src/siteQwenBRUTAL/ + +# IDE config +.idea/ + +# Generated AI-index output from the self-index run (keep the tracked placeholder) +/src/site/ai/* +!/src/site/ai/empty.md diff --git a/CLAUDE.md b/CLAUDE.md index d626f5a..96f0f2c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,7 @@ This document provides guidance for AI assistants working on the llamacpp-ai-ind - **Group ID:** `net.ladenthin` - **Artifact ID:** `llamacpp-ai-index-maven-plugin` -- **Version:** 1.0.0 +- **Version:** 1.0.1-SNAPSHOT - **Java:** target bytecode 1.8, built with JDK 21 - **License:** Apache 2.0 - **Author:** Bernard Ladenthin (Copyright 2026) @@ -126,6 +126,27 @@ The plugin operates in three logical phases, building a navigable index from fin ``` [Source .java files] → SourceFileIndexer → [*.java.ai.md files (deterministic header + AI body)] ``` +The `generate` goal is **plan-then-execute** and **rule-routed**: it first walks all candidate files, +routes each via the `` rules to a `(model, prompt)` — or a *skip*, or the explicit +*fallback* — and logs a tree grouped by model (which file gets which model + prompt). It then loads +**each model once** (groups sharing an `aiDefinitionKey`, sequentially → one model resident at a time, +bounded RAM) and indexes that group's files. A rule matches by a composable **`` tree** — ``/`` (each wraps its children in +``), `` (a single nested condition), over leaves +``, `` (`min`/`max` bytes), `` (`min`/`max`), ``/`` +(ISO-8601 instant vs file mtime), `` (base-relative glob) — evaluated by `AiConditionEvaluator` +against an `AiFileContext`; new leaf kinds are one field + one branch. Among matches the highest +`priority` wins (ties by declaration order). `true` ignores matching files (a high-priority +skip beats routes and the fallback); exactly one `true` (no condition) catches the +rest; a file matching no rule and no fallback **fails the build**. `aiIndex.planOnly=true` prints the +Markdown plan (file → rule id → prompt → rough time estimate, summed per model and overall) and stops +(no model loaded). The plan also computes each routed file's **context-window fit** up front (via +`AiInputWindowCalculator`, the same threshold the run uses to trim): a file larger than its routed +model's window is flagged in the plan and **always fails the build** (a hard abort). The resolution is +**configuration only** — the plugin never auto-picks a model: the user must add a `` +rule with a size `` that routes oversized files to a model with a large enough context window +(see the big-window fallback example in the POM). See `AiFieldGenerationSelector` (selection + validation), `AiCondition`/ +`AiConditionEvaluator` (the tree), and `AiIndexPlan` (the rendered plan). This is how one run can index +different file kinds/sizes with different models *and* prompts. **Phase 2 — Package Aggregation & Summarization** ``` @@ -163,7 +184,12 @@ the top of `execute()`. Covered by `MojoPhaseSkipTest`. | `GenerateMojo` | Phase 1: index + summarize source files | | `AggregatePackagesMojo` | Phase 2: aggregate + summarize package index files | | `AggregateProjectMojo` | Phase 3: build the single `project.ai.md` (deterministic listing; extends `AbstractAiIndexMojo` and builds a provider **only** when a `` opts into the AI overview) | -| `SourceFileIndexer` | Walks source trees, creates `.ai.md` files, calls AI to fill the document body | +| `SourceFileIndexer` | `collectCandidates` (walk + filters) / `classify` (→ `AiIndexPlan`) / `indexFile` (write one file with a given rule + provider) — split so a run plans first and loads one model per group | +| `AiFieldGenerationSelector` | Routes a file to a rule by its `` + priority; explicit fallback; `skip`; plus `validate(rules)` (fail-fast config check) | +| `AiCondition` / `AiConditionEvaluator` | Composable and/or/not condition tree (leaves: extensions/size/lines/modifiedAfter/modifiedBefore/pathGlob) + its evaluator (`matches`/`validate`/`usesLines`) | +| `AiIndexPlan` | The routing plan: routes grouped by model id, skips, unmatched, per-file context-window fit; renders the up-front tree | +| `AiInputWindowCalculator` | Pure calculator for the input window (max source chars before trimming + whether a source exceeds it); single source of truth shared by the run-time trim (`AiFieldGenerationSupport`) and the plan-time over-window check (`SourceFileIndexer.classify`) | +| `AiProgressBar` | Pure ASCII progress-bar renderer (`[##### ] 42%`); `GenerateMojo` logs it after each file, advancing by the running sum of per-file plan estimates over the grand total (with estimated time left + actual elapsed) | | `PackageIndexer` | Creates `package.ai.md` files with contents listings, calls AI to fill the document body | | `ProjectIndexer` | Phase 3: harvests each package's lead + relative link into one `project.ai.md`; deterministic listing, with an optional one-call AI `#### Overview` from the leads | | `AiMdLeadExtractor` | Pure extraction of the one-line blockquote lead from an `.ai.md` body (fallback: first non-blank line) | @@ -253,6 +279,9 @@ header block, so a `- F:` line in the body is never read as a link. | `subtrees` | `aiIndex.subtrees` | *(all)* | Limit to specific source subdirectories | | `fileExtensions` | `aiIndex.fileExtensions` | `.java` | File extensions to index | | `excludes` | `aiIndex.excludes` | *(none)* | Glob patterns (base-relative, `/` separators) for source files to skip, e.g. `**/package-info.java`, `**/generated/**` (`AiSourceExcludeFilter`) | +| `minFileSizeBytes` | `aiIndex.file.minSizeBytes` | `0` | Exclusive lower size bound; files `<=` this are skipped (`0` = no lower bound). For size-tiering across multiple `generate` executions | +| `maxFileSizeBytes` | `aiIndex.file.maxSizeBytes` | `0` | Inclusive upper size bound; files `>` this are skipped (`0` = unlimited). Pairs with `minFileSizeBytes` to form a band | +| `planOnly` | `aiIndex.planOnly` | `false` | Print the routing plan tree (model → files → prompt → window fit) and stop; no model loaded, nothing generated | | `generationProvider` | `aiIndex.generationProvider` | `mock` | `mock` or `llamacpp-jni` | | `llamaModelPath` | `aiIndex.llama.modelPath` | — | Path to GGUF model file | | `llamaContextSize` | `aiIndex.llama.contextSize` | `2048` | Context window size | @@ -326,7 +355,7 @@ Immutable value types are implemented as Java `record` types (e.g., `AiMdDocumen | Dependency | Version | Purpose | |---|---|---| -| `net.ladenthin:llama` | 5.0.2 | llama.cpp JNI binding (GGUF inference); pinned to the layered-package + immutable-wither API. Brings `slf4j-api` transitively, converged to 2.0.18 via ``. | +| `net.ladenthin:llama` | 5.0.3 | llama.cpp JNI binding (GGUF inference); released on Maven Central, carries the prompt-cache/slot APIs + GPU classifier jars. Brings `slf4j-api` transitively, converged to 2.0.18 via ``. | | `org.apache.maven:maven-plugin-api` | 3.9.13 | Maven plugin API (provided) | | `org.apache.maven.plugin-tools:maven-plugin-annotations` | 3.15.1 | `@Mojo`, `@Parameter` annotations (provided) | @@ -368,7 +397,7 @@ See [`../workspace/workflows/pull-request-workflow.md`](../workspace/workflows/p 3. **Incremental updates** — files with existing summaries are skipped unless `force=true`; checksums detect source changes. 4. **Unified indexing and summarization** — each indexer (`SourceFileIndexer`, `PackageIndexer`) both creates the `.ai.md` skeleton and fills in AI fields in a single pass; no separate summarization step is needed. 5. **Provider abstraction** — AI backends are pluggable through `AiGenerationProvider`; mock provider enables fully deterministic tests. -6. **Configuration-driven prompts** — prompt templates are defined in POM configuration, not hardcoded in Java; changing a prompt requires no code change. For the `generate` goal the per-file prompt is chosen by source extension (`AiFieldGenerationSelector`): each `` may carry an optional `` filter (e.g. `.java`/`.sql`), and an entry without one is the fallback — so a Java prompt, a SQL-schema prompt, and a generic fallback can coexist while one model stays loaded. +6. **Configuration-driven prompts & rule-based routing** — prompt templates are defined in POM configuration, not hardcoded in Java; changing a prompt requires no code change. For the `generate` goal each `` is a routing **rule** (`AiFieldGenerationSelector`): a composable `` tree (``/``/`` over leaves extensions/size/lines/modifiedAfter/modifiedBefore/pathGlob — `AiCondition`/`AiConditionEvaluator`), a `` (highest matching wins, ties by order), and a kind — route (``+``), `true` (ignore), or exactly one explicit `true`. So one run can route different file kinds/sizes to different models **and** prompts; the model id (`aiDefinitionKey`) carries the full parameter set (path, context, sampling…), and the run loads each model once. A file matching no rule and no fallback fails the build; `aiIndex.planOnly=true` previews the plan tree without loading a model. Prompts live once in a shared plugin-level `` and are referenced by id across all rules/executions (no duplication). ## Javadoc Conventions diff --git a/README.md b/README.md index 410c594..7a94b9e 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ It creates structured `.ai.md` files per source file and aggregates them into pa - Exclude trivial or generated files with glob patterns - Uses local models via llama.cpp (no cloud dependency) - Incremental updates (skips unchanged files) +- Logs a rough per-file duration estimate before each generation (size, token count, expected time) - Optimized for AI-assisted code understanding ## How It Works The plugin runs in three phases, building a navigable index from fine to coarse. @@ -140,7 +141,7 @@ It is published on Maven Central and resolves automatically — no manual instal net.ladenthin llama - 5.0.2 + 5.0.3 ``` ## Configuration @@ -151,11 +152,27 @@ The plugin is configured from three building blocks, declared on the plugin insi 2. **``** — define each prompt template once, each with a ``. A template takes two `%s` placeholders: the file/package name and the source (for packages, the child summaries; for the optional project overview, the per-package leads). -3. **``** — per goal, map one `` to one ``. This is - **required**: a goal with no field generation fails fast. The `generate` goal may list several - field generations and give each an optional `` filter so the per-file prompt is - chosen by source language (`.java` → a Java prompt, `.sql` → a SQL-schema prompt); an entry with - no `` is the fallback applied to any file no extension-specific entry matched. +3. **``** — per goal, the routing **rules**. Each rule maps a `` to an + `` (model id, which carries the full parameter set) and selects files with a + composable **``** tree: ``/``/`` over the leaves ``, `` + (``/`` bytes), `` (``/``), ``/`` (ISO-8601 + instant vs the file's last-modified time), and `` (base-relative glob). When several rules + match, the highest `` wins (ties by declaration order). A rule may instead be + `true` (ignore matching files — a high-priority skip beats routes and the fallback), and + **exactly one** `true` (no condition) catches everything else. A file that + matches no rule and no fallback **fails the build**. So one `generate` run can index different file + kinds/sizes with **different models *and* prompts**; it loads each model once. Run with + `-DaiIndex.planOnly=true` to print the routing plan (a copy-pasteable Markdown table: file → rule id → + prompt → context-window fit → rough time estimate, summed per model and overall) and stop before + loading any model. The plan also checks each file against its routed model's **context window**: a + file too large for the window would lose content if trimmed, so the build **always fails** (a hard + abort). The fix is **configuration only** — the plugin never picks a model for you: add a + `` rule with a size `` that routes oversized files to a model with a large + enough window (see the `granite-4.0-h-tiny-bigwindow` definition + the `big-window` rule in the POM — + IBM Granite 4.0-H-Tiny, Apache-2.0, a hybrid Mamba model whose KV cache grows only linearly, configured + at a 384K window to cover files up to ~1 MB; verified summarizing a ~995 KB / ~268K-token file on an + 8 GB GPU with no OOM. Quality is best within Granite's validated 128K (~500 KB) and degrades gradually + beyond it — a whole-file summary still beats a trimmed one). ```xml @@ -234,18 +251,21 @@ Index file: %s generate-resources generate - + + java file-body-java coder - - .java - + + .java + + fallback + true file-body-fallback coder @@ -284,6 +304,54 @@ Index file: %s ``` + +### Routing rules (conditions, priority, skip, plan) +Within one `generate` run you can route files to different models **and** prompts by size, language, +age or path. Example — small/medium/large Java files to three context presets, skip generated sources, +and a fallback for everything else: + +```xml + + + skip-generatedtrue100 + **/generated/** + + + java-smallfile-body-java-tersegpt-oss-20B-c16k + + .java + 16384 + + + + java-midfile-body-javagpt-oss-20B-c48k + + .java + 1638449152 + + + + java-largefile-body-java-detailedgpt-oss-20B-c96k + + .java + 49152 + + + + fallbacktrue + file-body-fallbackgpt-oss-20B-c96k + + +``` + +Notes: size bounds are **min-exclusive / max-inclusive** so `band2.min == band1.max` is non-overlapping; +`` works the same way; `2026-01-01T00:00:00Z` only (re)indexes +recently changed files. Preview the mapping without running a model: + +``` +mvn ai-index:generate -DaiIndex.planOnly=true +``` + ## Usage Run AI index generation: ``` @@ -315,8 +383,43 @@ Run-level parameters (set in ``): - `aiDefinitions` / `promptDefinitions` — named models / prompt templates, referenced by key - `fieldGenerations` — per goal: which `promptKey` runs with which `aiDefinitionKey` (**required**) -Per-model parameters — model path, context size, output tokens, temperature, top-p / top-k, -repeat penalty, threads — live inside each ``, not as top-level parameters. +### Per-model `` parameters + +Every model knob lives inside its `` (referenced by `aiDefinitionKey`), not as a top-level +plugin parameter. Only `key` and `modelPath` are required; everything else has a default. The defaults +below are the shipped values (`AiGenerationConfig.DEFAULT_*`). + +| Element | Default | Description | +|---|---|---| +| `key` | *(required)* | Identifier referenced by a rule's `aiDefinitionKey` | +| `modelPath` | *(required)* | Path to the GGUF model file | +| `contextSize` | `32768` | Context window in tokens | +| `maxOutputTokens` | `128` | Max generated tokens per call | +| `threads` | `8` | CPU threads for inference | +| `temperature` | `0.15` | Sampling temperature | +| `topP` | `0.9` | Nucleus (top-p) sampling threshold | +| `topK` | `40` | Top-k sampling limit (`0` = disabled) | +| `minP` | `0.0` | Min-p sampling threshold (`0.0` = disabled) | +| `topNSigma` | `-1.0` | Top-n-sigma sampling threshold (`-1.0` = disabled) | +| `repeatPenalty` | `1.0` | Repetition penalty (`1.0` = disabled) | +| `charsPerToken` | `4` | Chars-per-token estimate; drives the automatic `maxInputChars` trim budget (`maxInputChars` itself is derived, not a field). Use a value at or below your model's real ratio so the budget stays conservative | +| `warnOnTrim` | `true` | Log a warning when the source is trimmed to fit the window | +| `cachePrompt` | `true` | Reuse the shared prompt-prefix KV across files (`cache_prompt`) | +| `swaFull` | `true` | Keep the full-size sliding-window-attention KV cache (`--swa-full`) | +| `cacheReuse` | `256` | KV prefix-reuse minimum chunk size in tokens (`--cache-reuse`; `0` = off) | +| `gpuLayers` | `-1` | GPU layers to offload (`--gpu-layers`); `-1` = auto-fit to free VRAM, `0` = force CPU, `>0` = partial. GPU native only | +| `mainGpu` | `-1` | Primary GPU index (`--main-gpu`); `-1` = leave default. Matters on multi-GPU hosts (e.g. a Vulkan build enumerates every GPU) | +| `devices` | *(empty)* | Explicit device selection (`--device`), comma-separated backend device names (e.g. `Vulkan1`); takes precedence over `mainGpu` | +| `chatTemplateEnableThinking` | `true` | Enable the chat template's thinking mode | +| `reasoningEffort` | `low` | gpt-oss harmony reasoning effort (`low`/`medium`/`high`); empty omits the kwarg (e.g. for non-gpt-oss models) | +| `reasoningBudgetTokens` | `-1` | Cap on harmony reasoning tokens (`-1` = unrestricted) | +| `dryMultiplier` | `0.0` | DRY repetition-penalty multiplier (`0.0` = disabled); the other `dry*` knobs only apply when this is `> 0` | +| `dryBase` | `1.75` | DRY exponential base | +| `dryAllowedLength` | `2` | Longest n-gram that may repeat without DRY penalty | +| `dryPenaltyLastN` | `-1` | DRY look-back window in tokens (`-1` = whole context, `0` = off) | +| `drySequenceBreakers` | *(empty)* | DRY sequence-breaker strings; empty = the binding defaults | +| `stopStrings` | *(empty)* | Extra stop strings that end generation | + ## Prompt System Prompts are defined in the plugin configuration (``) and referenced by key from ``. The self-test profile defines five: @@ -358,8 +461,111 @@ src/site/ai/ ## TODO - **Expand PIT mutation-testing scope.** `` in `pom.xml` lists an explicit subset of classes verified at 100% mutation parity; widen it incrementally toward the whole `net.ladenthin.maven.llamacpp.aiindex.*` tree (the streambuffer whole-package model) as more classes reach parity. Generic PIT setup and invocation: see the [PIT policy](../workspace/policies/pit-mutation-testing.md). ## Recommended Models -- Qwen2.5 Coder (balanced quality and speed) -- Smaller instruct models for faster indexing +Based on an 8-model × 2-prompt benchmark run against this codebase — full results, per-model +pros/cons, a source-faithfulness deep-dive, and reproduction steps in +[docs/ai-index-benchmark](docs/ai-index-benchmark/COMPARISON.md): + +- **`gpt-oss-20B-mxfp4` — the production default** (switch with `-Dai.model=`). The native MXFP4 + quant at a 96K window; it inherits the benchmark's accuracy lead (gpt-oss-20b was most *accurate* per + file, won 5/6 in the per-file matrix — measured on the `c96k`/UD-Q4_K_XL quant, but E5 shows quant + choice is within noise so the native MXFP4 is the better-quality swap), run at `reasoningEffort=low` + and a 96K window so it covers files up to ~250 KB untrimmed. Slowest of the set (~2× the 30B) — the + accepted cost for accuracy. See the preset/timing details below. +- **Qwen3-Coder-30B-A3B-Instruct** — throughput alternative (and best of the non-reasoning models for + large Java files): most complete/faithful of the fast models, code-specialized, Apache-2.0, + ~3.3B-active MoE, 262K context. Pick it when throughput beats the last points of fidelity. +- **Granite-4.0-H-Tiny** — fastest on CPU (~4×, flat-KV hybrid, Apache-2.0); best for very large + or many files when throughput beats the last points of fidelity. +- **Seed-Coder-8B-Instruct** — clean, permissive (MIT) small dense coder. +- Avoid `Qwen3.5-4B` (thinking tax, no quality gain). + +### gpt-oss-20b presets, large files, and timing + +`gpt-oss` is a *reasoning* model whose analysis tokens share the output budget, so use +`reasoningEffort=low` for code summaries (best quality here) and size the budget to the file. The pom +ships three ready presets, tiered by the largest file you must cover — full rationale and measurements +in [COMPARISON.md §11](docs/ai-index-benchmark/COMPARISON.md): + +| Preset | context | covers up to | ~ time (CPU) | +|---|---|---|---| +| `gpt-oss-20B-c16k` | 16K | ~40 KB | ~1–2 min | +| `gpt-oss-20B-c48k` | 48K | ~125 KB | ~25 min @ 100 KB | +| **`gpt-oss-20B-c96k` (default)** | 96K | ~260 KB | ~80 min @ 250 KB | + +- **`c96k` is the default:** a measured A/B shows a wider context window costs only RAM, not per-file + time, so it covers every file up to ~250 KB with no trimming while small files stay just as fast. + Downshift only to save RAM. Hard ceiling is the 128K window (~480–500 KB of code). +- **Timing is quadratic, not linear:** prefill ≈ `24.4·n + 0.000674·n²` ms (n = prompt tokens), + because attention is O(n) per token — which is why throughput drops as files grow. The plugin logs + this estimate per file. + +## GPU acceleration (opt-in) +The default native is CPU (Ninja build, bundled in the main `net.ladenthin:llama` jar). On an NVIDIA +RTX 3070 a CUDA build measured **~4.5× the CPU decode speed**; Vulkan also works (AMD + NVIDIA) but pays +a one-time shader-compilation cost on the first run. OpenCL is intentionally not offered (llama.cpp's +OpenCL backend does not support NVIDIA GPUs). + +How the native is found: `net.ladenthin.llama.loader.LlamaLoader` tries `net.ladenthin.llama.lib.path`, +then `java.library.path`, then **extracts the native bundled in whatever `net.ladenthin:llama` jar is on +the classpath**. So there are two ways to enable a GPU when running the *published* plugin in your own +build. + +**Recommended — add the GPU classifier to the plugin's own classpath.** Declare the matching +`net.ladenthin:llama` classifier as a dependency of the plugin in your POM; the loader then extracts the +GPU `jllama.dll` from it — no library path to manage: + +```xml + + net.ladenthin + llamacpp-ai-index-maven-plugin + ... + + + net.ladenthin + llama + 5.0.3 + cuda13-windows-x86-64 + + + +``` + +``` +mvn ai-index:generate -Dai.gpuLayers=20 # + the GPU runtime on PATH (see below) +``` + +**Alternative — runtime library override (no POM change).** Point `net.ladenthin.llama.lib.path` at a +folder holding the GPU `jllama.dll` (extracted once from the classifier jar); it is tried before the +bundled native: + +``` +mvn ai-index:generate -Dnet.ladenthin.llama.lib.path=C:\path\to\gpu-native -Dai.gpuLayers=20 +``` + +In both cases: + +- **CUDA** needs a matching CUDA 13 toolkit + driver, and the toolkit's `bin\x64` (with `cudart64_13.dll`, + `cublas64_13.dll`) on `PATH` — the classifier jar bundles only `jllama.dll`, not the CUDA runtime. +- **`ai.gpuLayers`** (on the gpt-oss presets): `-1` (default) does **not** pin a layer count, so + llama.cpp **auto-fits** as many layers as fit the card's free VRAM — the robust "runs on any card" + setting (it never over-commits, so no OOM on a 6 GB card, and uses more layers on a bigger one). Pin a + positive number only to force a specific **partial** split (a fixed count disables auto-fit), or `0` to + force CPU. Measured on an 8 GB RTX 3070, auto-fit gpt-oss-20b ≈ 29 decode t/s (vs ≈ 8 on CPU); a card + with ≥ 16 GB fits all layers and is far faster. +- **Picking a GPU on a multi-GPU host** (`ai.mainGpu` / `ai.devices` on the gpt-oss presets): a **CUDA** + build only enumerates NVIDIA devices, so a single-NVIDIA host needs nothing. A **Vulkan** build + enumerates *every* GPU (an integrated GPU is often device `0`), so the default may pick the slower one — + set `-Dai.mainGpu=1` to select the discrete GPU, or `-Dai.devices=Vulkan1` for explicit device names + (these map to the binding's `--main-gpu` / `--device`). On any model definition the same knobs are the + `` / `` elements. + +**Profiles (this repo's own reactor build only — test/benchmark).** `-P gpu-cuda` / `-P gpu-vulkan` +swap the `net.ladenthin:llama` classifier (via the `llama.classifier` property) for the reactor's +test/compile classpath — handy for the native test or benchmarking on GPU here. They do **not** change +the native used when the *published* plugin runs in another build (the POM is not flattened, so the +classifier stays a property that resolves to the CPU default downstream) — use one of the two methods +above for real indexing. + ## Development Run full build: diff --git a/TODO.md b/TODO.md index 6f3fdb0..05ba6ac 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,9 @@ # TODO — llamacpp-ai-index-maven-plugin Open work items for this repo. Cross-cutting tracking lives in -[`../workspace/crossrepostatus.md`](../workspace/crossrepostatus.md); -items here are plugin-specific or are this repo's slice of a -cross-cutting initiative. +[`../workspace/crossrepostatus.md`](../workspace/crossrepostatus.md); items here are +plugin-specific or this repo's slice of a cross-cutting initiative. Completed work is +recorded in git history and `crossrepostatus.md`, not here. ## Open @@ -11,90 +11,14 @@ cross-cutting initiative. - **`@VisibleForTesting` audit.** No usages currently. Walk the production tree for package-private/protected methods or fields that exist purely so tests can reach them, and either annotate (`com.google.common.annotations.VisibleForTesting`) or move into the test source tree. -- **Null-safety refinement.** JSpecify + NullAway are now enforced at compile time in **strict JSpecify mode** with the extra options `CheckOptionalEmptiness`, `AcknowledgeRestrictiveAnnotations`, `AcknowledgeAndroidRecent`, `AssertsEnabled` (see `pom.xml`); `@NullMarked` on the package via `package-info.java`; JDK module exports in `.mvn/jvm.config`. Maven `@Parameter` / `@Component` fields are excluded from initializer checks; framework-populated POJOs (`AiPromptDefinition`, `AiModelDefinition`, `AiFieldGenerationConfig`, `AiGenerationConfig`) carry class-level `@SuppressWarnings({"NullAway.Init", "initialization.fields.uninitialized"})`. Open follow-up: review remaining unannotated public API surfaces for places where `@Nullable` would be more precise than the implicit non-null default. +- **Null-safety refinement.** JSpecify + NullAway are enforced at compile time in strict JSpecify mode (see `pom.xml`); `@NullMarked` on the package; framework-populated POJOs carry class-level `@SuppressWarnings({"NullAway.Init","initialization.fields.uninitialized"})`. Open follow-up: review remaining unannotated public API surfaces for places where `@Nullable` would be more precise than the implicit non-null default. -- **SpotBugs `effort=Max` + `threshold=Low`** — ✅ **enforced at the gate** (`0bddf2a`). `pom.xml` `Max` + `Low`; `spotbugs:check` is part of `mvn verify` and fails on any unsuppressed finding. The full clearing chain is recorded in [`../workspace/crossrepostatus.md`](../workspace/crossrepostatus.md) under "SpotBugs Max+Low". `spotbugs-exclude.xml` carries narrow `` blocks with rationale: Lombok-USBR, HelpMojo auto-gen family, Maven `@Parameter` SPP, identity-IMC, prompt-template `FORMAT_STRING`, fb-contrib flow-coarseness sites, NPE→`MojoExecutionException` bridge. +- **Expand PIT mutation scope (optional).** `pom.xml` wires `100` over an explicit `` list (config / document / prompt / provider / support value+logic classes, plus `indexer.AiInputWindowCalculator` and `support.AiProgressBar`), all killed at 100%. Still out (optional, need careful fixtures): `document.AiMdDocumentCodec` / `AiMdHeaderCodec`, `prompt.AiPromptPreparationSupport`, and the newer `indexer.AiIndexPlan` / `config.AiConditionGroup`. The orchestration layers (`indexer.*` walk, `mojo.*`) and the JNI provider stay out of PIT — they need a Maven/native context rather than pure-unit mutation (see crossrepostatus "Deliberate non-parity"). -- **Mutation-testing threshold enforcement (PIT)** — `pom.xml` wires `100`. The explicit `` list now covers **24 classes** (config / document / prompt / provider / support value + support classes; **200 mutations, all killed**). Latest additions landed with the three-level index work: `document.AiMdLeadExtractor` (project index), `config.AiFieldGenerationSelector` (extension-based prompt selection), and `support.AiSourceExcludeFilter` (exclude globs). Still open (optional): `document.AiMdDocumentCodec` / `AiMdHeaderCodec` / `prompt.AiPromptPreparationSupport` (need careful codec fixtures). The orchestration layers (`indexer.*`, `mojo.*`) and the JNI provider stay out of PIT — they need a Maven/native context rather than pure-unit mutation (see crossrepostatus "Deliberate non-parity"). +- **README install example version.** The consumer install example pins `1.0.0` — confirm `1.0.0` is actually published on Maven Central, or update the example. (The per-model `` parameters, incl. `minP`, are now fully documented in README "Per-model `` parameters".) -- **Additional ArchUnit rules to consider** — the full **`layeredArchitecture()`** rule and **per-module banned-imports** (`jniConfinedToProvider`, `mavenMojoAnnotationsConfinedToMojo`, `foundationIsMavenFree`) are now DONE (see "Done" below). No further ArchUnit rules outstanding. - -- **No LogCaptor smoke test needed** — this module has no logging code (`org.slf4j.*` not used in `src/main/java/`); production uses Maven's `Log` interface. If SLF4J logging is ever introduced, add a LogCaptor smoke test at the same time so the binding/configuration is exercised in tests. +- **Big-window fallback beyond ~1 MB.** The `granite-4.0-h-tiny-bigwindow` preset (384K context) covers source files up to ~1 MB; larger files hard-fail by design. If genuinely needed, add a still-larger preset (Granite allocates up to its 512K training limit, with further quality loss) or document a file-splitting workflow. - **Cross-repo code-quality TODOs** — see [`../workspace/policies/code-quality-todos.md`](../workspace/policies/code-quality-todos.md) for the canonical `@VisibleForTesting` design-fit review, package hierarchy review, and class/method naming review. This repo has no `@VisibleForTesting` usages today; the package and naming reviews are still open here. -## Done (kept for history) - -### Three-level hierarchical index + per-phase switches - -The project index (third level) and its surrounding navigation / prompt / scaling work: - -- **Project index (`aggregate-project` goal / `ProjectIndexer`)** — harvests the one-line blockquote - lead of every `package.ai.md` (`AiMdLeadExtractor`) into a single, always-loadable `project.ai.md` - table of contents. Deterministic listing, no model. Node type `x: project`, `PROJECT_AI_MD_FILENAME`. -- **Header `F` child-link navigation (level 2 → 1)** — `AiMdHeader` carries a repeatable `F` markdown - link list (children for a package, packages for the project), so navigation stays in the - machine-parseable header while the body stays free-form. `AiMdDocumentCodec` parses only the header - block, so a `- F:` line in the body is never read as a link. -- **Language-specific file prompts** — `AiFieldGenerationConfig` gained `fileExtensions`; - `AiFieldGenerationSelector` picks the per-file prompt by extension (`.java` / `.sql` / fallback) while - one model stays loaded. Backward compatible: a single extension-less entry is the universal fallback. -- **Exclude globs** — `AiSourceExcludeFilter` (a pure, cross-platform glob matcher: `*` within a - segment, `**` across, `?` one char) + the `excludes` parameter (`aiIndex.excludes`) skip - trivial/generated sources during the file walk. -- **Optional AI project overview** — opt-in `#### Overview` paragraph synthesised from the package - leads (never the full bodies), gated incrementally by folding the generation signature - (`promptKey:aiDefinitionKey`) — not the AI output — into the `c` checksum, so an unchanged project is - never re-inferred but enabling/switching the overview, or a package change, rebuilds it. -- **Independently switchable phases** — `AbstractAiIndexMojo` owns the global `skip` (`aiIndex.skip`), - the abstract `isPhaseSkipped()` seam and `shouldSkip() = skip || isPhaseSkipped()`; each goal adds one - `skip` `@Parameter` named after the index level (`aiIndex.file.skip` / `aiIndex.package.skip` / - `aiIndex.project.skip`). Covered by `MojoPhaseSkipTest`. - -Gates: 174 tests green (1 JNI integration test skipped without the native lib); SpotBugs `Max`+`Low` -clean; full PIT 200/200 (100%); javadoc clean. - -### Layered package restructure (flat plugin package → layered hierarchy) - -The 34 classes that sat flat in `net.ladenthin.maven.llamacpp.aiindex` were split -(via `git mv`, history preserved) into layered packages enforced by a new -`layeredArchitecture()` ArchUnit rule (Mojo → Indexer → Provider → Format → -Foundation): - -- **mojo** (entry): AbstractAiIndexMojo, GenerateMojo, AggregatePackagesMojo -- **indexer** (orchestration): SourceFileIndexer, PackageIndexer, AiFieldGenerationSupport -- **provider**: AiGenerationProvider(+Factory), Mock/LlamaCppJni providers, AiCompletionParser, LlamaCppJniConfig -- **document** (Format): AiMd* model/codecs + the AiGenerationRequest/AiGenerationResult carriers (they hold an AiMdHeader) -- **prompt** (Format): AiPromptDefinition, AiPreparedPrompt, AiPromptSupport, AiPromptPreparationSupport -- **config** (Foundation): AiGenerationConfig, AiGenerationKind, AiFieldGenerationConfig, AiModelDefinition, AiModelDefinitionSupport -- **support** (Foundation): AiChecksumSupport, AiTimeSupport, AiPathSupport, Java8CompatibilityHelper, ConvertToRecord - -Cycle-breaking placement: the generation carriers went to `document` (not -`provider`) because the `prompt` classes take an `AiGenerationRequest` parameter — -keeping them in `provider` created a `prompt ↔ provider` cycle. Test classes -mirrored into their subjects' packages; cross-package Javadoc `{@link}` references -fully-qualified; `module-info` exports the new packages. - -**jllama consumption updated in the same change** (this is what surfaced the need): -bumped `net.ladenthin:llama` 5.0.1 → 5.0.2-SNAPSHOT and adapted to its new shape — -package moves (`InferenceParameters`/`ModelParameters` → `…parameters`, `Pair` → -`…value`), the immutable-wither API (`InferenceParameters` `set*` → `with*`, -folding `withStopStrings` into the builder chain), corrected `setChatTemplateKwargs` -Javadoc links to `ModelParameters`, and a `` pin converging -`slf4j-api` to 2.0.18 (logback pulled an older patch). All 10 ArchUnit rules green; -54 tests pass (1 JNI integration test skipped without the native lib); `javadoc:jar` -clean. - -**Note**: 5.0.2-SNAPSHOT is the local jllama dev version carrying the layered -packages; pin the exact release version when jllama publishes the breaking change. - -- **Error Prone bug-pattern promotions to `ERROR`** — `034b553` (12 patterns promoted; `-Xlint:all` enabled). -- **`javac -Werror` + `-Xlint:all,-serial,-options,-classfile,-processing`** — done. EqualsGetClass warnings on the 7 `@ConvertToRecord` classes were fixed by switching to `instanceof` checks; `Java8CompatibilityHelper.formatted` carries an inline `@SuppressWarnings("AnnotateFormatMethod")`; generated `HelpMojo` is excluded from Error Prone via `-XepExcludedPaths`; `listOf` carries `@SafeVarargs` + `@SuppressWarnings({"unchecked","varargs"})`. -- **`-parameters` javac arg** — `7ae3279` (`true`; dropped for the test execution where jcstress / Lincheck reflection would otherwise break). -- **`--release N`** instead of `-source N -target N` — `7ae3279` (`${maven.compiler.release}` (release 8) for main sources, `9` for `module-info.java`). -- **Checker Framework as a second static-nullness pass** — wired in `pom.xml` (4.1.0) alongside NullAway. `HelpMojo` is skipped via `-AskipDefs`; framework-populated POJO classes carry `@SuppressWarnings("initialization.fields.uninitialized")`; record-style equals overrides use `@Nullable Object`. -- **JPMS `module-info.java` with module-level `@NullMarked`** — exports the single hand-written package `net.ladenthin.maven.llamacpp.aiindex`; the auto-generated `HelpMojo` package is deliberately NOT exported because Maven loads plugins classpath-only and never consults the descriptor for Mojo discovery. Two-execution `maven-compiler-plugin` pattern. Module-level `@NullMarked` IS set on the module descriptor; JSpecify is pulled in via `requires static org.jspecify;` so the annotation does not become a runtime dependency. -- **Banned-API enforcement** — Maven Enforcer (`d654442`), ArchUnit `System.exit` / `new Random` / `Thread.sleep` (`fd8cf80`), `sun.*` / `com.sun.*` / `jdk.internal.*` (`ad37355`). -- **ArchUnit additions** — public-fields-final (`d2b1af9`), `noPackageCycles` (`26a4f7b`). -- **Abstract the Java and test writing guidelines to a workspace-level shared layer.** Workspace version chain at [`../workspace/guides/src/CODE_WRITING_GUIDE-8.md`](../workspace/guides/src/CODE_WRITING_GUIDE-8.md) and [`../workspace/guides/test/TEST_WRITING_GUIDE-8.md`](../workspace/guides/test/TEST_WRITING_GUIDE-8.md); canonical TDD skill at [`../workspace/.claude/skills/java-tdd-guide/SKILL.md`](../workspace/.claude/skills/java-tdd-guide/SKILL.md). This repo's `CODE_WRITING_GUIDE.md` / `TEST_WRITING_GUIDE.md` now hold only plugin-specific supplements. -- **Standardised CLAUDE.md template** — [`../workspace/templates/CLAUDE.md.template`](../workspace/templates/CLAUDE.md.template). +- **No LogCaptor smoke test needed (note, not an action).** This module has no logging code (`org.slf4j.*` not used in `src/main/java/`); production uses Maven's `Log` interface. If SLF4J logging is ever introduced, add a LogCaptor smoke test at the same time so the binding/configuration is exercised in tests. diff --git a/docs/ai-index-benchmark/COMPARISON.md b/docs/ai-index-benchmark/COMPARISON.md new file mode 100644 index 0000000..b91b71d --- /dev/null +++ b/docs/ai-index-benchmark/COMPARISON.md @@ -0,0 +1,571 @@ +# AI Index — Model & Prompt Comparison + +Scored comparison of 8 local GGUF models × 2 prompt versions for the plugin's `.ai.md` +code-summarization task. Scope, hardware, and reproduction: see [README.md](README.md). +Generated 2026-06-27 from the trees in [outputs/](outputs/). + +All cells: 12 source files (`config` + `provider`) → 23 `.ai.md` each, 16K context, CPU. + +--- + +## 1. Quantitative metrics + +Columns: **avgLn** = mean lines per `.ai.md` (verbosity); **KB** = total output size; +**kw** = "keyword" hallucination hits; **fence** = stray ```` ``` ```` code fences (prompt forbids +them); **leak** = reasoning/``/harmony markers in output; **enum** = lines for the +trivial `AiGenerationKind` enum (lower = better section-omission); **pojo** = lines for the +`AiGenerationConfig` bean (lower = less accessor bloat); **s/file** = wall-seconds per summary. + +| Cell | avgLn | KB | kw | fence | leak | enum | pojo | s/file | +|---|---|---|---|---|---|---|---|---| +| deepseek-coder-v2-lite v1 | 62.4 | 70 | 0 | 0 | 0 | 39 | 77 | 84.1 | +| deepseek-coder-v2-lite v2 | 52.9 | 62 | 0 | **24** | 0 | 41 | 56 | 66.6 | +| gptoss-20b v1 | 55.5 | 60 | 0 | 0 | 0 | 35 | 77 | 129.0 | +| gptoss-20b v2 | 45.3 | 43 | 0 | 0 | 0 | **13** | 62 | 121.4 | +| granite4-h-tiny v1 | 60.7 | 82 | 0 | 0 | 0 | 53 | 84 | 59.8 | +| granite4-h-tiny v2 | 49.2 | 44 | 0 | 0 | 0 | 40 | 78 | **33.9** | +| qwen25coder-7b v1 | 53.8 | 57 | 0 | 0 | 0 | 21 | 109 | 141.1 | +| qwen25coder-7b v2 | 47.9 | 51 | 0 | **12** | 0 | 23 | 71 | 132.8 | +| qwen3-4b-2507 v1 | 54.4 | 63 | 0 | 0 | 0 | 40 | 64 | 80.6 | +| qwen3-4b-2507 v2 | 53.8 | 60 | 0 | 0 | 0 | 40 | 70 | 72.3 | +| qwen35-4b v1 | 50.7 | 71 | 0 | 0 | 0 | 33 | 82 | 100.8 | +| qwen35-4b v2 | 49.7 | 62 | 0 | 0 | 0 | 38 | 76 | 90.6 | +| qwen3coder-30b v1 | 51.9 | 52 | 0 | 0 | 0 | 40 | 84 | 72.6 | +| qwen3coder-30b v2 | 53.2 | 57 | 0 | 0 | 0 | 33 | 73 | 71.4 | +| seed-coder-8b v1 | 49.7 | 39 | 0 | 0 | 0 | 38 | 78 | 79.5 | +| seed-coder-8b v2 | 49.7 | 44 | 0 | **4** | 0 | 35 | 67 | 85.1 | + +--- + +## 2. Headline findings + +1. **No reasoning leakage anywhere (leak = 0 in all 16 cells).** llama.cpp's default + reasoning parsing strips Qwen `` *and* gpt-oss *harmony* channels server-side, so + `chatCompleteText` returns clean `content`. The Gemma-only `AiCompletionParser` was never + needed. **gpt-oss output is clean** — the feared harmony-marker leakage does not occur. +2. **No "keyword" hallucination (kw = 0 everywhere).** The keyword tic seen in the original + full-project 30B run did **not** reproduce in the `config`+`provider` scope — so v2's explicit + keyword ban is **untested here** (nothing to suppress). Re-check on the mojo/indexer packages. +3. **Prompt v2 reduces verbosity and accessor bloat broadly** — lower `avgLn`/`KB` for most + models, and `pojo` drops notably (qwen2.5-coder 109→71, deepseek 77→56, 30B 84→73, gpt-oss + 77→62). This is v2's clearest win. +4. **v2 induces code-fence violations on the *code-specialized* models** — DeepSeek (24), + Qwen2.5-Coder (12), Seed-Coder (4) wrap e.g. the `#### Type` line in ```` ```java ````; the + general models (gpt-oss, granite, qwen3-4b, qwen3.5-4b, qwen3-coder-30b) stay at **0**. This + is a v2 **regression** that must be fixed before v2 ships. +5. **Trivial-file omission (enum) is only partially honored** by v2 — gpt-oss obeyed it well + (35→13), 30B and granite partly; most models did not shrink. Prompt wording is not a reliable + lever for small models — filtering/deterministic handling is more dependable. +6. **Reasoning/thinking is a pure throughput tax with no quality payoff here.** + `qwen3.5-4b` (hybrid, thinks) ran 90–101 s/file vs the non-thinking `qwen3-4b-2507` at + 72–81 s/file with equal-or-better output. `gpt-oss-20b` is slowest of all (121–129 s/file) + despite being MoE — it spends tokens on harmony reasoning that is then discarded. + +--- + +## 3. Speed ranking (v2, s/file, fastest first) + +`granite4-h-tiny` **33.9** ≪ `deepseek-v2-lite` 66.6 < `qwen3coder-30b` 71.4 < `qwen3-4b-2507` +72.3 < `seed-coder-8b` 85.1 < `qwen35-4b` 90.6 < `gptoss-20b` 121.4 < `qwen25coder-7b` 132.8. + +Active-param count dominates CPU decode: the ~1B-active Granite hybrid is **~4× faster** than the +dense 7B Qwen2.5-Coder, and MoE low-active models (Granite, DeepSeek 2.4B, Qwen3-Coder 3.3B) lead. + +--- + +## 4. Qualitative quality (sampled: `provider/AiGenerationProviderFactory.java`) + +| Tier | Models | Notes | +|---|---|---| +| **A — clean + accurate** | gpt-oss-20b, seed-coder-8b, qwen3-coder-30b | gpt-oss had the highest fidelity (captured the exact `"Unsupported AI provider: " + providerName` message and full dependency list) but is the slowest. Seed-Coder and Qwen3-Coder are clean, terse, and accurate. | +| **B — good, minor gaps** | granite-4.0-h-tiny, qwen3-4b-2507 | Granite is impressively accurate for ~1B active and by far the fastest (slightly incomplete dependency lists). Qwen3-4B-2507 is solid, terse, non-thinking. | +| **C — accurate but noisy** | deepseek-coder-v2-lite, qwen2.5-coder-7b, qwen3.5-4b | DeepSeek repeats the heading inside each section (`- **Purpose**: …`), leaks `{@link}` Javadoc tags, and triggers the most fences. Qwen2.5-Coder is the slowest and fences under v2. Qwen3.5-4B pays the thinking tax with no quality edge over Qwen3-4B-2507. | + +--- + +## 5. Per-model pros & cons + +| Model (active params) | Pros | Cons | +|---|---|---| +| **Qwen3-Coder-30B-A3B** (MoE ~3.3B) | Most complete & faithful content; code-specialized; clean (0 fences / 0 leak); fast for its quality (~71 s/file); Apache-2.0; 262K native ctx | Wrongly tags the class `final`; drops the `@SuppressWarnings` annotation; minor dangling `implements` line | +| **gpt-oss-20b** (MoE ~3.6B) | Highest fidelity — captured exact exception strings, constructor calls, and the unmodifiable/nullable `stopStrings` contract; clean; Apache-2.0 | Slowest (~121–129 s/file — harmony reasoning overhead); "final by default" nonsense; drops `@SuppressWarnings` | +| **Granite-4.0-H-Tiny** (MoE ~1B) | Fastest by far (~34 s/file); the only model that captured `@SuppressWarnings`; Apache-2.0; flat-KV hybrid → cheap long context | Verbose (repeats field lists across sections); wrong `final`; junk self-package dependency entry | +| **Seed-Coder-8B** (dense, MIT) | Clean, terse, accurate; avoided the `final` trap; permissive MIT | Calls the private fields "public fields"; drops `@SuppressWarnings`; v2 emits a few code fences | +| **Qwen3-4B-Instruct-2507** (dense) | Fast (~72 s/file); non-thinking; good core-logic capture; no fences | **Dropped all setters** from Public API (incomplete on a long file); overclaims thread-safety; "final fields" wrong | +| **Qwen2.5-Coder-7B** (dense) | Accurate, code-specialized; captured constructor + unmodifiable `stopStrings` | Slowest dense (~133–141 s/file); wrong `final`; accessor bloat (v1: 109 lines); v2 fences | +| **Qwen3.5-4B** (dense, hybrid) | Thorough API listing; avoided the `final` trap | Thinking tax (~90–101 s/file) with no quality edge; **fabricated field counts** (claimed 25 constants / 16 fields vs real ~13 / 14); junk self-dependency | +| **DeepSeek-Coder-V2-Lite** (MoE ~2.4B) | Fast (~67–84 s/file); accurate body content | **Copied the prompt's "Calculates VAT for invoices" example as the lead** — instruction-following failure; redundant `- **Label**:` echoing; most fences (24); leaked `{@link}` Javadoc tags; **license is a use-restricted custom *DeepSeek Model License* (weights), not OSI/commercial-OK** | + +## 6. Source-faithfulness deep-dive — `AiGenerationConfig.java` (largest in-scope file, 414 lines) + +Each model's summary of this complex POJO was checked field-by-field against the real source. +Cross-model findings: + +- **`final` is hallucinated by 6 of 8 models.** The class is `public class AiGenerationConfig` + (NOT final); only Qwen3.5-4B and Seed-Coder got it right. Likely pattern-matching — most classes + in this repo *are* `final`. A reliable, recurring inaccuracy. +- **Annotation capture is poor.** Only Granite reported `@SuppressWarnings({"NullAway.Init", …})`; + every other model dropped it. Most did capture `@ToString`. +- **The blockquote lead is the riskiest field.** DeepSeek emitted the prompt's literal *example* + (`Calculates VAT for invoices`); the others produced correct domain leads. +- **Completeness varies on a long member list.** gpt-oss / Qwen3-Coder-30B / Qwen2.5-Coder listed + the full accessor set accurately; Qwen3-4B-2507 omitted every setter; Qwen3.5-4B invented counts. +- **`equals`/`hashCode` intentionally absent** (managed by identity) — no model surfaced this + subtlety (acceptable; it requires reasoning about a *negative*). + +Implication: the structural facts models get wrong (class modifiers, annotations, exact member +sets, dependency lists) are exactly the ones an **AST / deterministic extractor would get right**. +The prose sections (lead, purpose, core logic) are where the model adds real value — which argues +for a hybrid deterministic-structure + AI-prose design. + +## 7. Recommendations + +- **Production default (this project): `gpt-oss-20B-mxfp4`** (native-MXFP4 swap of the benchmarked + `c96k`/UD-Q4_K_XL; same 96K window, quant choice within noise per E5). Chosen for maximum per-file + fidelity, run at `reasoningEffort=low` and a 96K window so it covers files up to ~250 KB untrimmed + (§11). It is the slowest of the set, accepted here because accuracy is the priority — details below. +- **Throughput alternative: `Qwen3-Coder-30B-A3B-Instruct`** — clean, accurate, code-specialized, + Apache-2.0, ~71 s/file (~3.3B active MoE); pick it when throughput beats the last points of fidelity. +- **Why gpt-oss is the precision pick:** it is the most *faithful* model in the study. + It won the per-file matrix **5 of 6** (§8), was the only model to consistently avoid the `final` + hallucination, copied no prompt examples, and captured exact exception messages, the full member + sets, and the complete JNI pipeline — including correct (unsynchronized) lazy-init where others + invented "double-checked locking". Its harmony chain-of-thought — the very thing that makes it + the slowest (~121–129 s/file, §3) — is what buys the extra accuracy, so the speed cost is + irrelevant in this scenario. Pair it with the **v1 prompt** and a **generous `maxOutputTokens`** + so long member lists are never truncated, and run each file at the model's full context. Output is + clean (0 harmony leakage, §2). For an even higher ceiling you *could* trial larger local models + not benchmarked here (e.g. `Qwen3.6-35B-A3B`, `gemma-4-26B-A4B`), but among the tested set + `gpt-oss-20b` is the precision winner. (For the same one-off job where you still want it to finish + noticeably sooner with only a small fidelity trade, fall back to `Qwen3-Coder-30B-A3B`.) +- **Best for large Java files: `Qwen3-Coder-30B-A3B-Instruct`**, with `Granite-4.0-H-Tiny` as the + high-throughput alternative. Large files mean a big prefill + a long member list to enumerate. + On the 414-line `AiGenerationConfig` the 30B kept the member list complete and accurate, and its + 262K native context + ~3.3B-active MoE handle long input affordably; the full-project baseline + (28 KB `PackageIndexer.java`) confirmed it stays complete (one `Serializable` slip). Granite's + flat-KV hybrid makes very large/​many files the cheapest on CPU (~4× faster) — use it when + throughput beats the last few points of fidelity. **Caveat:** large files were not directly swept + across all models (scope was `config`+`provider`, max 414 lines); this extrapolates from that + file, model architecture, and the 30B full-project baseline. Avoid `Qwen3-4B-2507` for large + files specifically — it dropped members on the long list. +- **Best permissive small dense coder: `Seed-Coder-8B-Instruct`** — MIT, clean output, no fence + issue. `Qwen2.5-Coder-7B` (Apache-2.0) matches it on *accuracy* once fences are post-stripped + (see §9 re-test) but is the slowest dense model — prefer Seed-Coder unless you specifically want + the Qwen tokenizer/ecosystem. +- **Budget / laptop: `Qwen3-4B-Instruct-2507`** (non-thinking) over `Qwen3.5-4B` — faster, no + thinking tax, equal-or-better output (but not for the largest files; see above). +- **Avoid for *batch / throughput* work:** `gpt-oss-20b` (highest fidelity but slowest — reserve it + for the max-precision use above, not bulk runs), `Qwen2.5-Coder-7B` (slowest dense), + `DeepSeek-Coder-V2-Lite` (the VAT-lead and fence/format noise). +- **Regardless of model:** expect the `final`/annotation/exact-member inaccuracies above. The + durable fix is deterministic AST extraction for the structural sections (see §6). + +### Prompt v1 vs v2 + +v2 is **promising but not yet shippable**: it genuinely tightens output and cuts accessor bloat, +but the **code-fence regression on code-specialized models** is a blocker. Recommended before +adoption: add an explicit, example-backed "never wrap any section in a code fence" instruction +(and/or strip leading ```` ```lang ```` deterministically), then re-test. For non-code models v2 is +already a net improvement. The trivial-file omission and keyword-ban goals are better served by +the indexer's filtering than by prompt wording. + +--- + +## 8. Per-file model matrix + +Six source files of deliberately different archetypes were each summarized by all 8 models +(**v1 / production prompt**) and scored field-by-field against the real source. One table per file. + +### AiGenerationKind.java — enum / marker +*Source:* A trivial `public enum AiGenerationKind` with two constants, `FILE_SUMMARY` and `PACKAGE_SUMMARY`, marking AI-generation scope (file vs. package); no methods. + +| Model | Faithfulness (vs source) | Completeness | Key issues | Verdict | +|---|---|---|---|---| +| Qwen3-Coder-30B | Mostly accurate; "final" ok | Over-complete, bloated | Constants as methods `FILE_SUMMARY()`; verbose | Fair — method formatting | +| gpt-oss-20b | Accurate; constants correct | Right-sized | Minor: trailing whitespace only | Good — clean, faithful | +| Granite-4.0-H-Tiny | Accurate; `public` correct | Complete but padded | Many empty "No..." filler lines | Good — faithful, verbose | +| Seed-Coder-8B | Wrong: claims `sealed` | Adequate | Hallucinated `sealed`; self-ref dependency | Poor — invented modifier | +| DeepSeek-Coder-V2-Lite | Accurate; `public enum` right | Good | Constants as methods `FILE_SUMMARY()` | Fair — method formatting | +| Qwen2.5-Coder-7B | Fully accurate | Concise, appropriate | None notable | Excellent — terse, correct | +| Qwen3-4B-2507 | Wrong API signatures | Over-stated | `FILE_SUMMARY(file)→void`; self-ref dep | Poor — invented params | +| Qwen3.5-4B | Wrong: "no modifiers" | Concise | Missed `public`; self-ref dependency | Fair — modifier error | + +**Best for this file:** Qwen2.5-Coder-7B — accurate, no hallucinations, appropriately short for a trivial enum. + +### AiGenerationConfig.java — large config POJO +*Source:* A mutable, non-final JavaBean (`@ToString` + `@SuppressWarnings`) carrying ~13 `DEFAULT_*` constants and ~14 fields with full getter/setter pairs, where `getStopStrings` returns an unmodifiable list or null; equals/hashCode intentionally absent. + +| Model | Faithfulness (vs source) | Completeness | Key issues | Verdict | +|---|---|---|---|---| +| Qwen3-Coder-30B | Mostly right; getStopStrings nuance ok | Full getters+setters, deps correct | Says "final" (wrong); misses @SuppressWarnings | Good — final error | +| gpt-oss-20b | Strong; clean, no fabrication | Full API, deps, lead all correct | "final by default" (wrong); misses @SuppressWarnings | Good — lone final slip | +| Granite-4.0-H-Tiny | Captured @SuppressWarnings correctly | Full API, all fields listed | "Final: Yes" (wrong); junk referenced types | Good — final error, minor junk | +| Seed-Coder-8B | Avoids final but "Public fields" wrong | Full API present | Drops `List` dep; sloppy concurrency claim | Fair — field/dep errors | +| DeepSeek-Coder-V2-Lite | Lead copied from prompt example | Full API present | "Calculates VAT" lead; says final twice | Poor — copied lead + final | +| Qwen2.5-Coder-7B | "No return types" contradicts getters | Full API present | Says "Final"; self-contradictory output | Fair — final + contradiction | +| Qwen3-4B-2507 | "final fields" wrong; bad concurrency | Drops ALL setters | Setters missing; claims thread-safe | Poor — setters dropped | +| Qwen3.5-4B | Correctly non-final `public class` | Full getters+setters | Invents 25 constants/16 fields; junk self-dep | Fair — fabricated counts | + +**Best for this file:** gpt-oss-20b — most complete and faithful with no fabricated counts or junk deps; only flaw is the "final by default" note. + +### AiGenerationProvider.java — interface / contract +*Source:* A `public interface AiGenerationProvider extends AutoCloseable` with an abstract `generate(request)`, a default temperature-override `generate(request, float)` that delegates, and a default no-op `close()`. + +| Model | Faithfulness (vs source) | Completeness | Key issues | Verdict | +|---|---|---|---|---| +| Qwen3-Coder-30B | Correct interface + AutoCloseable, both generate methods | Misses `close()` in API | Lists AutoCloseable as a "dependency" | Good — accurate, slight gap | +| gpt-oss-20b | Fully correct; interface, extends, all 3 members | All methods incl. default `close()` | None notable | Excellent — complete & precise | +| Granite-4.0-H-Tiny | Correct interface/extends, both generate | Omits `close()`; deps miss AiGenerationRequest | Thin coverage | Good — terse but right | +| Seed-Coder-8B | Wrong: "Extends AiGenerationRequest" | Has close, both generate | Fabricated extends; false thread-safety | Poor — invented inheritance | +| DeepSeek-Coder-V2-Lite | Wrong: "Extends AiGenerationRequest" | All 3 methods listed | Fabricated extends; false thread-safety claim | Poor — invented inheritance | +| Qwen2.5-Coder-7B | Correct interface/extends, exact signatures | Misses `close()` in API | "Constructor params" odd for interface | Good — signatures accurate | +| Qwen3-4B-2507 | Correct interface, extends, all 3 members | Complete incl. `close()` | Minor: omits "may be blank" | Good — clean and faithful | +| Qwen3.5-4B | Interface/extends correct | All 3 methods | Invented core logic (validates, runs llama.cpp inference) | Fair — hallucinated impl detail | + +**Best for this file:** gpt-oss-20b — correct interface, all three members with accurate signatures and deps, no hallucination. + +### AiGenerationProviderFactory.java — factory / wiring +*Source:* A `@ToString` (non-final) factory whose `create(providerName, llamaConfig, promptSupport)` returns `MockAiGenerationProvider` for null/blank/"mock", `LlamaCppJniAiGenerationProvider` for "llamacpp-jni", else throws `IllegalArgumentException("Unsupported AI provider: " + providerName)`. + +| Model | Faithfulness (vs source) | Completeness | Key issues | Verdict | +|---|---|---|---|---| +| Qwen3-Coder-30B | Accurate logic, but asserts "final" | All deps (6), full switch | Wrong: class not final; message unquoted | Good — false final | +| gpt-oss-20b | Fully accurate, no final claim | Exact message, full switch | Missing only LlamaCppJniConfig dep | Excellent — exact message | +| Granite-4.0-H-Tiny | Lead is prompt's "Calculates VAT" | Omits "mock" case; 3 deps only | VAT lead; "final"; deps incomplete | Poor — copied lead | +| Seed-Coder-8B | Accurate, correctly not final | Full switch incl. mock | Missing LlamaCppJniConfig + provider iface deps | Good — solid | +| DeepSeek-Coder-V2-Lite | Accurate, not final | Default-throw only in Exceptions section | `{@link}` leakage; deps miss provider classes | Fair — deps thin | +| Qwen2.5-Coder-7B | Very accurate, notes isBlank | Full switch, not final | Self-referential dep (Factory); deps incomplete | Good — junk dep | +| Qwen3-4B-2507 | Accurate; hedged "final (not marked)" | 5 deps, full switch | Confusing final wording; misses lombok dep | Good — final hedge | +| Qwen3.5-4B | Accurate; correctly says final *field* | 6 deps, full switch | Mild invention ("integration into system"); odd phrasing | Good — complete | + +**Best for this file:** gpt-oss-20b — only one with the exact exception message, correct non-final type, and clean full switch logic. + +### AiCompletionParser.java — algorithm / string parsing +*Source:* A non-final parser that strips a Gemma-4 thinking block (markers `<|channel>thought` / ``), returning text after the last end marker, throwing IOException on an unclosed block and mapping null to empty. + +| Model | Faithfulness (vs source) | Completeness | Key issues | Verdict | +|---|---|---|---|---| +| Qwen3-Coder-30B | Accurate; non-final, logic right | All sections, IOException + null | "Checks presence" not "last index" (minor) | Excellent | +| gpt-oss-20b | Fully accurate; last-index, null, msg | Thorough; markers + maxOutputTokens note | None significant | Excellent | +| Granite-4.0-H-Tiny | Logic right but calls class **final** | Good; but contradicts self on final | "Type: final" wrong; verbatim purpose copy | Fair — wrong modifier | +| Seed-Coder-8B | Accurate; non-final, edge cases noted | Concise; less marker detail | No "last marker" specificity | Good | +| DeepSeek-Coder-V2-Lite | Logic right but says **final class** | Very detailed sections | "public final class" wrong; not "last" | Fair — wrong modifier | +| Qwen2.5-Coder-7B | Accurate; non-final, last-index, null | Complete | Purpose claims it "stores" file (overreach) | Good | +| Qwen3-4B-2507 | Fully accurate; non-final, null, msg | Complete, clean | None significant | Excellent | +| Qwen3.5-4B | Content accurate where present | Missing Purpose + Type sections | Leaks stray code-fence; truncated header | Fair — corrupted output | + +**Best for this file:** gpt-oss-20b — accurate logic, captures last-index, null-handling, and the actionable maxOutputTokens message, with no errors. + +### LlamaCppJniAiGenerationProvider.java — heavy implementation (JNI) +*Source:* Lazy-loading llama.cpp JNI provider (implements `AiGenerationProvider` + `AutoCloseable`) that builds inference params via immutable withers, runs `chatCompleteText`, and parses output through `AiCompletionParser`. + +| Model | Faithfulness (vs source) | Completeness | Key issues | Verdict | +|---|---|---|---|---| +| Qwen3-Coder-30B | Accurate; lazy-load, withers, parser captured | Full: API, deps, exclude | Invented "double-checked locking" | Good — one false concurrency claim | +| gpt-oss-20b | Fully accurate; correct unsynchronized lazy-init | Full: fields, deps, withers, parser | None notable | Excellent — precise, complete | +| Granite-4.0-H-Tiny | Lead copied prompt example; wrong thread-safe claim | Moderate; misses parser class name | "Calculates VAT for invoices" lead | Poor — prompt-leak lead | +| Seed-Coder-8B | Mostly accurate; lazy + parser noted | Good | Wrong: thread-safe + double-checked locking | Fair — false concurrency | +| DeepSeek-Coder-V2-Lite | Lead copied prompt example; thread-safe wrong | Good core logic | "Calculates VAT for invoices" lead | Poor — prompt-leak lead | +| Qwen2.5-Coder-7B | Accurate; lazy, parser, withers all noted | Full deps + API | Honest "not handled" concurrency | Good — solid, no hallucination | +| Qwen3-4B-2507 | Accurate logic; lazy + parser captured | Full withers, deps | Wrong AiCompletionParser package; muddled concurrency | Good — minor dep/package slip | +| Qwen3.5-4B | Accurate; lifecycle, parser, exclude noted | Full deps + API | close() doesn't throw IOException | Good — small exception error | + +**Best for this file:** gpt-oss-20b — fully faithful, complete (lazy-load, wither chain, parser pipeline), correct concurrency, no hallucinations. + +### Matrix synthesis + +**"Best for this file" tally:** gpt-oss-20b **5/6**, Qwen2.5-Coder-7B **1/6** (the trivial enum). + +So **gpt-oss-20b is the per-file accuracy leader** — it alone avoided the `final` hallucination on +most files, copied no prompt examples, and captured exact exception messages and the JNI pipeline. +But this must be read against §3: **gpt-oss is the slowest model (~121–129 s/file)** because of +harmony reasoning overhead. The practical pick remains **Qwen3-Coder-30B-A3B** — consistently +"Good" across every archetype at **~71 s/file** — with gpt-oss reserved for when per-file fidelity +outweighs throughput. The dominant cross-file error for nearly every model is the **`final` +modifier hallucination** (a structural fact an AST extractor would get right — see §6); the worst +single failures are DeepSeek/Granite **copying the prompt's "Calculates VAT for invoices" example +as the lead**, and Qwen3-4B-2507 **dropping members** on longer files. + +## 9. External corroboration (published benchmarks) + +A web research pass cross-checked these findings against public benchmarks, leaderboards, and +official model cards. **Headline:** our *structural* findings are corroborated; our *accuracy +ranking* is novel and cannot be corroborated, because no public benchmark scores source-faithfulness +of code-index summaries and IFEval exists for only **2 of our 8** models. + +**Corroborated (at the mechanism / category level):** +- **Speed ↔ active params:** CPU decode is memory-bandwidth-bound and reads only active expert + weights, so a 30B-A3B decodes like a dense ~6B ([llama.cpp #19890](https://github.com/ggml-org/llama.cpp/discussions/19890)). + IBM publishes Granite 4.0 "~2× faster / >70% less RAM" ([IBM](https://www.ibm.com/granite/docs/models/granite)). + *(Our exact "~4× fastest Granite" magnitude is our own measurement.)* +- **Reasoning is a throughput tax** that helps hard tasks but not short summaries + ([OptimalThinkingBench](https://arxiv.org/html/2508.13141v1); "Stop Overthinking" + [survey](https://arxiv.org/pdf/2503.16419)) — supports our Qwen3.5-4B result. The *conditional* + exception (reasoning genuinely raised gpt-oss accuracy at a latency cost) is also documented + ([BrowseComp-Plus](https://arxiv.org/pdf/2508.06600), [DataRobot](https://www.datarobot.com/blog/testing-gpt-oss-models/)). +- **All four hallucination modes are named categories:** attribute/faithfulness hallucination (the + `final` slip), few-shot/prompt leakage (the "Calculates VAT for invoices" copy), format drift + (code fences), and negative-constraint instruction-following failure (ignoring "omit trivial + sections"). +- **Tooling:** llama.cpp `reasoning_format` parsing and the `--reasoning-format none` harmony-leak + are confirmed in the repo ([server README](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md), + [#15341](https://github.com/ggml-org/llama.cpp/discussions/15341)). + +**Novel (no public equivalent):** our source-faithfulness scoring for code-index summaries, the +per-file head-to-head (gpt-oss-20b 5/6), and CPU timings for these exact Q4_K_M quants at 16K on a +Ryzen 7 5800H. **Treat the §5/§8 accuracy ranking as internal evidence, not a public-record claim.** + +**The only published IFEval anchors for our set:** Granite-4.0-H-Tiny ≈ **81.4** avg (84.8 +instruct-strict) and Qwen3-4B-Instruct-2507 ≈ **83.4**. The other six models have no published +IFEval (gpt-oss-20b's official card has none; a ~69.5% figure circulating is unofficial). + +**Where we may be exposed:** +- **Qwen2.5-Coder-7B was under-ranked — confirmed by a follow-up re-test.** Public coding + benchmarks rank it strongly (Qwen reports it beats DeepSeek-Coder-V2-Lite and Codestral-22B; leads + CRUXEval at its size). We re-scored its **v2** output across all 6 archetype files with the stray + code fences treated as the deterministically-fixable format error they are. Fence-normalized, its + **comprehension is top-tier (top-3, alongside gpt-oss-20b)**: it correctly reports the *non-final* + classes (no `final` hallucination — unlike most models), the full accessor set with the + unmodifiable-list nuance, the interface's default-delegation contract, the parser's three-branch + control flow + IOException trigger, and the JNI lazy-load/inference/`close()` chain — with no + invented members, hallucinated inheritance, or copied-example leads. Residual issues are cosmetic + (one null-handling phrasing slip in `AiCompletionParser`; an "implements vs extends" nit). **So its + mid-pack matrix placement was a *format* artifact, not a comprehension deficit** — with a one-line + fence-stripping post-process it is a strong, permissive (Apache-2.0) option. The remaining catch is + speed: it is the slowest *dense* model (~133–141 s/file). +- **DeepSeek-Coder-V2-Lite low** agrees with the public record (its own paper concedes an + instruction-following gap). + +**License correction (applied above):** DeepSeek-Coder-V2-Lite weights are under a use-restricted +custom **DeepSeek Model License** (the repo *code* is MIT) — not "commercial-OK". Codestral remains +MNPL (non-commercial); the rest are Apache-2.0 (Qwen family, gpt-oss, Granite) or MIT (Seed-Coder). + +**Caveat — model-name collisions:** public IFEval figures are easy to mis-attribute across +`Qwen3-Coder-30B-A3B` vs `Qwen3-30B-A3B-2507` (the 83.7 figure is the non-thinking 30B, *not* the +Coder or the 4B) and `Qwen3.5-4B` vs `Qwen3-4B-Instruct-2507`. Anchors above are attributed carefully. + +## 10. Prompt-cache optimization (`cache_prompt`) + +The provider keeps the model loaded once and reuses the shared prompt-template prefix's KV across +files via llama.cpp `cache_prompt` (pinned to one slot); only the differing per-file source is +re-prefilled. A/B on the same model (Qwen3-Coder-30B-A3B @ 16K), file phase over `config`+`provider` +(12 files): + +| `cachePrompt` | wall time (12 files) | ~ per file | +|---|---|---| +| `false` (baseline) | 1055 s | ~88 s | +| `true` (default) | 950 s | ~79 s | + +**≈ 10 % faster (−105 s)**, output unchanged (prefix reuse is logit-exact). This is the *entire* +cacheable share: the remainder — per-file source prefill + decode — is inherently uncacheable, so a +system/user prompt split would add no further speed (only a possible, separate quality effect). +Enabled by default (`cachePrompt=true` on each model definition; needs `net.ladenthin:llama` +≥ 5.0.3 for the pinned-slot API). Measured at 16K context (the new CPU default — 64K's ~6 GB KV +caused memory paging on the test box that confounded timing). + +## 11. gpt-oss `reasoning_effort` (low / medium / high) + +gpt-oss is a *reasoning* model: it emits an internal `analysis` channel before the `final` answer, +and llama.cpp counts those reasoning tokens **in-band** against `maxOutputTokens`. The benchmark ran +the file phase (`config`+`provider`, 12 files) with `EXP-gpt-oss-20B` @ 16K, `maxOutputTokens=1536`, +flipping only `-Dai.reasoningEffort` across `low` / `medium` / `high`. + +**Headline: higher effort is strictly worse for this task — it is slower *and* truncates the +deliverable.** Because reasoning shares the fixed 1536-token budget, more reasoning leaves fewer +tokens for the actual summary, so the `final` answer gets cut off (or never starts). + +| Aspect (gpt-oss-20B @ 16K, file phase, 12 files) | `low` | `medium` | `high` | +|---|---|---|---| +| Wall time (12 files) | **1072 s** | 1545 s | aborted (≈ 8 min/file, ~4×) | +| ~ per file | **~89 s** | ~129 s | ~8 min/file (aborted) | +| Relative speed | **1.0× (fastest)** | ~1.44× slower | ~4× slower | +| Reasoning (`analysis`) tokens spent | minimal | moderate | large | +| Share of 1536-token budget left for the summary | ~all | ~half | little / none | +| `AiGenerationConfig.java` body | **complete** (all sections → `Concurrency`) | truncated mid `Public API` | truncated after `Annotated` (≈ 2 body lines) | +| `AiModelDefinition.java` body | **complete** (→ `Concurrency`) | complete | **header only — no body produced** | +| Truncation risk at `maxOutputTokens=1536` | low | medium (file-dependent) | high (frequent / total) | +| Summary structure when it completes | full, well-sectioned | comparable when not cut | rarely reaches the sections | +| Harmony-marker leakage into body | 0 | 0 | 0 | +| Net usefulness for this short-summary task | **best** | borderline | unusable at this budget | + +The `high` run was **aborted** after confirming the pattern: at the 1536 budget it truncates even +worse than `medium` (e.g. `AiModelDefinition.java` produced a header with no body) while running ~4× +slower — strictly dominated, so finishing all 12 files added no information. + +### Is there any benefit to medium/high? + +For this task — short, dense bullet summaries — **not at a tight output budget**. The summary content is +extraction/structuring, not multi-step problem solving, so the extra reasoning buys little quality; it +only consumes the budget the deliverable needs. The truncation above is a **budget artifact, not a +model limit**: give the reasoning room and the summary completes (see below). `low` remains the best +default — fastest, and the whole budget goes to the summary. + +### Clean runs, large files, and the context-window limit + +Two independent limits must both be satisfied for a clean run: + +| Limit | Controls | Failure if too small | +|---|---|---| +| `contextSize` | input (prompt + source) that fits the window | source **trimmed** before the model sees it | +| `maxOutputTokens` | reasoning **+** final answer (gpt-oss reasons in-band) | summary **truncated** mid-output | + +`charsPerToken=3` is set on all presets as a deliberately conservative *trim* guard (the synthetic +fixture measured ~4.2 chars/token; a later real-Java regression found **~4.8** — see +[gpt-oss-tuning.md](gpt-oss-tuning.md) Phase 5 — and 3 stays safely below both so a big file is never +silently over-fed past the real token window). (The earlier 1536-budget truncation was a *budget* +artifact, not a model limit — give the output room and the summary completes.) + +**How big can one file be?** gpt-oss-20b's native window is **`n_ctx_train = 131072` (128K tokens)**. +At ~4.2 chars/token that is the hard ceiling; the practical ceiling on CPU is *time*, not the window: + +| File size | ≈ tokens | fits 128K window? | practical on CPU? | +|---|---|---|---| +| ~40 KB | ~10 K | yes | yes — ~1–2 min/file | +| ~100 KB | ~24 K | yes | yes — ~25 min/file | +| ~250 KB | ~62 K | yes | borderline — **~80 min/file** | +| ~480–500 KB | ~115–120 K | edge (needs tiny output budget) | no — hours | +| > ~500 KB | > 122 K | **no — exceeds the window** | n/a | + +**Three size-tiered presets ship in the pom** (all `reasoningEffort=low`, `charsPerToken=3`): + +| Preset | `contextSize` | `maxOutputTokens` | covers file up to | ~ time (CPU) | +|---|---|---|---|---| +| `gpt-oss-20B-c16k` | 16384 | 2048 | ~40 KB | ~1–2 min | +| `gpt-oss-20B-c48k` | 49152 | 4096 | ~125 KB | ~25 min @ 100 KB | +| **`gpt-oss-20B-c96k` (default)** | 98304 | 6144 | ~260 KB | ~80 min @ 250 KB | + +**`c96k` is the default.** The A/B above proves a wider window costs only RAM, not per-file time, so +the widest practical window is the safe universal choice: one preset covers *every* file up to ~250 KB +with no trimming and no truncation, while small files stay just as fast. Downshift to `c48k`/`c16k` +only to save RAM on memory-constrained machines. + +### Size-tiering: one model per execution, routed by file size (E3) + +If you want the *RAM economy* of small contexts on small files **and** the reach of a big context on the +few large ones, split the `generate` goal into several executions, each filtered to a size band by +`minFileSizeBytes` (exclusive lower) / `maxFileSizeBytes` (inclusive upper) and pointed at the matching +preset (and, if you like, its own prompt). The model loads **once per execution** — no per-file reload — +and the source-checksum skip means each file is indexed exactly once: a small file done by the c16k band +is skipped by the later bands. + +```xml + +idx-smallgenerate + 16384 + … aiDefinitionKey=gpt-oss-20B-c16k … +idx-mediumgenerate + 1638449152 + … gpt-oss-20B-c48k … +idx-largegenerate + 49152 + … gpt-oss-20B-c96k … +``` + +Two rules: (1) use **non-overlapping** bands (`band2.min == band1.max`) — the skip is by source checksum +only, so it can't tell which prompt produced an existing `.ai.md`, and an overlapping band would leave +the first writer's output in place; (2) make the **last band unbounded** (`maxFileSizeBytes=0`) so files +above every band still get indexed (otherwise they get no `.ai.md` and vanish from the package listing). +Defaults are `0`/`0` (no size filter), so a single-execution setup is unaffected. + +**Validated end-to-end** (synthetic Java fixtures from +[`tools/generate-fixture.sh`](tools/generate-fixture.sh); `mvn generate-resources`, CPU-only): + +| Run | file | `truncated` | stop | output | total | prefill | decode | +|---|---|---|---|---|---|---|---| +| `c48k` | 96 KB / 2470 ln | **0** | natural (`n_decoded=1198`) | complete to `#### Concurrency` | ~25 min | ~978 s (24 K tok @ ~25 t/s) | ~522 s (@ ~2.3 t/s) | +| `c96k` | 253 KB / 6441 ln | **0** | natural (`n_decoded=738`) | complete to `#### Concurrency` | **~80 min** | ~4053 s (61 K tok @ ~15 t/s) | ~754 s (@ **~1.0 t/s**) | + +Both ran with no trim, no retries, `BUILD SUCCESS`, and summaries that span the whole file (first +field → last `adjustBucketN` → tail methods). The 250 KB summary was compact (738 tokens) and faithful +but mis-counted the bucket methods ("260" vs 329) — large inputs invite small quantitative slips even +when the structure is right. + +**Cost reality:** the bottleneck on big files is **CPU prefill + large-context decode, not the effort +level** — at 96K context decode drops to **~1 t/s** (vs ~2.3 t/s at 48K, ~10 t/s for small files), +and prefill is effectively O(n²). The output budget is barely used (738–1198 tokens), so for large +files the knobs that matter are `contextSize` + `charsPerToken` (fit untrimmed); the budget just needs +headroom. + +### Per-file timing model (why throughput "shrinks", and the logged ETA) + +There is no constant tokens/second. Prefill **per-token** cost grows *linearly* with the prompt +length `n` (attention is O(n) per token), so total prefill is **O(n²)**. Fitting the three measured +runs gives, on the reference CPU (Ryzen 7 5800H, 8 threads, gpt-oss-20b UD-Q4_K_XL): + +``` +prefill_ms(n) ≈ 24.4·n + 0.000674·n² n = prompt tokens +decode_ms(n, out) ≈ out·(56.8 + 0.01568·n) out = generated tokens +tokens n ≈ source_chars / 4.8 + ~700 (template) # real-Java fit; see gpt-oss-tuning.md Phase 5 +``` + +The plugin's `AiGenerationTimeEstimator` ships these constants (4.8 / 700) plus a +15 % display margin. + +The model reproduces every measured point to within ~0.5 %: + +| prompt tokens `n` | measured prefill | model prefill | +|---|---|---| +| 3 309 (~10 KB) | 88.3 s | 88.1 s | +| 24 081 (~96 KB) | 978.0 s | 978.5 s | +| 61 484 (~253 KB) | 4053 s | 4049 s | + +This is exactly why throughput "shrinks" as the prefill grows: per-token cost rises with `n` +(26.7 → 40.6 → 65.9 ms/tok across the three runs), and decode slows the same way (9.1 → 2.3 → 1.0 t/s) +because each generated token attends over the whole context. + +**The plugin logs this estimate per file** before generating, e.g.: + +``` +[INFO] Processing file '.../Foo.java' (96 KB source, ~24009 tokens) — estimated ~25 min (rough; ...) +``` + +implemented in `AiGenerationTimeEstimator` (the constants above are its calibration defaults, kept +honest by a regression test that asserts they reproduce the three measured points). The numbers are a +**rough, hardware-specific** order-of-magnitude hint: a different CPU/threads/model — or a GPU — +shifts the coefficients; only the quadratic *shape* is universal. + +### Strategy for a repo with mixed file sizes + +The plugin routes the model per file by **extension, not by size** (`AiFieldGenerationSelector`), so +one run cannot auto-pick a preset per file size. Key fact: **`contextSize` costs KV RAM (one-time), +not per-small-file speed** — prefill and decode scale with each file's *actual* token count, not with +the allocated window, so a small file stays fast even in a large context; you only pay the RAM. + +This was confirmed by an A/B run: the **same 10 KB file**, gpt-oss, everything identical except +`contextSize` (16K → 96K): + +| `contextSize` | proj. RAM (KV+compute) | prefill | decode | wall | +|---|---|---|---|---| +| 16384 | 2050 MiB | 26.67 ms/tok | 9.10 t/s | 159 s | +| 32768 | 2450 MiB | 26.61 ms/tok | 9.16 t/s | 165 s | +| 49152 | 2850 MiB | 26.55 ms/tok | 9.33 t/s | 159 s | +| 98304 | 4050 MiB | 26.52 ms/tok | 9.20 t/s | 168 s | + +RAM rises ~linearly (**~+400 MiB per +16K**) while prefill/decode/wall stay flat — a wider window is +**RAM-only** for small files. (These are the window-driven KV+compute figures at small *actual* input; +when a wide window is genuinely filled — ~60 K tokens plus context checkpoints up to 8 GB — real usage +climbs to the ~23 GB seen in the 250 KB run, but the *window-size* component scales as above.) Two +workable approaches: + +1. **One preset, sized to your largest file (simplest).** If your biggest class fits ~125 KB and you + have the RAM, run `c48k` for everything — small files are unaffected in speed. +2. **Split into scoped runs (RAM-constrained, or rare monster files).** + - cheap run: `c16k` with `` skipping the known big files (or `` limited to the + normal packages); + - targeted run: `c48k`/`c96k` with `` limited to the big file(s). + The model reloads per run, but the large context is paid only where needed; checksum incrementality + makes re-runs cheap once a file is summarized. + +Size-based auto-routing (file bytes → preset) is **not currently a feature** — it would be the clean +fix if mixed-size repos become common. + +## 12. Caveats + +- Quality tiers (§4) are from a **representative file sample**, not a full read of all 368 + summaries; metrics (§1) cover every file. +- The `config`+`provider` scope is small and light on package-info/enum-heavy or + keyword-prone files, so §2.2 (keywords) and §2.5 (omission) are under-exercised here. +- `s/file` includes one-time model load amortized across 23 generations; absolute numbers are + hardware-specific (Ryzen 7 5800H, CPU-only, 8 threads). +- The full-project 30B baseline (`*__fullproject-c64k`) differs in scope and context (47 files, + 65536) and is reference-only. diff --git a/docs/ai-index-benchmark/README.md b/docs/ai-index-benchmark/README.md new file mode 100644 index 0000000..398aa29 --- /dev/null +++ b/docs/ai-index-benchmark/README.md @@ -0,0 +1,88 @@ +# AI Index Benchmark — model & prompt comparison + +This directory captures a controlled comparison of **local GGUF models** and **two prompt +versions** for the plugin's code-summarization task (`.ai.md` generation), run on CPU. + +- **[COMPARISON.md](COMPARISON.md)** — scored results, per-model pros/cons, source deep-dive, recommendation. +- **[outputs/](outputs/)** — the raw generated `.ai.md` trees, one directory per cell. + +## Bottom line + +- **Production default: `gpt-oss-20B-mxfp4`** (the native-MXFP4 swap of the benchmarked `c96k`/UD-Q4_K_XL + — same 96K window; E5 shows quant choice is within noise, so the native quant is the better-quality + pick). Most faithful per file (gpt-oss-20b won 5/6 in the per-file matrix), run at `reasoningEffort=low` + and a 96K window so it covers files up to ~250 KB untrimmed (§11). Slowest of the set; chosen because + per-file accuracy is the priority. +- **Throughput alternative (and best of the non-reasoning models for large files): + `Qwen3-Coder-30B-A3B-Instruct`** — most complete & faithful of the fast models, code-specialized, + Apache-2.0, ~71 s/file (~3.3B-active MoE, 262K ctx). +- **Fastest / best for very large or many files: `Granite-4.0-H-Tiny`** — ~4× faster on CPU + (flat-KV hybrid, ~1B active), Apache-2.0, accept slightly lower fidelity. +- **Cleanest permissive small coder: `Seed-Coder-8B-Instruct`** (MIT). +- **Why `gpt-oss-20b` is the default (precision):** the per-file *accuracy* leader (won 5/6 in the + per-file matrix), most faithful, no hallucinated `final`/examples. It is the slowest (~2× the 30B, + harmony reasoning overhead) — the accepted cost for accuracy. Run it with `reasoningEffort=low` and + one of the three size-tiered presets (`gpt-oss-20B-c16k/c48k/c96k`, **default c96k**); context-window + limits, large-file (250 KB) validation, and the O(n²) timing model are in + [COMPARISON.md §11](COMPARISON.md). +- **Avoid:** `Qwen3.5-4B` (thinking tax, no quality gain) and `DeepSeek-Coder-V2-Lite` (copied the + prompt's example as a summary). +- **Cross-model caveat:** all models mis-state structural facts (e.g. `final`, annotations, exact + member sets); only prose sections are reliably model-added → a hybrid AST+AI design is the + durable fix. Prompt **v2** helps verbosity but isn't shippable yet (code-fence regression on + code models). Full detail: [COMPARISON.md](COMPARISON.md). + +## What was tested + +- **8 models × 2 prompts = 16 cells**, plus 1 full-project baseline (17 output trees). +- **Subtree scope:** `config` + `provider` packages (12 source files → 23 `.ai.md` each: + 12 file summaries + 10 package roll-ups + 1 project index). `package-info.java` / + `module-info.java` excluded. +- **Context:** all experiment cells run at **16384** (CPU-feasible; native windows up to 262144 + are not). The baseline used 65536. +- **Hardware:** AMD Ryzen 7 5800H, 8 threads, CPU-only, via `net.ladenthin:llama` (llama.cpp JNI). + +### Models (all Q4_K_M @ 16K ctx) + +| Cell key | Model | Active params | Sampling | +|---|---|---|---| +| qwen35-4b | Qwen3.5-4B | 4B dense | t0.7 p0.8 k20 rep1.05 | +| qwen25coder-7b | Qwen2.5-Coder-7B | 7B dense | t0.7 p0.8 k20 rep1.05 | +| gptoss-20b | gpt-oss-20b | ~3.6B (MoE) | t1.0 p1.0 k0 | +| qwen3coder-30b | Qwen3-Coder-30B-A3B | ~3.3B (MoE) | t0.7 p0.8 k20 rep1.05 | +| deepseek-coder-v2-lite | DeepSeek-Coder-V2-Lite | 2.4B (MoE) | t0.3 p0.9 k40 rep1.05 | +| seed-coder-8b | Seed-Coder-8B-Instruct | 8B dense | t0.3 p0.9 k40 rep1.05 | +| granite4-h-tiny | Granite-4.0-H-Tiny | ~1B (MoE-hybrid) | t0.0 (greedy) | +| qwen3-4b-2507 | Qwen3-4B-Instruct-2507 | 4B dense | t0.7 p0.8 k20 rep1.05 | + +### Prompts + +- **v1** — the production prompts (`file-body-java`, `package-body`). +- **v2** — experimental (`file-body-java-v2`, `package-body-v2`): adds a trivial-file + omission rule, JavaBean accessor grouping, an explicit "no invented keywords" ban, + single-child package pass-through, and a tighter brevity instruction. + +### Baseline + +`outputs/ai__qwen3coder-30b__v1__fullproject-c64k/` is the earlier **full-project** run +(47 files, 65536 ctx, v1). Different scope/context — **not** directly comparable to the 16K +config+provider cells; kept for reference. + +## Reproduce + +The self-test profile is parameterized. Each cell was produced by: + +```bash +mvn prepare-package -P ai-index-selftest -DskipTests \ + -Dexp.model= \ + -Dexp.filePrompt= \ + -Dexp.pkgPrompt= \ + -Dai.index.output.directory= +``` + +`EXP-*` model definitions, the v2 prompt templates, the `config`+`provider` subtree scope, and +the `package-info`/`module-info` excludes all live in the `ai-index-selftest` profile in +`pom.xml` (marked `claude2026_06_26_00`). The model files are catalogued in `X:\Modelle\index.md`. + +> These are temporary experiment scaffolds on the `claude2026_06_26_00` branch, not production +> configuration. diff --git a/docs/ai-index-benchmark/gpt-oss-tuning.md b/docs/ai-index-benchmark/gpt-oss-tuning.md new file mode 100644 index 0000000..ebb7910 --- /dev/null +++ b/docs/ai-index-benchmark/gpt-oss-tuning.md @@ -0,0 +1,485 @@ +# gpt-oss-20b tuning — unattended findings + +Autonomous tuning session for the `gpt-oss-20b` default of this plugin. Goal: turn the open +questions from [COMPARISON.md §11](COMPARISON.md) into **objectively measured** answers, run +unattended, and document everything here. + +- **Model:** `gpt-oss-20b-UD-Q4_K_XL.gguf` via llama.cpp JNI, CPU-only (AMD Ryzen 7 5800H, 8 threads). +- **Git baseline before the session:** `f14819b` (branch `claude2026_06_26_00`). +- **Date:** 2026-06-27. + +## Summary (TL;DR) + +| Phase | Question | Answer | +|---|---|---| +| 1 | Is higher `reasoning_effort` more accurate at adequate budget? | **No** — low/medium/high are equally accurate when not truncated; higher effort just decodes 4–8× more reasoning tokens (2–3× slower). `low` confirmed as default. | +| 2 | Lower temperature for extraction? | **Partly** — temp 0.0/0.3 were exact in my runs, BUT a web review found greedy/temp 0 triggers repetition "blackholes" in 81 % of gpt-oss prompts. Resolved to **temp 0.7 + min-p 0.05**. → **D1 (revised)** | +| 3 | Can a prompt fix the large-file miscount? | **Yes** — a "count exactly" prompt turned a wrong "150" into the exact "195" at no cost. → **D3** | +| 4 | Does the timing model hold? | **Yes** — `prefill ≈ 24.4·n + 0.000674·n²` within +1.1…+2.6 % over 25–150 KB (already the correct linear+quadratic SWA-aware shape). Count accuracy degrades with scale (exact ≤128 methods, off at 195). | +| 5 | Real-Java chars/token? | **~4.8** (not the fixture's 4.2); template ~713 tokens. → **D2** | + +**Net:** the shipped model defaults (gpt-oss, `reasoningEffort=low`, c96k) are validated. After a +two-round external web fact-check, three improvements were **implemented**: **D1** sampling → +temp 0.7 + min-p 0.05 (NOT temp 0 — greedy is unsafe for gpt-oss), **D2** estimator constants +4.8 / 700 + 15 % margin, **D3** count-exact prompt. D1 + D3 directly fix the structural-count +weakness that affects every model in the original benchmark. See *Decisions* below for the full +rationale and what was deferred. + +## Method — objective scoring via ground-truth fixtures + +The benchmark cells run the real `generate` goal on a **synthetic Java fixture of known structure** +(`docs/ai-index-benchmark/tools/generate-fixture.sh`: a ledger class with a known number of +`adjustBucketN` methods, 40 weight fields, and 6 tail methods). A scorer parses the produced +`.ai.md` plus the llama.cpp run log into objective metrics ([`tools/score.sh`](tools/score.sh)), so +"quality" becomes numbers a script can compare: + +| Metric | Meaning | +|---|---| +| `sections` | how many of the 9 expected `####` sections are present (Purpose…Concurrency) | +| `reachConc` | did the body reach the last section (`Concurrency`)? = not truncated mid-output | +| `claimBucket` | highest `adjustBucketN` the summary enumerates (vs the fixture's true N) | +| `countErr` | abs error of the claimed method count vs ground truth | +| `truncated` | llama.cpp input-trim flag (should be 0 = whole file fit) | +| `promptTok / prefillMs` | prefill size and time | +| `decodeTok / decodeMs` | generated tokens and decode time | +| `wall_s` | end-to-end seconds for the cell | + +Harness: a matrix-driven runner (idempotent, resumable, heartbeat) writes one TSV row per cell. The +`gpt-oss-bench` pom definition is fully parameterized (`-Dexp.ctx/out/temp/topp/topk/effort/filePrompt`) +so a run sweeps a dimension without touching the pom. (This benchmark wiring is temporary scaffolding, +reverted after the session; the production default stays `gpt-oss-20B-c96k`.) + +**Honest limitation:** synthetic fixtures are repetitive, so `sections`/`countErr`/timing are clean +signals but "reads well for an agent" is only partially captured. A few real files are used as a +reality check where noted. + +## Phase 1 — `reasoning_effort` × output budget (at adequate budget) + +**Question this settles:** we defaulted to `reasoningEffort=low` because `high` *truncated* at a fixed +1536-token budget. But is `high` actually *more accurate* when given enough budget, or just slower? + +**Setup:** 24 KB fixture (ground truth: **26** `adjustBucketN` methods), ctx 32768, temp 1.0, 2 reps +per cell. Prefill was constant (~208 s, 7245 prompt tokens) across all cells — the only variable is +decode (reasoning + answer). + +| effort | budget | wall (s) | decode tok | sections | reached `Concurrency` | count error | +|---|---|---|---|---|---|---| +| low | 2048 | 321 / 329 | 519 / 571 | 9 / 9 | yes / yes | 0 / 0 | +| low | 8192 | 315 / 340 | 533 / 611 | 9 / 9 | yes / yes | 0 / 0 | +| medium | 2048 | 514 / 540 | 1501 / **2048*** | 9 / **5*** | yes / **no*** | 0 / **25*** | +| medium | 8192 | 417 / 518 | 1266 / 1729 | 9 / 9 | yes / yes | 0 / 0 | +| high | 1536 | 1342 / 1400 | **1536 / 1536*** | **0 / 0*** | **no / no*** | — | +| high | 8192 | 762 / 1153 | 2806 / 4506 | 9 / 9 | yes / yes | 0 / 0 | + +`*` = output truncated because decode hit the token budget before the answer finished. + +**Findings** + +1. **At an adequate budget, all three efforts produce complete, equally accurate summaries** — 9/9 + sections and **count error 0** (correctly reported 26 methods). Higher effort bought **no** quality + on this extraction task. +2. **Higher effort only costs time.** Prefill is identical; high decodes **4–8× more tokens** (pure + reasoning) for the same result → **2–3× slower** (≈13–19 min vs ≈5.5 min for low). +3. **Truncation is a decode-budget function of effort, not a model defect.** `low` fits comfortably in + 2048; `medium` needs ≥ ~2500; `high` needs ≥ ~5000 to not cut off. At a fixed small budget, higher + effort truncates *first* (it spends the budget on reasoning). + +**Conclusion:** `reasoningEffort=low` is confirmed as the default — same accuracy and completeness as +medium/high, fastest, and the lowest truncation risk. This validates the shipped default. + +_(Scorer note: 2 complete cells show `claimBucket=NA` — the model described the method family in prose +without enumerating `adjustBucketN`, which the regex misses; both still reached `Concurrency` with full +sections, so they are complete, not failures.)_ + +## Phase 2 — temperature sweep + +**Question:** gpt-oss's card recommends temp 1.0, but for *extraction* (not creative writing) does a +lower temperature reduce miscounts / hallucination? + +**Setup:** 24 KB fixture (26 methods), low effort, budget 4096, top-p 1.0 / top-k 0, 2 reps per temp. +All cells completed (9/9 sections, no truncation); the variable is faithfulness + reproducibility. + +| temp | count error (r1 / r2) | reproducible? | wall (s) | +|---|---|---|---| +| 0.0 | **0 / 0** | **yes — both reps bit-identical** (502 dec tok, 2201 B) | 321 / 321 | +| 0.3 | **0 / 0** | near-identical | 327 / 322 | +| 0.7 | 0 / **25** | no | 329 / 299 | +| 1.0 (card default) | **14** / n.a.* | no | 301 / 314 | + +`*` = at temp 1.0 r1 the model reported **40** methods (true: 26); r2 phrased the count in prose +(scorer couldn't extract — not necessarily wrong). + +**Findings** + +1. **Lower temperature is more faithful for extraction.** temp 0.0 and 0.3 hit the exact count every + time; 0.7 and 1.0 produced wrong counts (1, 40) in some reps. Higher sampling variance → more + numeric/structural slips, with **no speed benefit** (decode time ~equal). +2. **temp 0.0 is deterministic** — identical `.ai.md` across reps. This matters for the plugin's + checksum-based incremental model: re-indexing an unchanged file yields the *same* output, so there + is no diff churn. + +**Conclusion:** for code indexing, **temp 0.0 (or 0.3)** beats the card's 1.0 — same speed, more +faithful, reproducible. *Small sample (2 reps); the direction is consistent and theory-backed, but +worth more reps before locking in.* → **candidate default change (deferred to user).** + +## Phase 3 — prompt variants for gpt-oss + +**Question:** can a gpt-oss-tuned prompt (explicit "state exact counts; recount before finalizing") +cut the structural-count error we observed ("260 vs 329 methods")? + +**Setup:** the case where the base prompt *fails* — 150 KB fixture (195 methods), temp 0 (deterministic), +low effort. Base prompt (`file-body-java`) vs a count-focused variant (`file-body-java-count`) that adds +two instructions: in *Public API*, "give the EXACT total count and index range for a member family", and +a *Rule* "COUNT EXACTLY … recount … never approximate or write 'similar'". + +| prompt | what it wrote | true | count error | wall | sections | +|---|---|---|---|---|---| +| `file-body-java` (base) | "150 bucket methods (1–150)" | 195 | **45** | 2239 s | 9/9 | +| `file-body-java-count` | "adjustBucket1..adjustBucket195 (**195 total**)" | 195 | **0** | 2254 s | 9/9 | + +**Findings** + +1. **The count-focused prompt eliminates the large-file miscount.** The base prompt rounded to a wrong + "150"; the variant reported the exact 195 — at the **same speed and completeness**. So the miscount is + not a hard model limit; an explicit "count exactly / give the range" instruction fixes it. +2. Combined with Phase 2 (temp) and Phase 4 (scale), the structural-count error has **two cheap + mitigations** — low temperature and an exact-count prompt — that together should keep counts correct + well beyond where the stock setup fails. → **candidate prompt improvement D3.** + +## Phase 4 — timing model + context ceiling refinement + +**Question:** harden the `prefill_ms(n) ≈ 24.4·n + 0.000674·n²` fit with more file-size points and find +the real practical/​hard ceiling empirically. + +**Setup:** fixtures 25/50/100/150 KB, low effort, temp 0.0 (deterministic), context sized to fit. + +| file | prompt tok `n` | measured prefill | model prefill | error | +|---|---|---|---|---| +| 25 KB | 7 424 | 213 s | 218 s | +2.6 % | +| 50 KB | 13 510 | 448 s | 453 s | +1.1 % | +| 100 KB | 25 503 | 1 035 s | 1 061 s | +2.5 % | +| 150 KB | 37 496 | 1 818 s | 1 863 s | +2.4 % | + +**Findings** + +1. **The quadratic model holds across 25–150 KB** — every new point is within **+1.1 % to +2.6 %**, and + the model consistently over-predicts by ~2 %. That bias is the *safe* direction for an ETA (it never + under-promises), so the shipped constants are kept as-is. +2. **Count accuracy degrades with scale even at temp 0.** Exact (count error 0) up to **128 methods** + (100 KB), but at **195 methods (150 KB) the model reported "150" — off by 45 (−23 %)**. So the + earlier "260 vs 329" miscount is *both* a temperature effect (Phase 2) *and* a scale effect: beyond + ~130–200 members the model stops counting and estimates. This gives Phase 3 a concrete target. +3. **Hard-ceiling probe deferred:** a ~450 KB file (~110 K tokens) would prefill for ~3 h on this CPU + (quadratic), so the 128 K-window ceiling (~480–500 KB) is left as the analytical bound from §11 + rather than burned in unattended. 250 KB is the validated practical limit. + +## Phase 5 — `charsPerToken` on real files + +**Question:** the estimator assumes ~4.2 chars/token (from the synthetic fixture); what is it on real +repo Java? + +**Setup:** 7 real source files (966 B … 29 KB) each indexed in its **own** process (so `cache_prompt` +can't undercount), recording bytes vs the llama.cpp full prompt-eval token count, then a linear fit +`promptTok = template + bytes / charsPerToken`. + +| file | bytes | prompt tok | +|---|---|---| +| AiTimeSupport | 966 | 858 | +| AiCompletionParser | 3 715 | 1 480 | +| AiMdHeaderCodec | 8 637 | 2 598 | +| AiModelDefinition | 12 921 | 3 476 | +| AiGenerationConfig | 15 843 | 4 145 | +| GenerateMojo | 6 510 | 1 929 | +| PackageIndexer | 29 086 | 6 664 | + +Fit: **`promptTok ≈ 713 + bytes / 4.81`** → real Java is **~4.8 chars/token**, template ≈ **713 tokens**. + +**Findings** + +1. **Real Java tokenizes at ~4.8 chars/token, not the 4.2 of the synthetic fixture** (real code has + more long identifiers/keywords per token). Template overhead is ~713 tokens, not 400. +2. The estimator's current `ESTIMATION_CHARS_PER_TOKEN=4.2` therefore **over-counts tokens** for real + Java → **over-estimates time** (the safe direction, but loose by ~12 %). → **candidate refinement D2.** +3. **Methodology caveat (important):** with `cache_prompt` on, a multi-file run undercounts per-file + prompt-eval tokens (the shared prefix is reused and not re-counted) — the first Phase 5 attempt + produced non-monotonic data (a 6.5 KB file showing fewer tokens than a 3.7 KB one). Measuring + chars/token requires one file per process (or `cache_prompt=false`). + +## Decisions — resolved after two rounds of web verification, then implemented + +Each candidate change was put through a two-round external web fact-check (findings verification, then +an adversarial challenge of the proposed changes). **The most important correction came from there, not +from my runs:** my Phase 2 favoured temperature 0.0, but the web review found that **greedy/temp 0 is +unsafe for gpt-oss** — a probing study reports greedy falls into "reasoning blackhole" repetition loops +in **81 % (162/200)** of prompts, and the official repo recommends temp 1.0/top-p 1.0. So D1 was +*revised*, not applied as I first proposed. + +- **D1 — sampling. IMPLEMENTED (revised).** Not temp 0. The three gpt-oss presets now use + **temperature 0.7, top-p 1.0, top-k 0, min-p 0.05, repeat-penalty 1.0** — the faithful-but-safe middle + ground (0.7 < the card's 1.0 to cut wording/count variance, well clear of the greedy blackhole zone; + min-p 0.05 as the primary, confidence-scaled truncation). This required **adding `min_p` support** to + the config chain (the plugin previously could not set it, so it would inherit the server's 0.1 + default). The bit-reproducibility goal was dropped (only achievable at unsafe temp 0); low *variance* + is pursued via the strict output schema + the D3 count rule instead. +- **D2 — ETA estimator constants. IMPLEMENTED.** `ESTIMATION_CHARS_PER_TOKEN` 4.2→**4.8** and + `PROMPT_TEMPLATE_TOKEN_OVERHEAD` 400→**700** (real-Java regression), plus an explicit **+15 % display + margin** (`ETA_SAFETY_MARGIN`) since 4.8 removes the accidental conservatism 4.2 provided. The + `24.4·n + 0.000674·n²` timing model is kept — the web review confirmed it is *already* the correct + linear-plus-quadratic (SWA-aware) shape, not a pure quadratic. +- **D3 — count-exact prompt. IMPLEMENTED.** Added to the production `file-body-java` prompt: a *Public + API* rule to **enumerate a near-identical member family in the analysis channel and emit only the + exact total + range in the final answer**, plus a global **COUNT EXACTLY** rule. (Phase 3: this turned + a wrong "150" into the exact "195" at no cost.) + +### Deferred (not implemented this session) +- **Reasoning/think budget** (`withReasoningBudgetTokens` exists in the binding): a useful backstop to + stop a runaway analysis channel crowding out the answer, but both reviews flag it as version-specific + with a known upstream bug — defer until pinned to a tested llama.cpp build. +- **Conditional `reasoning_effort=medium` for large-family files:** the count literature says counting + is the one sub-task where reasoning helps, but the plugin has no per-file-size routing (routing is by + extension only) — would need a new feature. +- **`--swa-full` / llama.cpp build-pin / DRY fallback:** operational, not plugin-level; documented as + recommendations only. + +### Must re-test before fully trusting D1 (from the web review) +1. **Loop/blackhole safety** of temp 0.7 + min-p 0.05 across a large, varied file set (≥200 files) — + target zero repetition blackholes and zero reasoning-overrun truncations. +2. **Count faithfulness** of the revised D3 rule across known large-family counts (26/128/195) at low + and medium effort, checking the enumeration does not leak into the final output. +3. **ETA accuracy + under-promise rate** with 4.8/700/+15 % on a fresh real-file set spanning 25–150 KB. + +## Round 3 — adversarial optimality review + on-machine re-test + +After D1/D2/D3 were implemented, a third external web review **challenged the optimality** of the +shipped config (not just the findings), and the three "must re-test" items above were run on the machine. + +**Web review verdict:** the shipped config (temp 0.7 + min-p 0.05, top-p 1.0, top-k 0, repeat-penalty +off; `reasoning_effort=low`; D3 prompt; c96k default; estimator 4.8/700/+15 %) is **sound and safe but +not provably optimal**. Highlights: +- temp 1.0/top-p 1.0 is OpenAI's *only* official rec; temp 0.7 + min-p 0.05 is a defensible community + deviation for faithful extraction (min-p 0.05–0.1 is the paper's recommended *primary* truncation, + and top-p 1.0 disables nucleus so there is no double-truncation). top-k 0 is *unconfirmed* community + guidance (fine to keep; ~1–2 % speed effect). +- greedy/temp 0 is unsafe (81 % loop rate); temp 0.7 *reduces* it but that 81 % is greedy-only — no + measured curve at 0.3–0.7. +- `reasoning_effort=low` confirmed; a **think/reasoning budget** is a recommended safety rail we omit. +- D3 "enumerate in analysis, total in final" is sound — llama.cpp parses the analysis channel out of + the returned answer (`reasoning_format` deepseek/auto with `--jinja`). +- the `24.4·n + 0.000674·n²` timing model is correctly **linear+quadratic (SWA-aware)**; ~4.8 chars/token + is reasonable for o200k_harmony. +- **Correction to my premise:** "quant fever" ≠ quantization (it is *numerical-target fixation*); + UD-Q4_K_XL is low-risk and gpt-oss is natively MXFP4. + +**On-machine re-test (shipped config; 16 real files ×2 reps + 5 ground-truth fixtures):** + +| Test | Result | +|---|---| +| **T1 blackhole/safety** | **PASS** — all 21 cells complete (9/9 sections), 0 truncations, 0 loops (duplicate-line ratio ≥40 % in zero cells; only the 0.5 KB enum showed 6–10 %, harmless). temp 0.7 + min-p 0.05 produced no blackholes (small sample). | +| **T2 count faithfulness** | **PASS** — exact count (error 0) at 26, 128, **and 195** methods, at **low AND medium** effort, all complete. The 195 case (previously "150") is robustly fixed by D3. | +| **T3 ETA accuracy** | **PARTIAL / conservative** — predicted vs actual on 8 real files: within ±15 % in 4/8, under-promised (actual > ETA) in only 1/8. The estimator **over-predicts small files** (the fixed ~800-token decode assumption dominates a tiny prefill) → it errs on the safe side; ±15 % precision is not consistently met, consistent with its "rough, hardware-specific" label. | + +**DRY check (read-only, as requested):** DRY exists in the `net.ladenthin:llama` binding **only at the +model/launch level** (`ModelParameters.setDry*` → `--dry-*`), not per-request (`InferenceParameters` +has no `withDry`). The plugin builds a `ModelParameters`, so DRY could be enabled there with no binding +change; for per-request control (uniform with min-p etc.) a `withDry*` addition to java-llama.cpp's +`InferenceParameters` was specified for a separate implementing agent. + +### Optional enhancements from the optimality review (E1–E6, deferred) +- **E1 — DRY loop-insurance.** Feasible at model level now; per-request pending the binding addition. + Belt-and-suspenders only (T1 already shows 0 loops). +- **E2 — reasoning/think budget** (`withReasoningBudgetTokens`). Recommended safety rail; upstream-buggy + / version-specific → pin a llama.cpp build first. +- **E3 — size context to file** (vs the c96k default). RAM-only saving (per-file time is flat per the + A/B); needs a smaller default or a size-routing feature. +- **E4 — `--swa-full`** for multi-file batches with a shared prefix (enables prefix-cache reuse). Ops flag. +- **E5 — native MXFP4 model file.** Cleanest faithfulness story; saves ~nothing over UD-Q4_K_XL. +- **E6 — top-n-sigma vs min-p** (`withTopNSigma`, temperature-invariant). A separate A/B measurement. + +**Bottom line:** the shipped D1/D2/D3 config is **verified safe and faithful on-machine** and judged +sound by an adversarial external review. No further default change is required; E1–E6 are optional +enhancements held for sign-off. + +## E-series enhancement experiments (CPU) + +The binding gained per-request `top_n_sigma`, `dry*`, `reasoning_budget`, and model-level `--swa-full` +(snapshot `5.0.3-20260628.125715-10`). Each enhancement is plumbed into the plugin behind a +default-off switch (production config unchanged) and measured. + +### E6 — top-n-sigma vs min-p — measured: **keep min-p** + +**Setup:** shipped config except sampling: **arm A = min-p 0.05** (top-n-sigma off), **arm B = +top-n-sigma 1.0** (min-p off); temp 0.7, low effort, ground-truth fixtures 26/128/195 methods. + +| file | arm A (min-p 0.05) | arm B (top-n-sigma 1.0) | +|---|---|---| +| 24 KB / 26 ×2 | count 0 err, complete | count 0 err, complete | +| 100 KB / 128 | count 0 err, complete | count 0 err, complete | +| **150 KB / 195** | **count 0 err, complete** | **INCOMPLETE — lead only, 0/9 sections** (early stop after the blockquote; no loop, no trim) | + +**Finding:** top-n-sigma ties min-p on small/medium files but **failed the hardest case** — on the +195-method file it emitted only the one-line lead and stopped, where min-p produced the full, exact +summary. So top-n-sigma is *not* a safe drop-in here; it offers no accuracy gain and is riskier on +large files. **Decision: keep `min_p 0.05` as the default; do not adopt top-n-sigma.** (Single rep on +the 195 cell — could be sampling variance, but min-p is already perfect, so there is no incentive to +switch.) The `top_n_sigma` plumbing stays in (default off) for future use. + +### E4 — swa-full + cache-reuse (batch prefix reuse) — measured: **helps batch runs** + +**Setup:** a 6-file batch sharing the system+developer prompt prefix, indexed in one model session. +**Arm A = default SWA** (`swaFull=false`, `cacheReuse=0`) vs **arm B = `swaFull=true` + `cacheReuse=256`**; +gpt-oss, temp 0.7, min-p 0.05, low effort. Per-file prefill (tokens / ms) from the llama.cpp log: + +| file (order) | A tokens | A prefill | B tokens | B prefill | +|---|---|---|---|---| +| 1 | 1585 | 44 s | 1585 | 40 s | +| 2 | 5231 | 149 s | 4498 | 120 s | +| 3 | 852 | 23 s | **118** | **3 s** | +| 4 | 1926 | 51 s | 1926 | 49 s | +| 5 | 628 | 17 s | **230** | **6 s** | +| 6 | 1302 | 35 s | 1302 | 32 s | +| **total prefill** | **11 524 tok / 319 s** | | **9 659 tok / 251 s (−21 %)** | +| **wall (6 files)** | **710 s** | | **624 s (−12 %)** | + +**Finding:** `--swa-full` + `--cache-reuse` **cut batch prefill ~21 % and wall time ~12 %** by reusing +the shared prompt prefix across files (large savings on files 3 and 5; little on others — reuse fires +inconsistently, likely slot/cache eviction within the run). This is a real throughput win for the +plugin's normal mode (indexing a whole project, many files sharing one prompt). Cost: ~2× SWA-layer KV +RAM, and no benefit for single-file runs. **Decision (signed off 2026-06-28): adopted as the shipped +default** — `DEFAULT_SWA_FULL=true` + `DEFAULT_CACHE_REUSE=256` — because the plugin's primary use is +overnight full-project indexing on a machine with RAM to spare, where the ~12% wall-time win matters and +the extra KV RAM is acceptable. Set `false` (and/or `0`) for +RAM-constrained single-file use. Worth a follow-up to make the reuse fire on every file (investigate the +eviction). + +### E2 — reasoning/think budget as a safety rail — measured: **no-op for gpt-oss (negative result)** + +**Hypothesis:** at high effort the in-band reasoning (harmony `analysis` channel) overruns the output +budget and starves the answer; capping it with `withReasoningBudgetTokens` should let the final answer +complete. **Setup:** one 27 KB fixture (26 methods), gpt-oss, temp 0.7, min-p 0.05, **high effort**, +`maxOutputTokens=2048`. **Arm A** = `reasoningBudgetTokens=-1` (unrestricted) vs **arm B** = +`reasoningBudgetTokens=1024`. + +| arm | budget | wall | sections | decode tokens | generations (incl. retries) | +|---|---|---|---|---|---| +| A | −1 (off) | 1602 s | **0 / 9** | 2036 | 4 | +| B | **1024** | 1663 s | **0 / 9** | 2040 | 4 | + +**Finding:** **the budget had no measurable effect.** Arm B ran straight into the same 2048 output cap +as arm A (decode ≈ 2040 both), produced an empty body both times, and the result was identical +(0 / 9 sections). `withReasoningBudgetTokens` is plumbed through to the binding, but it **does not +constrain gpt-oss harmony reasoning in the current binding / llama.cpp build** — the `analysis` channel +is not truncated at the budget. So the budget cannot be relied on as a safety rail for gpt-oss today. + +**Consequences:** +1. **High effort stays unusable for large files** (D-series already ships **low effort** as the default); + the budget knob does not rescue it. +2. The knob remains a plumbed **opt-in** (`reasoningBudgetTokens`, default −1) for future binding/model + support — harmless when off, ready if a later llama.cpp build honours it for harmony. +3. Both arms wasted **4 full generations (~27 min each)** producing nothing — the blank body triggered + the old retry loop (initial + 3 retries), all blank. This made the **retry mechanism's + cost-without-benefit obvious and motivated removing it entirely** (see the retry-removal change): a + blank body now fails fast with a single `WARN` instead of re-inferring 3× to the same empty result. + +**Build 11 re-test (Ninja native, CUDA, mxfp4) — the empty-body blackhole no longer reproduces; budget +still unproven.** Re-ran both arms on the newer `net.ladenthin:llama` build 11 native via CUDA (auto-fit +GPU): a ~27 KB / many-method fixture (`AiGenerationConfig.java`), gpt-oss-20b mxfp4, temp 0.7, **high +effort**, `maxOutputTokens=2048`, `contextSize=16384`. + +| arm | budget | prefill | decode tokens | decode t/s | body | +|---|---|---|---|---|---| +| A | −1 (off) | 6471 tok @ 446 t/s | **1604** (stopped < 2048 cap) | 20.4 | **non-empty**, 2615 chars, ~12 `#` headings | +| B | **1024** | 6471 tok @ 462 t/s | 1350 | 20.6 | non-empty, 2055 chars, 0 `#` headings | + +Two changes vs the original CPU run: (1) **high effort now completes a substantive answer** — neither arm +is blank and arm A stops naturally at 1604 tokens *below* the 2048 cap, so the original "reasoning +blackhole → 0/9 empty body, decode pinned at the cap" does **not** reproduce on build 11. (2) The +**reasoning budget is still not a demonstrable safety rail**: arm B decoded somewhat fewer tokens +(1350 vs 1604) but there is no clean truncation at 1024, and the structure difference (0 vs 12 headings) +is content variance at temp 0.7 from a single sample, not a budget effect. Conclusion unchanged: +`reasoningBudgetTokens` stays **opt-in, default −1**; low effort stays the shipped default (faster and +adequate). The only material update is that high effort is no longer outright broken for larger files on +build 11. + +### Retry mechanism removed (follow-up from E2) + +The empty-body retry loop (initial generation + up to `maxRetries` re-inferences at an escalating +temperature) was an early band-aid for EOS-early empty responses. With the shipped config (non-greedy +temp 0.7, system/user prompt split, adequate output budget) empty bodies no longer occur in normal +operation, and E2 showed that when they *do* occur (reasoning overrun) the retry is deterministically +counterproductive — it re-infers to the same empty result, wasting ~27 min for nothing. The whole +mechanism (loop, `maxRetries`, `retryTemperatureIncrement`, the `generate(request, temperatureOverride)` +provider overload) was removed; a blank body now fails fast with one `WARN`. There is no replacement +knob: fail-fast is unconditional. + +### E1 — DRY repetition suppression — plumbed as an opt-in safety knob (default off) + +**What it is:** DRY (Don't Repeat Yourself) penalises verbatim n-gram repetition during sampling, which +is the standard mitigation for runaway repetition loops (the degenerate "stuck repeating the same line" +failure mode). The binding exposes it per-request (`withDryMultiplier/Base/AllowedLength/PenaltyLastN/ +SequenceBreakers`), so unlike E2's reasoning budget it is **actually wired through to llama.cpp's +sampler**, not a no-op. + +**Decision — plumbed, default off, no measurement run.** The shipped gpt-oss config (low effort, +temp 0.7, min-p 0.05) does **not** exhibit repetition loops in any of the Phase 1–5 / E-series runs, so +there is no loop for DRY to fix on the default path; a with/without-DRY A/B would only confirm the +obvious on a contrived loop-prone config (e.g. greedy / temp 0, which we deliberately do not ship — +see D1 and the "reasoning blackhole" note). Rather than burn model time demonstrating that, DRY is +shipped as five **opt-in, per-request knobs that are completely neutral by default** +(`dryMultiplier=0.0` disables the sampler; `dryBase=1.75`, `dryAllowedLength=2`, `dryPenaltyLastN=-1`, +`drySequenceBreakers=∅` mirror the llama.cpp defaults). This matches the project rule of keeping every +sampling feature available for other models/users while never changing the shipped default behaviour. +**When to enable:** a different model or a high-temperature/creative config that starts looping — +set `dryMultiplier` to ~0.8 and tune from there. + +### E5 — quantization / "floating point vs 4-bit" — measured: **quant choice barely matters; F16 is the worst** + +**Question (user):** is a higher-precision (floating-point) gpt-oss build worth it over the shipped 4-bit? +**Key fact:** gpt-oss-20b ships *natively* in MXFP4 (4-bit microscaling float) for the MoE experts — a +"higher-precision" GGUF only upcasts the small non-expert tensors, so the F16 build is just 12.85 GB (not +~42 GB). **Setup:** the same 30 KB / 30-method fixture through all six local GGUFs at identical settings +(low effort, temp 0.7, min-p 0.05, ctx 32768, `maxOutputTokens=2048`), one model load per run, CPU. + +| GGUF | file | prefill t/s | decode t/s | sections | gens | +|---|---|---|---|---|---| +| `mxfp4` (native 4-bit) | 11.3 GB | 36.1 | 5.85 | **9/9** | 1 | +| `UD-Q4_K_XL` (shipped default) | 11.1 GB | 35.1 | 6.30 | **9/9** | 1 | +| `Q4_K_M` | 10.8 GB | 36.6 | **6.59** | **9/9** | 1 | +| `Q5_K_M` | 10.9 GB | 32.1 | 5.96 | **9/9** | 1 | +| `Q8_0` | 11.3 GB | 36.3 | 6.24 | **9/9** | 1 | +| `F16` (floating point) | 12.85 GB | 39.1 | **5.40** | **9/9** | 1 | + +**Findings:** +1. **Quality is quant-independent.** Every build produced a complete 9/9-section summary (and no retries, + `gens=1`). Going above 4-bit (Q8_0, F16) buys **nothing** in quality — exactly what the native-MXFP4 + property predicts. +2. **Speed is within run-to-run noise.** Decode spans 5.40–6.59 t/s (~18 %). No build is meaningfully + faster; the K-quants (`Q4_K_M`, `UD-Q4_K_XL`) edge out the rest, and **native `mxfp4` is not faster** + than them on this CPU. +3. **F16 is the worst choice:** the largest file (most RAM), the slowest decode, and zero quality gain — + the "floating point instead of 4-bit" idea is empirically not worth it. +4. **Decision: keep `UD-Q4_K_XL` as the default.** `Q4_K_M` is a hair faster + smaller, but the gap is + inside the noise, so it is not worth changing the shipped default. Avoid Q8_0/F16. + +*Caveat:* single fixture, single run per build, so the ~18 % decode spread is within plausible variance; +the robust conclusion is the ranking-free one — *quant precision changes neither quality nor speed +materially for this workload, and bigger-than-4-bit only costs RAM.* Run on the pre-session installed +plugin build (sampling is POM-driven and no retries fired, so the quant comparison is unaffected). + +--- + +## Opt-in sampling & cache knobs (reference for other models/users) + +Every experiment above left its feature **plumbed and default-neutral**, so the shipped gpt-oss behaviour +is unchanged but the knob is one POM line away for a different model or workload. All are settable on an +`` (per-model) and flow through `AiGenerationConfig`. + +| Knob (`` element) | Default (neutral) | What it does | Enable when… | Evidence | +|---|---|---|---|---| +| `minP` | `0.05` (shipped) / `0.0` (lib default) | Confidence-scaled primary truncation; robust on large files | Primary sampler — already on for gpt-oss | Phase 1–5, E6 | +| `topNSigma` | `-1.0` (off) | Temperature-invariant truncation, alternative to min-p | A model where top-n-sigma beats min-p | E6 (min-p won here) | +| `swaFull` | **`true` (on, shipped)** | Keep full SWA KV so the shared prompt prefix is reusable across files | On by default for batch/project indexing; set `false` for RAM-constrained single-file use | E4 (−12 % wall) | +| `cacheReuse` | **`256` (on, shipped)** | Cross-request KV prefix reuse min chunk (tokens) | On by default (pairs with `swaFull`); set `0` to disable | E4 | +| `reasoningBudgetTokens` | `-1` (unrestricted) | Cap harmony analysis tokens | A future binding/build that honours it for harmony | E2 (no-op today) | +| `dryMultiplier` (+ `dryBase`/`dryAllowedLength`/`dryPenaltyLastN`/`drySequenceBreakers`) | `0.0` (off) | Penalise verbatim n-gram repetition (break loops) | A model/config that loops (e.g. high temp) | E1 | + +Removed (no knob): the empty-body **retry** — a blank body fails fast with one `WARN` (see above). diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..74f4288 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,72 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:05:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices by configuring AI-driven field generation in a Maven plugin for code assistance. + +#### Purpose +- **Configure AI-driven field generation** for specific file types and prompts. +- **Associate prompts with AI model definitions** for generating content based on specified criteria. + +#### Type +- Class (`public`) +- Extends: `Object` +- Annotations: `@SuppressWarnings("NullAway.Init", "initialization.fields.uninitialized")`, `@ToString` + +#### Input +- Constructor parameters: None +- Method parameters: + - `promptKey`: String + - `aiDefinitionKey`: String + - `fileExtensions`: Collection (nullable) +- Injected dependencies: None +- Consumed fields: None +- Read resources: None + +#### Output +- Return types: + - `String getPromptKey()`: Returns the prompt template key. + - `String getAiDefinitionKey()`: Returns the AI model definition key. + - `List getFileExtensions()`: Returns the source file extensions that select this entry, or `null`. +- Produced state: None +- Mutated fields: + - `promptKey` + - `aiDefinitionKey` + - `fileExtensions` +- Written resources: None +- Side effects: None + +#### Core logic +- **Initialize the configuration** with default values. +- **Set and get prompt keys** for AI generation. +- **Set and get AI model definition keys** for specific configurations. +- **Manage file extensions** to determine applicability based on file types. + +#### Public API +- `getPromptKey() -> String`: Returns the key that identifies the prompt template. +- `setPromptKey(promptKey) -> void`: Sets the key that references an `AiPromptDefinition`. +- `getAiDefinitionKey() -> String`: Returns the key that references the `AiModelDefinition`. +- `setAiDefinitionKey(aiDefinitionKey) -> void`: Sets the key that references an `AiModelDefinition`. +- `getFileExtensions() -> List`: Returns the selecting file extensions, or `null`. +- `setFileExtensions(fileExtensions) -> void`: Sets the selecting file extensions. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collection` +- `java.util.Collections` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- Throws no exceptions. +- Handles null file extensions by setting them to `null`. + +#### Concurrency +- The class is not thread-safe as it does not manage any shared resources or synchronization mechanisms. + +#### EOF diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..0bd27e2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,48 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:07:06Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the {@link AiFieldGenerationConfig} that applies to a given source file, based on the entries' {@link AiFieldGenerationConfig#getFileExtensions() file extensions}. + +#### Purpose +- To determine the appropriate {@link AiFieldGenerationConfig} for a given source file based on its file extension. + +#### Type +- Class (`public final class AiFieldGenerationSelector`) + +#### Input +- `configs`: An iterable of {@link AiFieldGenerationConfig} objects, which may be null and will be skipped. +- `fileName`: The name of the source file (e.g., `Foo.java`). + +#### Output +- Returns the first matching {@link AiFieldGenerationConfig} based on the file extension or the first fallback entry if no match is found. If no entry matches and no fallback is configured, returns `null`. + +#### Core logic +1. Initialize a variable to hold the fallback configuration. +2. Iterate through each {@link AiFieldGenerationConfig} in the provided iterable. +3. Check if the current config is null; if so, skip to the next iteration. +4. Retrieve the file extensions for the current config. +5. If the extension list is null or empty, set this config as the fallback and continue. +6. Iterate through each extension in the current config's extension list. +7. Check if the file name ends with the current extension; if so, return this config. +8. After the loop, return the fallback config if no match was found. + +#### Public API +- `selectForFileName(configs: Iterable, fileName: String) -> @Nullable AiFieldGenerationConfig` + - Purpose: Returns the {@link AiFieldGenerationConfig} that applies to the given file name based on its extensions. + +#### Dependencies +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- Throws no exceptions; handles null entries in the configs iterable by skipping them. + +#### Concurrency +- The class and its methods are not thread-safe or synchronized, implying single-threaded usage. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..82c59fe --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,77 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:07:51Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices + +#### Purpose +- Provide a mutable configuration object for AI generation parameters. +- Support default values and provide access to these parameters through setters and getters. + +#### Type +- Class (`public final class AiGenerationConfig`) +- Lombok annotations: `@ToString` + +#### Input +- No constructor parameters. +- Default values are applied in the constructors. + +#### Output +- Return types for getter methods (e.g., `String getModelPath()`, `int getContextSize()`). +- Mutation of instance fields through setter methods (e.g., `setModelPath(String modelPath)`, `setStopStrings(@Nullable List stopStrings)`). + +#### Core logic +- **Initialization**: No explicit constructor logic beyond default values. +- **Parameter Setting**: Methods like `setModelPath(String modelPath)`, `setContextSize(int contextSize)`, etc., to modify configuration parameters. +- **Default Values**: Defined constants for each parameter (e.g., `DEFAULT_CONTEXT_SIZE`). + +#### Public API +- `getModelPath() -> String`: Returns the GGUF model file path. +- `setModelPath(String modelPath) -> void`: Sets the GGUF model file path. +- `getContextSize() -> int`: Returns the context window size in tokens. +- `setContextSize(int contextSize) -> void`: Sets the context window size in tokens. +- `getMaxOutputTokens() -> int`: Returns the maximum number of output tokens per inference call. +- `setMaxOutputTokens(int maxOutputTokens) -> void`: Sets the maximum number of output tokens per inference call. +- `getTemperature() -> float`: Returns the sampling temperature. +- `setTemperature(float temperature) -> void`: Sets the sampling temperature. +- `getThreads() -> int`: Returns the number of CPU threads used for inference. +- `setThreads(int threads) -> void`: Sets the number of CPU threads used for inference. +- `getCharsPerToken() -> int`: Returns the number of characters per token used in automatic maxInputChars calculation. +- `setCharsPerToken(int charsPerToken) -> void`: Sets the number of characters per token. +- `getMaxInputChars() -> int`: Returns the maximum number of input characters fed to the prompt. +- `setMaxInputChars(int maxInputChars) -> void`: Sets the maximum number of input characters fed to the prompt. +- `isWarnOnTrim() -> boolean`: Returns whether a warning is emitted when the prompt source text is trimmed. +- `setWarnOnTrim(boolean warnOnTrim) -> void`: Sets whether a warning is emitted when the prompt source text is trimmed. +- `getMaxRetries() -> int`: Returns the maximum number of retry attempts on empty-body responses. +- `setMaxRetries(int maxRetries) -> void`: Sets the maximum number of retry attempts on empty-body responses. +- `getRetryTemperatureIncrement() -> float`: Returns the temperature increment added on each retry attempt. +- `setRetryTemperatureIncrement(float retryTemperatureIncrement) -> void`: Sets the temperature increment added on each retry attempt. +- `getTopP() -> float`: Returns the nucleus-sampling probability threshold. +- `setTopP(float topP) -> void`: Sets the nucleus-sampling probability threshold. +- `getTopK() -> int`: Returns the top-k sampling limit. +- `setTopK(int topK) -> void`: Sets the top-k sampling limit. +- `getRepeatPenalty() -> float`: Returns the repetition penalty. +- `setRepeatPenalty(float repeatPenalty) -> void`: Sets the repetition penalty. +- `isChatTemplateEnableThinking() -> boolean`: Returns whether the model's chat-template thinking mode is enabled. +- `setChatTemplateEnableThinking(boolean chatTemplateEnableThinking) -> void`: Sets whether the model's chat-template thinking mode is enabled. +- `getStopStrings() -> @Nullable List`: Returns an unmodifiable view of the configured stop strings. +- `setStopStrings(@Nullable List stopStrings) -> void`: Sets the list of stop strings. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collections` +- `org.jspecify.annotations.Nullable` +- `lombok.ToString` + +#### Exceptions / Errors +- No explicit error handling or exception throwing mentioned. +- Nullable handling for `@Nullable List stopStrings`. + +#### Concurrency +- Class is final, implying it is not thread-safe. +- Fields are mutable but accessed through setter methods, suggesting controlled mutation in a single-threaded context. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..ba9143a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,39 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:10:51Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Identifies whether an AI generation operates on a single source file or a whole package. + +#### Purpose +- **Identify** the scope of AI generation (single file or entire package). + +#### Type +- `enum` +- Modifiers: `public` + +#### Input +- No input parameters. + +#### Output +- Enum constants: `FILE_SUMMARY`, `PACKAGE_SUMMARY`. + +#### Core logic +- **Define** two modes of AI generation based on the scope (single file or package). + +#### Public API +- `FILE_SUMMARY() -> AiGenerationKind` - Indicates AI generation for a single source file. +- `PACKAGE_SUMMARY() -> AiGenerationKind` - Indicates AI generation for an entire package. + +#### Dependencies +- No imports or referenced types. + +#### Exceptions / Errors +- No exceptions or error handling mentioned. + +#### Concurrency +- Enum values are thread-safe and do not involve concurrency. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..e63d4ee --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,99 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:11:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices by defining and managing AI model configurations for a Maven plugin, allowing for customization of parameters such as context size, number of threads, and more. + +#### Purpose +- **Configure AI model settings** for use in a Maven plugin that generates code based on specified AI model configurations. +- **Enable or disable thinking mode** for chat templates to control the chain-of-thought reasoning during generation. + +#### Type +- Class: `AiModelDefinition` +- Modifiers: `public` +- Extends: None +- Implements: None +- Key Generics or Bounds: None +- Notable Annotations: `@ToString`, `@SuppressWarnings` + +#### Input +- Parameters in constructors and setters: + - `key`: Unique identifier for the AI model definition. + - `modelPath`: Path to the GGUF model file. + - `contextSize`: Number of tokens in the model context window. + - `maxOutputTokens`: Maximum number of output tokens per inference call. + - `temperature`: Base sampling temperature for text generation. + - `threads`: Number of CPU threads for inference. + - `charsPerToken`: Characters per token for automatic max-input-chars calculation. + - `warnOnTrim`: Whether to emit a warning when source text is trimmed. + - `maxRetries`: Maximum number of retry attempts on empty body response. + - `retryTemperatureIncrement`: Temperature increment applied on each retry. + - `topP`: Nucleus-sampling probability threshold. + - `topK`: Top-k sampling limit. + - `repeatPenalty`: Repetition penalty applied to generated tokens. + - `chatTemplateEnableThinking`: Whether to enable thinking mode for chat templates. + - `stopStrings`: List of stop strings that terminate generation. + +#### Output +- Returns: + - `String getKey()`: Unique key for the AI model definition. + - `String getModelPath()`: Path to the GGUF model file. + - `int getContextSize()`: Context size in tokens. + - `int getMaxOutputTokens()`: Maximum output tokens per inference call. + - `float getTemperature()`: Base sampling temperature. + - `int getThreads()`: Number of threads for inference. + - `int getCharsPerToken()`: Characters per token for input character calculation. + - `boolean isWarnOnTrim()`: Whether to warn on trim. + - `int getMaxRetries()`: Maximum number of retry attempts. + - `float getRetryTemperatureIncrement()`: Temperature increment for retries. + - `float getTopP()`: Top-p value. + - `int getTopK()`: Top-k value. + - `float getRepeatPenalty()`: Repetition penalty. + - `boolean isChatTemplateEnableThinking()`: Whether thinking mode is enabled. + - `List getStopStrings()`: List of stop strings. +- Sets: + - Various fields through setter methods to configure the AI model settings. + +#### Core logic +1. **Default Constructor**: Initializes the object with default values from `AiGenerationConfig`. +2. **Setters and Getters**: Provide access to private fields for reading and updating the AI model configuration parameters. +3. **Utility Methods**: + - **getStopStrings()**: Returns an unmodifiable list of stop strings, ensuring immutability. + - **setStopStrings(Collection)**: Sets the stop strings collection, converting it to a mutable ArrayList internally. + +#### Public API +- `getKey() -> String`: Returns the unique key for the AI model definition. +- `getModelPath() -> String`: Returns the path to the GGUF model file. +- `getContextSize() -> int`: Returns the context size in tokens. +- `getMaxOutputTokens() -> int`: Returns the maximum output tokens per inference call. +- `getTemperature() -> float`: Returns the base sampling temperature. +- `getThreads() -> int`: Returns the number of threads for inference. +- `getCharsPerToken() -> int`: Returns the characters per token for input character calculation. +- `isWarnOnTrim() -> boolean`: Returns whether to warn on trim. +- `getMaxRetries() -> int`: Returns the maximum number of retry attempts. +- `getRetryTemperatureIncrement() -> float`: Returns the temperature increment for retries. +- `getTopP() -> float`: Returns the top-p value. +- `getTopK() -> int`: Returns the top-k value. +- `getRepeatPenalty() -> float`: Returns the repetition penalty. +- `isChatTemplateEnableThinking() -> boolean`: Returns whether thinking mode is enabled. +- `getStopStrings() -> List`: Returns the list of stop strings. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collection` +- `java.util.Collections` +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- Throws no exceptions. +- Handles null values by using `@Nullable` annotations and defensive copying where necessary. + +#### Concurrency +- The class is not inherently thread-safe as it does not synchronize access to its fields. However, the immutability of the configuration parameters ensures that concurrent access within a single thread is safe. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..1ab0f7e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,53 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:14:05Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by their key, returning the corresponding generation configurations. + +#### Purpose +- To provide a lookup table for AI model definitions to convert them into ready-to-use generation configurations. +- To enforce contract by ensuring non-null keys in the supplied list of definitions. + +#### Type +- Class (`public final class AiModelDefinitionSupport`) +- Uses Lombok annotations (`@ToString`). + +#### Input +- Constructor parameter: `definitions` (List) +- Method parameter: `key` (String) + +#### Output +- Return type: `AiGenerationConfig` +- Side effect: Throws exceptions for missing keys. + +#### Core logic +- Constructs a lookup table from the supplied list of AI model definitions. +- Ensures non-null keys and populates the map with corresponding generation configurations. +- Provides a method to retrieve the configuration by key. + +#### Public API +- `public AiModelDefinitionSupport(List definitions)` + - Constructs a new `AiModelDefinitionSupport` from the supplied definitions list. +- `public AiGenerationConfig getConfig(String key)` + - Returns the generation config associated with the given key. + +#### Dependencies +- `import java.util.HashMap;` +- `import java.util.List;` +- `import java.util.Map;` +- `import java.util.Objects;` +- `import lombok.ToString;` +- `import net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper;` + +#### Exceptions / Errors +- Throws `NullPointerException` if any entry has a null key. +- Throws `IllegalArgumentException` if no definition is registered for the given key. + +#### Concurrency +- The class and its methods are not thread-safe, as they rely on mutable state. +- Immutable objects or thread-local storage are not used within this class. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..88936e4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,53 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:20:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Calculates VAT for invoices by configuring AI-driven field generation in a Maven plugin for code assistance. + +#### Purpose +- **Configure AI-driven field generation** for specific file types and prompts. +- **Associate prompts with AI model definitions** for generating content based on specified criteria. + +#### Responsibilities +- **AiFieldGenerationConfig**: Manages configuration for AI-driven field generation, including prompt keys and AI model definitions. +- **AiFieldGenerationSelector**: Selects the appropriate `AiFieldGenerationConfig` for a given source file based on its file extensions. +- **AiGenerationConfig**: Provides a mutable configuration object for AI generation parameters, supporting default values and access through setters and getters. +- **AiGenerationKind**: Identifies whether an AI generation operates on a single source file or a whole package. +- **AiModelDefinition**: Defines and manages AI model configurations for use in a Maven plugin, allowing customization of parameters such as context size, number of threads, and more. +- **AiModelDefinitionSupport**: Resolves AI model definitions by their key, returning the corresponding generation configurations. + +#### Key units +- **AiFieldGenerationConfig**: Manages configuration for AI-driven field generation. +- **AiFieldGenerationSelector**: Selects appropriate configurations based on file extensions. +- **AiGenerationConfig**: Mutable configuration object for AI generation parameters. +- **AiGenerationKind**: Enumerates the scope of AI generation (single file or package). +- **AiModelDefinition**: Defines and manages AI model configurations. +- **AiModelDefinitionSupport**: Resolves AI model definitions by key. + +#### Data flow +Inputs are typically passed through constructors, setters, and getters to configure and retrieve parameters for AI field generation and model management. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collection` +- `java.util.Collections` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Cross-cutting +- **Shared configuration parameters**: Many classes share configuration parameters such as model paths, context sizes, and more. +- **Exception handling**: No exceptions are explicitly thrown in the provided summaries, but null values are handled with annotations. +- `java.util.List` is frequently used for collections of configurations or extensions. + +#### EOF diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..70f9f7e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,98 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:25:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> Calculates VAT for invoices by configuring AI-driven field generation in a Maven plugin for code assistance. + +#### Purpose +- **Configure AI-driven field generation** for specific file types and prompts. +- **Associate prompts with AI model definitions** for generating content based on specified criteria. + +#### Responsibilities +- **AiFieldGenerationConfig**: Manages configuration for AI-driven field generation, including prompt keys and AI model definitions. +- **AiFieldGenerationSelector**: Selects the appropriate `AiFieldGenerationConfig` for a given source file based on its file extensions. +- **AiGenerationConfig**: Provides a mutable configuration object for AI generation parameters, supporting default values and access through setters and getters. +- **AiGenerationKind**: Identifies whether an AI generation operates on a single source file or a whole package. +- **AiModelDefinition**: Defines and manages AI model configurations for use in a Maven plugin, allowing customization of parameters such as context size, number of threads, and more. +- **AiModelDefinitionSupport**: Resolves AI model definitions by their key, returning the corresponding generation configurations. + +#### Key units +- **AiFieldGenerationConfig**: Manages configuration for AI-driven field generation. +- **AiFieldGenerationSelector**: Selects appropriate configurations based on file extensions. +- **AiGenerationConfig**: Mutable configuration object for AI generation parameters. +- **AiGenerationKind**: Enumerates the scope of AI generation (single file or package). +- **AiModelDefinition**: Defines and manages AI model configurations. +- **AiModelDefinitionSupport**: Resolves AI model definitions by key. + +#### Data flow +Inputs are typically passed through constructors, setters, and getters to configure and retrieve parameters for AI field generation and model management. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collection` +- `java.util.Collections` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Cross-cutting +- **Shared configuration parameters**: Many classes share configuration parameters such as model paths, context sizes, and more. +- **Exception handling**: No exceptions are explicitly thrown in the provided summaries, but null values are handled with annotations. +- `java.util.List` is frequently used for collections of configurations or extensions. + +#### EOF + +> Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Purpose +- To provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides a pluggable AI backend for generating text based on specific requests. +- Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Key units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Provides a pluggable AI backend for generating text based on request specifications. +- `AiGenerationProviderFactory`: Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- `LlamaCppJniAiGenerationProvider`: Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- `LlamaCppJniConfig`: Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Data flow +- `AiCompletionParser` consumes raw completion text and produces cleaned answer text. +- `AiGenerationProvider` consumes `AiGenerationRequest` and produces AI-generated text. +- `AiGenerationProviderFactory` consumes provider name and configuration, producing an `AiGenerationProvider` instance. +- `LlamaCppJniAiGenerationProvider` consumes `AiGenerationRequest` and configuration, producing AI-generated text. +- `LlamaCppJniConfig` provides configuration parameters for the JNI provider. +- `MockAiGenerationProvider` consumes an `AiGenerationRequest`, produces a mock summary based on the file name and content. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Cross-cutting +- Shared base types/interfaces: `AiGenerationProvider`, `AutoCloseable` +- Common exception/error handling: Throws `IOException` in several methods. +- Threading/concurrency notes: The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- Configuration: `LlamaCppJniConfig` provides configuration parameters for the JNI provider. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..499200f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,57 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:15:00Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. + +#### Purpose +- To clean and extract the actual model answer from raw LLM completion text by removing internal reasoning blocks. + +#### Type +- Class (`public final class AiCompletionParser`) +- Modifiers: none +- Extends: `Object` +- Implements: none +- Key generics or type bounds: none +- Notable annotations: `@ToString` from Lombok + +#### Input +- Constructor parameters: none +- Method parameters: `response` (the raw completion text, may be `null`) +- Injected dependencies: none +- Consumed fields: none +- Read resources: none + +#### Output +- Return type: `String` (the cleaned answer text, never `null`) +- Produced state: none +- Mutated fields: none +- Written resources: none +- Side effects: Throws an `IOException` if a thinking block is started but the token budget is exhausted before the closing marker is emitted. + +#### Core logic +- **If `response` is `null`, return an empty string.** +- **Find the position of `THINKING_BLOCK_END_MARKER` in `response`.** + - If found, return the substring from this position to the end, trimmed. +- **Check if `THINKING_BLOCK_START_MARKER` is present without a corresponding `THINKING_BLOCK_END_MARKER`.** + - If true, throw an `IOException` with a message indicating the token budget was exhausted. +- **If neither marker is present, return the trimmed `response`.** + +#### Public API +- `parseCompletion(String response) -> String`: Strips any Gemma-4 thinking block from the response and returns the clean answer text, handling null input and potential exceptions. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` + +#### Exceptions / Errors +- Throws `IOException` if a thinking block is started but the token budget is exhausted before the closing marker is emitted. +- Treats `null` input as an empty response. + +#### Concurrency +- The class and its methods are not explicitly designed for concurrency, but they handle null inputs and exceptions safely in a single-threaded context. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..e3b228b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,46 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:15:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a pluggable AI backend for generating text based on specific requests. + +#### Purpose +- To enable various AI backend providers to generate text based on request specifications. +- To allow implementations to be either local (using llama.cpp) or mock for testing purposes. + +#### Type +- Interface (`public interface AiGenerationProvider extends AutoCloseable`) +- Extends: `AutoCloseable` + +#### Input +- Constructor and method parameters: + - `AiGenerationRequest request` in `generate(AiGenerationRequest request) throws IOException` + - `AiGenerationRequest request, float temperatureOverride` in `generate(final AiGenerationRequest request, final float temperatureOverride) throws IOException` + +#### Output +- Return type: `String` +- Side effects: Throws `IOException` if the underlying provider fails. + +#### Core logic +- **Primary Method**: + - Takes an `AiGenerationRequest` and generates text using the provider's default sampling parameters. +- **Default Method**: + - Allows overriding the temperature for specific generation calls, which can help in breaking EOS-early failure modes. + +#### Public API +- `String generate(AiGenerationRequest request) throws IOException` -> Generates text using default sampling parameters. +- `default String generate(final AiGenerationRequest request, final float temperatureOverride) throws IOException` -> Generates text using a specified temperature override. + +#### Dependencies +- Referenced types: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` + +#### Exceptions / Errors +- Throws `IOException` if the underlying provider fails. + +#### Concurrency +- The interface extends `AutoCloseable`, suggesting that implementations should handle resource management and potential concurrency issues. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..cca15e5 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,56 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:16:31Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an {@link AiGenerationProvider} implementation by name. + +#### Purpose +- To provide a factory method for creating different types of {@link AiGenerationProvider} implementations based on the provided name. + +#### Type +- Class (`public class AiGenerationProviderFactory`) +- Modifiers: `public` +- Extends: None +- Implements: None +- Key Generics or Type Bounds: None +- Notable Annotations: `@ToString` from Lombok + +#### Input +- Parameters: + - `providerName`: A string representing the provider key, which can be `"mock"` or `"llamacpp-jni"`. + - `llamaConfig`: Configuration for the llama.cpp JNI provider. + - `promptSupport`: Prompt lookup support passed to providers that need it. + +#### Output +- Return Type: {@link AiGenerationProvider} +- Produced State: A newly-created provider instance based on the provided name. +- Mutated Fields: None +- Written Resources: None +- Side Effects: Throws an `IllegalArgumentException` if the provider name is not recognized. + +#### Core logic +- **Default Provider**: If `providerName` is `null` or blank, return a {@link MockAiGenerationProvider}. +- **Switch Case**: Based on the `providerName`, instantiate and return the appropriate provider: + - `"mock"`: Returns a {@link MockAiGenerationProvider}. + - `"llamacpp-jni"`: Returns a {@link LlamaCppJniAiGenerationProvider} with the given configuration and prompt support. + +#### Public API +- `create(String providerName, LlamaCppJniConfig llamaConfig, AiPromptSupport promptSupport) -> AiGenerationProvider` + - Creates and returns an {@link AiGenerationProvider} instance based on the provided name. + +#### Dependencies +- Imports: + - `lombok.ToString` + - `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` + - `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper` + +#### Exceptions / Errors +- Throws `IllegalArgumentException` if the provider name is not recognized. + +#### Concurrency +- The class and its methods do not appear to handle concurrency explicitly, but it should be thread-safe given the immutability of the objects created and the absence of mutable state in the class itself. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..eaafdf2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,58 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:17:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. + +#### Purpose +- Provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Type +- Class: `LlamaCppJniAiGenerationProvider` +- Modifiers: `final` +- Implements: `AiGenerationProvider`, `AutoCloseable` + +#### Input +- Constructor parameters: `config`, `promptSupport` +- Method parameters: `request`, `temperatureOverride` + +#### Output +- Return type: `String` +- Produced state: AI-generated text response +- Mutated fields: `model` + +#### Core logic +- Lazily initializes the `LlamaModel` on the first call to `generate()`. +- Constructs a prompt using `AiPromptSupport.buildPrompt()`. +- Sets up `InferenceParameters` for model inference. +- Parses the completion result using `AiCompletionParser.parseCompletion()`. + +#### Public API +- `generate(AiGenerationRequest request) -> String`: Generates AI-generated text based on the request. +- `generate(AiGenerationRequest request, float temperatureOverride) -> String`: Generates AI-generated text with an optional temperature override. +- `close()`: Closes the `LlamaModel` when no longer needed. + +#### Dependencies +- `java.io.IOException` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- Throws `IOException` in `generate()` methods. +- Handles null inputs and parameters gracefully, using `Objects.requireNonNull()`. + +#### Concurrency +- The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- The `model` field is marked with `@ToString.Exclude` to exclude it from string representations for security and performance reasons. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..bdd0cc0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,79 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:18:22Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Immutable configuration for the llama.cpp JNI provider. + +#### Purpose +- Define and encapsulate configuration parameters for the llama.cpp JNI provider. +- Provide a record-shaped value type for future Java 17+ migration. + +#### Type +- Class (`final`): `LlamaCppJniConfig` +- Lombok annotations: `@ToString`, `@EqualsAndHashCode` +- Interface implemented: `ConvertToRecord` (annotation) + +#### Input +- Constructor parameters: + - `libraryPath`: String, may be null + - `modelPath`: String, must not be null + - `contextSize`: int + - `maxOutputTokens`: int + - `temperature`: float + - `threads`: int + - `topP`: float + - `topK`: int + - `repeatPenalty`: float + - `chatTemplateEnableThinking`: boolean + - `stopStrings`: List, may be null (treated as empty list) + +#### Output +- Public methods: + - `libraryPath() -> String` + - `modelPath() -> String` + - `contextSize() -> int` + - `maxOutputTokens() -> int` + - `temperature() -> float` + - `threads() -> int` + - `topP() -> float` + - `topK() -> int` + - `repeatPenalty() -> float` + - `chatTemplateEnableThinking() -> boolean` + - `stopStrings() -> List` + +#### Core logic +- **Initialization**: Ensures `modelPath` is not null. +- **Accessors**: Provide read-only access to all configuration fields. +- **Immutability**: All fields are final, ensuring the object cannot be modified once created. + +#### Public API +- `libraryPath() -> String`: Returns the native library path. +- `modelPath() -> String`: Returns the GGUF model file path. +- `contextSize() -> int`: Returns the context window size in tokens. +- `maxOutputTokens() -> int`: Returns the maximum number of output tokens per call. +- `temperature() -> float`: Returns the sampling temperature. +- `threads() -> int`: Returns the number of CPU threads. +- `topP() -> float`: Returns the nucleus-sampling probability threshold. +- `topK() -> int`: Returns the top-k sampling limit. +- `repeatPenalty() -> float`: Returns the repetition penalty. +- `chatTemplateEnableThinking() -> boolean`: Returns whether chat-template thinking mode is enabled. +- `stopStrings() -> List`: Returns an unmodifiable view of the configured stop strings. + +#### Dependencies +- `java.util.Collections` +- `java.util.List` +- `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Exceptions / Errors +- Throws a `NullPointerException` if `modelPath` is null during initialization. +- Handles null `stopStrings` by treating them as empty lists. + +#### Concurrency +- The class is immutable, making it inherently thread-safe and not requiring synchronization. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..d34b947 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,52 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:19:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices + +#### Purpose +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. +- To generate a deterministic summary based on an `AiGenerationRequest`. + +#### Type +- Class (`public final class MockAiGenerationProvider`) +- Implements `AiGenerationProvider` interface. +- Uses Lombok's `@ToString` annotation for generating string representations. + +#### Input +- Constructor parameters: none. +- Method parameters: `request` of type `AiGenerationRequest`. +- Consumed fields: `sourceFile` from `request`. + +#### Output +- Return type: `String`. +- Produced state: A mock summary based on the file name and content. +- Side effects: None explicitly stated, but assumes reading from the file system. + +#### Core logic +- Retrieves the source file path from the request. +- Extracts the file name from the path. +- Constructs a mock summary string using the file name. + +#### Public API +- `MockAiGenerationProvider() -> void`: Constructor for creating a new `MockAiGenerationProvider`. +- `generate(AiGenerationRequest request) -> String`: Generates a mock summary for an invoice based on the provided request. + +#### Dependencies +- `java.io.IOException` +- `java.nio.file.Path` +- `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider` + +#### Exceptions / Errors +- Throws `IOException` if there's an issue reading the file. +- Handles null file names by defaulting to the full path string. + +#### Concurrency +- The class is not thread-safe as it directly interacts with the file system and does not manage any shared resources or synchronization mechanisms. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..9a8e314 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,77 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:22:53Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Purpose +- To provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides a pluggable AI backend for generating text based on specific requests. +- Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Key units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Provides a pluggable AI backend for generating text based on request specifications. +- `AiGenerationProviderFactory`: Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- `LlamaCppJniAiGenerationProvider`: Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- `LlamaCppJniConfig`: Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Data flow +- `AiCompletionParser` consumes raw completion text and produces cleaned answer text. +- `AiGenerationProvider` consumes `AiGenerationRequest` and produces AI-generated text. +- `AiGenerationProviderFactory` consumes provider name and configuration, producing an `AiGenerationProvider` instance. +- `LlamaCppJniAiGenerationProvider` consumes `AiGenerationRequest` and configuration, producing AI-generated text. +- `LlamaCppJniConfig` provides configuration parameters for the JNI provider. +- `MockAiGenerationProvider` consumes an `AiGenerationRequest`, produces a mock summary based on the file name and content. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Cross-cutting +- Shared base types/interfaces: `AiGenerationProvider`, `AutoCloseable` +- Common exception/error handling: Throws `IOException` in several methods. +- Threading/concurrency notes: The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- Configuration: `LlamaCppJniConfig` provides configuration parameters for the JNI provider. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..383ca12 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,58 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:28:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Purpose +- To provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides a pluggable AI backend for generating text based on specific requests. +- Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Key units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Provides a pluggable AI backend for generating text based on request specifications. +- `AiGenerationProviderFactory`: Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- `LlamaCppJniAiGenerationProvider`: Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- `LlamaCppJniConfig`: Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Data flow +- `AiCompletionParser` consumes raw completion text and produces cleaned answer text. +- `AiGenerationProvider` consumes `AiGenerationRequest` and produces AI-generated text. +- `AiGenerationProviderFactory` consumes provider name and configuration, producing an `AiGenerationProvider` instance. +- `LlamaCppJniAiGenerationProvider` consumes `AiGenerationRequest` and configuration, producing AI-generated text. +- `LlamaCppJniConfig` provides configuration parameters for the JNI provider. +- `MockAiGenerationProvider` consumes an `AiGenerationRequest`, produces a mock summary based on the file name and content. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Cross-cutting +- Shared base types/interfaces: `AiGenerationProvider`, `AutoCloseable` +- Common exception/error handling: Throws `IOException` in several methods. +- Threading/concurrency notes: The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- Configuration: `LlamaCppJniConfig` provides configuration parameters for the JNI provider. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..5252a61 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,58 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:29:36Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Purpose +- To provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides a pluggable AI backend for generating text based on specific requests. +- Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Key units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Provides a pluggable AI backend for generating text based on request specifications. +- `AiGenerationProviderFactory`: Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- `LlamaCppJniAiGenerationProvider`: Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- `LlamaCppJniConfig`: Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Data flow +- `AiCompletionParser` consumes raw completion text and produces cleaned answer text. +- `AiGenerationProvider` consumes `AiGenerationRequest` and produces AI-generated text. +- `AiGenerationProviderFactory` consumes provider name and configuration, producing an `AiGenerationProvider` instance. +- `LlamaCppJniAiGenerationProvider` consumes `AiGenerationRequest` and configuration, producing AI-generated text. +- `LlamaCppJniConfig` provides configuration parameters for the JNI provider. +- `MockAiGenerationProvider` consumes an `AiGenerationRequest`, produces a mock summary based on the file name and content. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Cross-cutting +- Shared base types/interfaces: `AiGenerationProvider`, `AutoCloseable` +- Common exception/error handling: Throws `IOException` in several methods. +- Threading/concurrency notes: The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- Configuration: `LlamaCppJniConfig` provides configuration parameters for the JNI provider. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..ab23fbe --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,58 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:30:51Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Purpose +- To provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides a pluggable AI backend for generating text based on specific requests. +- Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Key units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Provides a pluggable AI backend for generating text based on request specifications. +- `AiGenerationProviderFactory`: Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- `LlamaCppJniAiGenerationProvider`: Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- `LlamaCppJniConfig`: Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Data flow +- `AiCompletionParser` consumes raw completion text and produces cleaned answer text. +- `AiGenerationProvider` consumes `AiGenerationRequest` and produces AI-generated text. +- `AiGenerationProviderFactory` consumes provider name and configuration, producing an `AiGenerationProvider` instance. +- `LlamaCppJniAiGenerationProvider` consumes `AiGenerationRequest` and configuration, producing AI-generated text. +- `LlamaCppJniConfig` provides configuration parameters for the JNI provider. +- `MockAiGenerationProvider` consumes an `AiGenerationRequest`, produces a mock summary based on the file name and content. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Cross-cutting +- Shared base types/interfaces: `AiGenerationProvider`, `AutoCloseable` +- Common exception/error handling: Throws `IOException` in several methods. +- Threading/concurrency notes: The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- Configuration: `LlamaCppJniConfig` provides configuration parameters for the JNI provider. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/package.ai.md new file mode 100644 index 0000000..1d8a51b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/net/package.ai.md @@ -0,0 +1,58 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:32:05Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Purpose +- To provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides a pluggable AI backend for generating text based on specific requests. +- Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Key units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Provides a pluggable AI backend for generating text based on request specifications. +- `AiGenerationProviderFactory`: Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- `LlamaCppJniAiGenerationProvider`: Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- `LlamaCppJniConfig`: Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Data flow +- `AiCompletionParser` consumes raw completion text and produces cleaned answer text. +- `AiGenerationProvider` consumes `AiGenerationRequest` and produces AI-generated text. +- `AiGenerationProviderFactory` consumes provider name and configuration, producing an `AiGenerationProvider` instance. +- `LlamaCppJniAiGenerationProvider` consumes `AiGenerationRequest` and configuration, producing AI-generated text. +- `LlamaCppJniConfig` provides configuration parameters for the JNI provider. +- `MockAiGenerationProvider` consumes an `AiGenerationRequest`, produces a mock summary based on the file name and content. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Cross-cutting +- Shared base types/interfaces: `AiGenerationProvider`, `AutoCloseable` +- Common exception/error handling: Throws `IOException` in several methods. +- Threading/concurrency notes: The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- Configuration: `LlamaCppJniConfig` provides configuration parameters for the JNI provider. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/package.ai.md new file mode 100644 index 0000000..82ad53d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/java/package.ai.md @@ -0,0 +1,58 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:33:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Purpose +- To provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides a pluggable AI backend for generating text based on specific requests. +- Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Key units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Provides a pluggable AI backend for generating text based on request specifications. +- `AiGenerationProviderFactory`: Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- `LlamaCppJniAiGenerationProvider`: Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- `LlamaCppJniConfig`: Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Data flow +- `AiCompletionParser` consumes raw completion text and produces cleaned answer text. +- `AiGenerationProvider` consumes `AiGenerationRequest` and produces AI-generated text. +- `AiGenerationProviderFactory` consumes provider name and configuration, producing an `AiGenerationProvider` instance. +- `LlamaCppJniAiGenerationProvider` consumes `AiGenerationRequest` and configuration, producing AI-generated text. +- `LlamaCppJniConfig` provides configuration parameters for the JNI provider. +- `MockAiGenerationProvider` consumes an `AiGenerationRequest`, produces a mock summary based on the file name and content. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Cross-cutting +- Shared base types/interfaces: `AiGenerationProvider`, `AutoCloseable` +- Common exception/error handling: Throws `IOException` in several methods. +- Threading/concurrency notes: The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- Configuration: `LlamaCppJniConfig` provides configuration parameters for the JNI provider. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/package.ai.md new file mode 100644 index 0000000..1febdab --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/main/package.ai.md @@ -0,0 +1,58 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:34:35Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Purpose +- To provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides a pluggable AI backend for generating text based on specific requests. +- Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Key units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Provides a pluggable AI backend for generating text based on request specifications. +- `AiGenerationProviderFactory`: Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- `LlamaCppJniAiGenerationProvider`: Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- `LlamaCppJniConfig`: Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Data flow +- `AiCompletionParser` consumes raw completion text and produces cleaned answer text. +- `AiGenerationProvider` consumes `AiGenerationRequest` and produces AI-generated text. +- `AiGenerationProviderFactory` consumes provider name and configuration, producing an `AiGenerationProvider` instance. +- `LlamaCppJniAiGenerationProvider` consumes `AiGenerationRequest` and configuration, producing AI-generated text. +- `LlamaCppJniConfig` provides configuration parameters for the JNI provider. +- `MockAiGenerationProvider` consumes an `AiGenerationRequest`, produces a mock summary based on the file name and content. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Cross-cutting +- Shared base types/interfaces: `AiGenerationProvider`, `AutoCloseable` +- Common exception/error handling: Throws `IOException` in several methods. +- Threading/concurrency notes: The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- Configuration: `LlamaCppJniConfig` provides configuration parameters for the JNI provider. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/package.ai.md new file mode 100644 index 0000000..bf6473c --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/package.ai.md @@ -0,0 +1,58 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:35:50Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Purpose +- To provide AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides a pluggable AI backend for generating text based on specific requests. +- Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Key units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Provides a pluggable AI backend for generating text based on request specifications. +- `AiGenerationProviderFactory`: Selects and instantiates an {@link AiGenerationProvider} implementation by name. +- `LlamaCppJniAiGenerationProvider`: Calculates VAT for invoices backed by the JNI binding of the llama.cpp library, providing AI-generated responses based on user prompts. +- `LlamaCppJniConfig`: Defines and encapsulates configuration parameters for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: To provide a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Data flow +- `AiCompletionParser` consumes raw completion text and produces cleaned answer text. +- `AiGenerationProvider` consumes `AiGenerationRequest` and produces AI-generated text. +- `AiGenerationProviderFactory` consumes provider name and configuration, producing an `AiGenerationProvider` instance. +- `LlamaCppJniAiGenerationProvider` consumes `AiGenerationRequest` and configuration, producing AI-generated text. +- `LlamaCppJniConfig` provides configuration parameters for the JNI provider. +- `MockAiGenerationProvider` consumes an `AiGenerationRequest`, produces a mock summary based on the file name and content. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) +- Interface `ConvertToRecord` (annotation) + +#### Cross-cutting +- Shared base types/interfaces: `AiGenerationProvider`, `AutoCloseable` +- Common exception/error handling: Throws `IOException` in several methods. +- Threading/concurrency notes: The provider is designed to be thread-safe as long as the underlying `LlamaModel` is thread-safe. +- Configuration: `LlamaCppJniConfig` provides configuration parameters for the JNI provider. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/project.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/project.ai.md new file mode 100644 index 0000000..e5d2253 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v1/project.ai.md @@ -0,0 +1,43 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: ABB3E8A8 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:37:09Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The project, "llamacpp-ai-index-maven-plugin," is designed to enhance code assistance through AI-driven field generation in a Maven plugin. It integrates with the llama.cpp library to provide AI-generated text responses based on user prompts, supporting various functionalities from configuration management to detailed provider services. Key subsystems include: + +1. **Configuration Management**: In the "config" package, VAT calculations for invoices are configured through AI-driven field generation, ensuring accurate and efficient processing within the Maven plugin framework. + +2. **AI-Generated Text Responses**: The "provider" package leverages a local GGUF model to generate text responses based on user prompts. This functionality is crucial for dynamic code assistance and decision support across the project. + +3. **Library Integration**: The core "llamacpp" package interfaces with the llama.cpp library, enabling advanced AI capabilities that are essential for the project's performance and accuracy in generating AI-driven text responses. + +These subsystems work cohesively to deliver a comprehensive solution for enhancing code assistance through AI within a Maven plugin environment. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Calculates VAT for invoices by configuring AI-driven field generation in a Maven plugin for code assistance. +- main/java/net/ladenthin/maven/llamacpp/aiindex — Calculates VAT for invoices by configuring AI-driven field generation in a Maven plugin for code assistance. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. +- main/java/net/ladenthin/maven/llamacpp — Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. +- main/java/net/ladenthin/maven — Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. +- main/java/net/ladenthin — Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. +- main/java/net — Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. +- main/java — Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. +- main — Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. +- . — Provides AI-generated text responses based on user prompts using a local GGUF model via the llama.cpp library. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..849819d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,53 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:37:48Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> This file defines a configuration POJO for field generation in a Maven plugin, associating prompt templates with AI model definitions for specific file types. + +#### Purpose +- **Associates** a prompt template with an AI model definition for field generation. +- **Declares** within the `` list in the plugin configuration. + +#### Type +```java +public class AiFieldGenerationConfig { + // Constructor, setters, and getters for private fields +} +``` + +#### Input +- `promptKey`: Key referencing an {@link AiPromptDefinition}. +- `aiDefinitionKey`: Key referencing an {@link AiModelDefinition}. +- `fileExtensions`: Optional list of file extensions to select this field generation. + +#### Output +- Returns: `String` for prompt key, AI definition key, and file extensions. +- Sets: `promptKey`, `aiDefinitionKey`, and `fileExtensions`. + +#### Core logic +1. **Constructor**: Initializes a new {@link AiFieldGenerationConfig}. +2. **getters/setters**: Provide access to private fields for prompt key, AI definition key, and file extensions. + +#### Public API +- `getPromptKey() -> String`: Returns the key for the prompt template. +- `setPromptKey(String promptKey)`: Sets the key for the prompt template. +- `getAiDefinitionKey() -> String`: Returns the key for the AI model definition. +- `setAiDefinitionKey(String aiDefinitionKey)`: Sets the key for the AI model definition. +- `getFileExtensions() -> @Nullable List`: Returns the file extensions that select this entry, or null if it's the fallback. +- `setFileExtensions(@Nullable Collection fileExtensions)`: Sets the file extensions that select this entry. + +#### Dependencies +- {@link AiModelDefinition} +- {@link AiModelDefinitionSupport} +- {@link net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition} + +#### Exceptions / Errors +- No notable exceptions or error conditions mentioned. + +#### Concurrency +- The class is mutable and instantiated via reflection, suggesting thread-unsafe usage without synchronization. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..6fc77c6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,60 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:39:06Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the AiFieldGenerationConfig that applies to a given source file, based on the entries' file extensions. + +#### Purpose +- Determines which AiFieldGenerationConfig applies to a specific source file based on its file extension. +- Provides a fallback configuration for files without a matching extension. +- Returns null if no configuration matches and no fallback is configured. + +#### Type +```java +public final class AiFieldGenerationSelector +extends Object +``` + +#### Input +- `configs`: Iterable - The list of configurations to evaluate, which may include null entries. +- `fileName`: String - The name of the source file (e.g., "Foo.java"). + +#### Output +- Returns the first matching AiFieldGenerationConfig based on the file extension. +- If no match is found and a fallback is configured, returns the fallback configuration. +- Returns null if no configuration matches and no fallback is configured. + +#### Core logic +1. Initialize a variable to hold the fallback configuration. +2. Iterate through each AiFieldGenerationConfig in the provided configs. +3. Skip null entries. +4. Check if the current config's file extensions list is empty or null. + - If empty, set this config as the fallback and continue. +5. Check if the fileName ends with any of the current config's extensions. + - If a match is found, return the current config. +6. After checking all configs, return the fallback config if no match was found. +7. Return null if no configuration matches and no fallback is configured. + +#### Public API +```java +selectForFileName(configs: Iterable, fileName: String) -> @Nullable AiFieldGenerationConfig +``` + +#### Dependencies +- `AiFieldGenerationConfig` +- `List` +- `@Nullable` + +#### Exceptions / Errors +- No exceptions are explicitly thrown. The method handles null entries by skipping them. + +#### Concurrency +- The class is not thread-safe as it does not maintain any state that could be affected by concurrent access. + +#### Purpose +- Defines the purpose of the AiFieldGenerationSelector class and its role in selecting a configuration based on file extensions. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..e0911f2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,56 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:39:50Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configuration object for AI generation parameters in a Maven plugin, facilitating interaction between the plugin and AI provider implementations. + +#### Purpose +- Define and manage AI generation parameters for a Maven plugin. +- Provide default values for various configuration options. + +#### Type +- Class (`public final class AiGenerationConfig`) +- Extends: `Object` +- Implements: `java.io.Serializable` (implicitly via Lombok's `@ToString`) +- Annotations: `@SuppressWarnings({"NullAway.Init", "initialization.fields.uninitialized"})`, `@ToString` + +#### Input +- No constructor parameters. +- No dependencies injected. +- No resources read. + +#### Output +- Returns: Various types (`String`, `int`, `float`, `boolean`, `List`) for configuration options. +- Sets: State of the object (fields) based on input values. + +#### Core logic +1. **Default Values**: Each field has a corresponding default value, ensuring flexibility and configurability. +2. **Getters and Setters**: Methods to retrieve and modify the state of the configuration object. +3. **Unmodifiable List**: The `stopStrings` field returns an unmodifiable view of the list to prevent external modification. + +#### Public API +1. `getModelPath() -> String`: Retrieve the model file path. +2. `setModelPath(String modelPath)`: Set the model file path. +3. `getContextSize() -> int`: Get the context window size in tokens. +4. `setContextSize(int contextSize)`: Set the context window size in tokens. +5. ... (similar for all fields) +6. `getStopStrings() -> @Nullable List`: Get an unmodifiable view of the stop strings. +7. `setStopStrings(@Nullable List stopStrings)`: Set the list of stop strings, allowing null to reset to an empty list. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collections` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- No exceptions or errors explicitly mentioned in the source code. +- Null handling is implicit in the use of `@Nullable` and defaulting to empty collections. + +#### Concurrency +- The class is not thread-safe as it stands, since setters modify state without synchronization. +- For thread safety, additional synchronization would be required around setter methods. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..9dc8295 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,41 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:41:49Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> This file defines constants for specifying the kind of AI generation, whether it operates on a single source file or a whole package. + +#### Purpose +- Define constants for specifying the kind of AI generation. + +#### Type +- `enum AiGenerationKind` +- Modifiers: public +- Extends: none +- Notable annotations: none + +#### Input +- None + +#### Output +- Constants: `FILE_SUMMARY`, `PACKAGE_SUMMARY` + +#### Core logic +- Represents the kind of AI generation. + +#### Public API +- `FILE_SUMMARY() -> AiGenerationKind`: Generation for a single source file. +- `PACKAGE_SUMMARY() -> AiGenerationKind`: Generation for a package aggregate. + +#### Dependencies +- None + +#### Exceptions / Errors +- None + +#### Concurrency +- Thread-safe: enum constants are inherently thread-safe. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..8452ac1 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,112 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:42:05Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines a mutable JavaBean configuration class for AI model parameters used in a Maven plugin, facilitating the reuse of model configurations across multiple field-generation entries and goals. + +#### Purpose +- **Configuration**: Provides a mutable POJO for storing and managing AI model parameters. +- **Reusability**: Allows a single model configuration to be defined once and reused across multiple field-generation entries and goals. + +#### Type +- `class AiModelDefinition` +- Modifiers: `public` +- Extends/Implements: None +- Notable Annotations: `@SuppressWarnings`, `@ToString` + +#### Input +- Constructor parameters: None +- Injected dependencies: None +- Consumed fields: + - `key` + - `modelPath` + - `contextSize` + - `maxOutputTokens` + - `temperature` + - `threads` + - `charsPerToken` + - `warnOnTrim` + - `maxRetries` + - `retryTemperatureIncrement` + - `topP` + - `topK` + - `repeatPenalty` + - `chatTemplateEnableThinking` + - `stopStrings` + +#### Output +- Return types: + - `String getKey()` + - `String getModelPath()` + - `int getContextSize()` + - `int getMaxOutputTokens()` + - `float getTemperature()` + - `int getThreads()` + - `int getCharsPerToken()` + - `boolean isWarnOnTrim()` + - `int getMaxRetries()` + - `float getRetryTemperatureIncrement()` + - `float getTopP()` + - `int getTopK()` + - `float getRepeatPenalty()` + - `boolean isChatTemplateEnableThinking()` + - `@Nullable List getStopStrings()` +- Produced/Mutated state: + - Fields are set via public setter methods. + +#### Core logic +- **Default Values**: Initializes fields with default values from `AiGenerationConfig`. +- **Getter and Setter Methods**: Provide access to private fields, ensuring flexibility in configuration management. + +#### Public API +- `String getKey()`: Returns the unique lookup key for this definition. +- `void setKey(final String key)`: Sets the unique lookup key for this definition. +- `String getModelPath()`: Returns the path to the GGUF model file. +- `void setModelPath(final String modelPath)`: Sets the path to the GGUF model file. +- `int getContextSize()`: Returns the context window size (in tokens). +- `void setContextSize(final int contextSize)`: Sets the context window size (in tokens). +- `int getMaxOutputTokens()`: Returns the maximum number of output tokens per inference call. +- `void setMaxOutputTokens(final int maxOutputTokens)`: Sets the maximum number of output tokens per inference call. +- `float getTemperature()`: Returns the base sampling temperature. +- `void setTemperature(final float temperature)`: Sets the base sampling temperature. +- `int getThreads()`: Returns the number of CPU threads for inference. +- `void setThreads(final int threads)`: Sets the number of CPU threads for inference. +- `int getCharsPerToken()`: Returns the number of characters per token used to automatically calculate the maximum input characters for the source code. +- `void setCharsPerToken(final int charsPerToken)`: Sets the number of characters per token for automatic max-input-chars calculation. +- `boolean isWarnOnTrim()`: Returns whether a warning is emitted when source text is trimmed. +- `void setWarnOnTrim(final boolean warnOnTrim)`: Sets whether a warning is emitted when source text is trimmed. +- `int getMaxRetries()`: Returns the maximum number of retry attempts when the provider returns an empty body. +- `void setMaxRetries(final int maxRetries)`: Sets the maximum number of retry attempts when the provider returns an empty body. +- `float getRetryTemperatureIncrement()`: Returns the temperature increment applied on each successive retry attempt. +- `void setRetryTemperatureIncrement(final float retryTemperatureIncrement)`: Sets the temperature increment applied on each successive retry attempt. +- `float getTopP()`: Returns the nucleus-sampling probability threshold. +- `void setTopP(final float topP)`: Sets the nucleus-sampling probability threshold. +- `int getTopK()`: Returns the top-k sampling limit. +- `void setTopK(final int topK)`: Sets the top-k sampling limit. +- `float getRepeatPenalty()`: Returns the repetition penalty. +- `void setRepeatPenalty(final float repeatPenalty)`: Sets the repetition penalty applied to already-generated tokens. +- `boolean isChatTemplateEnableThinking()`: Returns whether the model's chat-template thinking mode is enabled. +- `void setChatTemplateEnableThinking(final boolean chatTemplateEnableThinking)`: Sets whether the model's chat-template thinking mode is enabled. +- `@Nullable List getStopStrings()`: Returns the list of stop strings that terminate generation when encountered. +- `void setStopStrings(final @Nullable Collection stopStrings)`: Sets the list of stop strings that terminate generation when encountered. + +#### Dependencies +- Referenced types: + - `java.util.ArrayList` + - `java.util.Collection` + - `java.util.Collections` + - `org.jspecify.annotations.Nullable` + - `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig` + +#### Exceptions / Errors +- Throws: None +- Handles: Null values in setters, especially for collections like `stopStrings`. + +#### Concurrency +- The class is designed to be used in a single-threaded context as it does not manage any thread-safe operations internally. +- It is assumed that the Maven plugin framework managing instances of this class ensures thread safety when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..46d497c --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,54 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:45:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> This file defines a support class for resolving AI model definitions into generation configurations, ensuring efficient lookups and contract enforcement for missing keys. + +#### Purpose +- Provides a lookup table for AI model definitions to convert them into ready-to-use generation configurations. +- Ensures that every entry in the supplied list has a non-null key, throwing exceptions for null keys. + +#### Type +```java +public final class AiModelDefinitionSupport extends Object +``` + +#### Input +- `definitions`: List of `AiModelDefinition` entries; may be null or empty. + +#### Output +- A `Map` containing the resolved configurations. + +#### Core logic +1. Initializes the `configs` map with a capacity based on the size of the definitions list. +2. Iterates through the definitions list to populate the map, ensuring each entry has a non-null key. +3. Converts an `AiModelDefinition` into an `AiGenerationConfig` by copying all field values. + +#### Public API +```java +public AiGenerationConfig getConfig(String key) -> AiGenerationConfig +``` +- Purpose: Retrieves the generation configuration associated with the given key, throwing an exception if the key is not found. + +#### Dependencies +- `Map` +- `Java8CompatibilityHelper` + +#### Exceptions / Errors +- Throws `NullPointerException` if any entry in the definitions list has a null key. +- Throws `IllegalArgumentException` if no definition is registered for the given key. + +#### Concurrency +- The class is not thread-safe as it uses mutable state and external dependencies. + +#### Purpose +- Converts an `AiModelDefinition` into an `AiGenerationConfig`. + +```java +private static AiGenerationConfig toConfig(AiModelDefinition definition) -> AiGenerationConfig +``` diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..174072a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,47 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:51:12Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> This package provides a comprehensive set of tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. + +#### Purpose +- **Flexibility**: Allows for the association of prompt templates with specific AI models tailored for different file types. +- **Reusability**: Enables the reuse of AI model configurations across multiple field generation entries and Maven plugin goals. + +#### Responsibilities +- **Configuration Management**: Defines and manages AI model parameters in a mutable POJO format, suitable for configuration via Maven settings or programmatically. +- **Lookup Mechanism**: Provides a lookup table to convert AI model definitions into ready-to-use generation configurations, ensuring efficient access and error handling for missing keys. + +#### Key units +- **AiFieldGenerationConfig**: A mutable POJO for configuring field generation with prompt templates and AI models, associated with specific file extensions. +- **AiFieldGenerationSelector**: A utility class for selecting the appropriate `AiFieldGenerationConfig` based on the file extension of a source file. +- **AiGenerationConfig**: A configuration object encapsulating various parameters required for AI generation, including model path, context size, and more. +- **AiModelDefinition**: Defines constants for specifying the kind of AI generation, such as FILE_SUMMARY or PACKAGE_SUMMARY. +- **AiModelDefinitionSupport**: A support class providing a lookup mechanism for converting `AiModelDefinition` entries into `AiGenerationConfig` instances. + +#### Data flow +- Inputs to the package include various configuration parameters and a list of `AiModelDefinition` entries. +- The data flows through internal mechanisms to populate a map of `AiGenerationConfig` instances, which are then used by the `AiFieldGenerationSelector` to determine the appropriate configuration for a given file. + +#### Dependencies +- **Internal Collaborations**: The package depends on other units within the same package for configuration and lookup purposes. +- **External Modules**: No external modules are explicitly listed as dependencies, focusing on internal collaborations. + +#### Cross-cutting +- **Shared Base Types**: Utilizes Java's base types and collections for data handling. +- **Common Patterns**: Emphasizes the use of mutable POJOs and lookup tables to manage configurations efficiently. +- **Error Handling**: Implements exception handling for null keys and missing definitions, ensuring robust operation. + +#### Cross-cutting +- **Thread Safety**: The package does not inherently handle thread safety, relying on external frameworks to ensure thread-safe operations when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..a3c9f24 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,43 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:55:49Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. + +#### Purpose +- **Flexibility**: Allows for the association of prompt templates with specific AI models tailored for different file types. +- **Reusability**: Enables the reuse of AI model configurations across multiple field generation entries and Maven plugin goals. + +#### Responsibilities +- **Configuration Management**: Defines and manages AI model parameters in a mutable POJO format, suitable for configuration via Maven settings or programmatically. +- **Lookup Mechanism**: Provides a lookup table to convert AI model definitions into ready-to-use generation configurations, ensuring efficient access and error handling for missing keys. + +#### Key units +- **AiFieldGenerationConfig**: A mutable POJO for configuring field generation with prompt templates and AI models, associated with specific file extensions. +- **AiFieldGenerationSelector**: A utility class for selecting the appropriate `AiFieldGenerationConfig` based on the file extension of a source file. +- **AiGenerationConfig**: A configuration object encapsulating various parameters required for AI generation, including model path, context size, and more. +- **AiModelDefinition**: Defines constants for specifying the kind of AI generation, such as FILE_SUMMARY or PACKAGE_SUMMARY. +- **AiModelDefinitionSupport**: A support class providing a lookup mechanism for converting `AiModelDefinition` entries into `AiGenerationConfig` instances. + +#### Data flow +- Inputs to the package include various configuration parameters and a list of `AiModelDefinition` entries. +- The data flows through internal mechanisms to populate a map of `AiGenerationConfig` instances, which are then used by the `AiFieldGenerationSelector` to determine the appropriate configuration for a given file. + +#### Dependencies +- **Internal Collaborations**: The package depends on other units within the same package for configuration and lookup purposes. +- **External Modules**: No external modules are explicitly listed as dependencies, focusing on internal collaborations. + +#### Cross-cutting +- **Shared Base Types**: Utilizes Java's base types and collections for data handling. +- **Common Patterns**: Emphasizes the use of mutable POJOs and lookup tables to manage configurations efficiently. +- **Error Handling**: Implements exception handling for null keys and missing definitions, ensuring robust operation. + +#### Cross-cutting +- **Thread Safety**: The package does not inherently handle thread safety, relying on external frameworks to ensure thread-safe operations when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..23cd4f6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,48 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:46:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. + +#### Purpose +- To strip internal reasoning from a model's completion text and return only the actual answer. + +#### Type +```java +public class AiCompletionParser +``` +extends `Object` + +#### Input +- `response`: the raw completion text from the model, may be `null`. + +#### Output +- Returns the cleaned answer text, never `null`. +- Throws an `IOException` if a thinking block was started but the token budget was exhausted before the closing marker was emitted. + +#### Core logic +1. Check if `response` is `null`. If so, return an empty string. +2. Find the position of `THINKING_BLOCK_END_MARKER` in the response. +3. If found, return the substring from the end of this marker to the end of the string, trimmed. +4. If `THINKING_BLOCK_START_MARKER` is present but `THINKING_BLOCK_END_MARKER` is absent, throw an `IOException`. +5. If neither marker is present, return the response trimmed. + +#### Public API +```java +parseCompletion(response) -> String +``` +- Strips any Gemma-4 thinking block from `response` and returns the clean answer text. + +#### Dependencies +- `IOException` + +#### Exceptions / Errors +- Throws `IOException` if `THINKING_BLOCK_START_MARKER` is present but `THINKING_BLOCK_END_MARKER` is absent, indicating a token budget exhaustion inside the thinking block. + +#### Concurrency +- The class and its method do not inherently handle threading or concurrency issues. However, the method's behavior is stateless and thread-safe in its current implementation. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..46bec28 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,47 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:47:04Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a pluggable AI backend for generating text based on an AI generation request. + +#### Purpose +- To enable various AI backend implementations that can generate text from a given request. +- To abstract the details of the AI backend, allowing for different providers to be used interchangeably. + +#### Type +- `interface AiGenerationProvider extends AutoCloseable` + +#### Input +- `AiGenerationRequest request` + +#### Output +- `String` + +#### Core logic +- **Generate text** using the provider's default sampling parameters. +- **Handle exceptions** by throwing `IOException`. +- **Optional temperature override** for retry attempts, which delegates to the main generate method. + +#### Public API +- `generate(AiGenerationRequest request) -> String` + - Generates text for the given request using the provider's default sampling parameters. +- `generate(AiGenerationRequest request, float temperatureOverride) -> String` + - Generates text with a specified temperature override, which replaces any provider's own configuration. + +#### Dependencies +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `java.io.IOException` + +#### Exceptions / Errors +- Throws `IOException` if the underlying provider fails. + +#### Concurrency +- The interface extends `AutoCloseable`, implying that implementations should manage resource lifecycle properly. + +#### Concurrency +- Not explicitly mentioned in the provided source, but typical for resource management interfaces. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..6369bda --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,51 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:47:35Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an {@link AiGenerationProvider} implementation by name. + +#### Purpose +- **Purpose**: Defines a factory for creating instances of `AiGenerationProvider` based on the provided name. + +#### Type +- **Type**: Class (`public final class`), extends no other class, implements no interfaces. + +#### Input +- **Input**: + - `providerName`: A string representing the provider key (e.g., "mock" or "llamacpp-jni"). + - `llamaConfig`: Configuration for the llama.cpp JNI provider. + - `promptSupport`: Support for prompt lookup passed to providers that need it. + +#### Output +- **Output**: + - Returns an instance of `AiGenerationProvider`. + - Throws `IllegalArgumentException` if the provider name is not recognized. + +#### Core logic +- **Core logic**: + - Check if `providerName` is null or blank, and default to "mock" if true. + - Use a switch statement to return the appropriate `AiGenerationProvider` based on the `providerName`. + +#### Public API +- **Public API**: + - `create(String providerName, LlamaCppJniConfig llamaConfig, AiPromptSupport promptSupport) -> AiGenerationProvider` + - **Purpose**: Creates an `AiGenerationProvider` for the given provider name. + +#### Dependencies +- **Dependencies**: + - `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` + - `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper` + - `net.ladenthin.maven.llamacpp.aiindex.provider.MockAiGenerationProvider` + - `net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniAiGenerationProvider` + +#### Exceptions / Errors +- **Exceptions**: + - Throws `IllegalArgumentException` if the provider name is not recognized. + +#### Concurrency +- **Concurrency**: Not applicable (no threading or state mutations mentioned). diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..61076f0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,52 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:48:15Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a JNI-backed implementation for generating AI text using local llama.cpp models, supporting configurable prompts and inference settings. + +#### Purpose +- **To provide a JNI-backed implementation** of an AI text generation provider that uses local llama.cpp models. +- **To support configurable prompts and inference settings** for generating AI text based on user requests. + +#### Type +```java +public final class LlamaCppJniAiGenerationProvider implements AiGenerationProvider, AutoCloseable +``` + +#### Input +- `config`: `LlamaCppJniConfig` - configuration for the llama.cpp model. +- `promptSupport`: `AiPromptSupport` - support for building prompts based on user requests. + +#### Output +- `String` - generated AI text based on the provided request and configuration settings. +- Throws `IOException` - if there's an issue with input/output operations. + +#### Core logic +1. **Initialization**: Constructs a new `LlamaCppJniAiGenerationProvider` object, initializing it with the given configuration and prompt support. +2. **Model Loading**: Loads the GGUF model lazily on the first call to `generate(...)`, using the provided configuration settings. +3. **Prompt Building**: Constructs a prompt based on the user request using the `promptSupport`. +4. **Inference Parameters Configuration**: Sets up inference parameters including messages, temperature, and other settings based on the configuration. +5. **Completion Parsing**: Parses the completion text from the model's output using `AiCompletionParser`. +6. **Resource Management**: Closes the model when the provider is closed, releasing resources. + +#### Public API +- `generate(AiGenerationRequest request) -> String`: Generates AI text based on the given request. +- `generate(AiGenerationRequest request, float temperatureOverride) -> String`: Generates AI text with an optional temperature override. +- `close()`: Closes the provider, releasing native resources. + +#### Dependencies +- `net.ladenthin.llama.LlamaModel` - JNI binding for llama.cpp models. +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` - Represents an AI generation request. +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` - Supports building prompts for AI generation. +- `org.jspecify.annotations.Nullable` - For nullable type annotations. + +#### Exceptions / Errors +- Throws `IOException` if there's an issue with input/output operations during generation. + +#### Concurrency +- The provider is not thread-safe; it should be managed in a single-threaded context or with appropriate synchronization. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..babc7d3 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,88 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:49:22Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Immutable configuration for the llama.cpp JNI provider. + +#### Purpose +- Provides immutable configuration settings for the llama.cpp JNI provider. +- Uses a record-shaped value type marked with `@ConvertToRecord` for future Java 17+ migration. + +#### Type +```java +public final class LlamaCppJniConfig +``` + +#### Input +- `libraryPath`: native library path; may be `null`. +- `modelPath`: path to the GGUF model file. +- `contextSize`: context window size in tokens. +- `maxOutputTokens`: maximum number of output tokens per call. +- `temperature`: sampling temperature. +- `threads`: number of CPU threads. +- `topP`: nucleus-sampling probability threshold. +- `topK`: top-k sampling limit. +- `repeatPenalty`: repetition penalty. +- `chatTemplateEnableThinking`: whether chat-template thinking mode is enabled. +- `stopStrings`: stop strings; may be `null` (treated as empty). + +#### Output +- Returns: + - `libraryPath`: native library path, or `null` to use the bundled library. + - `modelPath`: model file path. + - `contextSize`: context window size. + - `maxOutputTokens`: maximum output tokens. + - `temperature`: sampling temperature. + - `threads`: number of CPU threads. + - `topP`: top-p value. + - `topK`: top-k value. + - `repeatPenalty`: repeat penalty. + - `chatTemplateEnableThinking`: whether chat-template thinking mode is enabled. + - `stopStrings`: unmodifiable list of stop strings. + +#### Core logic +1. Ensures `modelPath` is not `null`. +2. Initializes all fields with provided values, treating `null` stop strings as an empty list. + +#### Public API +- `libraryPath() -> String` + - Returns the native library path. +- `modelPath() -> String` + - Returns the GGUF model file path. +- `contextSize() -> int` + - Returns the context window size in tokens. +- `maxOutputTokens() -> int` + - Returns the maximum number of output tokens per call. +- `temperature() -> float` + - Returns the sampling temperature. +- `threads() -> int` + - Returns the number of CPU threads. +- `topP() -> float` + - Returns the nucleus-sampling probability threshold. +- `topK() -> int` + - Returns the top-k sampling limit. +- `repeatPenalty() -> float` + - Returns the repetition penalty. +- `chatTemplateEnableThinking() -> boolean` + - Returns whether chat-template thinking mode is enabled. +- `stopStrings() -> List` + - Returns an unmodifiable view of the configured stop strings. + +#### Dependencies +- `java.util.Objects` +- `java.util.List` +- `java.util.Collections` +- `lombok.EqualsAndHashCode` +- `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord` + +#### Exceptions / Errors +- Throws `NullPointerException` if `modelPath` is `null`. + +#### Concurrency +- The class is immutable, hence thread-safe. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..b409f23 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,46 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:50:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> MockAiGenerationProvider is a deterministic test-only implementation of AiGenerationProvider that returns a mock summary for testing purposes. + +#### Purpose +- Provide a mock AI generation summary for testing purposes. + +#### Type +```java +public class MockAiGenerationProvider implements AiGenerationProvider { +``` + +#### Input +- `final AiGenerationRequest request`: The AI generation request containing the source file to be summarized. + +#### Output +- `String`: A mock summary string for the given file name. + +#### Core logic +1. Extract the source file path from the request. +2. Retrieve the file name from the path. +3. Construct a mock summary string using the file name. + +#### Public API +```java +public String generate(final AiGenerationRequest request) -> String { + // Returns a mock summary for the given file. +} +``` + +#### Dependencies +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `java.nio.file.Path` + +#### Exceptions / Errors +- Throws `IOException`: If there is an issue reading the file or processing the request. + +#### Concurrency +- This class is thread-safe as it does not maintain any state that would be affected by concurrent access. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..11e4c68 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,58 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T03:53:33Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> Provides a pluggable AI backend for generating text based on an AI generation request, with support for configurable prompts and inference settings. + +#### Purpose +- To enable various AI backend implementations that can generate text from a given request. +- To abstract the details of the AI backend, allowing for different providers to be used interchangeably. + +#### Responsibilities +- **AiCompletionParser.java**: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- **AiGenerationProvider.java**: Provides a pluggable AI backend for generating text based on an AI generation request. +- **AiGenerationProviderFactory.java**: Selects and instantiates an `AiGenerationProvider` implementation by name. +- **LlamaCppJniAiGenerationProvider.java**: Provides a JNI-backed implementation for generating AI text using local llama.cpp models, supporting configurable prompts and inference settings. +- **LlamaCppJniConfig.java**: Immutable configuration for the llama.cpp JNI provider. +- **MockAiGenerationProvider.java**: MockAiGenerationProvider is a deterministic test-only implementation of AiGenerationProvider that returns a mock summary for testing purposes. + +#### Key units +- **AiCompletionParser**: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- **AiGenerationProvider**: Provides a pluggable AI backend for generating text based on an AI generation request. +- **AiGenerationProviderFactory**: Selects and instantiates an `AiGenerationProvider` implementation by name. +- **LlamaCppJniAiGenerationProvider**: Provides a JNI-backed implementation for generating AI text using local llama.cpp models, supporting configurable prompts and inference settings. +- **LlamaCppJniConfig**: Immutable configuration for the llama.cpp JNI provider. +- **MockAiGenerationProvider**: MockAiGenerationProvider is a deterministic test-only implementation of AiGenerationProvider that returns a mock summary for testing purposes. + +#### Data flow +Inputs move through the package to outputs as follows: +1. `AiGenerationRequest` objects are processed by `AiGenerationProvider` implementations to generate text. +2. Configurations and prompts are managed by `LlamaCppJniConfig` and passed to `LlamaCppJniAiGenerationProvider`. +3. The result is parsed using `AiCompletionParser` before being stored in an AI index file. + +#### Dependencies +- **External modules**: + - `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` + - `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` + - `org.jspecify.annotations.Nullable` +- **Internal modules**: + - `net.ladenthin.llama.LlamaModel` + - `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper` + - `net.ladenthin.maven.llamacpp.aiindex.provider.MockAiGenerationProvider` + +#### Cross-cutting +- **Shared base types**: `IOException`, `AutoCloseable` +- **Common error handling**: Throws `IOException` for issues with input/output operations. +- **Concurrency**: The provider is not thread-safe and should be managed in a single-threaded context or with appropriate synchronization. +- **Configuration management**: Configurations are managed by `LlamaCppJniConfig`, which ensures that `modelPath` is not `null`. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..d47894a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,42 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:56:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. + +#### Purpose +- **Flexibility**: Allows for the association of prompt templates with specific AI models tailored for different file types. +- **Reusability**: Enables the reuse of AI model configurations across multiple field generation entries and Maven plugin goals. + +#### Responsibilities +- **Configuration Management**: Defines and manages AI model parameters in a mutable POJO format, suitable for configuration via Maven settings or programmatically. +- **Lookup Mechanism**: Provides a lookup table to convert AI model definitions into ready-to-use generation configurations, ensuring efficient access and error handling for missing keys. + +#### Key units +- **AiFieldGenerationConfig**: A mutable POJO for configuring field generation with prompt templates and AI models, associated with specific file extensions. +- **AiFieldGenerationSelector**: A utility class for selecting the appropriate `AiFieldGenerationConfig` based on the file extension of a source file. +- **AiGenerationConfig**: A configuration object encapsulating various parameters required for AI generation, including model path, context size, and more. +- **AiModelDefinition**: Defines constants for specifying the kind of AI generation, such as FILE_SUMMARY or PACKAGE_SUMMARY. +- **AiModelDefinitionSupport**: A support class providing a lookup mechanism for converting `AiModelDefinition` entries into `AiGenerationConfig` instances. + +#### Data flow +- Inputs to the package include various configuration parameters and a list of `AiModelDefinition` entries. +- The data flows through internal mechanisms to populate a map of `AiGenerationConfig` instances, which are then used by the `AiFieldGenerationSelector` to determine the appropriate configuration for a given file. + +#### Dependencies +- **Internal Collaborations**: The package depends on other units within the same package for configuration and lookup purposes. +- **External Modules**: No external modules are explicitly listed as dependencies, focusing on internal collaborations. + +#### Cross-cutting +- **Shared Base Types**: Utilizes Java's base types and collections for data handling. +- **Common Patterns**: Emphasizes the use of mutable POJOs and lookup tables to manage configurations efficiently. +- **Error Handling**: Implements exception handling for null keys and missing definitions, ensuring robust operation. + +#### Cross-cutting +- **Thread Safety**: The package does not inherently handle thread safety, relying on external frameworks to ensure thread-safe operations when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..6e37bce --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,42 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:57:43Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. + +#### Purpose +- **Flexibility**: Allows for the association of prompt templates with specific AI models tailored for different file types. +- **Reusability**: Enables the reuse of AI model configurations across multiple field generation entries and Maven plugin goals. + +#### Responsibilities +- **Configuration Management**: Defines and manages AI model parameters in a mutable POJO format, suitable for configuration via Maven settings or programmatically. +- **Lookup Mechanism**: Provides a lookup table to convert AI model definitions into ready-to-use generation configurations, ensuring efficient access and error handling for missing keys. + +#### Key units +- **AiFieldGenerationConfig**: A mutable POJO for configuring field generation with prompt templates and AI models, associated with specific file extensions. +- **AiFieldGenerationSelector**: A utility class for selecting the appropriate `AiFieldGenerationConfig` based on the file extension of a source file. +- **AiGenerationConfig**: A configuration object encapsulating various parameters required for AI generation, including model path, context size, and more. +- **AiModelDefinition**: Defines constants for specifying the kind of AI generation, such as FILE_SUMMARY or PACKAGE_SUMMARY. +- **AiModelDefinitionSupport**: A support class providing a lookup mechanism for converting `AiModelDefinition` entries into `AiGenerationConfig` instances. + +#### Data flow +- Inputs to the package include various configuration parameters and a list of `AiModelDefinition` entries. +- The data flows through internal mechanisms to populate a map of `AiGenerationConfig` instances, which are then used by the `AiFieldGenerationSelector` to determine the appropriate configuration for a given file. + +#### Dependencies +- **Internal Collaborations**: The package depends on other units within the same package for configuration and lookup purposes. +- **External Modules**: No external modules are explicitly listed as dependencies, focusing on internal collaborations. + +#### Cross-cutting +- **Shared Base Types**: Utilizes Java's base types and collections for data handling. +- **Common Patterns**: Emphasizes the use of mutable POJOs and lookup tables to manage configurations efficiently. +- **Error Handling**: Implements exception handling for null keys and missing definitions, ensuring robust operation. + +#### Cross-cutting +- **Thread Safety**: The package does not inherently handle thread safety, relying on external frameworks to ensure thread-safe operations when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..e3f951b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,42 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:58:31Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. + +#### Purpose +- **Flexibility**: Allows for the association of prompt templates with specific AI models tailored for different file types. +- **Reusability**: Enables the reuse of AI model configurations across multiple field generation entries and Maven plugin goals. + +#### Responsibilities +- **Configuration Management**: Defines and manages AI model parameters in a mutable POJO format, suitable for configuration via Maven settings or programmatically. +- **Lookup Mechanism**: Provides a lookup table to convert AI model definitions into ready-to-use generation configurations, ensuring efficient access and error handling for missing keys. + +#### Key units +- **AiFieldGenerationConfig**: A mutable POJO for configuring field generation with prompt templates and AI models, associated with specific file extensions. +- **AiFieldGenerationSelector**: A utility class for selecting the appropriate `AiFieldGenerationConfig` based on the file extension of a source file. +- **AiGenerationConfig**: A configuration object encapsulating various parameters required for AI generation, including model path, context size, and more. +- **AiModelDefinition**: Defines constants for specifying the kind of AI generation, such as FILE_SUMMARY or PACKAGE_SUMMARY. +- **AiModelDefinitionSupport**: A support class providing a lookup mechanism for converting `AiModelDefinition` entries into `AiGenerationConfig` instances. + +#### Data flow +- Inputs to the package include various configuration parameters and a list of `AiModelDefinition` entries. +- The data flows through internal mechanisms to populate a map of `AiGenerationConfig` instances, which are then used by the `AiFieldGenerationSelector` to determine the appropriate configuration for a given file. + +#### Dependencies +- **Internal Collaborations**: The package depends on other units within the same package for configuration and lookup purposes. +- **External Modules**: No external modules are explicitly listed as dependencies, focusing on internal collaborations. + +#### Cross-cutting +- **Shared Base Types**: Utilizes Java's base types and collections for data handling. +- **Common Patterns**: Emphasizes the use of mutable POJOs and lookup tables to manage configurations efficiently. +- **Error Handling**: Implements exception handling for null keys and missing definitions, ensuring robust operation. + +#### Cross-cutting +- **Thread Safety**: The package does not inherently handle thread safety, relying on external frameworks to ensure thread-safe operations when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/package.ai.md new file mode 100644 index 0000000..4acf386 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/net/package.ai.md @@ -0,0 +1,42 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T03:59:19Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. + +#### Purpose +- **Flexibility**: Allows for the association of prompt templates with specific AI models tailored for different file types. +- **Reusability**: Enables the reuse of AI model configurations across multiple field generation entries and Maven plugin goals. + +#### Responsibilities +- **Configuration Management**: Defines and manages AI model parameters in a mutable POJO format, suitable for configuration via Maven settings or programmatically. +- **Lookup Mechanism**: Provides a lookup table to convert AI model definitions into ready-to-use generation configurations, ensuring efficient access and error handling for missing keys. + +#### Key units +- **AiFieldGenerationConfig**: A mutable POJO for configuring field generation with prompt templates and AI models, associated with specific file extensions. +- **AiFieldGenerationSelector**: A utility class for selecting the appropriate `AiFieldGenerationConfig` based on the file extension of a source file. +- **AiGenerationConfig**: A configuration object encapsulating various parameters required for AI generation, including model path, context size, and more. +- **AiModelDefinition**: Defines constants for specifying the kind of AI generation, such as FILE_SUMMARY or PACKAGE_SUMMARY. +- **AiModelDefinitionSupport**: A support class providing a lookup mechanism for converting `AiModelDefinition` entries into `AiGenerationConfig` instances. + +#### Data flow +- Inputs to the package include various configuration parameters and a list of `AiModelDefinition` entries. +- The data flows through internal mechanisms to populate a map of `AiGenerationConfig` instances, which are then used by the `AiFieldGenerationSelector` to determine the appropriate configuration for a given file. + +#### Dependencies +- **Internal Collaborations**: The package depends on other units within the same package for configuration and lookup purposes. +- **External Modules**: No external modules are explicitly listed as dependencies, focusing on internal collaborations. + +#### Cross-cutting +- **Shared Base Types**: Utilizes Java's base types and collections for data handling. +- **Common Patterns**: Emphasizes the use of mutable POJOs and lookup tables to manage configurations efficiently. +- **Error Handling**: Implements exception handling for null keys and missing definitions, ensuring robust operation. + +#### Cross-cutting +- **Thread Safety**: The package does not inherently handle thread safety, relying on external frameworks to ensure thread-safe operations when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/package.ai.md new file mode 100644 index 0000000..b64f845 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/java/package.ai.md @@ -0,0 +1,42 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:00:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. + +#### Purpose +- **Flexibility**: Allows for the association of prompt templates with specific AI models tailored for different file types. +- **Reusability**: Enables the reuse of AI model configurations across multiple field generation entries and Maven plugin goals. + +#### Responsibilities +- **Configuration Management**: Defines and manages AI model parameters in a mutable POJO format, suitable for configuration via Maven settings or programmatically. +- **Lookup Mechanism**: Provides a lookup table to convert AI model definitions into ready-to-use generation configurations, ensuring efficient access and error handling for missing keys. + +#### Key units +- **AiFieldGenerationConfig**: A mutable POJO for configuring field generation with prompt templates and AI models, associated with specific file extensions. +- **AiFieldGenerationSelector**: A utility class for selecting the appropriate `AiFieldGenerationConfig` based on the file extension of a source file. +- **AiGenerationConfig**: A configuration object encapsulating various parameters required for AI generation, including model path, context size, and more. +- **AiModelDefinition**: Defines constants for specifying the kind of AI generation, such as FILE_SUMMARY or PACKAGE_SUMMARY. +- **AiModelDefinitionSupport**: A support class providing a lookup mechanism for converting `AiModelDefinition` entries into `AiGenerationConfig` instances. + +#### Data flow +- Inputs to the package include various configuration parameters and a list of `AiModelDefinition` entries. +- The data flows through internal mechanisms to populate a map of `AiGenerationConfig` instances, which are then used by the `AiFieldGenerationSelector` to determine the appropriate configuration for a given file. + +#### Dependencies +- **Internal Collaborations**: The package depends on other units within the same package for configuration and lookup purposes. +- **External Modules**: No external modules are explicitly listed as dependencies, focusing on internal collaborations. + +#### Cross-cutting +- **Shared Base Types**: Utilizes Java's base types and collections for data handling. +- **Common Patterns**: Emphasizes the use of mutable POJOs and lookup tables to manage configurations efficiently. +- **Error Handling**: Implements exception handling for null keys and missing definitions, ensuring robust operation. + +#### Cross-cutting +- **Thread Safety**: The package does not inherently handle thread safety, relying on external frameworks to ensure thread-safe operations when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/package.ai.md new file mode 100644 index 0000000..5c91641 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/main/package.ai.md @@ -0,0 +1,42 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:00:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. + +#### Purpose +- **Flexibility**: Allows for the association of prompt templates with specific AI models tailored for different file types. +- **Reusability**: Enables the reuse of AI model configurations across multiple field generation entries and Maven plugin goals. + +#### Responsibilities +- **Configuration Management**: Defines and manages AI model parameters in a mutable POJO format, suitable for configuration via Maven settings or programmatically. +- **Lookup Mechanism**: Provides a lookup table to convert AI model definitions into ready-to-use generation configurations, ensuring efficient access and error handling for missing keys. + +#### Key units +- **AiFieldGenerationConfig**: A mutable POJO for configuring field generation with prompt templates and AI models, associated with specific file extensions. +- **AiFieldGenerationSelector**: A utility class for selecting the appropriate `AiFieldGenerationConfig` based on the file extension of a source file. +- **AiGenerationConfig**: A configuration object encapsulating various parameters required for AI generation, including model path, context size, and more. +- **AiModelDefinition**: Defines constants for specifying the kind of AI generation, such as FILE_SUMMARY or PACKAGE_SUMMARY. +- **AiModelDefinitionSupport**: A support class providing a lookup mechanism for converting `AiModelDefinition` entries into `AiGenerationConfig` instances. + +#### Data flow +- Inputs to the package include various configuration parameters and a list of `AiModelDefinition` entries. +- The data flows through internal mechanisms to populate a map of `AiGenerationConfig` instances, which are then used by the `AiFieldGenerationSelector` to determine the appropriate configuration for a given file. + +#### Dependencies +- **Internal Collaborations**: The package depends on other units within the same package for configuration and lookup purposes. +- **External Modules**: No external modules are explicitly listed as dependencies, focusing on internal collaborations. + +#### Cross-cutting +- **Shared Base Types**: Utilizes Java's base types and collections for data handling. +- **Common Patterns**: Emphasizes the use of mutable POJOs and lookup tables to manage configurations efficiently. +- **Error Handling**: Implements exception handling for null keys and missing definitions, ensuring robust operation. + +#### Cross-cutting +- **Thread Safety**: The package does not inherently handle thread safety, relying on external frameworks to ensure thread-safe operations when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/package.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/package.ai.md new file mode 100644 index 0000000..2c6f220 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/package.ai.md @@ -0,0 +1,42 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:01:43Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. + +#### Purpose +- **Flexibility**: Allows for the association of prompt templates with specific AI models tailored for different file types. +- **Reusability**: Enables the reuse of AI model configurations across multiple field generation entries and Maven plugin goals. + +#### Responsibilities +- **Configuration Management**: Defines and manages AI model parameters in a mutable POJO format, suitable for configuration via Maven settings or programmatically. +- **Lookup Mechanism**: Provides a lookup table to convert AI model definitions into ready-to-use generation configurations, ensuring efficient access and error handling for missing keys. + +#### Key units +- **AiFieldGenerationConfig**: A mutable POJO for configuring field generation with prompt templates and AI models, associated with specific file extensions. +- **AiFieldGenerationSelector**: A utility class for selecting the appropriate `AiFieldGenerationConfig` based on the file extension of a source file. +- **AiGenerationConfig**: A configuration object encapsulating various parameters required for AI generation, including model path, context size, and more. +- **AiModelDefinition**: Defines constants for specifying the kind of AI generation, such as FILE_SUMMARY or PACKAGE_SUMMARY. +- **AiModelDefinitionSupport**: A support class providing a lookup mechanism for converting `AiModelDefinition` entries into `AiGenerationConfig` instances. + +#### Data flow +- Inputs to the package include various configuration parameters and a list of `AiModelDefinition` entries. +- The data flows through internal mechanisms to populate a map of `AiGenerationConfig` instances, which are then used by the `AiFieldGenerationSelector` to determine the appropriate configuration for a given file. + +#### Dependencies +- **Internal Collaborations**: The package depends on other units within the same package for configuration and lookup purposes. +- **External Modules**: No external modules are explicitly listed as dependencies, focusing on internal collaborations. + +#### Cross-cutting +- **Shared Base Types**: Utilizes Java's base types and collections for data handling. +- **Common Patterns**: Emphasizes the use of mutable POJOs and lookup tables to manage configurations efficiently. +- **Error Handling**: Implements exception handling for null keys and missing definitions, ensuring robust operation. + +#### Cross-cutting +- **Thread Safety**: The package does not inherently handle thread safety, relying on external frameworks to ensure thread-safe operations when multiple instances are created and manipulated concurrently. diff --git a/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/project.ai.md b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/project.ai.md new file mode 100644 index 0000000..47c5442 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__deepseek-coder-v2-lite__v2/project.ai.md @@ -0,0 +1,43 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: DA1C3F88 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:02:36Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The project "llamacpp-ai-index-maven-plugin" is designed to facilitate the integration of AI-driven text generation capabilities within a Maven plugin framework. It achieves this by organizing its functionality into several key packages, each serving specific purposes: + +1. The `config` package is pivotal for setting up and customizing AI model configurations, which are essential for generating text based on specific prompts and settings. This ensures that the plugin can adapt to various file types and goals, enhancing its flexibility and utility. + +2. The `provider` package introduces a pluggable AI backend that supports different inference settings and configurable prompts. This allows the system to dynamically generate text according to varying requirements, making it adaptable to diverse applications within the Maven plugin context. + +3. The core packages such as `llamacpp`, `maven`, and `ladenthin` are responsible for managing and configuring AI field generation across different file types and goals. They ensure that the AI model configurations can be reused and extended as needed, thereby enhancing the overall functionality and scalability of the plugin. + +These packages work cohesively to provide a comprehensive solution for incorporating AI-driven text generation into Maven plugin development, ensuring high flexibility and reusability in managing AI configurations. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — This package provides a comprehensive set of tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. +- main/java/net/ladenthin/maven/llamacpp/aiindex — This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Provides a pluggable AI backend for generating text based on an AI generation request, with support for configurable prompts and inference settings. +- main/java/net/ladenthin/maven/llamacpp — This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. +- main/java/net/ladenthin/maven — This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. +- main/java/net/ladenthin — This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. +- main/java/net — This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. +- main/java — This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. +- main — This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. +- . — This package provides comprehensive tools for configuring and managing AI field generation in a Maven plugin, ensuring flexibility and reusability of AI model configurations across various file types and goals. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..c8fec14 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,51 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:03:49Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures a prompt template and AI model key for Maven index field generation. + +#### Purpose +- Defines plugin configuration for a single AI field-generation step. +- Links prompt key to model definition for each file processed. + +#### Type +- Class `AiFieldGenerationConfig` +- Mutability: mutable JavaBean +- Annotation: `@ToString` +- Suppresses initialization warnings. + +#### Input +- Constructor: no-arg, no-op. +- Setters: `setPromptKey(String)`, `setAiDefinitionKey(String)`, `setFileExtensions(Collection)`. +- Parameters: prompt key, model definition key, optional file extensions. + +#### Output +- Getters: `getPromptKey()`, `getAiDefinitionKey()`, `getFileExtensions()`. +- `getFileExtensions()` returns unmodifiable list or null. +- Mutated internal state via setters. + +#### Core logic +- Defensive copy of file extension collection on set. +- Null handling: null or empty collection → null fallback. +- `getFileExtensions()` wraps internal list with `Collections.unmodifiableList`. + +#### Public API +- `AiFieldGenerationConfig() -> void` – create instance. +- `getPromptKey() -> String` – retrieve prompt key. +- `setPromptKey(String)` – set prompt key. +- `getAiDefinitionKey() -> String` – retrieve AI model key. +- `setAiDefinitionKey(String)` – set AI model key. +- `getFileExtensions() -> List` – get unmodifiable file extensions. +- `setFileExtensions(Collection)` – set file extensions defensively. + +#### Dependencies +- `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` +- Referenced types: `AiModelDefinition`, `AiPromptDefinition`, `AiFieldGenerationSelector` +- Maven plugin configuration context. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..8f0b43d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,46 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:05:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the field‑generation configuration applicable to a source file by file‑extension matching. + +#### Purpose +- Resolve AiFieldGenerationConfig for a given file name. + +#### Type +- `final class AiFieldGenerationSelector` +- Annotated with `@ToString`; no superclass. + +#### Input +- `Iterable configs` – declaration order; null entries ignored. +- `String fileName` – source file name to match. + +#### Output +- `@Nullable AiFieldGenerationConfig` – first extension‑matching config, else first fallback, else `null`. + +#### Core logic +- Iterate over `configs`; skip `null`. +- Retrieve `config.getFileExtensions()`; if null/empty store as `fallback`. +- For each `extension` in list, if `fileName.endsWith(extension)` return `config`. +- After loop, return `fallback`. + +#### Public API +- `AiFieldGenerationSelector()` – constructor, no initialization. +- `selectForFileName(configs, fileName) -> AiFieldGenerationConfig?` – determine config for file. + +#### Dependencies +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` +- `net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig` + +#### Exceptions / Errors +- None; no checked exceptions thrown. + +#### Concurrency +- No synchronization; instance is immutable. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..b907558 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,77 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:07:32Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> A mutable configuration holder for AI generation parameters, used to transfer settings from Maven to AI providers. + +#### Purpose +- Stores AI generation options (model path, sampling, retries, input limits). +- Acts as a JavaBean populated by Maven plugin. + +#### Type +- Class `AiGenerationConfig` (public), final by default, annotated `@ToString` (Lombok), no additional modifiers. + +#### Input +- Constructor (no parameters). +- Setters: `setModelPath`, `setContextSize`, `setMaxOutputTokens`, `setTemperature`, `setThreads`, `setCharsPerToken`, `setMaxInputChars`, `setWarnOnTrim`, `setMaxRetries`, `setRetryTemperatureIncrement`, `setTopP`, `setTopK`, `setRepeatPenalty`, `setChatTemplateEnableThinking`, `setStopStrings`. +- Defaults initialized in field declarations. + +#### Output +- Getters: `getModelPath`, `getContextSize`, `getMaxOutputTokens`, `getTemperature`, `getThreads`, `getCharsPerToken`, `getMaxInputChars`, `isWarnOnTrim`, `getMaxRetries`, `getRetryTemperatureIncrement`, `getTopP`, `getTopK`, `getRepeatPenalty`, `isChatTemplateEnableThinking`, `getStopStrings`. +- Unmodifiable view of stop strings. + +#### Core logic +- Constants define default values for context, output tokens, temperature, threads, input chars, etc. +- Fields hold mutable state initialized to defaults. +- `setStopStrings` replaces internal list or clears to empty. +- `getStopStrings` returns `Collections.unmodifiableList` or `null` if internal list unset. +- No additional computation or algorithm. + +#### Public API +- `AiGenerationConfig()` → construct empty config. +- `getModelPath() -> String` → model file path. +- `setModelPath(String)` → set model path. +- `getContextSize() -> int` → context window size. +- `setContextSize(int)` → set context size. +- `getMaxOutputTokens() -> int` → max output tokens. +- `setMaxOutputTokens(int)` → set max output tokens. +- `getTemperature() -> float` → sampling temperature. +- `setTemperature(float)` → set temperature. +- `getThreads() -> int` → CPU thread count. +- `setThreads(int)` → set thread count. +- `getCharsPerToken() -> int` → chars per token ratio. +- `setCharsPerToken(int)` → set ratio. +- `getMaxInputChars() -> int` → max input chars. +- `setMaxInputChars(int)` → set max input chars. +- `isWarnOnTrim() -> boolean` → trim warning flag. +- `setWarnOnTrim(boolean)` → set trim warning. +- `getMaxRetries() -> int` → max retry attempts. +- `setMaxRetries(int)` → set max retries. +- `getRetryTemperatureIncrement() -> float` → retry temperature increment. +- `setRetryTemperatureIncrement(float)` → set increment. +- `getTopP() -> float` → nucleus sampling threshold. +- `setTopP(float)` → set top‑p. +- `getTopK() -> int` → top‑k limit. +- `setTopK(int)` → set top‑k. +- `getRepeatPenalty() -> float` → repetition penalty. +- `setRepeatPenalty(float)` → set penalty. +- `isChatTemplateEnableThinking() -> boolean` → chat‑template thinking flag. +- `setChatTemplateEnableThinking(boolean)` → set flag. +- `getStopStrings() -> List` → unmodifiable stop strings. +- `setStopStrings(List)` → set stop strings. + +#### Dependencies +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`. +- `lombok.ToString`. +- `org.jspecify.annotations.Nullable`. + +#### Exceptions / Errors +- No checked or unchecked exceptions thrown. + +#### Concurrency +- Class is not thread‑safe; state changes via setters. No synchronization. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..34f2fd2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,35 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:11:06Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines AI generation target: single file or entire package. + +#### Purpose +- Identifies AI generation scope for configuration. +- Distinguishes file‑level from package‑level generation steps. + +#### Type +- `enum AiGenerationKind` +- Final, non‑abstract; extends `java.lang.Enum`. + +#### Core logic +- Declares constants `FILE_SUMMARY` and `PACKAGE_SUMMARY`. +- No additional methods or logic. + +#### Public API +- `FILE_SUMMARY` → single‑file generation. +- `PACKAGE_SUMMARY` → package‑wide generation. + +#### Dependencies +- None. + +#### Exceptions / Errors +- None. + +#### Concurrency +- Immutable by design; thread‑safe. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..c4f3c0b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,50 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:12:08Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines a Maven‑plugin configuration bean for AI model parameters such as model path, context size, temperature, and stop strings, allowing reuse across field‑generation goals. + +#### Purpose +- Holds AI model configuration for Maven plugin. +- Enables definition sharing via lookup key. + +#### Type +- Public class, mutable JavaBean, annotated @ToString, @SuppressWarnings. + +#### Input +- Constructor: no-arg, default values. +- Setters accept: + - key (String) + - modelPath (String) + - contextSize (int) + - maxOutputTokens (int) + - temperature (float) + - threads (int) + - charsPerToken (int) + - warnOnTrim (boolean) + - maxRetries (int) + - retryTemperatureIncrement (float) + - topP (float) + - topK (int) + - repeatPenalty (float) + - chatTemplateEnableThinking (boolean) + - stopStrings (Collection\) + +#### Output +- Getters return stored values; getStopStrings returns unmodifiable view or null. +- Mutators assign provided values; setStopStrings clones collection. + +#### Core logic +- Numeric fields initialized with defaults from AiGenerationConfig. +- No validation or error handling. +- List handling: defensive copy on set, unmodifiable view on get. + +#### Public API +- `getKey() -> String` – retrieve lookup key. +- `setKey(String) -> void` – assign lookup key. +- `getModelPath() -> String` diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..033d100 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,59 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:16:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Builds a lookup table for AI model definitions, returning ready‑to‑use generation configs. + +#### Purpose +- Provides mapping from a definition key to a fully populated `AiGenerationConfig`. +- Ensures early validation of configuration entries. + +#### Type +- `final class` `AiModelDefinitionSupport` +- Annotated `@ToString`. + +#### Input +- Constructor `AiModelDefinitionSupport(List definitions)` + - Accepts `null` or empty list → no configs. + - Each `AiModelDefinition` must have non‑null `key`. +- `getConfig(String key)` receives key for lookup. + +#### Output +- Constructor initializes `configs: Map`. +- `getConfig` returns the corresponding config or throws `IllegalArgumentException`. + +#### Core logic +- Constructor + - If `definitions` null → empty `HashMap` with capacity for 0. + - Else pre‑size `HashMap` for count. + - Iterate over definitions: + - Validate key non‑null, error message includes index and definition. + - Convert definition to config via `toConfig`. + - Put key‑config pair into map. +- `getConfig` + - Retrieve from map; if missing → throw `IllegalArgumentException` with prefix `Missing AI model definition for key: `. +- `toConfig` + - Instantiates `AiGenerationConfig`. + - Copies all properties from `AiModelDefinition`. + +#### Public API +- `AiModelDefinitionSupport(List definitions) -> void` – build lookup map. +- `AiGenerationConfig getConfig(String key) -> config` – fetch config by key. + +#### Dependencies +- `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects` +- `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper` +- `AiModelDefinition`, `AiGenerationConfig` + +#### Exceptions / Errors +- Constructor: throws `NullPointerException` if any `AiModelDefinition.key` is null, message includes list index. +- `getConfig`: throws `IllegalArgumentException` when key not found. + +#### Concurrency +- Immutable after construction; `configs` not modified elsewhere. No synchronization required. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..da413cc --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,55 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:29:28Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Provides a framework for configuring, selecting, and mapping AI model settings used by a Maven plugin to generate index fields. + +#### Purpose +- Manage AI model and prompt definitions for Maven-based index field generation. +- Resolve appropriate configuration per source file and convert definitions into executable AI settings. + +#### Responsibilities +- **Configuration beans** – `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`. +- **Selection logic** – `AiFieldGenerationSelector` chooses the config that matches a file’s extension. +- **Definition support** – `AiModelDefinitionSupport` builds a key‑to‑config lookup for model definitions. +- **Scope identification** – `AiGenerationKind` distinguishes file‑level from package‑level AI generation. + +#### Key units +- **AiFieldGenerationConfig** – mutable bean holding prompt key, model key, and optional file‑extension filters. +- **AiFieldGenerationSelector** – selects the first matching config for a file name, falls back to a generic config. +- **AiGenerationConfig** – holds concrete AI generation parameters (model path, context size, temperature, etc.) and is used by the AI engine. +- **AiModelDefinition** – Maven‑plugin bean that defines reusable AI model settings, referenced by key. +- **AiModelDefinitionSupport** – constructs a read‑only map from definition key to `AiGenerationConfig`; validates keys. +- **AiGenerationKind** – enum marking generation scope (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +1. Maven plugin reads `` and `` XML elements → creates `AiFieldGenerationConfig` and `AiModelDefinition` instances. +2. `AiModelDefinitionSupport` converts each `AiModelDefinition` into an `AiGenerationConfig` and stores in a lookup map. +3. During execution, `AiFieldGenerationSelector` receives a file name and a list of `AiFieldGenerationConfig` objects and returns the applicable config. +4. The selected config supplies the prompt key and model definition key, which are resolved to an `AiGenerationConfig` via `AiModelDefinitionSupport`. +5. The resulting `AiGenerationConfig` drives the AI generation engine to produce index fields. + +#### Dependencies +- Standard Java collections (`ArrayList`, `HashMap`, `List`, `Map`, `Collections`). +- Lombok `@ToString` for readable `toString` implementations. +- `org.jspecify.annotations.Nullable` to denote optional values. +- `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper` used by `AiModelDefinitionSupport`. +- Maven plugin configuration context (implicit). + +#### Cross-cutting +- Defensive copying of collections in setters; unmodifiable views in getters to preserve immutability of exposed data. +- Null‑aware logic: file‑extension lists may be `null` to indicate “no restriction”. +- No validation of numeric ranges; defaults mirror `AiGenerationConfig` constants. +- Thread‑unsafe state in configuration classes; `AiModelDefinitionSupport` is immutable after construction. +- Reuse of the same `@ToString` annotation across all beans for consistent logging. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..3d7d6ca --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,58 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:36:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> Enables Maven to generate index fields by selecting AI prompts and running llama.cpp locally or via a mock, producing clean text for documentation. + +#### Purpose +- Configure AI prompts, models, and context for Maven index generation. +- Execute AI generation using llama.cpp JNI or deterministic mock. + +#### Responsibilities +- **Configuration** – Parse `` and `` XML elements, expose `AiFieldGenerationConfig`, `AiGenerationConfig`, and `AiModelDefinition`. +- **Selection** – `AiFieldGenerationSelector` picks the first matching config for a file’s extension. +- **Provider** – `AiGenerationProviderFactory` creates a provider (`MockAiGenerationProvider` or `LlamaCppJniAiGenerationProvider`). +- **Parsing** – `AiCompletionParser` extracts the final answer from raw completions. +- **Prompt building** – `AiPromptSupport` (used by JNI provider) creates prompt strings for the model. + +#### Key units +- **AiFieldGenerationConfig** – mutable bean: prompt key, model key, optional file‑extension filters. +- **AiGenerationConfig** – concrete AI parameters: model path, context, temperature, etc.; drives the generation engine. +- **AiModelDefinition** – reusable definition referenced by key; converted by `AiModelDefinitionSupport`. +- **AiGenerationProvider** – interface for generating text; default temperature/close logic. +- **AiGenerationProviderFactory** – selects provider implementation based on key. +- **LlamaCppJniAiGenerationProvider** – builds prompt, configures `InferenceParameters`, calls `model.chatCompleteText`, parses result. +- **MockAiGenerationProvider** – deterministic summary for tests. +- **AiCompletionParser** – removes Gemma‑4 thinking blocks, returns clean string. + +#### Data flow +1. Maven reads `` & `` → creates config objects. +2. `AiModelDefinitionSupport` builds a read‑only map `definitionKey → AiGenerationConfig`. +3. During run, `AiFieldGenerationSelector` selects the applicable `AiFieldGenerationConfig` for a source file. +4. Selected config’s model key resolves to an `AiGenerationConfig` via the support map. +5. `AiGenerationProviderFactory.create` returns the provider. +6. Caller submits `AiGenerationRequest` (prompt key, source, header). +7. JNI provider builds prompt, wraps in chat messages, configures `InferenceParameters`, invokes `model.chatCompleteText`. +8. Raw completion is parsed by `AiCompletionParser` → cleaned answer returned. + +#### Dependencies +- Java collections (`List`, `Map`, etc.). +- Lombok `@ToString` for logging. +- `org.jspecify.annotations.Nullable` for optional fields. +- `net.ladenthin.llama` model, parameters, and Pair classes. +- Native JNI library via `LlamaCppJniConfig`. +- Internal helpers: `Java8CompatibilityHelper`, `AiPromptSupport`, `AiGenerationRequest`. + +#### Cross-cutting +- **Immutability**: Config objects are immutable after construction; mutable setters expose defensive copies. +- **Thread‑safety**: JNI provider performs lazy, unsynchronized initialization; parser and mock provider are stateless. +- **Exception handling**: `IOException` for JNI failures, `IllegalArgumentException` for unknown provider keys. +- **Factory pattern**: Centralizes provider creation, simplifying extension. +- **Logging**: Consistent `@ToString` annotations across beans. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..37e014b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,51 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:17:43Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Extracts the model's final answer from LLM output by removing Gemma‑4 thinking blocks. + +#### Purpose +- Parse raw LLM completion text. +- Remove internal reasoning block. + +#### Type +- **class** AiCompletionParser, non‑final, annotated `@ToString`. +- Extends `Object`. + +#### Input +- `AiCompletionParser()` constructor – no arguments. +- `parseCompletion(String response)` – raw completion string, may be `null`. + +#### Output +- Clean answer string, never `null`. +- Throws `IOException` if thinking block starts but ends missing. + +#### Core logic +- If `response` is `null`, return empty string. +- Find last index of `THINKING_BLOCK_END_MARKER`. +- If present, return substring after it, trimmed. +- If `THINKING_BLOCK_START_MARKER` exists without end marker, throw `IOException`. +- Otherwise, return trimmed original response. + +#### Public API +- `AiCompletionParser()` → `void` – constructor. +- `String parseCompletion(String response)` → `String` – parse response, remove thinking block. +- `String THINKING_BLOCK_START_MARKER` → `String` – start marker token. +- `String THINKING_BLOCK_END_MARKER` → `String` – end marker token. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` + +#### Exceptions / Errors +- Throws `IOException` when start marker present but end marker missing. +- Error message advises increasing `maxOutputTokens`. + +#### Concurrency +- No explicit synchronization; instance fields are immutable constants. +- Thread‑safe for shared usage. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..b151921 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,50 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:19:37Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines a pluggable AI backend that generates text for AiGenerationRequest objects. + +#### Purpose +- Supplies a text generation service for Maven llama.cpp AI indexing. +- Supports local or mock implementations. + +#### Type +- `interface` +- `extends AutoCloseable` +- Default methods for temperature override and close. + +#### Input +- `generate(AiGenerationRequest request)` – prompt key, source file, source text, current header. +- `generate(AiGenerationRequest request, float temperatureOverride)` – same request plus override temperature. +- `close()` – no arguments. + +#### Output +- `String generate(...)` – generated text, never `null`. +- `String generate(..., float)` – delegates to default, may ignore temperature. +- `void close()` – does nothing by default. + +#### Core logic +- `generate(AiGenerationRequest)` – must produce text using provider’s default sampling. +- `generate(..., float)` – default delegates to `generate(request)`. +- `close()` – default no‑op; can be overridden for resource cleanup. + +#### Public API +- `generate(AiGenerationRequest) -> String` – generate text. +- `generate(AiGenerationRequest, float) -> String` – generate with temperature override. +- `close() -> void` – close provider. + +#### Dependencies +- `java.io.IOException` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` + +#### Exceptions / Errors +- `throws IOException` if underlying provider fails. +- Temperature override ignored by default; provider may override. + +#### Concurrency +- No synchronization; default implementation stateless. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..830b868 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,54 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:20:57Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Creates an AI generation provider instance based on a supplied provider key. + +#### Purpose +- Factory for `AiGenerationProvider` implementations. + +#### Type +- `class AiGenerationProviderFactory` +- `@ToString` via Lombok. +- No inheritance or interfaces. + +#### Input +- Constructor: none. +- `create(String providerName, LlamaCppJniConfig llamaConfig, AiPromptSupport promptSupport)` + - `providerName`: key, may be null or blank. + - `llamaConfig`: config for JNI provider. + - `promptSupport`: prompt lookup support. + +#### Output +- Returns a new `AiGenerationProvider` instance. +- Throws `IllegalArgumentException` for unknown providerName. + +#### Core logic +- If `providerName` is null or blank → return `MockAiGenerationProvider`. +- `switch` on `providerName`: + - `"mock"` → `MockAiGenerationProvider`. + - `"llamacpp-jni"` → `LlamaCppJniAiGenerationProvider(llamaConfig, promptSupport)`. + - default → throw `IllegalArgumentException`. + +#### Public API +- `AiGenerationProviderFactory()` – no‑op constructor. +- `create(String, LlamaCppJniConfig, AiPromptSupport) -> AiGenerationProvider` – selects provider. + +#### Dependencies +- `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper` +- `net.ladenthin.maven.llamacpp.aiindex.provider.MockAiGenerationProvider` +- `net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniAiGenerationProvider` +- `net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider` + +#### Exceptions / Errors +- `IllegalArgumentException` – “Unsupported AI provider: ”. + +#### Concurrency +- No thread‑safety concerns; instance field is immutable helper. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..7612941 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,65 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:22:42Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates text with a local llama.cpp model via JNI. + +#### Purpose +- Implements local text generation for AiGenerationProvider +- Lazy‑initializes llama.cpp model to reduce startup cost + +#### Type +- final class `LlamaCppJniAiGenerationProvider` +- implements `AiGenerationProvider`, `AutoCloseable` +- fields: `LlamaCppJniConfig config`; `@Nullable LlamaModel model`; `AiPromptSupport promptSupport`; `AiCompletionParser completionParser` + +#### Input +- Constructor receives `LlamaCppJniConfig config`, `AiPromptSupport promptSupport` +- `generate(request)` consumes `AiGenerationRequest` +- `generate(request, temperatureOverride)` consumes `AiGenerationRequest`, `float temperatureOverride` + +#### Output +- `generate(...)` returns generated text `String` +- `close()` frees native llama model resources + +#### Core logic +- Lazily create `LlamaModel` with `ModelParameters` derived from `config` +- Build request prompt via `promptSupport.buildPrompt(request)` +- Wrap prompt in a user `Pair` message list +- Configure `InferenceParameters` with chat template, temperature, max output tokens, top‑p, top‑k, repeat penalty, stop strings +- Call `model.chatCompleteText(inferenceParameters)` to get raw completion +- Parse raw completion through `AiCompletionParser.parseCompletion` + +#### Public API +- `LlamaCppJniAiGenerationProvider(config, promptSupport)` → initializes provider +- `generate(request)` → returns text, uses default temperature +- `generate(request, temperatureOverride)` → returns text with overridden temperature +- `close()` → releases native model + +#### Dependencies +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` +- `java.io.IOException` +- `java.util.ArrayList` +- `java.util.Collections` +- `java.util.List` +- `java.util.Objects` +- `lombok.ToString` + +#### Exceptions / Errors +- `generate` declares `throws IOException` +- Constructor enforces non‑null `config` and `promptSupport` via `Objects.requireNonNull` + +#### Concurrency +- `model()` performs unsynchronized lazy initialization; not thread‑safe +- Provider assumes single‑threaded usage or external synchronization diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..87108d2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,75 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:25:29Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Immutable config holder for llama.cpp JNI provider parameters. + +#### Purpose +- Supplies configuration to llama.cpp JNI provider +- Defines model, inference, and sampling options + +#### Type +- `final class LlamaCppJniConfig` +- Annotations: `@ConvertToRecord`, `@ToString`, `@EqualsAndHashCode` +- Fields: `libraryPath`, `modelPath`, `contextSize`, `maxOutputTokens`, `temperature`, `threads`, `topP`, `topK`, `repeatPenalty`, `chatTemplateEnableThinking`, `stopStrings` + +#### Input +- Constructor parameters: + - `String libraryPath` (native lib path, may be null) + - `String modelPath` (GGUF model file, non‑null) + - `int contextSize` (context window tokens) + - `int maxOutputTokens` (max tokens per call) + - `float temperature` (sampling temperature) + - `int threads` (CPU threads) + - `float topP` (nucleus threshold) + - `int topK` (top‑k limit) + - `float repeatPenalty` (repetition penalty) + - `boolean chatTemplateEnableThinking` (chat‑template mode) + - `List stopStrings` (may be null → empty list) + +#### Output +- Getter methods expose stored values: + - `libraryPath()` + - `modelPath()` + - `contextSize()` + - `maxOutputTokens()` + - `temperature()` + - `threads()` + - `topP()` + - `topK()` + - `repeatPenalty()` + - `chatTemplateEnableThinking()` + - `stopStrings()` returns unmodifiable list + +#### Core logic +- Constructor enforces `modelPath` non‑null +- Normalizes `stopStrings` to `Collections.emptyList()` if null + +#### Public API +- `libraryPath() -> String` (native lib path) +- `modelPath() -> String` (model file path) +- `contextSize() -> int` (context tokens) +- `maxOutputTokens() -> int` (max output tokens) +- `temperature() -> float` (sampling temp) +- `threads() -> int` (CPU threads) +- `topP() -> float` (top‑p) +- `topK() -> int` (top‑k) +- `repeatPenalty() -> float` (repetition penalty) +- `chatTemplateEnableThinking() -> boolean` (chat‑template mode) +- `stopStrings() -> List` (unmodifiable stop strings) + +#### Dependencies +- `java.util.Collections`, `java.util.List`, `java.util.Objects` +- `lombok.EqualsAndHashCode`, `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord` + +#### Exceptions / Errors +- Constructor throws `NullPointerException` if `modelPath` is null + +#### Concurrency +- Immutable after construction; thread‑safe access to all fields. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..84808e3 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,50 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:28:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides deterministic AI summary mock for testing purposes. + +#### Purpose +- Supplies a mock AiGenerationProvider for unit tests. +- Returns a predictable summary string for a given source file. + +#### Type +- `class MockAiGenerationProvider` +- `public` +- implements `AiGenerationProvider` +- annotated with `@ToString` (Lombok) + +#### Input +- `AiGenerationRequest request` +- `request.sourceFile()` yields a `Path` + +#### Output +- `String` in format `"Mock summary for "` +- May throw `IOException` + +#### Core logic +- Retrieve source file path from request. +- Resolve file name: `file.getFileName()` or fallback to full path string. +- Concatenate prefix with file name and return. + +#### Public API +- `generate(AiGenerationRequest) -> String` – returns deterministic mock summary. + +#### Dependencies +- `java.io.IOException` +- `java.nio.file.Path` +- `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider` + +#### Exceptions / Errors +- Declares `throws IOException`; no internal error handling. +- Handles null `fileNamePath` with fallback to full path string. + +#### Concurrency +- No synchronization; class is stateless and thread‑safe. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..6947e68 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,59 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:32:48Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> Provides pluggable AI text generation for Maven‑based llama.cpp indexing, featuring a JNI local provider, a deterministic mock, and parsing utilities to clean LLM output. + +#### Purpose +- Deliver AI generation services for Maven llama.cpp indexer. +- Support local (JNI) and mock backends. + +#### Responsibilities +- **Parsing** – Extract final answer from raw completion (AiCompletionParser). +- **Contract** – Define generation API (`AiGenerationProvider`). +- **Factory** – Create provider instances from a key (`AiGenerationProviderFactory`). +- **JNI Implementation** – Lazily load llama.cpp, build prompts, run inference (`LlamaCppJniAiGenerationProvider`). +- **Configuration** – Immutable holder for JNI parameters (`LlamaCppJniConfig`). +- **Mocking** – Deterministic summary for tests (`MockAiGenerationProvider`). + +#### Key units +- `AiCompletionParser`: strips Gemma‑4 thinking blocks, returns clean string. +- `AiGenerationProvider`: interface for generating text, with default temperature/close logic. +- `AiGenerationProviderFactory`: selects provider (`"mock"` → `MockAiGenerationProvider`, `"llamacpp-jni"` → `LlamaCppJniAiGenerationProvider`). +- `LlamaCppJniAiGenerationProvider`: builds prompt via `AiPromptSupport`, configures `InferenceParameters`, invokes `model.chatCompleteText`, parses result. +- `LlamaCppJniConfig`: record‑style immutable config (paths, context, tokens, temperature, threads, top‑p/k, repeat penalty, stop strings). +- `MockAiGenerationProvider`: returns `"Mock summary for "` from `AiGenerationRequest`. + +#### Data flow +1. `AiGenerationProviderFactory.create` → provider instance. +2. Caller passes `AiGenerationRequest` (prompt key, source, header). +3. JNI provider builds prompt (`promptSupport.buildPrompt`). +4. Wraps prompt in chat message pair, configures `InferenceParameters` from `LlamaCppJniConfig`. +5. Calls `model.chatCompleteText` → raw completion. +6. `AiCompletionParser.parseCompletion` → trimmed answer. +7. Result returned to caller. + +#### Dependencies +- `net.ladenthin.llama` (model, parameters, Pair). +- `lombok` for annotations. +- `jspecify.annotations.Nullable`. +- Internal: `AiGenerationRequest`, `AiPromptSupport`, `Java8CompatibilityHelper`. +- Native JNI library path supplied via `LlamaCppJniConfig`. + +#### Cross-cutting +- **Immutability**: `LlamaCppJniConfig` and most helper classes are immutable, thread‑safe. +- **Exception handling**: `IOException` for provider failures, `IllegalArgumentException` for unknown provider keys. +- **Concurrency**: `AiCompletionParser` is stateless; `LlamaCppJniAiGenerationProvider` performs unsynchronized lazy initialization, not thread‑safe by default. +- **Factory pattern**: Centralizes provider creation, allows easy extension. +- **Logging/ToString**: Lombok `@ToString` on key classes for debugging. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..86099c6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,57 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:38:54Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> Generates index documentation fields by selecting AI prompts and executing llama.cpp or a mock provider to produce clean, model‑driven text. + +#### Purpose +- Configure AI prompts and models for Maven index generation. +- Execute AI generation via llama.cpp JNI or deterministic mock. + +#### Responsibilities +- **Configuration** – parse `` and `` XML; expose `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`. +- **Selection** – `AiFieldGenerationSelector` picks the first matching config for a file’s extension. +- **Provider** – `AiGenerationProviderFactory` creates `MockAiGenerationProvider` or `LlamaCppJniAiGenerationProvider`. +- **Parsing** – `AiCompletionParser` extracts the final answer from raw completions. +- **Prompt building** – `AiPromptSupport` (used by JNI provider) creates prompt strings for the model. + +#### Key units +- **AiFieldGenerationConfig** – bean with prompt key, model key, optional file‑extension filters. +- **AiGenerationConfig** – concrete AI parameters: model path, context, temperature, etc.; drives the generation engine. +- **AiModelDefinition** – reusable definition referenced by key; converted by `AiModelDefinitionSupport`. +- **AiGenerationProvider** – interface for generating text; default temperature/close logic. +- **AiGenerationProviderFactory** – selects provider implementation based on key. +- **LlamaCppJniAiGenerationProvider** – builds prompt, configures `InferenceParameters`, calls `model.chatCompleteText`. +- **MockAiGenerationProvider** – deterministic summary for tests. +- **AiCompletionParser** – removes Gemma‑4 thinking blocks, returns clean string. + +#### Data flow +1. Maven reads `` & `` → creates config objects. +2. `AiModelDefinitionSupport` builds a read‑only map `definitionKey → AiGenerationConfig`. +3. During run, `AiFieldGenerationSelector` selects the applicable `AiFieldGenerationConfig` for a source file. +4. Selected config’s model key resolves to an `AiGenerationConfig` via the support map. +5. `AiGenerationProviderFactory.create` returns the provider. +6. Caller submits `AiGenerationRequest` (prompt key, source, header). +7. JNI provider builds prompt, wraps in chat messages, configures `InferenceParameters`, invokes `model.chatCompleteText`. +8. Raw completion is parsed by `AiCompletionParser` → cleaned answer returned. + +#### Dependencies +- Java collections (`List`, `Map`). +- Lombok `@ToString`. +- `org.jspecify.annotations.Nullable`. +- `net.ladenthin.llama` model, parameters, and `Pair` classes. +- Native JNI library via `LlamaCppJniConfig`. +- Internal helpers: `Java8CompatibilityHelper`, `AiPromptSupport`, `AiGenerationRequest`. + +#### Cross-cutting +- **Immutability** – config objects immutable after construction; mutable setters expose defensive copies. +- **Thread‑safety** – JNI provider performs lazy, unsynchronized initialization; parser and mock provider are stateless. +- **Exception handling** – `IOException` for JNI failures, `IllegalArgumentException` for unknown provider keys. +- **Factory pattern** – centralizes provider creation. +- **Logging** – consistent `@ToString` annotations across beans. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..963e0f2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,54 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:40:49Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> Generates AI‑driven index fields for Maven projects using llama.cpp or a mock provider, converting configured prompts into clean, model‑produced text for documentation. + +#### Purpose +- Automate generation of index documentation fields via AI prompts. +- Support deterministic testing with a mock provider alongside live llama.cpp execution. + +#### Responsibilities +- **Configuration** – parse XML `` & `` into beans (`AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`). +- **Selection** – `AiFieldGenerationSelector` chooses the applicable config per source file extension. +- **Provider Creation** – `AiGenerationProviderFactory` supplies either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. +- **Prompt Building & Parsing** – `AiPromptSupport` constructs prompts; `AiCompletionParser` extracts clean answers from raw completions. + +#### Key units +- **AiFieldGenerationConfig** – immutable bean with prompt key, model key, and optional file‑extension filters. +- **AiGenerationConfig** – concrete AI settings (model path, context size, temperature). +- **AiModelDefinition** – reusable definition referenced by key; mapped by `AiModelDefinitionSupport`. +- **AiGenerationProvider** – interface for generating text; implemented by JNI and mock providers. +- **LlamaCppJniAiGenerationProvider** – builds chat messages, configures `InferenceParameters`, calls `model.chatCompleteText`. +- **MockAiGenerationProvider** – deterministic summaries for unit tests. +- **AiCompletionParser** – strips Gemma‑4 thinking blocks, returns clean string. +- **AiFieldGenerationSelector** – matches file extensions to the first matching `AiFieldGenerationConfig`. + +#### Data flow +1. Maven loads `` and `` XML → constructs config objects. +2. `AiModelDefinitionSupport` creates a read‑only map `definitionKey → AiGenerationConfig`. +3. During execution, `AiFieldGenerationSelector` selects the config applicable to the source file. +4. Selected config’s model key resolves to an `AiGenerationConfig`. +5. `AiGenerationProviderFactory.create` returns the appropriate provider. +6. Caller issues `AiGenerationRequest` (prompt key, source, header). +7. JNI provider builds prompt, configures `InferenceParameters`, invokes `model.chatCompleteText`. +8. `AiCompletionParser` cleans the raw completion → final answer returned. + +#### Dependencies +- Java collections (`List`, `Map`), Lombok `@ToString`, `org.jspecify.annotations.Nullable`. +- `net.ladenthin.llama` model and parameter classes. +- Native JNI library via `LlamaCppJniConfig`. +- Internal helpers: `Java8CompatibilityHelper`, `AiPromptSupport`, `AiGenerationRequest`. + +#### Cross-cutting +- **Immutability** – configuration beans immutable after construction; defensive copies in setters. +- **Thread‑safety** – JNI provider lazily initializes the model without synchronization; parser and mock provider are stateless. +- **Exception handling** – `IOException` for JNI errors, `IllegalArgumentException` for unknown provider keys. +- **Factory pattern** – centralizes provider creation in `AiGenerationProviderFactory`. +- **Logging & Debugging** – consistent `@ToString` annotations across all beans for traceability. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..ad6c583 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,54 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:42:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> Generates AI‑driven index fields for Maven projects, converting configured prompts into clean, model‑produced text for documentation. + +#### Purpose +- Automate generation of index documentation fields via AI prompts. +- Support deterministic testing with a mock provider alongside live llama.cpp execution. + +#### Responsibilities +- **Configuration** – parse XML `` & `` into beans (`AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`). +- **Selection** – `AiFieldGenerationSelector` chooses applicable config per source file extension. +- **Provider Creation** – `AiGenerationProviderFactory` supplies either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. +- **Prompt Building & Parsing** – `AiPromptSupport` constructs prompts; `AiCompletionParser` extracts clean answers from raw completions. + +#### Key units +- **AiFieldGenerationConfig** – immutable bean with prompt key, model key, optional file‑extension filters. +- **AiGenerationConfig** – concrete AI settings (model path, context size, temperature). +- **AiModelDefinition** – reusable definition referenced by key; mapped by `AiModelDefinitionSupport`. +- **AiGenerationProvider** – interface for generating text; implemented by JNI and mock providers. +- **LlamaCppJniAiGenerationProvider** – builds chat messages, configures `InferenceParameters`, calls `model.chatCompleteText`. +- **MockAiGenerationProvider** – deterministic summaries for unit tests. +- **AiCompletionParser** – strips Gemma‑4 thinking blocks, returns clean string. +- **AiFieldGenerationSelector** – matches file extensions to the first matching `AiFieldGenerationConfig`. + +#### Data flow +1. Maven reads `` & `` XML → constructs config objects. +2. `AiModelDefinitionSupport` creates a read‑only map `definitionKey → AiGenerationConfig`. +3. During execution, `AiFieldGenerationSelector` selects config applicable to the source file. +4. Selected config’s model key resolves to an `AiGenerationConfig`. +5. `AiGenerationProviderFactory.create` returns the appropriate provider. +6. Caller issues `AiGenerationRequest` (prompt key, source, header). +7. JNI provider builds prompt, configures `InferenceParameters`, invokes `model.chatCompleteText`. +8. `AiCompletionParser` cleans raw completion → final answer returned. + +#### Dependencies +- Java collections (`List`, `Map`), Lombok `@ToString`, `org.jspecify.annotations.Nullable`. +- `net.ladenthin.llama` model and parameter classes. +- Native JNI library via `LlamaCppJniConfig`. +- Internal helpers: `Java8CompatibilityHelper`, `AiPromptSupport`, `AiGenerationRequest`. + +#### Cross-cutting +- **Immutability** – configuration beans immutable after construction; defensive copies in setters. +- **Thread‑safety** – JNI provider lazily initializes the model without synchronization; parser and mock provider are stateless. +- **Exception handling** – `IOException` for JNI errors, `IllegalArgumentException` for unknown provider keys. +- **Factory pattern** – centralizes provider creation in `AiGenerationProviderFactory`. +- **Logging & Debugging** – consistent `@ToString` annotations across all beans for traceability. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/package.ai.md new file mode 100644 index 0000000..31a32bb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/net/package.ai.md @@ -0,0 +1,55 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:44:24Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> Generates AI‑driven index fields for Maven projects, converting configured prompts into clean, model‑produced text for documentation. + +#### Purpose +- Automates creation of documentation index fields via AI prompts. +- Supports deterministic testing with a mock provider alongside live llama.cpp execution. + +#### Responsibilities +- **Configuration** – parse `` & `` XML into immutable beans (`AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`). +- **Selection** – `AiFieldGenerationSelector` matches file‑extension filters to the first applicable config. +- **Provider Creation** – `AiGenerationProviderFactory` supplies `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. +- **Prompt Handling** – `AiPromptSupport` builds prompts; `AiCompletionParser` extracts clean answers from raw completions. + +#### Key units +- `AiFieldGenerationConfig`: prompt key, model key, optional file‑extension filters. +- `AiGenerationConfig`: model path, context size, temperature. +- `AiModelDefinition`: reusable model definition referenced by key. +- `AiGenerationProvider`: interface; implementations include `LlamaCppJniAiGenerationProvider` and `MockAiGenerationProvider`. +- `LlamaCppJniAiGenerationProvider`: configures `InferenceParameters`, calls `model.chatCompleteText`. +- `MockAiGenerationProvider`: deterministic summaries for unit tests. +- `AiCompletionParser`: removes Gemma‑4 thinking blocks, returns clean string. +- `AiFieldGenerationSelector`: matches source file extensions to the first matching `AiFieldGenerationConfig`. +- `AiPromptSupport`: constructs prompt text from configuration. + +#### Data flow +1. Maven reads XML → constructs config objects. +2. `AiModelDefinitionSupport` maps definition keys to `AiGenerationConfig`. +3. During execution, `AiFieldGenerationSelector` selects applicable config for a source file. +4. Selected config’s model key retrieves an `AiGenerationConfig`. +5. `AiGenerationProviderFactory.create` provides the appropriate provider. +6. Caller submits `AiGenerationRequest` (prompt key, source, header). +7. JNI provider builds prompt, configures `InferenceParameters`, invokes `model.chatCompleteText`. +8. `AiCompletionParser` cleans raw completion → final answer returned. + +#### Dependencies +- Java collections (`List`, `Map`), Lombok `@ToString`, `org.jspecify.annotations.Nullable`. +- `net.ladenthin.llama` model and parameter classes. +- Native JNI library via `LlamaCppJniConfig`. +- Internal helpers: `Java8CompatibilityHelper`, `AiPromptSupport`, `AiGenerationRequest`. + +#### Cross-cutting +- **Immutability** – configuration beans are immutable after construction; defensive copies in setters. +- **Thread‑safety** – JNI provider lazily initializes the model without synchronization; parser and mock provider are stateless. +- **Exception handling** – `IOException` for JNI errors, `IllegalArgumentException` for unknown provider keys. +- **Factory pattern** – `AiGenerationProviderFactory` centralizes provider creation. +- **Logging & Debugging** – consistent `@ToString` annotations across all beans for traceability. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/package.ai.md new file mode 100644 index 0000000..445dcc1 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/java/package.ai.md @@ -0,0 +1,56 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:46:09Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> Generates AI‑driven index fields for Maven projects, converting configured prompts into clean, model‑produced text for documentation. + +#### Purpose +- Automates creation of documentation index fields via AI prompts. +- Supports deterministic testing with a mock provider and live llama.cpp execution. + +#### Responsibilities +- **Configuration** – parse `` & `` XML into immutable beans (`AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`). +- **Selection** – `AiFieldGenerationSelector` matches file‑extension filters to the first applicable config. +- **Provider Creation** – `AiGenerationProviderFactory` supplies `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. +- **Prompt Handling** – `AiPromptSupport` builds prompts; `AiCompletionParser` extracts clean answers from raw completions. + +#### Key units +- `AiFieldGenerationConfig`: prompt key, model key, optional file‑extension filters. +- `AiGenerationConfig`: model path, context size, temperature. +- `AiModelDefinition`: reusable model definition referenced by key. +- `AiGenerationProvider`: interface; implementations include `LlamaCppJniAiGenerationProvider` and `MockAiGenerationProvider`. +- `LlamaCppJniAiGenerationProvider`: configures `InferenceParameters`, calls `model.chatCompleteText`. +- `MockAiGenerationProvider`: deterministic summaries for unit tests. +- `AiCompletionParser`: removes Gemma‑4 thinking blocks, returns clean string. +- `AiFieldGenerationSelector`: matches source file extensions to the first matching `AiFieldGenerationConfig`. +- `AiPromptSupport`: constructs prompt text from configuration. + +#### Data flow +1. Maven reads XML → constructs config objects. +2. `AiModelDefinitionSupport` maps definition keys to `AiGenerationConfig`. +3. During execution, `AiFieldGenerationSelector` selects applicable config for a source file. +4. Selected config’s model key retrieves an `AiGenerationConfig`. +5. `AiGenerationProviderFactory.create` supplies the appropriate provider. +6. Caller submits `AiGenerationRequest` (prompt key, source, header). +7. JNI provider builds prompt, configures `InferenceParameters`, invokes `model.chatCompleteText`. +8. `AiCompletionParser` cleans raw completion → final answer returned. + +#### Dependencies +- Java collections (`List`, `Map`). +- Lombok `@ToString`, `org.jspecify.annotations.Nullable`. +- `net.ladenthin.llama` model and parameter classes. +- Native JNI library via `LlamaCppJniConfig`. +- Internal helpers: `Java8CompatibilityHelper`, `AiPromptSupport`, `AiGenerationRequest`. + +#### Cross-cutting +- **Immutability** – configuration beans are immutable after construction. +- **Thread‑safety** – JNI provider lazily initializes the model without synchronization. +- **Exception handling** – `IOException` for JNI errors, `IllegalArgumentException` for unknown provider keys. +- **Factory pattern** – `AiGenerationProviderFactory` centralizes provider creation. +- **Logging & debugging** – consistent `@ToString` annotations across all beans for traceability. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/package.ai.md new file mode 100644 index 0000000..d9e0da6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/main/package.ai.md @@ -0,0 +1,54 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:48:28Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Generates AI‑based documentation index fields for Maven projects, translating XML configuration into prompts and extracting clean model completions. + +#### Purpose +- Automates creation of AI‑driven index fields for Maven documentation. +- Supports deterministic testing and live llama.cpp execution. + +#### Responsibilities +- **Configuration** – parse `` & `` XML into immutable beans (`AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`). +- **Selection** – `AiFieldGenerationSelector` matches file‑extension filters to the first applicable config. +- **Provider Creation** – `AiGenerationProviderFactory` supplies `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. +- **Prompt Handling** – `AiPromptSupport` builds prompts; `AiCompletionParser` extracts clean answers from raw completions. + +#### Key units +- `AiFieldGenerationConfig` – prompt key, model key, optional file‑extension filters. +- `AiGenerationConfig` – model path, context size, temperature. +- `AiModelDefinition` – reusable model definition referenced by key. +- `AiGenerationProvider` – interface; implementations `LlamaCppJniAiGenerationProvider` and `MockAiGenerationProvider`. +- `AiCompletionParser` – removes Gemma‑4 thinking blocks, returns clean string. +- `AiFieldGenerationSelector` – matches source file extensions to the first matching config. +- `AiPromptSupport` – constructs prompt text from configuration. + +#### Data flow +1. Maven parses XML → constructs config beans. +2. `AiModelDefinitionSupport` maps keys to `AiGenerationConfig`. +3. Execution: `AiFieldGenerationSelector` picks applicable config for a source file. +4. Selected config’s model key yields `AiGenerationConfig`. +5. `AiGenerationProviderFactory.create` supplies the appropriate provider. +6. Caller submits `AiGenerationRequest` (prompt key, source, header). +7. JNI provider builds prompt, configures `InferenceParameters`, calls `model.chatCompleteText`. +8. `AiCompletionParser` cleans raw completion → final answer returned. + +#### Dependencies +- Java collections (`List`, `Map`). +- Lombok `@ToString`, `org.jspecify.annotations.Nullable`. +- `net.ladenthin.llama` model and parameter classes. +- Native JNI via `LlamaCppJniConfig`. +- Internal helpers: `Java8CompatibilityHelper`, `AiPromptSupport`, `AiGenerationRequest`. + +#### Cross-cutting +- Immutability of configuration beans. +- Thread‑safety: JNI provider lazily initializes model. +- Exception handling: `IOException` for JNI errors, `IllegalArgumentException` for unknown provider keys. +- Factory pattern: `AiGenerationProviderFactory` centralizes provider creation. +- Consistent logging via `@ToString`. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/package.ai.md new file mode 100644 index 0000000..f696b08 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/package.ai.md @@ -0,0 +1,54 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:50:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Generates AI‑driven Maven documentation index fields by parsing XML config, selecting model definitions, and invoking llama.cpp for clean completions. + +#### Purpose +- Automates creation of AI‑driven index fields for Maven projects. +- Enables deterministic testing and live llama.cpp execution. + +#### Responsibilities +- **Configuration** – parse `` & `` XML into immutable beans (`AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`). +- **Selection** – `AiFieldGenerationSelector` matches file‑extension filters to the first applicable config. +- **Provider Creation** – `AiGenerationProviderFactory` supplies `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. +- **Prompt Handling** – `AiPromptSupport` builds prompts; `AiCompletionParser` extracts clean answers from raw completions. + +#### Key units +- `AiFieldGenerationConfig` – prompt key, model key, optional file‑extension filters. +- `AiGenerationConfig` – model path, context size, temperature. +- `AiModelDefinition` – reusable model definition referenced by key. +- `AiGenerationProvider` – interface; implementations `LlamaCppJniAiGenerationProvider` and `MockAiGenerationProvider`. +- `AiCompletionParser` – removes Gemma‑4 thinking blocks, returns clean string. +- `AiFieldGenerationSelector` – matches source file extensions to the first matching config. +- `AiPromptSupport` – constructs prompt text from configuration. + +#### Data flow +1. Maven parses XML → constructs config beans. +2. `AiModelDefinitionSupport` maps keys to `AiGenerationConfig`. +3. `AiFieldGenerationSelector` picks applicable config for a source file. +4. Selected config’s model key yields `AiGenerationConfig`. +5. `AiGenerationProviderFactory.create` supplies the appropriate provider. +6. Caller submits `AiGenerationRequest` (prompt key, source, header). +7. JNI provider builds prompt, configures `InferenceParameters`, calls `model.chatCompleteText`. +8. `AiCompletionParser` cleans raw completion → final answer returned. + +#### Dependencies +- Java collections (`List`, `Map`). +- Lombok `@ToString`, `org.jspecify.annotations.Nullable`. +- `net.ladenthin.llama` model and parameter classes. +- Native JNI via `LlamaCppJniConfig`. +- Internal helpers: `Java8CompatibilityHelper`, `AiPromptSupport`, `AiGenerationRequest`. + +#### Cross-cutting +- Immutability of configuration beans. +- Thread‑safety: JNI provider lazily initializes model. +- Exception handling: `IOException` for JNI errors, `IllegalArgumentException` for unknown provider keys. +- Factory pattern: `AiGenerationProviderFactory` centralizes provider creation. +- Consistent logging via Lombok `@ToString`. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/project.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/project.ai.md new file mode 100644 index 0000000..5f04f9e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v1/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: B269F9D9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:51:57Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The llamacpp‑ai‑index‑maven‑plugin translates XML configuration into AI prompts, selects model settings via a configurable mapping framework, and generates clean, model‑driven index fields for documentation. Core subsystems include a configuration package that maps model settings, an AI index package that orchestrates prompt selection and llama.cpp execution, and a provider package that offers pluggable providers such as a JNI local llama.cpp provider, a deterministic mock, and parsing utilities for cleaning LLM output. The plugin invokes llama.cpp locally or through the mock provider, then parses and sanitises the completion text before injecting it into the generated documentation index. This design enables developers to integrate AI‑generated index content into Maven projects while maintaining control over model selection and output formatting. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Provides a framework for configuring, selecting, and mapping AI model settings used by a Maven plugin to generate index fields. +- main/java/net/ladenthin/maven/llamacpp/aiindex — Enables Maven to generate index fields by selecting AI prompts and running llama.cpp locally or via a mock, producing clean text for documentation. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Provides pluggable AI text generation for Maven‑based llama.cpp indexing, featuring a JNI local provider, a deterministic mock, and parsing utilities to clean LLM output. +- main/java/net/ladenthin/maven/llamacpp — Generates index documentation fields by selecting AI prompts and executing llama.cpp or a mock provider to produce clean, model‑driven text. +- main/java/net/ladenthin/maven — Generates AI‑driven index fields for Maven projects using llama.cpp or a mock provider, converting configured prompts into clean, model‑produced text for documentation. +- main/java/net/ladenthin — Generates AI‑driven index fields for Maven projects, converting configured prompts into clean, model‑produced text for documentation. +- main/java/net — Generates AI‑driven index fields for Maven projects, converting configured prompts into clean, model‑produced text for documentation. +- main/java — Generates AI‑driven index fields for Maven projects, converting configured prompts into clean, model‑produced text for documentation. +- main — Generates AI‑based documentation index fields for Maven projects, translating XML configuration into prompts and extracting clean model completions. +- . — Generates AI‑driven Maven documentation index fields by parsing XML config, selecting model definitions, and invoking llama.cpp for clean completions. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..00b4f6a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,54 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:53:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines the configuration for a single AI field‑generation step, mapping a prompt key to a model key and optionally restricting it to file extensions. + +#### Purpose +- Configure a single AI generation step. +- Associate a prompt template with a model definition. + +#### Type +- `public class AiFieldGenerationConfig` – extends `Object`; annotated with `@ToString`, `@SuppressWarnings`. + +#### Input +- Constructor: `AiFieldGenerationConfig()`. +- Setters: `setPromptKey(String)`, `setAiDefinitionKey(String)`, `setFileExtensions(Collection)`. +- Maven injects values via setters. + +#### Output +- `getPromptKey()` → `String` – returns prompt key. +- `getAiDefinitionKey()` → `String` – returns model key. +- `getFileExtensions()` → `@Nullable List` – unmodifiable list or `null`. + +#### Core logic +- Defensive copy of incoming file extensions (`new ArrayList<>(fileExtensions)`). +- Return unmodifiable view (`Collections.unmodifiableList`) in getter. +- Null handling: `null` or empty treated as fallback. + +#### Public API +- `AiFieldGenerationConfig()` → void – default constructor. +- `String getPromptKey()` → prompt key. +- `void setPromptKey(String)` → set prompt key. +- `String getAiDefinitionKey()` → model key. +- `void setAiDefinitionKey(String)` → set model key. +- `@Nullable List getFileExtensions()` → list or null. +- `void setFileExtensions(Collection)` → copy list. + +#### Dependencies +- `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition` +- `net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinition` + +#### Exceptions / Errors +- No checked or unchecked exceptions thrown or caught. + +#### Concurrency +- None declared; class is mutable but no thread‑safety guarantees. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..0cf5fcb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,46 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:55:45Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the AI field generation configuration for a file by matching its extension, returning the first applicable entry or a fallback. + +#### Purpose +- Determines the `AiFieldGenerationConfig` that applies to a source file. +- Provides a language‑specific configuration or a generic fallback. + +#### Type +class, final; Lombok `@ToString`; in package `net.ladenthin.maven.llamacpp.aiindex.config`. + +#### Input +- `Iterable configs` (may contain `null` entries) +- `String fileName` (e.g., `"Foo.java"`) + +#### Output +- `@Nullable AiFieldGenerationConfig` – first matching entry, fallback, or `null`. + +#### Core logic +- Initialize `fallback = null`. +- Iterate over `configs`; skip if `config == null`. +- Retrieve `config.getFileExtensions()`. +- If the extension list is `null` or empty, assign as `fallback` if unset. +- Else iterate extensions; if `fileName.endsWith(extension)` return `config`. +- After loop, return `fallback`. + +#### Public API +- `selectForFileName(Iterable, String) -> @Nullable AiFieldGenerationConfig` returns the matching or fallback config. + +#### Dependencies +- `AiFieldGenerationConfig` +- `java.util.List` +- `lombok.ToString` + +#### Exceptions / Errors +- None thrown; handles `null` config entries gracefully. + +#### Concurrency +- Thread‑safe: only local variables are used, no shared mutable state. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..2ae11ba --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,62 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T21:57:38Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Mutable configuration carrying AI generation parameters between Maven config and AI provider implementations. + +#### Purpose +- Stores AI model path, sampling, retry, and prompt limits. +- Exposes getters/setters for Maven plugin configuration. + +#### Type +`class AiGenerationConfig; public; Lombok @ToString; no equals/hashCode; mutable JavaBean.` + +#### Input +- `new AiGenerationConfig()` (no args). +- `setModelPath(String)`, `setContextSize(int)`, `setMaxOutputTokens(int)`, `setTemperature(float)`, `setThreads(int)`, `setCharsPerToken(int)`, `setMaxInputChars(int)`, `setWarnOnTrim(boolean)`, `setMaxRetries(int)`, `setRetryTemperatureIncrement(float)`, `setTopP(float)`, `setTopK(int)`, `setRepeatPenalty(float)`, `setChatTemplateEnableThinking(boolean)`, `setStopStrings(List)`. + +#### Output +- `getModelPath() -> String`. +- `getContextSize() -> int`. +- `getMaxOutputTokens() -> int`. +- `getTemperature() -> float`. +- `getThreads() -> int`. +- `getCharsPerToken() -> int`. +- `getMaxInputChars() -> int`. +- `isWarnOnTrim() -> boolean`. +- `getMaxRetries() -> int`. +- `getRetryTemperatureIncrement() -> float`. +- `getTopP() -> float`. +- `getTopK() -> int`. +- `getRepeatPenalty() -> float`. +- `isChatTemplateEnableThinking() -> boolean`. +- `getStopStrings() -> @Nullable List (unmodifiable)`. + +#### Core logic +- Declares default constants for context size, output tokens, temperature, threads, input char limits, etc. +- Initializes fields with default values. +- Provides mutable JavaBean setters that update fields. +- `getStopStrings()` returns `Collections.unmodifiableList` of internal list. +- `setStopStrings(null)` resets to an empty `ArrayList`. +- `@ToString` generates a diagnostic string over all fields. + +#### Public API +- `getModelPath() -> String returns GGUF model path`. +- `setModelPath(String) -> void assigns model file path`. +- `getContextSize() -> int returns token window size`. +- `setContextSize(int) -> void sets context size`. +- `getMaxOutputTokens() -> int returns max output tokens`. +- `setMaxOutputTokens(int) -> void sets max output tokens`. +- `getTemperature() -> float returns sampling temperature`. +- `setTemperature(float) -> void sets sampling temperature`. +- `getThreads() -> int returns CPU thread count`. +- `setThreads(int) -> void sets thread count`. +- `getCharsPerToken() -> int returns chars‑per‑token ratio`. +- `setCharsPerToken(int) -> void sets ratio`. +- `getMaxInputChars() -> int returns max input chars`. +- `setMaxInputChars(int) -> diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..0716eec --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,13 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:02:27Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines AI generation scopes: file or package + +#### Purpose +- Specifies the granularity of AI generation: FILE_SUMMARY or PACKAGE_SUMMARY. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..8c2f8b5 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,105 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:03:03Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines mutable configuration for an LLM model used by a Maven plugin. + +#### Purpose +- Holds model lookup key and parameters +- Allows reuse across field‑generation goals + +#### Type +- public class AiModelDefinition; Lombok @ToString; defaults from AiGenerationConfig + +#### Input +- Constructor AiModelDefinition() – no‑op +- setKey(String) – assigns lookup key +- setModelPath(String) – assigns GGUF model path +- setContextSize(int) – assigns context window size +- setMaxOutputTokens(int) – assigns max tokens per inference +- setTemperature(float) – assigns base temperature +- setThreads(int) – assigns CPU thread count +- setCharsPerToken(int) – assigns char‑per‑token ratio +- setWarnOnTrim(boolean) – enables trim warning +- setMaxRetries(int) – assigns retry limit +- setRetryTemperatureIncrement(float) – sets retry temperature delta +- setTopP(float) – assigns nucleus‑sampling threshold +- setTopK(int) – assigns top‑k limit +- setRepeatPenalty(float) – assigns repetition penalty +- setChatTemplateEnableThinking(boolean) – toggles chat‑template thinking +- setStopStrings(Collection) – assigns stop‑strings list + +#### Output +- getKey() -> lookup key +- getModelPath() -> model file path +- getContextSize() -> context token count +- getMaxOutputTokens() -> max output tokens +- getTemperature() -> sampling temperature +- getThreads() -> CPU thread count +- getCharsPerToken() -> char‑per‑token value +- isWarnOnTrim() -> trim‑warning flag +- getMaxRetries() -> retry limit +- getRetryTemperatureIncrement() -> retry temperature delta +- getTopP() -> nucleus‑sampling threshold +- getTopK() -> top‑k limit +- getRepeatPenalty() -> repetition penalty +- isChatTemplateEnableThinking() -> chat‑template flag +- getStopStrings() -> immutable stop‑string list + +#### Core logic +- Initializes numeric fields with AiGenerationConfig defaults +- Stores fields; setters perform shallow assignments +- getStopStrings() returns unmodifiable view to preserve immutability + +#### Public API +- AiModelDefinition() -> no‑op constructor +- getKey() -> String key lookup +- setKey(String) -> assign key +- getModelPath() -> String path +- setModelPath(String) -> assign path +- getContextSize() -> int context size +- setContextSize(int) -> assign context size +- getMaxOutputTokens() -> int max output +- setMaxOutputTokens(int) -> assign max output +- getTemperature() -> float temperature +- setTemperature(float) -> assign temperature +- getThreads() -> int thread count +- setThreads(int) -> assign threads +- getCharsPerToken() -> int chars per token +- setCharsPerToken(int) -> assign chars per token +- isWarnOnTrim() -> boolean trim warning flag +- setWarnOnTrim(boolean) -> set trim warning flag +- getMaxRetries() -> int retries +- setMaxRetries(int) -> set retry limit +- getRetryTemperatureIncrement() -> float retry delta +- setRetryTemperatureIncrement(float) -> set retry delta +- getTopP() -> float top‑p value +- setTopP(float) -> set top‑p value +- getTopK() -> int top‑k value +- setTopK(int) -> set top‑k value +- getRepeatPenalty() -> float repeat penalty +- setRepeatPenalty(float) -> set repeat penalty +- isChatTemplateEnableThinking() -> boolean chat template flag +- setChatTemplateEnableThinking(boolean) -> set chat template flag +- getStopStrings() -> List stop strings +- setStopStrings(Collection) -> assign stop strings + +#### Dependencies +- AiGenerationConfig +- java.util.ArrayList +- java.util.Collection +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- None declared; all setters accept null where allowed + +#### Concurrency +- No explicit thread‑safety mechanisms; instance is not immutable. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..19b6485 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,45 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:07:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> This class maps AI model definitions to ready‑to‑use generation configurations for the llama‑cpp AI plugin. + +#### Purpose +- Maps `AiModelDefinition` entries to `AiGenerationConfig` objects. +- Validates non‑null keys and provides eager lookup errors. + +#### Type +final class `AiModelDefinitionSupport`; Lombok `@ToString`; holds `configs` map and a `Java8CompatibilityHelper`. + +#### Input +- Constructor `AiModelDefinitionSupport(List definitions)` – list may be `null`/empty. +- `getConfig(String key)` – key must not be `null`. + +#### Output +- Constructor builds the internal `configs` map. +- `getConfig` returns the matching `AiGenerationConfig` or throws. + +#### Core logic +- **Constructor**: + - If `definitions` is `null`, create an empty map. + - Otherwise pre‑size a `HashMap` using `Java8CompatibilityHelper`. + - Iterate definitions; for each, `Objects.requireNonNull` on `definition.getKey()` with an index‑based message. + - Put `definition.getKey()` → `toConfig(definition)` into `configs`. +- **getConfig**: Retrieve config from `configs`; if `null`, throw `IllegalArgumentException` with `"Missing AI model definition for key: " + key`. +- **toConfig**: Instantiate `AiGenerationConfig` and copy all fields from `AiModelDefinition`. + +#### Public API +- `AiModelDefinitionSupport(List)` → builds lookup map. +- `getConfig(String)` → `AiGenerationConfig`; throws if key absent. + +#### Dependencies +`AiModelDefinition`, `AiGenerationConfig`, `Java8CompatibilityHelper`, `HashMap`, `List`, `Map`, `Objects`, Lombok `@ToString`. + +#### Exceptions / Errors +- Constructor: `NullPointerException` when any `definition.getKey()` is `null`. +- `getConfig`: `IllegalArgumentException` if key not found. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..a960b65 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,51 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:19:54Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Configures and maps AI field‑generation steps for Maven‑based projects, allowing field‑specific prompts, model definitions, and extension‑based selection. + +#### Purpose +- Central AI configuration provider for Maven Llama‑Cpp plugin. +- Supplies prompt‑model mappings, file‑extension filtering, and runtime generation settings. + +#### Responsibilities +- **Prompt‑Model mapping** – `AiFieldGenerationConfig` holds prompt key ↔ model key. +- **Extension selection** – `AiFieldGenerationSelector` resolves applicable config per file. +- **Runtime generation parameters** – `AiGenerationConfig` and `AiModelDefinition` expose model path, context, temperature, etc. +- **Definition lookup** – `AiModelDefinitionSupport` validates and retrieves `AiGenerationConfig` for a given key. + +#### Key units +- **AiFieldGenerationConfig** – mutable DTO for a single field‑generation step; defensive copies of file extensions. +- **AiFieldGenerationSelector** – static helper returning the first matching or fallback config for a filename. +- **AiGenerationConfig** – JavaBean holding generation hyper‑parameters; exposes unmodifiable stop‑string list. +- **AiModelDefinition** – mutable model definition mirroring `AiGenerationConfig`; used by plugin configuration. +- **AiModelDefinitionSupport** – constructs a lookup map of key → `AiGenerationConfig`; throws on missing keys. +- **AiGenerationKind** – enum defining FILE_SUMMARY or PACKAGE_SUMMARY scopes (unused in current flow). + +#### Data flow +1. Maven injects `AiFieldGenerationConfig` instances via setters. +2. `AiFieldGenerationSelector.selectForFileName()` chooses the config matching a source file’s extension. +3. `AiModelDefinitionSupport` builds a map from `AiModelDefinition` keys to `AiGenerationConfig`. +4. The chosen `AiGenerationConfig` drives the Llama‑Cpp AI provider during field generation. + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiModelDefinition`, `AiGenerationConfig`, `AiFieldGenerationSelector`. +- External: Lombok (`@ToString`), Java Collections (`ArrayList`, `Collections`, `List`, `Map`, `HashMap`), `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition`. + +#### Cross-cutting +- Defensive copying of mutable collections and returning unmodifiable views. +- Null handling: `null` or empty file extensions treated as fallbacks. +- Thread safety: selector uses local variables; other classes are mutable without synchronization. +- Lombok `@ToString` for diagnostics but no `equals`/`hashCode`. +- Consistent use of JavaBean getters/setters for Maven injection. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..45fc638 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,55 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:26:20Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> Provides a Maven‑based AI field‑generation framework with configurable prompt‑model mappings and pluggable Llama‑Cpp JNI or mock providers for text generation. + +#### Purpose +- Configure AI field generation for Maven Llama‑Cpp plugin. +- Expose pluggable Llama‑Cpp JNI or mock generation backends. + +#### Responsibilities +- **Configuration** – `AiFieldGenerationConfig`, `AiFieldGenerationSelector`, `AiGenerationConfig`, `AiModelDefinition`, `AiModelDefinitionSupport`. +- **Provider** – `AiCompletionParser`, `AiGenerationProvider`, `AiGenerationProviderFactory`, `LlamaCppJniAiGenerationProvider`, `LlamaCppJniConfig`, `MockAiGenerationProvider`. + +#### Key units +- `AiFieldGenerationConfig` – DTO for a single prompt‑model mapping, copies extensions. +- `AiFieldGenerationSelector` – static helper selecting the first matching config for a filename. +- `AiGenerationConfig` – JavaBean of hyper‑parameters, exposes unmodifiable stop strings. +- `AiModelDefinition` – mutable model definition mirroring `AiGenerationConfig`. +- `AiModelDefinitionSupport` – builds key → `AiGenerationConfig` map, validates keys. +- `AiGenerationProvider` – contract: `generate(AiGenerationRequest)` with optional temperature, `close()`. +- `AiGenerationProviderFactory` – selects provider implementation, defaults to `MockAiGenerationProvider`. +- `LlamaCppJniAiGenerationProvider` – lazily constructs `LlamaModel`, builds `InferenceParameters`, calls native `chatCompleteText`, parses result. +- `LlamaCppJniConfig` – immutable settings: library path, model path, context size, max output, sampling params, stop strings. +- `MockAiGenerationProvider` – deterministic summary `"Mock summary for "`. +- `AiCompletionParser` – removes `THINKING_BLOCK_*` markers, throws `IOException` on incomplete blocks. + +#### Data flow +1. Maven injects `AiFieldGenerationConfig` instances. +2. `AiFieldGenerationSelector.selectForFileName()` picks config by file extension. +3. `AiModelDefinitionSupport` maps `AiModelDefinition` keys to `AiGenerationConfig`. +4. `AiGenerationProviderFactory.create()` selects provider (JNI or mock). +5. Provider builds prompt via `AiPromptSupport`, constructs `InferenceParameters`. +6. Native `LlamaModel.chatCompleteText` executes. +7. `AiCompletionParser.parseCompletion()` strips internal reasoning blocks. +8. Final answer returned to caller. + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiModelDefinition`, `AiGenerationConfig`, `AiFieldGenerationSelector`, `AiModelDefinitionSupport`, `AiPromptSupport`. +- External: Lombok (`@ToString`, `@EqualsAndHashCode`), Java Collections (`List`, `Map`, `HashMap`), `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition`. +- Provider internals: `Java8CompatibilityHelper`, `InferenceParameters`, `ModelParameters`, `LlamaModel`. + +#### Cross-cutting +- Defensive copying and unmodifiable views for mutable collections. +- Null handling: empty/`null` extensions treated as fallbacks. +- Thread safety: selector uses local variables; config classes immutable after construction. +- Lombok for concise data classes. +- Consistent `IOException` for parsing or I/O errors. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..50a3c02 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,41 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:10:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses LLM completion text to strip internal thinking blocks and retrieve the final answer. + +#### Purpose +- Parses Gemma‑4 responses, removing internal chain‑of‑thought reasoning. +- Provides a clean answer string for AI indexing. + +#### Type +public class AiCompletionParser @ToString + +#### Input +- `parseCompletion(String response)` receives raw completion text, may be `null`. + +#### Output +- Returns a non‑null trimmed answer string. +- Throws `IOException` if a thinking block is opened but not closed. + +#### Core logic +- If `response` is `null`, return empty string. +- Find last index of `THINKING_BLOCK_END_MARKER`. +- If found, return substring after the end marker, trimmed. +- If not found but `THINKING_BLOCK_START_MARKER` exists, throw `IOException` with actionable message. +- Otherwise return trimmed `response`. + +#### Public API +- `parseCompletion(String response) -> String cleaned answer` (throws IOException if thinking block incomplete) + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` + +#### Exceptions / Errors +- `IOException` if `THINKING_BLOCK_START_MARKER` is present without a corresponding `THINKING_BLOCK_END_MARKER`; message suggests increasing token budget. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..db4d1d9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,41 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:11:47Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> AiGenerationProvider defines a pluggable backend that generates AI text from an AiGenerationRequest. + +#### Purpose +- Pluggable AI backend for generating text from AiGenerationRequest. +- Supports local llama.cpp or mock providers for testing. + +#### Type +- interface AiGenerationProvider extends AutoCloseable. + +#### Input +- `generate(AiGenerationRequest request)` – request includes prompt key, source file, source text, and current header. +- `generate(AiGenerationRequest request, float temperatureOverride)` – same request plus per‑call temperature. + +#### Output +- `String` – never `null`, may be blank if no tokens. +- `void close()` – default no‑op. + +#### Core logic +- `generate(request)` must produce text. +- `generate(request, temperatureOverride)` defaults to delegating to `generate(request)`. +- `close()` performs no operation. + +#### Public API +- `generate(AiGenerationRequest) -> String`: generates text with default sampling parameters. +- `generate(AiGenerationRequest, float) -> String`: generates text overriding temperature; defaults to `generate(request)`. +- `close() -> void`: closes the provider (no-op by default). + +#### Dependencies +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest + +#### Exceptions / Errors +- Both `generate` methods and `close` declare `throws IOException`. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..647aeff --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,44 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:13:22Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an `AiGenerationProvider` implementation by name. + +#### Purpose +- Instantiate the requested `AiGenerationProvider` based on a provider key. + +#### Type +- `class` `AiGenerationProviderFactory` (public) annotated with `@ToString`; holds a `Java8CompatibilityHelper` field. + +#### Input +- `String providerName` +- `LlamaCppJniConfig llamaConfig` +- `AiPromptSupport promptSupport` + +#### Output +- A newly created `AiGenerationProvider` instance +- Defaults to `MockAiGenerationProvider` when `providerName` is blank or `null` + +#### Core logic +- If `providerName` is `null` or blank → return `MockAiGenerationProvider` +- Switch on `providerName`: + - `"mock"` → return `MockAiGenerationProvider` + - `"llamacpp-jni"` → return `LlamaCppJniAiGenerationProvider(llamaConfig, promptSupport)` + - otherwise → throw `IllegalArgumentException("Unsupported AI provider: " + providerName)` + +#### Public API +- `create(String, LlamaCppJniConfig, AiPromptSupport) -> AiGenerationProvider` – creates provider instance + +#### Dependencies +- `Java8CompatibilityHelper`, `AiPromptSupport`, `LlamaCppJniConfig`, `MockAiGenerationProvider`, `LlamaCppJniAiGenerationProvider`, `AiGenerationProvider` + +#### Exceptions / Errors +- Throws `IllegalArgumentException` for unrecognized provider names + +#### Concurrency +- No threading or immutability concerns shown. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..f38f037 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,50 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:14:42Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides local AI text generation using llama.cpp via JNI, lazily loading a GGUF model and parsing chat completions. + +#### Purpose +- Supplies text completions for AI generation requests. +- Lazily loads and caches a native LlamaModel. + +#### Type +final class LlamaCppJniAiGenerationProvider implements AiGenerationProvider, AutoCloseable @ToString + +#### Input +- LlamaCppJniConfig config (modelPath, contextSize, threads, etc.) +- AiPromptSupport promptSupport +- AiGenerationRequest request +- Optional float temperatureOverride + +#### Output +- String completion +- closes native LlamaModel on close() + +#### Core logic +- `model()` lazily constructs `LlamaModel` with `ModelParameters` from config. +- `generate(request)` calls `generate(request, config.temperature())`. +- `generate(request, temp)` builds prompt via `promptSupport.buildPrompt`. +- Builds `InferenceParameters` with messages, temperature, NPredict, topP, topK, repeatPenalty, stopStrings. +- Calls `model().chatCompleteText(inferenceParameters)` and parses result with `AiCompletionParser.parseCompletion`. +- `close()` releases native resources if model is loaded. + +#### Public API +- generate(AiGenerationRequest) -> String produces completion with configured temperature +- generate(AiGenerationRequest, float) -> String produces completion with overridden temperature +- close() -> void releases native model + +#### Dependencies +- LlamaCppJniConfig, AiPromptSupport, AiGenerationRequest, AiCompletionParser, LlamaModel, InferenceParameters, ModelParameters, Pair + +#### Exceptions / Errors +- generate methods throw IOException if native call fails +- close() handles absent model gracefully + +#### Concurrency +- No thread‑safety guarantees; single‑thread use implied. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..34418e9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,54 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:16:12Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Immutable configuration holder for llama.cpp JNI provider parameters. + +#### Purpose +- Holds immutable settings for llama.cpp JNI invocation. + +#### Type +- public final class LlamaCppJniConfig; annotations: @ConvertToRecord, @ToString, @EqualsAndHashCode. + +#### Input +- Constructor params: String libraryPath, String modelPath, int contextSize, int maxOutputTokens, float temperature, int threads, float topP, int topK, float repeatPenalty, boolean chatTemplateEnableThinking, List stopStrings. +- modelPath required, stopStrings may be null. + +#### Output +- Accessors return field values; stopStrings() returns unmodifiable view. +- No side effects. + +#### Core logic +- Validate modelPath non‑null. +- Assign all fields; default empty list for null stopStrings. +- Provide record‑style getters. + +#### Public API +- `LlamaCppJniConfig(String, String, int, int, float, int, float, int, float, boolean, List) -> LlamaCppJniConfig` creates immutable config. +- `String libraryPath() -> String` native library path or null. +- `String modelPath() -> String` GGUF model path. +- `int contextSize() -> int` token window size. +- `int maxOutputTokens() -> int` max output per call. +- `float temperature() -> float` sampling temperature. +- `int threads() -> int` CPU thread count. +- `float topP() -> float` nucleus‑sampling threshold. +- `int topK() -> int` top‑k sampling limit. +- `float repeatPenalty() -> float` repetition penalty. +- `boolean chatTemplateEnableThinking() -> boolean` chat‑template thinking flag. +- `List stopStrings() -> List` unmodifiable stop‑strings list. + +#### Dependencies +- java.util.Collections, java.util.List, java.util.Objects +- lombok.EqualsAndHashCode, lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord + +#### Exceptions / Errors +- NullPointerException if modelPath is null. + +#### Concurrency +- Class is immutable; thread‑safe. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..db0acc9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,40 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:18:24Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Deterministic provider returning mock summaries for AiGenerationRequests during testing. + +#### Purpose +- Deterministic mock for `AiGenerationProvider` used in unit tests. + +#### Type +- public class `MockAiGenerationProvider` implements `AiGenerationProvider`; @ToString. + +#### Input +- `AiGenerationRequest request` – retrieves source file via `request.sourceFile()`. + +#### Output +- `String` "Mock summary for " + fileName; may throw `IOException`. + +#### Core logic +- Retrieve `Path file = request.sourceFile()`. +- Extract file name with `file.getFileName()`. +- Fallback to full path string if `getFileName()` is null. +- Return `"Mock summary for " + fileName`. + +#### Public API +- `generate(AiGenerationRequest) -> String` deterministic mock summary. + +#### Dependencies +- `AiGenerationRequest`, `AiGenerationProvider`, `java.io.IOException`, `java.nio.file.Path`, `lombok.ToString`. + +#### Exceptions / Errors +- Declares `throws IOException` (no runtime checks performed). + +#### Concurrency +- None. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..4d6ba9a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,58 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:22:58Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> Provides pluggable AI text generation backends (llama.cpp JNI or mock) and parses LLM completions into clean answers. + +#### Purpose +- Expose a configurable AI generation provider API. +- Parse raw model outputs, removing internal reasoning blocks. + +#### Responsibilities +- **Parsing**: `AiCompletionParser` cleans completion text. +- **Interface**: `AiGenerationProvider` defines generation contract. +- **Factory**: `AiGenerationProviderFactory` selects provider implementation. +- **JNI provider**: `LlamaCppJniAiGenerationProvider` loads a GGUF model, builds prompts, and invokes native inference. +- **Configuration**: `LlamaCppJniConfig` holds immutable JNI settings. +- **Mock**: `MockAiGenerationProvider` supplies deterministic summaries for tests. + +#### Key units +- `AiCompletionParser` – removes `THINKING_BLOCK_*` markers; throws `IOException` on incomplete blocks. +- `AiGenerationProvider` – `generate(AiGenerationRequest)` and optional temperature override; `close()` default no‑op. +- `AiGenerationProviderFactory` – `create(String, LlamaCppJniConfig, AiPromptSupport)` returns provider; defaults to `MockAiGenerationProvider`. +- `LlamaCppJniAiGenerationProvider` – lazily builds `LlamaModel`, constructs `InferenceParameters`, calls native `chatCompleteText`, and parses result. +- `LlamaCppJniConfig` – immutable holder for library path, model path, context size, max output, sampling params, stop strings. +- `MockAiGenerationProvider` – returns `"Mock summary for "` based on request’s source file. + +#### Data flow +1. Caller invokes `AiGenerationProviderFactory.create(...)`. +2. Provider receives `AiGenerationRequest` (prompt key, source file/text, header). +3. For JNI provider, `AiPromptSupport.buildPrompt` generates chat prompt. +4. `InferenceParameters` constructed with temperature, NPredict, topP/K, repeatPenalty, stopStrings. +5. Native `LlamaModel.chatCompleteText` executed. +6. Output parsed by `AiCompletionParser.parseCompletion` to strip reasoning blocks. +7. Final answer returned to caller. + +#### Dependencies +- Factory ↔ `Java8CompatibilityHelper`, `AiPromptSupport`, `LlamaCppJniConfig`, provider classes. +- JNI provider ↔ `LlamaCppJniConfig`, `AiPromptSupport`, `AiGenerationRequest`, `LlamaModel`, `InferenceParameters`, `ModelParameters`. +- Config ↔ `ConvertToRecord`, `Objects`, `List`. +- Parser ↔ `IOException`, `lombok.ToString`. +- Mock ↔ `AiGenerationRequest`, `Path`. + +#### Cross-cutting +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) for concise data classes. +- Consistent `IOException` for I/O or parsing errors. +- Immutability of `LlamaCppJniConfig` ensures thread safety. +- Lazy initialization pattern in `LlamaCppJniAiGenerationProvider`. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..47555d4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,52 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:28:56Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> A Maven‑based AI field‑generation framework for Llama‑Cpp that maps prompts to models and offers pluggable JNI or mock providers. + +#### Purpose +- Configure AI field generation for the Llama‑Cpp Maven plugin. +- Provide pluggable Llama‑Cpp JNI or deterministic mock backends. + +#### Responsibilities +- **Configuration** – `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`, `AiModelDefinitionSupport`. +- **Provider** – `AiGenerationProvider`, `AiGenerationProviderFactory`, `LlamaCppJniAiGenerationProvider`, `MockAiGenerationProvider`. +- **Parsing** – `AiCompletionParser`. + +#### Key units +- `AiFieldGenerationConfig`: DTO for prompt‑model mapping, copies extensions. +- `AiFieldGenerationSelector`: chooses first matching config by file extension. +- `AiGenerationConfig`: immutable hyper‑parameters, unmodifiable stop strings. +- `AiModelDefinition`: mutable mirror of `AiGenerationConfig`. +- `AiModelDefinitionSupport`: builds key → `AiGenerationConfig` map, validates keys. +- `AiGenerationProvider`: contract `generate(AiGenerationRequest)`; optional temperature; `close()`. +- `AiGenerationProviderFactory`: selects provider implementation; defaults to `MockAiGenerationProvider`. +- `LlamaCppJniAiGenerationProvider`: lazily constructs `LlamaModel`, builds `InferenceParameters`, calls native `chatCompleteText`, parses result. +- `LlamaCppJniConfig`: immutable settings (library path, model path, context size, max output, sampling, stop strings). +- `MockAiGenerationProvider`: deterministic summary `"Mock summary for "`. +- `AiCompletionParser`: removes `THINKING_BLOCK_*` markers, throws `IOException` on incomplete blocks. + +#### Data flow +1. Maven injects `AiFieldGenerationConfig` instances. +2. `AiFieldGenerationSelector.selectForFileName()` picks config by file extension. +3. `AiModelDefinitionSupport` maps `AiModelDefinition` keys to `AiGenerationConfig`. +4. `AiGenerationProviderFactory.create()` selects provider (JNI or mock). +5. Provider builds prompt via `AiPromptSupport`, constructs `InferenceParameters`. +6. Native `LlamaModel.chatCompleteText` executes. +7. `AiCompletionParser.parseCompletion()` removes internal reasoning blocks. +8. Final answer returned to caller. + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiModelDefinition`, `AiGenerationConfig`, `AiFieldGenerationSelector`, `AiModelDefinitionSupport`, `AiPromptSupport`. +- External: Lombok annotations, Java Collections (`List`, `Map`, `HashMap`), `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition`, Llama‑Cpp JNI types (`InferenceParameters`, `ModelParameters`, `LlamaModel`). + +#### Cross-cutting +- Defensive copying and unmodifiable views for mutable collections. +- Null handling: empty/`null` extensions treated as fallbacks. +- Thread safety via local variables; config classes immutable after construction. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..af153c8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,11 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:31:50Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> A Maven‑based AI field‑generation framework for Llama‑Cpp that maps prompts to models and offers pluggable JNI or mock providers. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..a791fa8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,11 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:33:00Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> A Maven‑based AI field‑generation framework for Llama‑Cpp that maps prompts to models and offers pluggable JNI or mock providers. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/package.ai.md new file mode 100644 index 0000000..2fb14ed --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/net/package.ai.md @@ -0,0 +1,38 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:33:39Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> A Maven‑based AI field‑generation framework that maps prompts to Llama‑Cpp models and provides pluggable JNI or mock providers. + +#### Purpose +- Enables field‑generation in AI applications using Llama‑Cpp. +- Supports flexible provider configuration (JNI, mock). + +#### Responsibilities +- **Prompt‑Model Mapping** – translates user prompts into specific Llama‑Cpp model calls. +- **Provider Abstraction** – offers a common interface for JNI or mock implementations. + +#### Key units +- **Framework Core** – orchestrates prompt mapping and provider selection. +- **Provider Interface** – defines contract for JNI and mock providers. + +#### Data flow +1. Prompt received from user/API. +2. Framework Core selects appropriate model. +3. Provider Interface invokes Llama‑Cpp via JNI or mock. +4. Result returned to caller. + +#### Dependencies +- Llama‑Cpp native library via JNI. +- Maven build system for dependency management. +- Optional mock provider for testing. + +#### Cross-cutting +- Pluggable provider pattern for extensibility. +- Mock support for isolated testing and CI. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/package.ai.md new file mode 100644 index 0000000..5bbed40 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/java/package.ai.md @@ -0,0 +1,38 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:35:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> A Maven‑based AI field‑generation framework mapping prompts to Llama‑Cpp models with pluggable JNI or mock providers. + +#### Purpose +- Enables field‑generation in AI applications using Llama‑Cpp. +- Supports flexible provider configuration (JNI, mock). + +#### Responsibilities +- **Prompt‑Model Mapping** – translates user prompts into specific Llama‑Cpp model calls. +- **Provider Abstraction** – offers a common interface for JNI or mock implementations. + +#### Key units +- **Framework Core** – orchestrates prompt mapping and provider selection. +- **Provider Interface** – defines contract for JNI and mock providers. + +#### Data flow +1. Prompt received from user/API. +2. Framework Core selects appropriate model. +3. Provider Interface invokes Llama‑Cpp via JNI or mock. +4. Result returned to caller. + +#### Dependencies +- Llama‑Cpp native library via JNI. +- Maven build system for dependency management. +- Optional mock provider for testing. + +#### Cross-cutting +- Pluggable provider pattern for extensibility. +- Mock support for isolated testing and CI. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/package.ai.md new file mode 100644 index 0000000..a1c938b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/main/package.ai.md @@ -0,0 +1,38 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:36:13Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> A Maven‑based AI field‑generation framework mapping prompts to Llama‑Cpp models with pluggable JNI or mock providers. + +#### Purpose +- Enables field‑generation in AI applications using Llama‑Cpp. +- Supports flexible provider configuration (JNI, mock). + +#### Responsibilities +- **Prompt‑Model Mapping** – translates user prompts into specific Llama‑Cpp model calls. +- **Provider Abstraction** – offers a common interface for JNI or mock implementations. + +#### Key units +- **Framework Core** – orchestrates prompt mapping and provider selection. +- **Provider Interface** – defines contract for JNI and mock providers. + +#### Data flow +1. Prompt received from user/API. +2. Framework Core selects appropriate model. +3. Provider Interface invokes Llama‑Cpp via JNI or mock. +4. Result returned to caller. + +#### Dependencies +- Llama‑Cpp native library via JNI. +- Maven build system for dependency management. +- Optional mock provider for testing. + +#### Cross-cutting +- Pluggable provider pattern for extensibility. +- Mock support for isolated testing and CI. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/package.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/package.ai.md new file mode 100644 index 0000000..8ee1a1b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/package.ai.md @@ -0,0 +1,38 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:37:20Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> This package provides a Maven‑based AI field‑generation framework that maps prompts to Llama‑Cpp models with pluggable JNI or mock providers. + +#### Purpose +- Enables field‑generation in AI applications using Llama‑Cpp. +- Supports flexible provider configuration (JNI, mock). + +#### Responsibilities +- **Prompt‑Model Mapping** – translates user prompts into specific Llama‑Cpp model calls. +- **Provider Abstraction** – offers a common interface for JNI and mock implementations. + +#### Key units +- **Framework Core** – orchestrates prompt mapping and provider selection. +- **Provider Interface** – defines contract for JNI and mock providers. + +#### Data flow +1. Prompt received from user/API. +2. Framework Core selects appropriate model. +3. Provider Interface invokes Llama‑Cpp via JNI or mock. +4. Result returned to caller. + +#### Dependencies +- Llama‑Cpp native library via JNI. +- Maven build system for dependency management. +- Optional mock provider for testing. + +#### Cross-cutting +- Pluggable provider pattern for extensibility. +- Mock support for isolated testing and CI. diff --git a/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/project.ai.md b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/project.ai.md new file mode 100644 index 0000000..50d3d19 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__gptoss-20b__v2/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: D8A7261C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:38:32Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +llamacpp-ai-index-maven-plugin is a Maven‑based AI field‑generation framework that maps prompts to Llama‑Cpp models with pluggable JNI or mock providers. Its core subsystems include the aiindex package, which orchestrates prompt‑to‑model mappings and field‑generation logic, and the provider package, which supplies pluggable text‑generation backends and parses LLM completions into clean answers. The config package offers configuration and mapping of AI field‑generation steps, allowing field‑specific prompts, model definitions, and extension‑based selection, thereby tying the framework together for declarative Maven project integration. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Configures and maps AI field‑generation steps for Maven‑based projects, allowing field‑specific prompts, model definitions, and extension‑based selection. +- main/java/net/ladenthin/maven/llamacpp/aiindex — Provides a Maven‑based AI field‑generation framework with configurable prompt‑model mappings and pluggable Llama‑Cpp JNI or mock providers for text generation. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Provides pluggable AI text generation backends (llama.cpp JNI or mock) and parses LLM completions into clean answers. +- main/java/net/ladenthin/maven/llamacpp — A Maven‑based AI field‑generation framework for Llama‑Cpp that maps prompts to models and offers pluggable JNI or mock providers. +- main/java/net/ladenthin/maven — A Maven‑based AI field‑generation framework for Llama‑Cpp that maps prompts to models and offers pluggable JNI or mock providers. +- main/java/net/ladenthin — A Maven‑based AI field‑generation framework for Llama‑Cpp that maps prompts to models and offers pluggable JNI or mock providers. +- main/java/net — A Maven‑based AI field‑generation framework that maps prompts to Llama‑Cpp models and provides pluggable JNI or mock providers. +- main/java — A Maven‑based AI field‑generation framework mapping prompts to Llama‑Cpp models with pluggable JNI or mock providers. +- main — A Maven‑based AI field‑generation framework mapping prompts to Llama‑Cpp models with pluggable JNI or mock providers. +- . — This package provides a Maven‑based AI field‑generation framework that maps prompts to Llama‑Cpp models with pluggable JNI or mock providers. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..3c7683d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,53 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:06:26Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices + +#### Purpose +- Associates a prompt template key with an AI model definition key for field generation. + +#### Type +- Class, final, no extends/implements, no generics. + +#### Input +- Constructor and method parameters: `promptKey`, `aiDefinitionKey`, `fileExtensions`. +- Consumed fields: `promptKey`, `aiDefinitionKey`, `fileExtensions`. +- Read resources: none. + +#### Output +- Return types: `String` for getters, `List` for `getFileExtensions()`. +- Produced state: none. +- Mutated fields: `promptKey`, `aiDefinitionKey`, `fileExtensions`. +- Written resources: none. +- Side effects: none. + +#### Core Logic +- Retrieves prompt key. +- Retrieves AI model definition key. +- Retrieves file extensions. +- Sets prompt key. +- Sets AI model definition key. +- Sets file extensions. + +#### Public API +- `getPromptKey() -> String`: Returns the prompt template key. +- `setPromptKey(promptKey) -> void`: Sets the prompt template key. +- `getAiDefinitionKey() -> String`: Returns the AI model definition key. +- `setAiDefinitionKey(aiDefinitionKey) -> void`: Sets the AI model definition key. +- `getFileExtensions() -> @Nullable List`: Returns the file extensions. +- `setFileExtensions(fileExtensions) -> void`: Sets the file extensions. + +#### Dependencies +- Imports: `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. + +#### Exceptions / Errors +- None notable. + +#### Concurrency +- No threading, synchronization, immutability, or thread-safety notes. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..e9957ff --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,53 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:07:12Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices + +#### Purpose +- Selects the appropriate AI field generation configuration based on source file extensions. + +#### Type +- Class: `AiFieldGenerationSelector` +- Final: Yes +- Extends: None +- Implements: None +- Key generics and type bounds: None + +#### Input +- Constructor: None +- Method Parameters: + - `configs` (Iterable): Configured field generations + - `fileName` (String): Source file name + +#### Output +- Return Types: + - `AiFieldGenerationConfig`: The selected configuration + - `null`: When no match is found and no fallback is configured + +#### Core Logic +- Iterates over `configs`: + - Skips `null` entries + - Checks if the configuration has non-empty extensions + - Matches `fileName` with extensions + - Returns the first matching configuration + - Falls back to the first extension-agnostic entry if no match is found + - Returns `null` if no match and no fallback is configured + +#### Public API +- `selectForFileName(Iterable, String) -> @Nullable AiFieldGenerationConfig`: Returns the first extension-matching entry, else the first fallback entry, else `null`. + +#### Dependencies +- Imports: `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable` +- Referenced Types: `AiFieldGenerationConfig` + +#### Exceptions / Errors +- None explicitly thrown or caught in the provided source. + +#### Concurrency +- Not explicitly addressed in the provided source. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..a25413a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,84 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:07:42Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI generation parameters for Maven-based AI model interactions + +#### Purpose +- Mutable configuration object for AI generation steps +- Carries parameters between Maven configuration and AI provider implementations + +#### Type +- Class: `AiGenerationConfig` +- Final: Yes +- Extends: None +- Implements: None +- Key generics and type bounds: None +- Annotations: `@ToString`, `@SuppressWarnings({"NullAway.Init", "initialization.fields.uninitialized"})` + +#### Input +- Constructor and method parameters: `modelPath`, `contextSize`, `maxOutputTokens`, `temperature`, `threads`, `charsPerToken`, `maxInputChars`, `warnOnTrim`, `maxRetries`, `retryTemperatureIncrement`, `topP`, `topK`, `repeatPenalty`, `chatTemplateEnableThinking`, `stopStrings` +- Injected dependencies: None +- Consumed fields: `modelPath`, `contextSize`, `maxOutputTokens`, `temperature`, `threads`, `charsPerToken`, `maxInputChars`, `warnOnTrim`, `maxRetries`, `retryTemperatureIncrement`, `topP`, `topK`, `repeatPenalty`, `chatTemplateEnableThinking`, `stopStrings` +- Read resources: None + +#### Output +- Return types: `String`, `int`, `float`, `List` +- Produced state: None +- Mutated fields: `modelPath`, `contextSize`, `maxOutputTokens`, `temperature`, `threads`, `charsPerToken`, `maxInputChars`, `warnOnTrim`, `maxRetries`, `retryTemperatureIncrement`, `topP`, `topK`, `repeatPenalty`, `chatTemplateEnableThinking`, `stopStrings` +- Written resources: None +- Side effects: None + +#### Core logic +- Default values for configuration parameters +- Getter and setter methods for each configuration parameter +- Automatic calculation of `maxInputChars` based on context size, output tokens, prompt overhead, and safety margin +- Unmodifiable view of stop strings + +#### Public API +- `getModelPath() -> String`: Returns the GGUF model file path +- `setModelPath(String) -> void`: Sets the GGUF model file path +- `getContextSize() -> int`: Returns the context window size in tokens +- `setContextSize(int) -> void`: Sets the context window size in tokens +- `getMaxOutputTokens() -> int`: Returns the maximum number of output tokens per inference call +- `setMaxOutputTokens(int) -> void`: Sets the maximum number of output tokens per inference call +- `getTemperature() -> float`: Returns the sampling temperature +- `setTemperature(float) -> void`: Sets the sampling temperature +- `getThreads() -> int`: Returns the number of CPU threads used for inference +- `setThreads(int) -> void`: Sets the number of CPU threads used for inference +- `getCharsPerToken() -> int`: Returns the number of characters per token used in automatic `maxInputChars` calculation +- `setCharsPerToken(int) -> void`: Sets the number of characters per token +- `getMaxInputChars() -> int`: Returns the maximum number of input characters fed to the prompt +- `setMaxInputChars(int) -> void`: Sets the maximum number of input characters fed to the prompt +- `isWarnOnTrim() -> boolean`: Returns whether a warning is emitted when the prompt source text is trimmed +- `setWarnOnTrim(boolean) -> void`: Sets whether a warning is emitted when the prompt source text is trimmed +- `getMaxRetries() -> int`: Returns the maximum number of retry attempts on empty-body responses +- `setMaxRetries(int) -> void`: Sets the maximum number of retry attempts on empty-body responses +- `getRetryTemperatureIncrement() -> float`: Returns the temperature increment added on each retry attempt +- `setRetryTemperatureIncrement(float) -> void`: Sets the temperature increment added on each retry attempt +- `getTopP() -> float`: Returns the nucleus-sampling probability threshold +- `setTopP(float) -> void`: Sets the nucleus-sampling probability threshold +- `getTopK() -> int`: Returns the top-k sampling limit +- `setTopK(int) -> void`: Sets the top-k sampling limit +- `getRepeatPenalty() -> float`: Returns the repetition penalty +- `setRepeatPenalty(float) -> void`: Sets the repetition penalty +- `isChatTemplateEnableThinking() -> boolean`: Returns whether the model's chat-template thinking mode is enabled +- `setChatTemplateEnableThinking(boolean) -> void`: Sets whether the model's chat-template thinking mode is enabled +- `getStopStrings() -> @Nullable List`: Returns an unmodifiable view of the configured stop strings +- `setStopStrings(@Nullable List) -> void`: Sets the list of stop strings + +#### Dependencies +- Imports: `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable` +- Referenced types: `ArrayList`, `Collections`, `Lombok`, `Net.ladenthin.maven.llamacpp.aiindex.config`, `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- No notable thrown/caught exceptions +- No notable null-handling or error conditions + +#### Concurrency +- No threading, synchronization, immutability, or thread-safety notes diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..10e0a56 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,53 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:09:25Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Identifies whether an AI generation operates on a single source file or a whole package. + +#### Purpose +- Identifies AI generation operation scope: single file or package. + +#### Type +- Enum: `AiGenerationKind` +- Modifiers: `public` +- No extends / implements +- No generics or type bounds +- No notable annotations + +#### Input +- No constructor parameters +- No injected dependencies +- No consumed fields +- No read resources + +#### Output +- No return values +- No produced state +- No mutated fields +- No written resources +- No side effects + +#### Core logic +- Enum with two constants: + - `FILE_SUMMARY`: Generation step for a single source file. + - `PACKAGE_SUMMARY`: Generation step for a package aggregate. + +#### Public API +- `FILE_SUMMARY`: Identifies generation for a single source file. +- `PACKAGE_SUMMARY`: Identifies generation for a package aggregate. + +#### Dependencies +- No imports +- No referenced types + +#### Exceptions / Errors +- No notable thrown/caught exceptions +- No null-handling or error conditions + +#### Concurrency +- No threading, synchronization, immutability, or thread-safety notes diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..7238055 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,69 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:09:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices + +#### Purpose +- Provides a configuration POJO for pairing a lookup key with AI model parameters. + +#### Type +- Class, final, no extends/implements, uses lombok.ToString, lombok.NonNull, org.jspecify.annotations.Nullable. + +#### Input +- Constructor and method parameters: key, modelPath, contextSize, maxOutputTokens, temperature, threads, charsPerToken, warnOnTrim, maxRetries, retryTemperatureIncrement, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings. + +#### Output +- Returns: key, modelPath, contextSize, maxOutputTokens, temperature, threads, charsPerToken, warnOnTrim, maxRetries, retryTemperatureIncrement, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings. +- Mutates: key, modelPath, contextSize, maxOutputTokens, temperature, threads, charsPerToken, warnOnTrim, maxRetries, retryTemperatureIncrement, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings. + +#### Core logic +- Provides getters and setters for all configuration parameters. +- Manages default values from `AiGenerationConfig`. +- Handles nullable stop strings. + +#### Public API +- `getKey() -> String`: Returns the lookup key. +- `setKey(String) -> void`: Sets the lookup key. +- `getModelPath() -> String`: Returns the model path. +- `setModelPath(String) -> void`: Sets the model path. +- `getContextSize() -> int`: Returns context size. +- `setContextSize(int) -> void`: Sets context size. +- `getMaxOutputTokens() -> int`: Returns max output tokens. +- `setMaxOutputTokens(int) -> void`: Sets max output tokens. +- `getTemperature() -> float`: Returns temperature. +- `setTemperature(float) -> void`: Sets temperature. +- `getThreads() -> int`: Returns thread count. +- `setThreads(int) -> void`: Sets thread count. +- `getCharsPerToken() -> int`: Returns chars-per-token ratio. +- `setCharsPerToken(int) -> void`: Sets chars-per-token ratio. +- `isWarnOnTrim() -> boolean`: Returns warning flag. +- `setWarnOnTrim(boolean) -> void`: Sets warning flag. +- `getMaxRetries() -> int`: Returns max retries. +- `setMaxRetries(int) -> void`: Sets max retries. +- `getRetryTemperatureIncrement() -> float`: Returns retry temperature increment. +- `setRetryTemperatureIncrement(float) -> void`: Sets retry temperature increment. +- `getTopP() -> float`: Returns top-p value. +- `setTopP(float) -> void`: Sets top-p value. +- `getTopK() -> int`: Returns top-k value. +- `setTopK(int) -> void`: Sets top-k value. +- `getRepeatPenalty() -> float`: Returns repeat penalty. +- `setRepeatPenalty(float) -> void`: Sets repeat penalty. +- `isChatTemplateEnableThinking() -> boolean`: Returns chat template thinking flag. +- `setChatTemplateEnableThinking(boolean) -> void`: Sets chat template thinking flag. +- `getStopStrings() -> @Nullable List`: Returns stop strings. +- `setStopStrings(Collection) -> void`: Sets stop strings. + +#### Dependencies +- Imports: java.util.ArrayList, java.util.Collection, java.util.Collections, java.util.List, lombok.ToString, org.jspecify.annotations.Nullable, net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig. + +#### Exceptions / Errors +- No notable exceptions or errors. + +#### Concurrency +- No concurrency considerations noted. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..01db891 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,43 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:11:00Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices + +#### Purpose +- Resolves {@link AiModelDefinition} entries by their key, returning the corresponding {@link AiGenerationConfig}. + +#### Type +- Class, final, implements Java8CompatibilityHelper. + +#### Input +- List definitions. + +#### Output +- Map configs; AiGenerationConfig getConfig(String key). + +#### Core Logic +- Constructs a lookup table from AI model definitions. +- Ensures each definition has a non-null key. +- Converts definitions to generation configs. +- Throws NullPointerException for null keys. +- Throws IllegalArgumentException for missing keys. + +#### Public API +- AiGenerationConfig getConfig(String key) -> AiGenerationConfig; Returns generation config for a key. +- toConfig(AiModelDefinition) -> AiGenerationConfig; Converts definition to config. + +#### Dependencies +- java.util.HashMap; java.util.List; java.util.Map; java.util.Objects; net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper. + +#### Exceptions / Errors +- NullPointerException for null keys. +- IllegalArgumentException for missing keys. + +#### Concurrency +- HashMap is not thread-safe; consider synchronization for concurrent access. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..62ed7e7 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,57 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:14:16Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Calculates VAT for invoices + +#### Purpose +- Provides configuration and selection mechanisms for AI field generation based on file extensions and model definitions. + +#### Responsibilities +- `AiFieldGenerationConfig`: Associates prompt and AI model definition keys with file extensions for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Configures AI generation parameters for Maven-based AI model interactions. +- `AiGenerationKind`: Identifies whether AI generation operates on a single source file or a whole package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. + +#### Key Units +- `AiFieldGenerationConfig`: Associates prompt template keys with AI model definition keys for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Carries parameters between Maven configuration and AI provider implementations. +- `AiGenerationKind`: Identifies AI generation operation scope: single file or package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. + +#### Data Flow +- `AiFieldGenerationConfig` is instantiated with prompt and AI model definition keys and file extensions. +- `AiFieldGenerationSelector` iterates over configurations to select one based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` determines the scope of AI generation (single file or package). +- `AiModelDefinition` provides configuration parameters for AI model interactions. +- `AiModelDefinitionSupport` resolves AI model definition entries by their key, returning the corresponding AI generation configuration. + +#### Dependencies +- `AiFieldGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiFieldGenerationSelector` imports `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationKind` has no imports. +- `AiModelDefinition` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`. +- `AiModelDefinitionSupport` imports `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. + +#### Cross-cutting +- No recurring patterns across files noted. + +#### Summary +This package provides a comprehensive set of classes and configurations for calculating VAT for invoices through AI field generation, selection, and AI model interactions, with clear dependencies and responsibilities structured around specific functional roles. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..53dd83f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,74 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:16:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. + +#### Purpose +- Provides configuration and selection mechanisms for AI field generation based on file extensions and model definitions. +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides AI text generation for prompts using specified or default sampling parameters. + +#### Responsibilities +- `AiFieldGenerationConfig`: Associates prompt and AI model definition keys with file extensions for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Configures AI generation parameters for Maven-based AI model interactions. +- `AiGenerationKind`: Identifies whether AI generation operates on a single source file or a whole package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Pluggable AI backend for generating text based on prompts. +- `AiGenerationProviderFactory`: Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. +- `LlamaCppJniAiGenerationProvider`: Provides a service for generating AI-based completion based on llama.cpp configurations. +- `LlamaCppJniConfig`: Provides configuration for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Key Units +- `AiFieldGenerationConfig`: Associates prompt template keys with AI model definition keys for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Carries parameters between Maven configuration and AI provider implementations. +- `AiGenerationKind`: Identifies AI generation operation scope: single file or package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory`: Selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider`: Uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig`: Configures the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Data Flow +- `AiFieldGenerationConfig` is instantiated with prompt and AI model definition keys and file extensions. +- `AiFieldGenerationSelector` iterates over configurations to select one based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` determines the scope of AI generation (single file or package). +- `AiModelDefinition` provides configuration parameters for AI model interactions. +- `AiModelDefinitionSupport` resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser` processes raw completion text to extract the model answer. +- `AiGenerationProvider` generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory` selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider` uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig` configures the llama.cpp JNI provider. + +#### Dependencies +- `AiFieldGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiFieldGenerationSelector` imports `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationKind` has no imports. +- `AiModelDefinition` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`. +- `AiModelDefinitionSupport` imports `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. +- `AiCompletionParser` imports `java.io.IOException`, `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.ToString`, `net.ladenthin.llama.LlamaModel`, `net.ladenthin.llama.parameters.InferenceParameters`, `net.ladenthin.llama.parameters.ModelParameters`, `net.ladenthin.llama.value.Pair`, `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`. + +#### Cross-cutting +- Thread-safe due to lazy initialization of the model and use of immutable parameters. +- Immutable configuration with value semantics. + +#### Summary +This package provides a comprehensive set of classes and configurations for calculating VAT for invoices through AI field generation, selection, and AI model interactions, with clear dependencies and responsibilities structured around specific functional roles. Additionally, it includes tools for parsing LLM completion text and generating AI text using llama.cpp JNI bindings, emphasizing modularity, thread safety, and configurability. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..835e01d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,43 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:11:29Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. + +#### Purpose +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. + +#### Type +- Class, final + +#### Input +- `response`: raw completion text from the model, may be `null` + +#### Output +- Cleaned answer text, never `null` + +#### Core Logic +- If `response` is `null`, return an empty string. +- Find the last occurrence of `THINKING_BLOCK_END_MARKER`. + - If found, return the substring after this marker, trimmed. + - If not found but `THINKING_BLOCK_START_MARKER` is present, throw an `IOException` indicating the token budget was exhausted. + - If neither marker is present, return the trimmed response. + +#### Public API +- `parseCompletion(response) -> String` + Strips any Gemma-4 thinking block from `response` and returns the clean answer text. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` + +#### Exceptions / Errors +- Throws `IOException` if a thinking block was started but the token budget was exhausted before the closing marker was emitted. + +#### Concurrency +- Not explicitly noted, but the class is non-final to allow subclassing and mocking in tests. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..97fc10a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,39 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:11:58Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides AI text generation for prompts using specified or default sampling parameters. + +#### Purpose +- Pluggable AI backend for generating text based on prompts. + +#### Type +- Interface: `AiGenerationProvider` extending `AutoCloseable`. + +#### Input +- `AiGenerationRequest` (prompt key, source file, source text, current header). + +#### Output +- Generated text (`String`); never `null`, but may be blank. + +#### Core Logic +- `generate(AiGenerationRequest request)`: Generates text using default parameters. +- `generate(AiGenerationRequest request, float temperatureOverride)`: Overrides temperature for sampling. + +#### Public API +- `generate(AiGenerationRequest request) -> String`: Generates text with default settings. +- `generate(AiGenerationRequest request, float temperatureOverride) -> String`: Generates text with specified temperature. + +#### Dependencies +- `java.io.IOException`: For handling I/O exceptions. + +#### Exceptions / Errors +- `IOException`: Thrown by underlying provider failures. + +#### Concurrency +- Not explicitly noted; assumes thread safety based on interface design. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..d3abc18 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,39 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:12:20Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices + +#### Purpose +- Selects and instantiates an `AiGenerationProvider` implementation by name. + +#### Type +- Class, final, no extends/implements, no generics. + +#### Input +- `providerName` (String), `llamaConfig` (LlamaCppJniConfig), `promptSupport` (AiPromptSupport). + +#### Output +- `AiGenerationProvider` instance. + +#### Core Logic +- Returns `MockAiGenerationProvider` if `providerName` is null or blank. +- Returns `LlamaCppJniAiGenerationProvider` for "llamacpp-jni". +- Throws `IllegalArgumentException` for unsupported providers. + +#### Public API +- `create(String providerName, LlamaCppJniConfig llamaConfig, AiPromptSupport promptSupport) -> AiGenerationProvider` selects provider based on name. + +#### Dependencies +- `Java8CompatibilityHelper`, `LlamaCppJniConfig`, `AiPromptSupport`. + +#### Exceptions / Errors +- Throws `IllegalArgumentException` for unsupported providers. + +#### Concurrency +- No explicit concurrency notes. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..d96ad6e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,53 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:12:40Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. + +#### Purpose +- Provides a service for generating AI-based completion based on llama.cpp configurations. + +#### Type +- Class, final, implements `AiGenerationProvider` and `AutoCloseable`. + +#### Input +- `AiGenerationRequest request`: Request parameters for generation. +- `float temperatureOverride`: Override temperature for generation. + +#### Output +- `String`: Generated completion text. + +#### Core Logic +- Loads the GGUF model lazily on first use. +- Constructs `InferenceParameters` with provided configurations. +- Builds prompt using `AiPromptSupport`. +- Parses completion using `completionParser`. + +#### Public API +- `LlamaCppJniAiGenerationProvider(LlamaCppJniConfig config, AiPromptSupport promptSupport)`: Initializes the provider. +- `String generate(AiGenerationRequest request)`: Generates completion text. +- `String generate(AiGenerationRequest request, float temperatureOverride)`: Generates completion text with temperature override. +- `void close()`: Closes the native llama.cpp model. + +#### Dependencies +- `java.io.IOException`: For handling I/O exceptions. +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`: For data structures. +- `java.util.Objects`: For object utility methods. +- `lombok.ToString`: For generating toString method. +- `net.ladenthin.llama.LlamaModel`: For llama.cpp model handling. +- `net.ladenthin.llama.parameters.InferenceParameters`: For inference parameters. +- `net.ladenthin.llama.parameters.ModelParameters`: For model parameters. +- `net.ladenthin.llama.value.Pair`: For pairing strings. +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`: For generation request. +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`: For prompt support. + +#### Exceptions / Errors +- `IOException`: Thrown when handling I/O operations. + +#### Concurrency +- The class is thread-safe due to the lazy initialization of the model and use of immutable parameters. No explicit synchronization is required. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..156d1c6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,64 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:13:20Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates VAT for invoices + +#### Purpose +- Provides configuration for the llama.cpp JNI provider. + +#### Type +- Kind: final class +- Modifiers: none +- Extends: none +- Implements: none +- Key generics and type bounds: none +- Notable annotations: @ConvertToRecord, @ToString, @EqualsAndHashCode + +#### Input +- Constructor and method parameters: libraryPath, modelPath, contextSize, maxOutputTokens, temperature, threads, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings +- Injected dependencies: none +- Consumed fields: none +- Read resources: none + +#### Output +- Produced state: none +- Mutated fields: none +- Written resources: none +- Side effects: none + +#### Core logic +- Immutable configuration with value semantics +- Accessors for each configuration parameter + +#### Public API +- libraryPath() -> String: Returns the native library path +- modelPath() -> String: Returns the GGUF model file path +- contextSize() -> int: Returns the context window size in tokens +- maxOutputTokens() -> int: Returns the maximum number of output tokens per call +- temperature() -> float: Returns the sampling temperature +- threads() -> int: Returns the number of CPU threads +- topP() -> float: Returns the nucleus-sampling probability threshold +- topK() -> int: Returns the top-k sampling limit +- repeatPenalty() -> float: Returns the repetition penalty +- chatTemplateEnableThinking() -> boolean: Returns whether chat-template thinking mode is enabled +- stopStrings() -> List: Returns an unmodifiable view of the configured stop strings + +#### Dependencies +- java.util.Collections +- java.util.List +- java.util.Objects +- lombok.EqualsAndHashCode +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord + +#### Exceptions / Errors +- None + +#### Concurrency +- Immutable configuration; thread-safe by design diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..2f29fe6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,43 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:13:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Calculates deterministic mock summaries for AI generation requests in testing. + +#### Purpose +- Provides deterministic mock summaries for AI generation requests. + +#### Type +- Class +- Final +- Implements `AiGenerationProvider` + +#### Input +- `AiGenerationRequest request`: Source file path and name. + +#### Output +- Returns a mock summary string for the provided request. + +#### Core Logic +- Retrieves file name from `request`. +- Constructs and returns a mock summary string. + +#### Public API +- `MockAiGenerationProvider()`: No-op constructor. +- `String generate(final AiGenerationRequest request) throws IOException`: Generates a mock summary. + +#### Dependencies +- `java.io.IOException` +- `java.nio.file.Path` +- `lombok.ToString` + +#### Exceptions / Errors +- Throws `IOException` if file name retrieval fails. + +#### Concurrency +- Not explicitly noted, but the class is thread-safe due to its stateless nature. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..1493daf --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,59 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:15:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> A package for parsing LLM completion text and providing AI text generation services using llama.cpp JNI bindings. + +#### Purpose +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides AI text generation for prompts using specified or default sampling parameters. + +#### Responsibilities +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Pluggable AI backend for generating text based on prompts. +- Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. + +#### Key Units +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- `AiGenerationProvider`: Pluggable AI backend for generating text based on prompts. +- `AiGenerationProviderFactory`: Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. +- `LlamaCppJniAiGenerationProvider`: Provides a service for generating AI-based completion based on llama.cpp configurations. +- `LlamaCppJniConfig`: Provides configuration for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Data Flow +- `AiCompletionParser` processes raw completion text to extract the model answer. +- `AiGenerationProvider` generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory` selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider` uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig` configures the llama.cpp JNI provider. + +#### Dependencies +- `java.io.IOException`: For handling I/O exceptions. +- `java.util.ArrayList`, `java.util.Collections`, `java.util.List`: For data structures. +- `java.util.Objects`: For object utility methods. +- `lombok.ToString`: For generating toString method. +- `net.ladenthin.llama.LlamaModel`: For llama.cpp model handling. +- `net.ladenthin.llama.parameters.InferenceParameters`: For inference parameters. +- `net.ladenthin.llama.parameters.ModelParameters`: For model parameters. +- `net.ladenthin.llama.value.Pair`: For pairing strings. +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`: For generation request. +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`: For prompt support. + +#### Cross-cutting +- Thread-safe due to lazy initialization of the model and use of immutable parameters. +- Immutable configuration with value semantics. + +#### Summary +This package provides comprehensive tools for parsing LLM completion text and generating AI text using llama.cpp JNI bindings, with a focus on modularity, thread safety, and configurability. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..fba0c8f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,73 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:18:15Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. + +#### Purpose +- Provides configuration and selection mechanisms for AI field generation based on file extensions and model definitions. +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides AI text generation for prompts using specified or default sampling parameters. + +#### Responsibilities +- `AiFieldGenerationConfig`: Associates prompt and AI model definition keys with file extensions for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Configures AI generation parameters for Maven-based AI model interactions. +- `AiGenerationKind`: Identifies whether AI generation operates on a single source file or a whole package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Pluggable AI backend for generating text based on prompts. +- `AiGenerationProviderFactory`: Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. +- `LlamaCppJniAiGenerationProvider`: Provides a service for generating AI-based completion based on llama.cpp configurations. +- `LlamaCppJniConfig`: Provides configuration for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Key Units +- `AiFieldGenerationConfig`: Associates prompt template keys with AI model definition keys for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Carries parameters between Maven configuration and AI provider implementations. +- `AiGenerationKind`: Identifies AI generation operation scope: single file or package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory`: Selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider`: Uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig`: Configures the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Data Flow +- `AiFieldGenerationConfig` is instantiated with prompt and AI model definition keys and file extensions. +- `AiFieldGenerationSelector` iterates over configurations to select one based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` determines the scope of AI generation (single file or package). +- `AiModelDefinition` provides configuration parameters for AI model interactions. +- `AiModelDefinitionSupport` resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser` processes raw completion text to extract the model answer. +- `AiGenerationProvider` generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory` selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider` uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig` configures the llama.cpp JNI provider. + +#### Dependencies +- `AiFieldGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiFieldGenerationSelector` imports `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationKind` has no imports. +- `AiModelDefinition` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`. +- `AiModelDefinitionSupport` imports `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. +- `AiCompletionParser` imports `java.io.IOException`, `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.ToString`, `net.ladenthin.llama.LlamaModel`, `net.ladenthin.llama.parameters.InferenceParameters`, `net.ladenthin.llama.parameters.ModelParameters`, `net.ladenthin.llama.value.Pair`, `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`. + +#### Cross-cutting +- Thread-safe due to lazy initialization of the model and use of immutable parameters. +- Immutable configuration with value semantics. + +#### Summary +This package provides a comprehensive set of classes and configurations for calculating VAT for invoices through AI field generation, selection, and AI model interactions, with clear dependencies and responsibilities structured around specific functional roles. Additionally, it includes tools for parsing LLM completion text and generating AI text using llama.cpp JNI bindings, emphasizing modularity, thread safety, and configurability. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..bec72c6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,73 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:19:47Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. + +#### Purpose +- Provides configuration and selection mechanisms for AI field generation based on file extensions and model definitions. +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides AI text generation for prompts using specified or default sampling parameters. + +#### Responsibilities +- `AiFieldGenerationConfig`: Associates prompt and AI model definition keys with file extensions for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Configures AI generation parameters for Maven-based AI model interactions. +- `AiGenerationKind`: Identifies whether AI generation operates on a single source file or a whole package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Pluggable AI backend for generating text based on prompts. +- `AiGenerationProviderFactory`: Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. +- `LlamaCppJniAiGenerationProvider`: Provides a service for generating AI-based completion based on llama.cpp configurations. +- `LlamaCppJniConfig`: Provides configuration for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Key Units +- `AiFieldGenerationConfig`: Associates prompt template keys with AI model definition keys for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Carries parameters between Maven configuration and AI provider implementations. +- `AiGenerationKind`: Identifies AI generation operation scope: single file or package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory`: Selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider`: Uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig`: Configures the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Data Flow +- `AiFieldGenerationConfig` is instantiated with prompt and AI model definition keys and file extensions. +- `AiFieldGenerationSelector` iterates over configurations to select one based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` determines the scope of AI generation (single file or package). +- `AiModelDefinition` provides configuration parameters for AI model interactions. +- `AiModelDefinitionSupport` resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser` processes raw completion text to extract the model answer. +- `AiGenerationProvider` generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory` selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider` uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig` configures the llama.cpp JNI provider. + +#### Dependencies +- `AiFieldGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiFieldGenerationSelector` imports `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationKind` has no imports. +- `AiModelDefinition` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`. +- `AiModelDefinitionSupport` imports `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. +- `AiCompletionParser` imports `java.io.IOException`, `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.ToString`, `net.ladenthin.llama.LlamaModel`, `net.ladenthin.llama.parameters.InferenceParameters`, `net.ladenthin.llama.parameters.ModelParameters`, `net.ladenthin.llama.value.Pair`, `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`. + +#### Cross-cutting +- Thread-safe due to lazy initialization of the model and use of immutable parameters. +- Immutable configuration with value semantics. + +#### Summary +This package provides a comprehensive set of classes and configurations for calculating VAT for invoices through AI field generation, selection, and AI model interactions, with clear dependencies and responsibilities structured around specific functional roles. Additionally, it includes tools for parsing LLM completion text and generating AI text using llama.cpp JNI bindings, emphasizing modularity, thread safety, and configurability. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..149035f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,73 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:21:18Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. + +#### Purpose +- Provides configuration and selection mechanisms for AI field generation based on file extensions and model definitions. +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides AI text generation for prompts using specified or default sampling parameters. + +#### Responsibilities +- `AiFieldGenerationConfig`: Associates prompt and AI model definition keys with file extensions for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Configures AI generation parameters for Maven-based AI model interactions. +- `AiGenerationKind`: Identifies whether AI generation operates on a single source file or a whole package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Pluggable AI backend for generating text based on prompts. +- `AiGenerationProviderFactory`: Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. +- `LlamaCppJniAiGenerationProvider`: Provides a service for generating AI-based completion based on llama.cpp configurations. +- `LlamaCppJniConfig`: Provides configuration for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Key Units +- `AiFieldGenerationConfig`: Associates prompt template keys with AI model definition keys for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Carries parameters between Maven configuration and AI provider implementations. +- `AiGenerationKind`: Identifies AI generation operation scope: single file or package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory`: Selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider`: Uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig`: Configures the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Data Flow +- `AiFieldGenerationConfig` is instantiated with prompt and AI model definition keys and file extensions. +- `AiFieldGenerationSelector` iterates over configurations to select one based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` determines the scope of AI generation (single file or package). +- `AiModelDefinition` provides configuration parameters for AI model interactions. +- `AiModelDefinitionSupport` resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser` processes raw completion text to extract the model answer. +- `AiGenerationProvider` generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory` selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider` uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig` configures the llama.cpp JNI provider. + +#### Dependencies +- `AiFieldGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiFieldGenerationSelector` imports `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationKind` has no imports. +- `AiModelDefinition` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`. +- `AiModelDefinitionSupport` imports `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. +- `AiCompletionParser` imports `java.io.IOException`, `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.ToString`, `net.ladenthin.llama.LlamaModel`, `net.ladenthin.llama.parameters.InferenceParameters`, `net.ladenthin.llama.parameters.ModelParameters`, `net.ladenthin.llama.value.Pair`, `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`. + +#### Cross-cutting +- Thread-safe due to lazy initialization of the model and use of immutable parameters. +- Immutable configuration with value semantics. + +#### Summary +This package provides a comprehensive set of classes and configurations for calculating VAT for invoices through AI field generation, selection, and AI model interactions, with clear dependencies and responsibilities structured around specific functional roles. Additionally, it includes tools for parsing LLM completion text and generating AI text using llama.cpp JNI bindings, emphasizing modularity, thread safety, and configurability. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/package.ai.md new file mode 100644 index 0000000..5bc8317 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/net/package.ai.md @@ -0,0 +1,73 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:22:50Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. + +#### Purpose +- Provides configuration and selection mechanisms for AI field generation based on file extensions and model definitions. +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides AI text generation for prompts using specified or default sampling parameters. + +#### Responsibilities +- `AiFieldGenerationConfig`: Associates prompt and AI model definition keys with file extensions for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Configures AI generation parameters for Maven-based AI model interactions. +- `AiGenerationKind`: Identifies whether AI generation operates on a single source file or a whole package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Pluggable AI backend for generating text based on prompts. +- `AiGenerationProviderFactory`: Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. +- `LlamaCppJniAiGenerationProvider`: Provides a service for generating AI-based completion based on llama.cpp configurations. +- `LlamaCppJniConfig`: Provides configuration for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Key Units +- `AiFieldGenerationConfig`: Associates prompt template keys with AI model definition keys for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Carries parameters between Maven configuration and AI provider implementations. +- `AiGenerationKind`: Identifies AI generation operation scope: single file or package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory`: Selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider`: Uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig`: Configures the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Data Flow +- `AiFieldGenerationConfig` is instantiated with prompt and AI model definition keys and file extensions. +- `AiFieldGenerationSelector` iterates over configurations to select one based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` determines the scope of AI generation (single file or package). +- `AiModelDefinition` provides configuration parameters for AI model interactions. +- `AiModelDefinitionSupport` resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser` processes raw completion text to extract the model answer. +- `AiGenerationProvider` generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory` selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider` uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig` configures the llama.cpp JNI provider. + +#### Dependencies +- `AiFieldGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiFieldGenerationSelector` imports `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationKind` has no imports. +- `AiModelDefinition` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`. +- `AiModelDefinitionSupport` imports `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. +- `AiCompletionParser` imports `java.io.IOException`, `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.ToString`, `net.ladenthin.llama.LlamaModel`, `net.ladenthin.llama.parameters.InferenceParameters`, `net.ladenthin.llama.parameters.ModelParameters`, `net.ladenthin.llama.value.Pair`, `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`. + +#### Cross-cutting +- Thread-safe due to lazy initialization of the model and use of immutable parameters. +- Immutable configuration with value semantics. + +#### Summary +This package provides a comprehensive set of classes and configurations for calculating VAT for invoices through AI field generation, selection, and AI model interactions, with clear dependencies and responsibilities structured around specific functional roles. Additionally, it includes tools for parsing LLM completion text and generating AI text using llama.cpp JNI bindings, emphasizing modularity, thread safety, and configurability. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/package.ai.md new file mode 100644 index 0000000..10eea6a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/java/package.ai.md @@ -0,0 +1,73 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:24:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. + +#### Purpose +- Provides configuration and selection mechanisms for AI field generation based on file extensions and model definitions. +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides AI text generation for prompts using specified or default sampling parameters. + +#### Responsibilities +- `AiFieldGenerationConfig`: Associates prompt and AI model definition keys with file extensions for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Configures AI generation parameters for Maven-based AI model interactions. +- `AiGenerationKind`: Identifies whether AI generation operates on a single source file or a whole package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Pluggable AI backend for generating text based on prompts. +- `AiGenerationProviderFactory`: Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. +- `LlamaCppJniAiGenerationProvider`: Provides a service for generating AI-based completion based on llama.cpp configurations. +- `LlamaCppJniConfig`: Provides configuration for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Key Units +- `AiFieldGenerationConfig`: Associates prompt template keys with AI model definition keys for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Carries parameters between Maven configuration and AI provider implementations. +- `AiGenerationKind`: Identifies AI generation operation scope: single file or package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory`: Selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider`: Uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig`: Configures the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Data Flow +- `AiFieldGenerationConfig` is instantiated with prompt and AI model definition keys and file extensions. +- `AiFieldGenerationSelector` iterates over configurations to select one based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` determines the scope of AI generation (single file or package). +- `AiModelDefinition` provides configuration parameters for AI model interactions. +- `AiModelDefinitionSupport` resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser` processes raw completion text to extract the model answer. +- `AiGenerationProvider` generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory` selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider` uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig` configures the llama.cpp JNI provider. + +#### Dependencies +- `AiFieldGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiFieldGenerationSelector` imports `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationKind` has no imports. +- `AiModelDefinition` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`. +- `AiModelDefinitionSupport` imports `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. +- `AiCompletionParser` imports `java.io.IOException`, `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.ToString`, `net.ladenthin.llama.LlamaModel`, `net.ladenthin.llama.parameters.InferenceParameters`, `net.ladenthin.llama.parameters.ModelParameters`, `net.ladenthin.llama.value.Pair`, `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`. + +#### Cross-cutting +- Thread-safe due to lazy initialization of the model and use of immutable parameters. +- Immutable configuration with value semantics. + +#### Summary +This package provides a comprehensive set of classes and configurations for calculating VAT for invoices through AI field generation, selection, and AI model interactions, with clear dependencies and responsibilities structured around specific functional roles. Additionally, it includes tools for parsing LLM completion text and generating AI text using llama.cpp JNI bindings, emphasizing modularity, thread safety, and configurability. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/package.ai.md new file mode 100644 index 0000000..876ab6f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/main/package.ai.md @@ -0,0 +1,73 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:25:52Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. + +#### Purpose +- Provides configuration and selection mechanisms for AI field generation based on file extensions and model definitions. +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides AI text generation for prompts using specified or default sampling parameters. + +#### Responsibilities +- `AiFieldGenerationConfig`: Associates prompt and AI model definition keys with file extensions for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Configures AI generation parameters for Maven-based AI model interactions. +- `AiGenerationKind`: Identifies whether AI generation operates on a single source file or a whole package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Pluggable AI backend for generating text based on prompts. +- `AiGenerationProviderFactory`: Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. +- `LlamaCppJniAiGenerationProvider`: Provides a service for generating AI-based completion based on llama.cpp configurations. +- `LlamaCppJniConfig`: Provides configuration for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Key Units +- `AiFieldGenerationConfig`: Associates prompt template keys with AI model definition keys for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Carries parameters between Maven configuration and AI provider implementations. +- `AiGenerationKind`: Identifies AI generation operation scope: single file or package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory`: Selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider`: Uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig`: Configures the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Data Flow +- `AiFieldGenerationConfig` is instantiated with prompt and AI model definition keys and file extensions. +- `AiFieldGenerationSelector` iterates over configurations to select one based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` determines the scope of AI generation (single file or package). +- `AiModelDefinition` provides configuration parameters for AI model interactions. +- `AiModelDefinitionSupport` resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser` processes raw completion text to extract the model answer. +- `AiGenerationProvider` generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory` selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider` uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig` configures the llama.cpp JNI provider. + +#### Dependencies +- `AiFieldGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiFieldGenerationSelector` imports `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationKind` has no imports. +- `AiModelDefinition` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`. +- `AiModelDefinitionSupport` imports `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. +- `AiCompletionParser` imports `java.io.IOException`, `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.ToString`, `net.ladenthin.llama.LlamaModel`, `net.ladenthin.llama.parameters.InferenceParameters`, `net.ladenthin.llama.parameters.ModelParameters`, `net.ladenthin.llama.value.Pair`, `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`. + +#### Cross-cutting +- Thread-safe due to lazy initialization of the model and use of immutable parameters. +- Immutable configuration with value semantics. + +#### Summary +This package provides a comprehensive set of classes and configurations for calculating VAT for invoices through AI field generation, selection, and AI model interactions, with clear dependencies and responsibilities structured around specific functional roles. Additionally, it includes tools for parsing LLM completion text and generating AI text using llama.cpp JNI bindings, emphasizing modularity, thread safety, and configurability. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/package.ai.md new file mode 100644 index 0000000..340805e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/package.ai.md @@ -0,0 +1,73 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:27:24Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. + +#### Purpose +- Provides configuration and selection mechanisms for AI field generation based on file extensions and model definitions. +- Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. +- Provides AI text generation for prompts using specified or default sampling parameters. + +#### Responsibilities +- `AiFieldGenerationConfig`: Associates prompt and AI model definition keys with file extensions for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Configures AI generation parameters for Maven-based AI model interactions. +- `AiGenerationKind`: Identifies whether AI generation operates on a single source file or a whole package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Pluggable AI backend for generating text based on prompts. +- `AiGenerationProviderFactory`: Calculates VAT for invoices using the llama.cpp JNI binding and GGUF models locally. +- `LlamaCppJniAiGenerationProvider`: Provides a service for generating AI-based completion based on llama.cpp configurations. +- `LlamaCppJniConfig`: Provides configuration for the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Key Units +- `AiFieldGenerationConfig`: Associates prompt template keys with AI model definition keys for field generation. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on source file extensions. +- `AiGenerationConfig`: Carries parameters between Maven configuration and AI provider implementations. +- `AiGenerationKind`: Identifies AI generation operation scope: single file or package. +- `AiModelDefinition`: Provides a configuration POJO for pairing a lookup key with AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser`: Parses raw LLM completion text to extract the model answer. +- `AiGenerationProvider`: Generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory`: Selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider`: Uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig`: Configures the llama.cpp JNI provider. +- `MockAiGenerationProvider`: Provides deterministic mock summaries for AI generation requests in testing. + +#### Data Flow +- `AiFieldGenerationConfig` is instantiated with prompt and AI model definition keys and file extensions. +- `AiFieldGenerationSelector` iterates over configurations to select one based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` determines the scope of AI generation (single file or package). +- `AiModelDefinition` provides configuration parameters for AI model interactions. +- `AiModelDefinitionSupport` resolves AI model definition entries by their key, returning the corresponding AI generation configuration. +- `AiCompletionParser` processes raw completion text to extract the model answer. +- `AiGenerationProvider` generates text based on `AiGenerationRequest`. +- `AiGenerationProviderFactory` selects and instantiates an `AiGenerationProvider` implementation by name. +- `LlamaCppJniAiGenerationProvider` uses llama.cpp JNI bindings to generate text. +- `LlamaCppJniConfig` configures the llama.cpp JNI provider. + +#### Dependencies +- `AiFieldGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiFieldGenerationSelector` imports `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationConfig` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +- `AiGenerationKind` has no imports. +- `AiModelDefinition` imports `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`. +- `AiModelDefinitionSupport` imports `java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. +- `AiCompletionParser` imports `java.io.IOException`, `java.util.ArrayList`, `java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.ToString`, `net.ladenthin.llama.LlamaModel`, `net.ladenthin.llama.parameters.InferenceParameters`, `net.ladenthin.llama.parameters.ModelParameters`, `net.ladenthin.llama.value.Pair`, `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`. + +#### Cross-cutting +- Thread-safe due to lazy initialization of the model and use of immutable parameters. +- Immutable configuration with value semantics. + +#### Summary +This package provides a comprehensive set of classes and configurations for calculating VAT for invoices through AI field generation, selection, and AI model interactions, with clear dependencies and responsibilities structured around specific functional roles. Additionally, it includes tools for parsing LLM completion text and generating AI text using llama.cpp JNI bindings, emphasizing modularity, thread safety, and configurability. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/project.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/project.ai.md new file mode 100644 index 0000000..620357a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v1/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: D6FBE2AC +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:28:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The llamacpp-ai-index-maven-plugin project is structured around a central package for calculating VAT for invoices using AI field generation, selection, and AI model interactions. It includes sub-packages for parsing LLM completion text and providing AI text generation services using llama.cpp JNI bindings. The project integrates various components to facilitate seamless AI interactions and invoice processing, ensuring efficient and accurate financial calculations. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Calculates VAT for invoices +- main/java/net/ladenthin/maven/llamacpp/aiindex — A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — A package for parsing LLM completion text and providing AI text generation services using llama.cpp JNI bindings. +- main/java/net/ladenthin/maven/llamacpp — A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. +- main/java/net/ladenthin/maven — A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. +- main/java/net/ladenthin — A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. +- main/java/net — A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. +- main/java — A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. +- main — A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. +- . — A package for calculating VAT for invoices through AI field generation, selection, and AI model interactions. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..be5f7e8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,60 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:29:25Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Maven plugin configuration POJO associating prompt templates with AI model definitions for field generation. + +#### Purpose +- Config POJO for associating prompt templates with AI model definitions. +- Used in Maven plugin configuration for field generation. + +#### Type +- Class: `AiFieldGenerationConfig` +- Extends: `java.lang.Object` +- Implements: `java.io.Serializable` +- Key generics: `java.util.List` +- Annotations: `@ToString`, `@SuppressWarnings({"NullAway.Init", "initialization.fields.uninitialized"})` + +#### Input +- Constructor parameters: none +- Dependencies: none +- Consumed fields: `promptKey`, `aiDefinitionKey`, `fileExtensions` +- Read resources: none + +#### Output +- Return types: `String` for getters, `void` for setters +- Produced/mutated state: none +- Written resources: none +- Side effects: none + +#### Core logic +- Creates a new instance with no-op. +- Sets and gets `promptKey`, `aiDefinitionKey`, and `fileExtensions`. +- `getFileExtensions()` returns an unmodifiable list or `null`. + +#### Public API +- `AiFieldGenerationConfig()`: no-op constructor +- `getPromptKey() -> String`: returns prompt template key +- `setPromptKey(String)`: sets prompt template key +- `getAiDefinitionKey() -> String`: returns AI model definition key +- `setAiDefinitionKey(String)`: sets AI model definition key +- `getFileExtensions() -> @Nullable List`: returns file extensions or `null` +- `setFileExtensions(Collection)`: sets file extensions, defensively copied + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collections` +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- None notable + +#### Concurrency +- Not applicable (no threading or concurrency concerns) diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..0ba8dae --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,55 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:30:11Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the appropriate AI field generation configuration based on a source file's extensions. + +#### Purpose +- Chooses the correct AI field generation configuration for a given source file based on file extensions. +- Supports extension-specific prompts and a fallback for files without matching extensions. + +#### Type +- Class: `AiFieldGenerationSelector` +- Extends: None +- Implements: None +- Key generics: None +- Annotations: `@ToString`, `@lombok.ToString`, `@org.jspecify.annotations.Nullable` + +#### Input +- Constructor: None +- Method `selectForFileName`: + - `Iterable configs`: Configurations in declaration order. + - `String fileName`: The source file name. + +#### Output +- Returns: `AiFieldGenerationConfig` or `null` +- Produces: Config selection based on file extensions. +- Writes: None +- Side effects: None + +#### Core Logic +- Iterates over `configs`: + - Skips `null` entries. + - Checks if the configuration has non-empty extensions. + - Matches `fileName` with each extension. + - Returns the first matching configuration. + - Falls back to the first configuration with no extensions or `null` if none match. + +#### Public API +- `AiFieldGenerationSelector()`: No-op constructor. +- `selectForFileName(Iterable, String)`: Returns the appropriate `AiFieldGenerationConfig` based on file extensions. + +#### Dependencies +- `AiFieldGenerationConfig` +- `List` + +#### Exceptions / Errors +- None explicitly thrown or caught. + +#### Concurrency +- Not explicitly threaded or thread-safe. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..d9f1db4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,78 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:30:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> This file defines a mutable configuration object for AI generation steps, managing parameters like model path, context size, output tokens, temperature, retry policies, input trimming, and stop strings. + +#### Purpose +- Mutable configuration object for AI generation parameters. +- Manages model path, context size, output tokens, temperature, retry policies, input trimming, and stop strings. + +#### Type +- Class (`AiGenerationConfig`) extends `java.lang.Object`; implements `java.io.Serializable`. + +#### Input +- Constructor parameters: none. +- Dependencies: none. +- Consumed fields: `modelPath`, `contextSize`, `maxOutputTokens`, `temperature`, `threads`, `charsPerToken`, `maxInputChars`, `warnOnTrim`, `maxRetries`, `retryTemperatureIncrement`, `topP`, `topK`, `repeatPenalty`, `chatTemplateEnableThinking`, `stopStrings`. + +#### Output +- Returns: instance fields (`modelPath`, `contextSize`, `maxOutputTokens`, `temperature`, `threads`, `charsPerToken`, `maxInputChars`, `warnOnTrim`, `maxRetries`, `retryTemperatureIncrement`, `topP`, `topK`, `repeatPenalty`, `chatTemplateEnableThinking`, `stopStrings`). +- Produced state: none. +- Written resources: none. +- Side effects: none. + +#### Core logic +- Initializes with default values. +- Provides getter and setter methods for all configuration parameters. +- Manages stop strings as an unmodifiable list. + +#### Public API +- `AiGenerationConfig()`: Creates a new instance with default parameters. +- `getModelPath()`: Returns the model path. +- `setModelPath(String)`: Sets the model path. +- `getContextSize()`: Returns the context size. +- `setContextSize(int)`: Sets the context size. +- `getMaxOutputTokens()`: Returns the max output tokens. +- `setMaxOutputTokens(int)`: Sets the max output tokens. +- `getTemperature()`: Returns the temperature. +- `setTemperature(float)`: Sets the temperature. +- `getThreads()`: Returns the number of threads. +- `setThreads(int)`: Sets the number of threads. +- `getCharsPerToken()`: Returns chars per token. +- `setCharsPerToken(int)`: Sets chars per token. +- `getMaxInputChars()`: Returns max input chars. +- `setMaxInputChars(int)`: Sets max input chars. +- `isWarnOnTrim()`: Returns trim warning status. +- `setWarnOnTrim(boolean)`: Sets trim warning status. +- `getMaxRetries()`: Returns max retries. +- `setMaxRetries(int)`: Sets max retries. +- `getRetryTemperatureIncrement()`: Returns retry temperature increment. +- `setRetryTemperatureIncrement(float)`: Sets retry temperature increment. +- `getTopP()`: Returns top-p value. +- `setTopP(float)`: Sets top-p value. +- `getTopK()`: Returns top-k value. +- `setTopK(int)`: Sets top-k value. +- `getRepeatPenalty()`: Returns repeat penalty. +- `setRepeatPenalty(float)`: Sets repeat penalty. +- `isChatTemplateEnableThinking()`: Returns chat-template thinking status. +- `setChatTemplateEnableThinking(boolean)`: Sets chat-template thinking status. +- `getStopStrings()`: Returns unmodifiable list of stop strings. +- `setStopStrings(List)`: Sets stop strings. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collections` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- None explicitly mentioned. + +#### Concurrency +- Thread-safe for immutable fields; mutable fields are managed within the class. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..3684a7d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,40 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:32:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Identifies whether an AI generation operates on a single source file or a whole package. + +#### Purpose +- Enum for AI generation kind: single file or package summary. + +#### Type +- Enum: `AiGenerationKind` + +#### Input +- None + +#### Output +- None + +#### Core logic +- Defines two constants: + - `FILE_SUMMARY` + - `PACKAGE_SUMMARY` + +#### Public API +- `FILE_SUMMARY`: Identifies generation for a single source file. +- `PACKAGE_SUMMARY`: Identifies generation for a package aggregate. + +#### Dependencies +- None + +#### Exceptions / Errors +- None + +#### Concurrency +- Not thread-safe (enum is inherently immutable and thread-safe) diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..54a173b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,71 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:32:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Maven plugin configuration POJO that pairs a lookup key with a complete set of AI model parameters. + +#### Purpose +- Represents AI model configuration for Maven plugin. +- Allows reuse across multiple field-generation entries and goals. + +#### Type +- Class, `public class AiModelDefinition`, extends `java.lang.Object`, implements `java.io.Serializable`. + +#### Input +- Constructor parameters: none. +- Dependencies: none. + +#### Output +- Returns: getters for configuration parameters. +- Produces: mutable state changes via setters. + +#### Core Logic +- Initializes with default values from `AiGenerationConfig`. +- Provides getters/setters for configuration parameters. +- Manages stop strings list. + +#### Public API +- `getKey() -> String`: Returns the unique lookup key. +- `setKey(String) -> void`: Sets the unique lookup key. +- `getModelPath() -> String`: Returns the model path. +- `setModelPath(String) -> void`: Sets the model path. +- `getContextSize() -> int`: Returns context size. +- `setContextSize(int) -> void`: Sets context size. +- `getMaxOutputTokens() -> int`: Returns max output tokens. +- `setMaxOutputTokens(int) -> void`: Sets max output tokens. +- `getTemperature() -> float`: Returns temperature. +- `setTemperature(float) -> void`: Sets temperature. +- `getThreads() -> int`: Returns thread count. +- `setThreads(int) -> void`: Sets thread count. +- `getCharsPerToken() -> int`: Returns chars-per-token ratio. +- `setCharsPerToken(int) -> void`: Sets chars-per-token ratio. +- `isWarnOnTrim() -> boolean`: Returns warning flag. +- `setWarnOnTrim(boolean) -> void`: Sets warning flag. +- `getMaxRetries() -> int`: Returns max retries. +- `setMaxRetries(int) -> void`: Sets max retries. +- `getRetryTemperatureIncrement() -> float`: Returns retry temperature increment. +- `setRetryTemperatureIncrement(float) -> void`: Sets retry temperature increment. +- `getTopP() -> float`: Returns top-p value. +- `setTopP(float) -> void`: Sets top-p value. +- `getTopK() -> int`: Returns top-k value. +- `setTopK(int) -> void`: Sets top-k value. +- `getRepeatPenalty() -> float`: Returns repeat penalty. +- `setRepeatPenalty(float) -> void`: Sets repeat penalty. +- `isChatTemplateEnableThinking() -> boolean`: Returns chat template thinking flag. +- `setChatTemplateEnableThinking(boolean) -> void`: Sets chat template thinking flag. +- `getStopStrings() -> @Nullable List`: Returns stop strings. +- `setStopStrings(Collection) -> void`: Sets stop strings. + +#### Dependencies +- `AiGenerationConfig`: referenced for default values. + +#### Exceptions / Errors +- None notable. + +#### Concurrency +- Not explicitly noted, but all setters allow mutable state changes. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..55d7f9e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,47 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:33:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key to generate AI generation configurations. + +#### Purpose +- Provides a lookup table for AI model definitions. +- Converts `AiModelDefinition` entries to `AiGenerationConfig` objects. + +#### Type +- Class + final + lombok.ToString + +#### Input +- List of `AiModelDefinition` objects +- Java8CompatibilityHelper dependency + +#### Output +- Map of `String` keys to `AiGenerationConfig` objects +- Throws `NullPointerException` for null keys +- Throws `IllegalArgumentException` for missing keys + +#### Core logic +- Constructs a map of `AiGenerationConfig` objects from `AiModelDefinition` entries +- Ensures each `AiModelDefinition` has a non-null `key` +- Converts `AiModelDefinition` fields to `AiGenerationConfig` fields + +#### Public API +- `AiModelDefinitionSupport(List)`: Builds the configuration map +- `AiGenerationConfig getConfig(String)`: Retrieves config by key + +#### Dependencies +- `HashMap` +- `Objects` +- `Java8CompatibilityHelper` + +#### Exceptions / Errors +- `NullPointerException` for null keys +- `IllegalArgumentException` for missing keys + +#### Concurrency +- Thread-safe due to immutable `HashMap` usage diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..ae3ba4f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,66 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:36:36Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> This package provides a comprehensive configuration and generation framework for AI field generation in Maven plugins, facilitating the association of prompt templates with AI model definitions and the selection of appropriate configurations based on source file extensions. + +#### Purpose +- Config POJO for associating prompt templates with AI model definitions. +- Chooses the correct AI field generation configuration for a given source file based on file extensions. +- Defines mutable configuration object for AI generation parameters. +- Identifies whether an AI generation operates on a single source file or a whole package. +- Represents AI model configuration for Maven plugin. +- Provides a lookup table for AI model definitions. + +#### Responsibilities +- `AiFieldGenerationConfig`: Config POJO for associating prompt templates with AI model definitions. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on a source file's extensions. +- `AiGenerationConfig`: Mutable configuration object for AI generation parameters. +- `AiGenerationKind`: Enum for AI generation kind: single file or package summary. +- `AiModelDefinition`: Maven plugin configuration POJO that pairs a lookup key with a complete set of AI model parameters. +- `AiModelDefinitionSupport`: Resolves AI model definitions by key to generate AI generation configurations. + +#### Key units +- `AiFieldGenerationConfig`: Config POJO for associating prompt templates with AI model definitions. +- `AiFieldGenerationSelector`: Chooses the correct AI field generation configuration for a given source file based on file extensions. +- `AiGenerationConfig`: Mutable configuration object for AI generation parameters. +- `AiGenerationKind`: Enum for AI generation kind: single file or package summary. +- `AiModelDefinition`: Represents AI model configuration for Maven plugin. +- `AiModelDefinitionSupport`: Resolves AI model definitions by key to generate AI generation configurations. + +#### Data flow +- `AiFieldGenerationConfig` is instantiated and configured with prompt keys, AI model definition keys, and file extensions. +- `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` identifies the type of AI generation. +- `AiModelDefinition` is used to configure AI model parameters. +- `AiModelDefinitionSupport` resolves `AiModelDefinition` entries to `AiGenerationConfig` objects. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collections` +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` +- `HashMap` +- `Objects` +- `Java8CompatibilityHelper` + +#### Cross-cutting +- Immutable configuration objects for thread safety. +- Default values for mutable configurations. +- Error handling for missing keys and null inputs. + +#### Summary +This package offers a robust framework for AI field generation in Maven plugins, providing configuration POJOs, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions, all designed to streamline the integration and customization of AI functionalities within Maven projects. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..2d7e254 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,62 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:38:35Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> This package provides a comprehensive configuration and generation framework for AI field generation in Maven plugins, facilitating the association of prompt templates with AI model definitions and the selection of appropriate configurations based on source file extensions. + +#### Purpose +- Config POJO for associating prompt templates with AI model definitions. +- Chooses the correct AI field generation configuration for a given source file based on file extensions. +- Defines mutable configuration object for AI generation parameters. +- Identifies whether an AI generation operates on a single source file or a whole package. +- Represents AI model configuration for Maven plugin. +- Provides a lookup table for AI model definitions. + +#### Responsibilities +- `AiFieldGenerationConfig`: Config POJO for associating prompt templates with AI model definitions. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration based on a source file's extensions. +- `AiGenerationConfig`: Mutable configuration object for AI generation parameters. +- `AiGenerationKind`: Enum for AI generation kind: single file or package summary. +- `AiModelDefinition`: Represents AI model configuration for Maven plugin. +- `AiModelDefinitionSupport`: Resolves AI model definitions by key to generate AI generation configurations. + +#### Key units +- `AiFieldGenerationConfig`: Config POJO for associating prompt templates with AI model definitions. +- `AiFieldGenerationSelector`: Chooses the correct AI field generation configuration based on a source file's extensions. +- `AiGenerationConfig`: Mutable configuration object for AI generation parameters. +- `AiGenerationKind`: Enum for AI generation kind: single file or package summary. +- `AiModelDefinition`: Represents AI model configuration for Maven plugin. +- `AiModelDefinitionSupport`: Resolves AI model definitions by key to generate AI generation configurations. + +#### Data flow +- `AiFieldGenerationConfig` is instantiated and configured with prompt keys, AI model definition keys, and file extensions. +- `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on source file extensions. +- `AiGenerationConfig` is used to configure AI generation parameters. +- `AiGenerationKind` identifies the type of AI generation. +- `AiModelDefinition` is used to configure AI model parameters. +- `AiModelDefinitionSupport` resolves `AiModelDefinition` entries to `AiGenerationConfig` objects. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collections` +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` +- `HashMap` +- `Objects` +- `Java8CompatibilityHelper` + +#### Cross-cutting +- Immutable configuration objects for thread safety. +- Default values for mutable configurations. +- Error handling for missing keys and null inputs. + +#### Summary +This package offers a robust framework for AI field generation in Maven plugins, providing configuration POJOs, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions, all designed to streamline the integration and customization of AI functionalities within Maven projects. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..1336943 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,44 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:33:51Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. + +#### Purpose +- Parses raw LLM completion text. +- Strips model-internal thinking block. +- Returns the actual model answer. + +#### Type +- Class: `AiCompletionParser` (non-final). + +#### Input +- `String response`: raw completion text from the model, may be `null`. + +#### Output +- `String`: cleaned answer text, never `null`. + +#### Core Logic +- Checks if `response` is `null`; returns empty string if true. +- Finds the last occurrence of `THINKING_BLOCK_END_MARKER`. + - If found, returns text after the marker, trimmed. + - If not found but `THINKING_BLOCK_START_MARKER` is present, throws `IOException`. + - If neither marker is present, returns trimmed `response`. + +#### Public API +- `parseCompletion(String response) throws IOException`: Strips thinking block and returns answer. + +#### Dependencies +- `java.io.IOException`. +- `lombok.ToString`. + +#### Exceptions / Errors +- Throws `IOException` if thinking block starts but end marker is absent. + +#### Concurrency +- Not explicitly covered in the source. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..fcc6650 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,41 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:34:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> A pluggable AI backend that generates text for an AiGenerationRequest, supporting both local and mock providers. + +#### Purpose +- Provides AI text generation functionality. +- Supports both local and mock implementations. + +#### Type +- Interface: `AiGenerationProvider` extends `AutoCloseable`. + +#### Input +- `AiGenerationRequest` for prompt key, source file, source text, and current header. + +#### Output +- Generated text as a `String`. +- May throw `IOException`. + +#### Core Logic +- `generate(AiGenerationRequest request)`: Generates text using default parameters. +- `generate(AiGenerationRequest request, float temperatureOverride)`: Overrides temperature for generation. + +#### Public API +- `String generate(AiGenerationRequest request) throws IOException`: Generates text with default settings. +- `String generate(AiGenerationRequest request, float temperatureOverride) throws IOException`: Generates text with specified temperature. + +#### Dependencies +- `AiGenerationRequest`: Used for generating text. + +#### Exceptions / Errors +- `IOException`: Thrown by the provider on failure. + +#### Concurrency +- Not explicitly mentioned, but the interface is designed to be thread-safe as it is stateless. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..5107e88 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,45 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:34:39Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> A factory for selecting and instantiating an AI generation provider by name. + +#### Purpose +- Factory class to instantiate `AiGenerationProvider` implementations based on a provider name. + +#### Type +- Class: `AiGenerationProviderFactory` extends `Object`; implements no interfaces; no generics; `@ToString`. + +#### Input +- Constructor: none. +- Method `create(String providerName, LlamaCppJniConfig llamaConfig, AiPromptSupport promptSupport)`. + +#### Output +- Returns: `AiGenerationProvider` instance. +- Produces: `MockAiGenerationProvider` or `LlamaCppJniAiGenerationProvider` based on input. + +#### Core Logic +- If `providerName` is null or blank, return `MockAiGenerationProvider`. +- If `providerName` is "mock", return `MockAiGenerationProvider`. +- If `providerName` is "llamacpp-jni", return `LlamaCppJniAiGenerationProvider`. +- Otherwise, throw `IllegalArgumentException`. + +#### Public API +- `create(String providerName, LlamaCppJniConfig llamaConfig, AiPromptSupport promptSupport) -> AiGenerationProvider` + Creates an AI generation provider based on the provider name. + +#### Dependencies +- `Java8CompatibilityHelper` +- `LlamaCppJniConfig` +- `AiPromptSupport` + +#### Exceptions / Errors +- Throws `IllegalArgumentException` for unsupported provider names. + +#### Concurrency +- Not explicitly noted; assumes single-threaded usage. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..130094a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,57 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:35:04Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> This file provides a Java implementation of an AI generation provider using the llama.cpp JNI binding to run GGUF models locally. + +#### Purpose +- Implements `AiGenerationProvider` for local GGUF model inference. +- Lazy-loads and caches `LlamaModel` instances. + +#### Type +- Class: `LlamaCppJniAiGenerationProvider` +- Implements: `AiGenerationProvider`, `AutoCloseable` +- Extends: None +- Key generics: None +- Annotations: `@ToString`, `@Nullable` + +#### Input +- Constructor parameters: `LlamaCppJniConfig config`, `AiPromptSupport promptSupport` +- Consumed fields: None + +#### Output +- Return types: `String` (generated text) +- Produced/mutated state: `LlamaModel` (cached) +- Written resources: None +- Side effects: Lazy loading of native llama.cpp model + +#### Core logic +- Lazy initialization of `LlamaModel` on first `generate` call. +- Builds prompt using `AiPromptSupport`. +- Constructs `InferenceParameters` with configuration settings. +- Executes `model.chatCompleteText` to generate completion. + +#### Public API +- `LlamaCppJniAiGenerationProvider(LlamaCppJniConfig config, AiPromptSupport promptSupport)` +- `String generate(AiGenerationRequest request) throws IOException` +- `String generate(AiGenerationRequest request, float temperatureOverride) throws IOException` +- `void close()` + +#### Dependencies +- `LlamaCppJniConfig` +- `AiPromptSupport` +- `LlamaModel` +- `InferenceParameters` +- `Pair` +- `AiCompletionParser` + +#### Exceptions / Errors +- `IOException` from `completionParser.parseCompletion` and `model.chatCompleteText`. + +#### Concurrency +- Not explicitly covered in the source. Assumes single-threaded usage due to lack of threading constructs. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..35c28d5 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,53 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:35:40Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Immutable configuration for the llama.cpp JNI provider. + +#### Purpose +- Immutable configuration class for llama.cpp JNI provider. +- Record-shaped value type with generated equals, hashCode, and toString. + +#### Type +- Class `LlamaCppJniConfig` (final) extends `Object`; implements `java.lang.AutoCloseable` (not present in source). + +#### Input +- Constructor parameters: `libraryPath`, `modelPath`, `contextSize`, `maxOutputTokens`, `temperature`, `threads`, `topP`, `topK`, `repeatPenalty`, `chatTemplateEnableThinking`, `stopStrings`. + +#### Output +- Returns: `libraryPath()`, `modelPath()`, `contextSize()`, `maxOutputTokens()`, `temperature()`, `threads()`, `topP()`, `topK()`, `repeatPenalty()`, `chatTemplateEnableThinking()`, `stopStrings()`. + +#### Core logic +- Ensures `modelPath` is not null. +- Initializes fields with provided values; `stopStrings` defaults to empty list if null. + +#### Public API +- `libraryPath() -> String` +- `modelPath() -> String` +- `contextSize() -> int` +- `maxOutputTokens() -> int` +- `temperature() -> float` +- `threads() -> int` +- `topP() -> float` +- `topK() -> int` +- `repeatPenalty() -> float` +- `chatTemplateEnableThinking() -> boolean` +- `stopStrings() -> List` + +#### Dependencies +- `java.util.Collections` +- `java.util.List` +- `java.util.Objects` +- `lombok.EqualsAndHashCode` +- `lombok.ToString` + +#### Exceptions / Errors +- None notable. + +#### Concurrency +- Immutable configuration; thread-safe. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..d7f60a8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,41 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:36:16Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> A deterministic AI generation provider that returns a mock summary for testing. + +#### Purpose +- Provides a deterministic mock summary for testing AI generation requests. + +#### Type +- Class: `MockAiGenerationProvider` implements `AiGenerationProvider`. + +#### Input +- `AiGenerationRequest request`: Input request containing source file details. + +#### Output +- `String`: Returns a mock summary string for the provided request. + +#### Core Logic +- Retrieves the file name from the request. +- Constructs and returns a mock summary string prefixed with "Mock summary for " followed by the file name. + +#### Public API +- `MockAiGenerationProvider()`: No-op constructor. +- `String generate(final AiGenerationRequest request) throws IOException`: Generates a mock summary for the given request. + +#### Dependencies +- `java.io.IOException`: Exception thrown if an I/O error occurs. +- `lombok.ToString`: Annotation for generating toString method. +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`: Interface for AI generation requests. + +#### Exceptions / Errors +- `IOException`: Thrown if an I/O error occurs during request processing. + +#### Concurrency +- Not explicitly noted in the source. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..b183014 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,56 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:37:49Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> A package for parsing LLM completion text, generating AI text, and providing configurable AI generation providers. + +#### Purpose +- Parses raw LLM completion text. +- Generates AI text with configurable providers. + +#### Responsibilities +- `AiCompletionParser`: Strips thinking block from completion text. +- `AiGenerationProvider`: Interface for AI text generation. +- `AiGenerationProviderFactory`: Factory for instantiating `AiGenerationProvider` implementations. +- `LlamaCppJniAiGenerationProvider`: JNI-based local GGUF model inference. +- `LlamaCppJniConfig`: Configuration for llama.cpp JNI provider. +- `MockAiGenerationProvider`: Mock provider for deterministic testing. + +#### Key units +- `AiCompletionParser`: Parses and cleans completion text. +- `AiGenerationProvider`: Generates AI text. +- `AiGenerationProviderFactory`: Factory for provider instantiation. +- `LlamaCppJniAiGenerationProvider`: Local GGUF model inference. +- `LlamaCppJniConfig`: Configuration for llama.cpp. +- `MockAiGenerationProvider`: Mock text generation. + +#### Data flow +- `AiGenerationRequest` -> `AiGenerationProviderFactory` -> `AiGenerationProvider` -> `String` (generated text). + +#### Dependencies +- `java.io.IOException`. +- `lombok.ToString`. +- `lombok.EqualsAndHashCode`. +- `lombok.ToString`. +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`. +- `lombok`. + +#### Cross-cutting +- Thread-safe design for `AiGenerationProvider`. +- Lazy loading of `LlamaModel` in `LlamaCppJniAiGenerationProvider`. + +#### Notable internal collaborations +- `AiCompletionParser` for text parsing. +- `LlamaCppJniConfig` for llama.cpp configuration. +- `AiGenerationRequest` for request handling. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..0ddbe91 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,11 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:39:25Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> This package offers a robust framework for AI field generation in Maven plugins, providing configuration POJOs, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions, all designed to streamline the integration and customization of AI functionalities within Maven projects. diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..96b9cf4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,41 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:39:39Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions to streamline AI integration and customization in Maven projects. + +#### Purpose +- Facilitates AI field generation in Maven plugins +- Provides configuration management and selection mechanisms +- Supports mutable generation configurations +- Includes a lookup system for AI model definitions + +#### Responsibilities +- Configuration POJOs for AI field generation +- Mechanisms for selecting AI models +- Mutable generation configurations +- Lookup system for AI model definitions + +#### Key Units +- `Configuration`: Manages AI field generation configurations +- `ModelSelector`: Selects appropriate AI models based on criteria +- `MutableGenerationConfig`: Provides mutable configurations for AI generation +- `ModelLookup`: Facilitates lookup of AI model definitions + +#### Data Flow +Inputs from configuration files and user preferences flow through the system, processed by `Configuration` and `ModelSelector` to generate mutable configurations via `MutableGenerationConfig`, which are then utilized by `ModelLookup` to retrieve the appropriate AI models. + +#### Dependencies +- Utilizes Maven plugin infrastructure +- Relies on external AI model definitions and configurations + +#### Cross-cutting +- Shared base types for configuration and model management +- Common error handling across components +- Concurrency considerations in mutable generation configurations diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..85101f7 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,41 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:40:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. + +#### Purpose +- Facilitates AI field generation in Maven plugins +- Provides configuration management and selection mechanisms +- Supports mutable generation configurations +- Includes a lookup system for AI model definitions + +#### Responsibilities +- Configuration POJOs for AI field generation +- Mechanisms for selecting AI models +- Mutable generation configurations +- Lookup system for AI model definitions + +#### Key Units +- `Configuration`: Manages AI field generation configurations +- `ModelSelector`: Selects appropriate AI models based on criteria +- `MutableGenerationConfig`: Provides mutable configurations for AI generation +- `ModelLookup`: Facilitates lookup of AI model definitions + +#### Data Flow +Inputs from configuration files and user preferences flow through the system, processed by `Configuration` and `ModelSelector` to generate mutable configurations via `MutableGenerationConfig`, which are then utilized by `ModelLookup` to retrieve the appropriate AI models. + +#### Dependencies +- Utilizes Maven plugin infrastructure +- Relies on external AI model definitions and configurations + +#### Cross-cutting +- Shared base types for configuration and model management +- Common error handling across components +- Concurrency considerations in mutable generation configurations diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/package.ai.md new file mode 100644 index 0000000..dba4424 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/net/package.ai.md @@ -0,0 +1,41 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:40:23Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. + +#### Purpose +- Facilitates AI field generation in Maven plugins +- Provides configuration management and selection mechanisms +- Supports mutable generation configurations +- Includes a lookup system for AI model definitions + +#### Responsibilities +- Configuration POJOs for AI field generation +- Mechanisms for selecting AI models +- Mutable generation configurations +- Lookup system for AI model definitions + +#### Key Units +- `Configuration`: Manages AI field generation configurations +- `ModelSelector`: Selects appropriate AI models based on criteria +- `MutableGenerationConfig`: Provides mutable configurations for AI generation +- `ModelLookup`: Facilitates lookup of AI model definitions + +#### Data Flow +Inputs from configuration files and user preferences flow through the system, processed by `Configuration` and `ModelSelector` to generate mutable configurations via `MutableGenerationConfig`, which are then utilized by `ModelLookup` to retrieve the appropriate AI models. + +#### Dependencies +- Utilizes Maven plugin infrastructure +- Relies on external AI model definitions and configurations + +#### Cross-cutting +- Shared base types for configuration and model management +- Common error handling across components +- Concurrency considerations in mutable generation configurations diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/package.ai.md new file mode 100644 index 0000000..5f1ff7a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/java/package.ai.md @@ -0,0 +1,41 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:40:45Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. + +#### Purpose +- Facilitates AI field generation in Maven plugins +- Provides configuration management and selection mechanisms +- Supports mutable generation configurations +- Includes a lookup system for AI model definitions + +#### Responsibilities +- Configuration POJOs for AI field generation +- Mechanisms for selecting AI models +- Mutable generation configurations +- Lookup system for AI model definitions + +#### Key Units +- `Configuration`: Manages AI field generation configurations +- `ModelSelector`: Selects appropriate AI models based on criteria +- `MutableGenerationConfig`: Provides mutable configurations for AI generation +- `ModelLookup`: Facilitates lookup of AI model definitions + +#### Data Flow +Inputs from configuration files and user preferences flow through the system, processed by `Configuration` and `ModelSelector` to generate mutable configurations via `MutableGenerationConfig`, which are then utilized by `ModelLookup` to retrieve the appropriate AI models. + +#### Dependencies +- Utilizes Maven plugin infrastructure +- Relies on external AI model definitions and configurations + +#### Cross-cutting +- Shared base types for configuration and model management +- Common error handling across components +- Concurrency considerations in mutable generation configurations diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/package.ai.md new file mode 100644 index 0000000..fc29032 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/main/package.ai.md @@ -0,0 +1,41 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:41:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. + +#### Purpose +- Facilitates AI field generation in Maven plugins +- Provides configuration management and selection mechanisms +- Supports mutable generation configurations +- Includes a lookup system for AI model definitions + +#### Responsibilities +- Configuration POJOs for AI field generation +- Mechanisms for selecting AI models +- Mutable generation configurations +- Lookup system for AI model definitions + +#### Key Units +- `Configuration`: Manages AI field generation configurations +- `ModelSelector`: Selects appropriate AI models based on criteria +- `MutableGenerationConfig`: Provides mutable configurations for AI generation +- `ModelLookup`: Facilitates lookup of AI model definitions + +#### Data Flow +Inputs from configuration files and user preferences flow through the system, processed by `Configuration` and `ModelSelector` to generate mutable configurations via `MutableGenerationConfig`, which are then utilized by `ModelLookup` to retrieve the appropriate AI models. + +#### Dependencies +- Utilizes Maven plugin infrastructure +- Relies on external AI model definitions and configurations + +#### Cross-cutting +- Shared base types for configuration and model management +- Common error handling across components +- Concurrency considerations in mutable generation configurations diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/package.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/package.ai.md new file mode 100644 index 0000000..1c75721 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/package.ai.md @@ -0,0 +1,41 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:41:30Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. + +#### Purpose +- Facilitates AI field generation in Maven plugins +- Provides configuration management and selection mechanisms +- Supports mutable generation configurations +- Includes a lookup system for AI model definitions + +#### Responsibilities +- Configuration POJOs for AI field generation +- Mechanisms for selecting AI models +- Mutable generation configurations +- Lookup system for AI model definitions + +#### Key Units +- `Configuration`: Manages AI field generation configurations +- `ModelSelector`: Selects appropriate AI models based on criteria +- `MutableGenerationConfig`: Provides mutable configurations for AI generation +- `ModelLookup`: Facilitates lookup of AI model definitions + +#### Data Flow +Inputs from configuration files and user preferences flow through the system, processed by `Configuration` and `ModelSelector` to generate mutable configurations via `MutableGenerationConfig`, which are then utilized by `ModelLookup` to retrieve the appropriate AI models. + +#### Dependencies +- Utilizes Maven plugin infrastructure +- Relies on external AI model definitions and configurations + +#### Cross-cutting +- Shared base types for configuration and model management +- Common error handling across components +- Concurrency considerations in mutable generation configurations diff --git a/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/project.ai.md b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/project.ai.md new file mode 100644 index 0000000..640a82a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__granite4-h-tiny__v2/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: 69D7D78F +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:41:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The llamacpp-ai-index-maven-plugin project is structured around a comprehensive framework for AI field generation within Maven plugins. It includes packages dedicated to configuration management, AI model selection, and AI text generation, facilitating seamless integration of AI functionalities into Maven projects. The main components are organized to support prompt template association with AI model definitions, selection of appropriate configurations based on source file extensions, and parsing of LLM completion text for AI generation. Together, these packages form a cohesive system designed to streamline the development and customization of AI features in Maven-based applications. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — This package provides a comprehensive configuration and generation framework for AI field generation in Maven plugins, facilitating the association of prompt templates with AI model definitions and the selection of appropriate configurations based on source file extensions. +- main/java/net/ladenthin/maven/llamacpp/aiindex — This package provides a comprehensive configuration and generation framework for AI field generation in Maven plugins, facilitating the association of prompt templates with AI model definitions and the selection of appropriate configurations based on source file extensions. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — A package for parsing LLM completion text, generating AI text, and providing configurable AI generation providers. +- main/java/net/ladenthin/maven/llamacpp — This package offers a robust framework for AI field generation in Maven plugins, providing configuration POJOs, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions, all designed to streamline the integration and customization of AI functionalities within Maven projects. +- main/java/net/ladenthin/maven — This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions to streamline AI integration and customization in Maven projects. +- main/java/net/ladenthin — This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. +- main/java/net — This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. +- main/java — This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. +- main — This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. +- . — This package provides a comprehensive framework for AI field generation within Maven plugins, offering configuration management, selection mechanisms, mutable generation configurations, and a lookup system for AI model definitions. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..08d364e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,78 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:18:48Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Manages AI field generation configuration in Maven plugin + +#### Purpose +- Holds configuration for associating prompt templates with AI models for field generation. +- Used within a list in the plugin configuration to define individual field-generation steps. + +#### Type +- Class +- Abstract: No +- Final: Yes +- Sealed: No +- Extends: None +- Implements: None +- Generics: None +- Key annotations: `@ToString`, `@Nullable` + +#### Input +- Constructor parameters: None +- Injected dependencies: None +- Consumed fields: None +- Read resources: None + +#### Output +- Return types: + - `String` (getters) + - `List` (getters) +- Produced state: + - `promptKey` + - `aiDefinitionKey` + - `fileExtensions` +- Written resources: None +- Side effects: None + +#### Core logic +- Holds configuration for a single field-generation step. +- References an AI model definition by key. +- Optionally specifies file extensions to select this entry. + +#### Public API +- `AiFieldGenerationConfig() -> void` — Creates a new configuration instance. +- `String getPromptKey() -> String` — Returns the prompt template key. +- `void setPromptKey(final String promptKey) -> void` — Sets the prompt template key. +- `String getAiDefinitionKey() -> String` — Returns the AI model definition key. +- `void setAiDefinitionKey(final String aiDefinitionKey) -> void` — Sets the AI model definition key. +- `@Nullable List getFileExtensions() -> @Nullable List` — Returns the source file extensions that select this entry. +- `void setFileExtensions(final @Nullable Collection fileExtensions) -> void` — Sets the source file extensions that select this entry. + +#### Dependencies +- Imports: + - `java.util.ArrayList` + - `java.util.Collection` + - `java.util.Collections` + - `java.util.List` + - `lombok.ToString` + - `org.jspecify.annotations.Nullable` +- Referenced types: + - `AiModelDefinition` + - `AiPromptDefinition` + +#### Exceptions / Errors +- Notable thrown/caught exceptions: None +- Null-handling: Uses `@Nullable` and defensive copying for list operations +- Error conditions: None + +#### Concurrency +- Threading: None +- Synchronization: None +- Immutability: None +- Thread-safety notes: None diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..63f25b4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,44 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:21:38Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the `AiFieldGenerationConfig` that applies to a given source file based on file extensions. + +#### Purpose +- Configures selection of AI field generation settings for source files based on their extensions. + +#### Type +- Class (`public final class`) +- Annotations: `@ToString`, `@Nullable` + +#### Input +- `configs`: Iterable of `AiFieldGenerationConfig` objects (nullable entries are skipped) +- `fileName`: String representing the source file name + +#### Output +- Returns the first `AiFieldGenerationConfig` whose non-empty extension list matches the file name, else the first fallback entry, else `null` + +#### Core logic +- Iterates through each `AiFieldGenerationConfig` in the provided iterable +- Skips any `null` entries +- Checks if the `AiFieldGenerationConfig` has a non-empty list of file extensions +- If no extension list or it is empty, sets this as the fallback configuration +- For each extension, checks if the file name ends with that extension and returns the corresponding `AiFieldGenerationConfig` +- If no matching configuration is found, returns the fallback configuration + +#### Public API +- `selectForFileName(final Iterable configs, final String fileName) -> @Nullable AiFieldGenerationConfig`: Selects the appropriate field generation configuration for a given file name. + +#### Dependencies +- Imports: `java.util.List`, `lombok.ToString`, `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- No notable exceptions; handles `null` entries in `configs` by skipping them + +#### Concurrency +- Not thread-safe; intended to be used in a single-threaded environment diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..4d9d24a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,109 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:22:58Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Manages configuration parameters for AI generation steps in a Maven project. + +#### Purpose +- Holds all parameters for an AI generation step. +- Transports these parameters between the Maven configuration layer and AI provider implementations. + +#### Type +- Class +- Final +- Lombok annotations: `@ToString` + +#### Input +- No constructor parameters. +- No injected dependencies. +- Consumed fields: + - `modelPath` + - `contextSize` + - `maxOutputTokens` + - `temperature` + - `threads` + - `charsPerToken` + - `maxInputChars` + - `warnOnTrim` + - `maxRetries` + - `retryTemperatureIncrement` + - `topP` + - `topK` + - `repeatPenalty` + - `chatTemplateEnableThinking` + - `stopStrings` + +#### Output +- No return types. +- Mutated fields: + - `modelPath` + - `contextSize` + - `maxOutputTokens` + - `temperature` + - `threads` + - `charsPerToken` + - `maxInputChars` + - `warnOnTrim` + - `maxRetries` + - `retryTemperatureIncrement` + - `topP` + - `topK` + - `repeatPenalty` + - `chatTemplateEnableThinking` + - `stopStrings` + +#### Core logic +- Defines default values for AI generation parameters. +- Provides getter and setter methods to configure and retrieve these parameters. + +#### Public API +- `AiGenerationConfig()`: Creates a new instance with default settings. +- `getModelPath() -> String`: Returns the model file path. +- `setModelPath(String modelPath)`: Sets the model file path. +- `getContextSize() -> int`: Returns the context window size in tokens. +- `setContextSize(int contextSize)`: Sets the context window size in tokens. +- `getMaxOutputTokens() -> int`: Returns the maximum number of output tokens per inference call. +- `setMaxOutputTokens(int maxOutputTokens)`: Sets the maximum number of output tokens per inference call. +- `getTemperature() -> float`: Returns the sampling temperature. +- `setTemperature(float temperature)`: Sets the sampling temperature. +- `getThreads() -> int`: Returns the number of CPU threads used for inference. +- `setThreads(int threads)`: Sets the number of CPU threads used for inference. +- `getCharsPerToken() -> int`: Returns the number of characters per token used in automatic `maxInputChars` calculation. +- `setCharsPerToken(int charsPerToken)`: Sets the number of characters per token. +- `getMaxInputChars() -> int`: Returns the maximum number of input characters fed to the prompt. +- `setMaxInputChars(int maxInputChars)`: Sets the maximum number of input characters fed to the prompt. +- `isWarnOnTrim() -> boolean`: Returns whether a warning is emitted when the prompt source text is trimmed. +- `setWarnOnTrim(boolean warnOnTrim)`: Sets whether a warning is emitted when the prompt source text is trimmed. +- `getMaxRetries() -> int`: Returns the maximum number of retry attempts on empty-body responses. +- `setMaxRetries(int maxRetries)`: Sets the maximum number of retry attempts on empty-body responses. +- `getRetryTemperatureIncrement() -> float`: Returns the temperature increment added on each retry attempt. +- `setRetryTemperatureIncrement(float retryTemperatureIncrement)`: Sets the temperature increment added on each retry attempt. +- `getTopP() -> float`: Returns the nucleus-sampling probability threshold. +- `setTopP(float topP)`: Sets the nucleus-sampling probability threshold. +- `getTopK() -> int`: Returns the top-k sampling limit. +- `setTopK(int topK)`: Sets the top-k sampling limit. +- `getRepeatPenalty() -> float`: Returns the repetition penalty. +- `setRepeatPenalty(float repeatPenalty)`: Sets the repetition penalty. +- `isChatTemplateEnableThinking() -> boolean`: Returns whether the model's chat-template thinking mode is enabled. +- `setChatTemplateEnableThinking(boolean chatTemplateEnableThinking)`: Sets whether the model's chat-template thinking mode is enabled. +- `getStopStrings() -> List`: Returns an unmodifiable view of the configured stop strings. +- `setStopStrings(List stopStrings)`: Sets the list of stop strings. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collections` +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- No notable exceptions. +- Null-handling: `stopStrings` is set to an empty list if `null` is passed. + +#### Concurrency +- Not concurrency-related. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..aa02345 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,21 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:29:16Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Identifies whether an AI generation operates on a single source file or a whole package. + +#### Type +enum + +#### Core logic +- Defines two constants: `FILE_SUMMARY` and `PACKAGE_SUMMARY`. +- Each constant represents a type of AI generation step. + +#### Public API +- `FILE_SUMMARY` -> Represents a generation step that produces fields for a single source file. +- `PACKAGE_SUMMARY` -> Represents a generation step that produces fields for a package aggregate. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..697990b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,109 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:29:37Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Represents a configuration POJO for AI model definitions used in a Maven plugin. + +#### Purpose +- Stores and manages parameters for AI models. +- Configurable via Maven plugin. +- Shared across multiple field-generation entries. + +#### Type +- Class +- Lombok `@ToString` annotation + +#### Input +- No constructor parameters +- Injected dependencies: None noted +- Consumed fields: + - `key` + - `modelPath` + - `contextSize` + - `maxOutputTokens` + - `temperature` + - `threads` + - `charsPerToken` + - `warnOnTrim` + - `maxRetries` + - `retryTemperatureIncrement` + - `topP` + - `topK` + - `repeatPenalty` + - `chatTemplateEnableThinking` + - `stopStrings` + +#### Output +- Produced state: + - `key` + - `modelPath` + - `contextSize` + - `maxOutputTokens` + - `temperature` + - `threads` + - `charsPerToken` + - `warnOnTrim` + - `maxRetries` + - `retryTemperatureIncrement` + - `topP` + - `topK` + - `repeatPenalty` + - `chatTemplateEnableThinking` + - `stopStrings` + +#### Core logic +- Holds configuration parameters for AI models. +- Provides getter and setter methods for each parameter. +- Ensures default values are set from `AiGenerationConfig` when not explicitly defined. + +#### Public API +- `AiModelDefinition()` -> Creates a new instance with default values. +- `String getKey()` -> Returns the unique lookup key. +- `void setKey(String key)` -> Sets the unique lookup key. +- `String getModelPath()` -> Returns the path to the GGUF model file. +- `void setModelPath(String modelPath)` -> Sets the path to the GGUF model file. +- `int getContextSize()` -> Returns the context window size. +- `void setContextSize(int contextSize)` -> Sets the context window size. +- `int getMaxOutputTokens()` -> Returns the maximum number of output tokens. +- `void setMaxOutputTokens(int maxOutputTokens)` -> Sets the maximum number of output tokens. +- `float getTemperature()` -> Returns the base sampling temperature. +- `void setTemperature(float temperature)` -> Sets the base sampling temperature. +- `int getThreads()` -> Returns the number of CPU threads for inference. +- `void setThreads(int threads)` -> Sets the number of CPU threads for inference. +- `int getCharsPerToken()` -> Returns the number of characters per token. +- `void setCharsPerToken(int charsPerToken)` -> Sets the number of characters per token. +- `boolean isWarnOnTrim()` -> Returns whether a warning is emitted when source text is trimmed. +- `void setWarnOnTrim(boolean warnOnTrim)` -> Sets whether a warning is emitted when source text is trimmed. +- `int getMaxRetries()` -> Returns the maximum number of retry attempts. +- `void setMaxRetries(int maxRetries)` -> Sets the maximum number of retry attempts. +- `float getRetryTemperatureIncrement()` -> Returns the temperature increment applied on each successive retry attempt. +- `void setRetryTemperatureIncrement(float retryTemperatureIncrement)` -> Sets the temperature increment applied on each successive retry attempt. +- `float getTopP()` -> Returns the nucleus-sampling probability threshold. +- `void setTopP(float topP)` -> Sets the nucleus-sampling probability threshold. +- `int getTopK()` -> Returns the top-k sampling limit. +- `void setTopK(int topK)` -> Sets the top-k sampling limit. +- `float getRepeatPenalty()` -> Returns the repetition penalty. +- `void setRepeatPenalty(float repeatPenalty)` -> Sets the repetition penalty applied to already-generated tokens. +- `boolean isChatTemplateEnableThinking()` -> Returns whether the model's chat-template thinking mode is enabled. +- `void setChatTemplateEnableThinking(boolean chatTemplateEnableThinking)` -> Sets whether the model's chat-template thinking mode is enabled. +- `List getStopStrings()` -> Returns the list of stop strings that terminate generation when encountered. +- `void setStopStrings(Collection stopStrings)` -> Sets the list of stop strings that terminate generation when encountered. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collection` +- `java.util.Collections` +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- No notable exceptions or error handling explicitly noted. + +#### Concurrency +- No concurrency-related notes or synchronization mechanisms. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..0d5063e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,62 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:35:05Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key, converting them to ready-to-use generation configurations. + +#### Purpose +- Provides a lookup table for AI model configurations. +- Validates and processes AI model definition entries. +- Converts `AiModelDefinition` entries into `AiGenerationConfig` objects. + +#### Type +- Class: final +- Extends: None +- Implements: None +- Key generics and type bounds: `` +- Lombok annotations: `@ToString` + +#### Input +- Constructor parameter: + - `definitions`: List of `AiModelDefinition` +- Dependencies: + - `Java8CompatibilityHelper` + +#### Output +- Return type: None (throws exceptions) +- Produced state: `configs`: Map of AI model keys to generation configurations +- Mutated fields: None +- Written resources: None +- Side effects: Throws exceptions for invalid configurations + +#### Core logic +- Validates each `AiModelDefinition` entry to ensure it has a non-null key. +- Constructs a `HashMap` to store the configuration mappings. +- Converts each `AiModelDefinition` into an `AiGenerationConfig`. +- Throws `NullPointerException` if any entry has a null key. +- Throws `IllegalArgumentException` if no definition is registered for a given key. + +#### Public API +- `AiModelDefinitionSupport(List definitions) -> Constructs a new AiModelDefinitionSupport from the supplied definitions list.` +- `AiGenerationConfig getConfig(String key) -> Returns the AiGenerationConfig associated with the given key.` + +#### Dependencies +- Imports: + - `java.util.HashMap` + - `java.util.List` + - `java.util.Map` + - `java.util.Objects` + - `lombok.ToString` + - `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper` + +#### Exceptions / Errors +- Throws `NullPointerException` if any entry has a null key. +- Throws `IllegalArgumentException` if no definition is registered for a given key. + +#### Concurrency +- Not explicitly handled; thread safety is not guaranteed. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..67e43fd --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:47:32Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Manages AI-related configurations and operations in a Maven plugin, including field generation, model definitions, and configuration support. + +#### Purpose +- Handles the configuration and management of AI models and operations within a Maven project. +- Provides mechanisms for selecting and applying AI configurations based on file types. +- Facilitates the execution of AI operations such as generating fields for source files or packages. + +#### Responsibilities +- **AI Configuration Management**: Defines and manages parameters for AI generation steps, including model settings and generation parameters. +- **Configuration Resolution**: Resolves and validates AI model definitions to generate ready-to-use configurations. +- **Field Generation Configuration**: Manages the configuration for associating prompt templates with AI models for field generation. +- **File Extension-based Selection**: Selects appropriate AI field generation settings based on file extensions. + +#### Key Units +- **AiGenerationConfig**: Manages all parameters for an AI generation step, ensuring they are correctly configured and transported between layers. +- **AiModelDefinition**: Represents a configuration POJO for AI model definitions, storing parameters that can be used across multiple field-generation entries. +- **AiFieldGenerationConfig**: Holds configuration for associating prompt templates with AI models for field generation, used within a list in the plugin configuration. +- **AiFieldGenerationSelector**: Selects the appropriate AI field generation settings for source files based on their extensions, ensuring that the correct configurations are applied. + +#### Data Flow +- Configuration data flows from the Maven plugin configuration to `AiModelDefinition` and `AiGenerationConfig`, where it is validated and stored. +- When a source file needs to be processed, the `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on the file's extension, and the `AiGenerationConfig` is used to execute the AI operations. + +#### Dependencies +- **Internal Collaborations**: + - `AiModelDefinitionSupport`: Provides a lookup table for AI model configurations and converts them into ready-to-use generation configurations. + - `Java8CompatibilityHelper`: Ensures compatibility with Java 8 features. +- **External Modules/Tables**: None explicitly mentioned in the provided summaries. + +#### Cross-cutting +- **Shared Base Types/Interfaces**: None explicitly mentioned in the provided summaries. +- **Common Exception/Error Handling**: Handles `NullPointerException` and `IllegalArgumentException` for invalid configurations. +- **Concurrency**: Not explicitly handled; thread safety is not guaranteed. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..f7fb8fb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,41 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:57:37Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. + +#### Purpose +- Handles the configuration and management of AI models and operations within a Maven project. +- Provides mechanisms for selecting and applying AI configurations based on file types. +- Facilitates the execution of AI operations such as generating fields for source files or packages. + +#### Responsibilities +- **AI Configuration Management**: Defines and manages parameters for AI generation steps, including model settings and generation parameters. +- **Configuration Resolution**: Resolves and validates AI model definitions to generate ready-to-use configurations. +- **Field Generation Configuration**: Manages the configuration for associating prompt templates with AI models for field generation. +- **File Extension-based Selection**: Selects appropriate AI field generation settings based on file extensions. + +#### Key Units +- **AiGenerationConfig**: Manages all parameters for an AI generation step, ensuring they are correctly configured and transported between layers. +- **AiModelDefinition**: Represents a configuration POJO for AI model definitions, storing parameters that can be used across multiple field-generation entries. +- **AiFieldGenerationConfig**: Holds configuration for associating prompt templates with AI models for field generation, used within a list in the plugin configuration. +- **AiFieldGenerationSelector**: Selects the appropriate AI field generation settings for source files based on their extensions, ensuring that the correct configurations are applied. + +#### Data Flow +- Configuration data flows from the Maven plugin configuration to `AiModelDefinition` and `AiGenerationConfig`, where it is validated and stored. +- When a source file needs to be processed, the `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on the file's extension, and the `AiGenerationConfig` is used to execute the AI operations. + +#### Dependencies +- **Internal Collaborations**: + - `AiModelDefinitionSupport`: Provides a lookup table for AI model configurations and converts them into ready-to-use generation configurations. + - `Java8CompatibilityHelper`: Ensures compatibility with Java 8 features. + +#### Cross-cutting +- **Common Exception/Error Handling**: Handles `NullPointerException` and `IllegalArgumentException` for invalid configurations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..8679ee3 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,47 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:37:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. + +#### Purpose +- Parses raw LLM completion text. +- Extracts the model answer by removing internal thinking blocks. +- Stores the clean answer text in an AI index file. + +#### Type +- Class +- Non-final + +#### Input +- `response`: The raw completion text from the model, may be `null`. + +#### Output +- Returns the cleaned answer text, never `null`. +- Throws `IOException` if a thinking block was started but the token budget was exhausted before the closing marker was emitted. + +#### Core logic +- If `response` is `null`, return an empty string. +- Find the last occurrence of `THINKING_BLOCK_END_MARKER`. + - If found, return the text after the marker, trimmed. + - If not found and `THINKING_BLOCK_START_MARKER` is present, throw an `IOException`. +- If neither marker is present, return the response, trimmed. + +#### Public API +- `AiCompletionParser() -> void`: Creates a new `AiCompletionParser`. +- `parseCompletion(final String response) -> String`: Strips any Gemma-4 thinking block from `response` and returns the clean answer text. + +#### Dependencies +- `java.io.IOException` +- `lombok.ToString` + +#### Exceptions / Errors +- Throws `IOException` if a thinking block was started but the token budget was exhausted before the closing marker was emitted. + +#### Concurrency +- Not applicable diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..0ab7265 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,37 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:38:52Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a pluggable interface for generating text based on AI requests. + +#### Purpose +- Defines a contract for generating text from AI requests. +- Supports both default and temperature-overridden generations. +- Ensures proper resource management with `AutoCloseable`. + +#### Type +- Interface +- Extends `AutoCloseable` + +#### Core logic +- `generate(AiGenerationRequest request)`: Generates text using default parameters. +- `generate(AiGenerationRequest request, float temperatureOverride)`: Generates text with a specified temperature override. + +#### Public API +- `generate(AiGenerationRequest request) -> String`: Generates text using the provider's default sampling parameters. +- `generate(AiGenerationRequest request, float temperatureOverride) -> String`: Generates text with the specified temperature override. +- `close() -> void`: Closes the provider, ensuring resources are properly released. + +#### Dependencies +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` + +#### Exceptions / Errors +- Throws `IOException` if the underlying provider fails. + +#### Concurrency +- Not explicitly addressed in the provided source. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..231cabc --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,61 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:39:52Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an `AiGenerationProvider` implementation by name. + +#### Purpose +- Selects and instantiates an `AiGenerationProvider` based on the provided name. + +#### Type +- Class: `public class AiGenerationProviderFactory` +- Modifiers: None +- Extends: None +- Implements: None +- Generics: None +- Annotations: `@ToString` + +#### Input +- Constructor: No parameters +- Method: + - `create(String providerName, LlamaCppJniConfig llamaConfig, AiPromptSupport promptSupport) -> AiGenerationProvider` + - Parameters: + - `providerName`: The name of the provider to create. + - `llamaConfig`: Configuration for the llama.cpp JNI provider. + - `promptSupport`: Support for prompt lookup passed to providers. + +#### Output +- Return type: `AiGenerationProvider` +- Produced state: None +- Mutated fields: None +- Written resources: None +- Side effects: None + +#### Core logic +- Checks if `providerName` is null or blank using `compatibilityHelper.isBlank(providerName)`. +- If `providerName` is null or blank, returns a new `MockAiGenerationProvider`. +- Switches on `providerName`: + - If `"mock"`, returns a new `MockAiGenerationProvider`. + - If `"llamacpp-jni"`, returns a new `LlamaCppJniAiGenerationProvider` with `llamaConfig` and `promptSupport`. + - Throws an `IllegalArgumentException` if the provider name is not recognized. + +#### Public API +- `create(String providerName, LlamaCppJniConfig llamaConfig, AiPromptSupport promptSupport) -> AiGenerationProvider`: Creates an `AiGenerationProvider` based on the given provider name. + +#### Dependencies +- Imports: + - `lombok.ToString` + - `net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProviderFactory` + - `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` + - `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper` + +#### Exceptions / Errors +- Throws `IllegalArgumentException` if the provider name is not recognized. + +#### Concurrency +- No concurrency or synchronization notes. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..f6c7e67 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,64 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:41:24Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Implements an AI generation provider using the llama.cpp JNI binding to generate text based on prompts. + +#### Purpose +- Provides a service for generating AI text based on prompts using the llama.cpp JNI binding. +- Lazy loads the GGUF model on first use and caches it for subsequent calls. +- Handles the generation process, including building prompts, setting inference parameters, and parsing completions. + +#### Type +- Class +- Final +- Implements `AiGenerationProvider` and `AutoCloseable` +- Imports Lombok's `@ToString` annotation + +#### Input +- Constructor parameters: + - `config` (`LlamaCppJniConfig`) + - `promptSupport` (`AiPromptSupport`) +- Method parameters: + - `request` (`AiGenerationRequest`) + - `temperatureOverride` (`float`) + +#### Output +- Return type: `String` +- Produced state: None +- Mutated fields: `model` +- Written resources: None +- Side effects: Loads the GGUF model, generates text using llama.cpp, and closes the model handle + +#### Core logic +- Lazy loads the GGUF model on first use. +- Builds a prompt from the `AiGenerationRequest`. +- Sets inference parameters based on the configuration and request. +- Calls `chatCompleteText` on the model to generate text. +- Parses the generated completion using `AiCompletionParser`. + +#### Public API +- `LlamaCppJniAiGenerationProvider(LlamaCppJniConfig config, AiPromptSupport promptSupport)` -> Initializes the provider with a configuration and prompt support object. +- `String generate(AiGenerationRequest request) throws IOException` -> Generates text using the default temperature. +- `String generate(AiGenerationRequest request, float temperatureOverride) throws IOException` -> Generates text with a specified temperature override. +- `void close()` -> Closes the model handle. + +#### Dependencies +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- Throws `IOException` from the `generate` methods. + +#### Concurrency +- Not explicitly handled in the provided source. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..da32b2f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,83 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:43:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides immutable configuration for the llama.cpp JNI provider. + +#### Purpose +- Immutable configuration for the llama.cpp JNI provider. +- Used to store and access various parameters for the provider's operation. + +#### Type +- Class +- Final +- `@ConvertToRecord` +- `@ToString` +- `@EqualsAndHashCode` +- Extends: `java.lang.Object` + +#### Input +- Constructor parameters: + - `libraryPath`: native library path; may be `null` + - `modelPath`: path to the GGUF model file (required) + - `contextSize`: context window size in tokens + - `maxOutputTokens`: maximum number of output tokens per call + - `temperature`: sampling temperature + - `threads`: number of CPU threads + - `topP`: nucleus-sampling probability threshold + - `topK`: top-k sampling limit + - `repeatPenalty`: repetition penalty + - `chatTemplateEnableThinking`: whether chat-template thinking mode is enabled + - `stopStrings`: stop strings; may be `null` (treated as empty) + +#### Output +- Return types: + - `String`: native library path, or `null` to use the bundled library + - `String`: model file path + - `int`: context window size + - `int`: maximum output tokens + - `float`: sampling temperature + - `int`: number of CPU threads + - `float`: nucleus-sampling probability threshold + - `int`: top-k value + - `float`: repeat penalty + - `boolean`: whether chat-template thinking mode is enabled + - `List`: unmodifiable list of stop strings + +#### Core logic +- Immutable configuration class with eleven fields. +- Constructor validates the `modelPath` and initializes all fields. +- Accessor methods return the values of the fields. + +#### Public API +- `LlamaCppJniConfig(String libraryPath, String modelPath, int contextSize, int maxOutputTokens, float temperature, int threads, float topP, int topK, float repeatPenalty, boolean chatTemplateEnableThinking, List stopStrings) -> void` : Creates a new configuration instance. +- `String libraryPath() -> String` : Returns the native library path. +- `String modelPath() -> String` : Returns the GGUF model file path. +- `int contextSize() -> int` : Returns the context window size in tokens. +- `int maxOutputTokens() -> int` : Returns the maximum number of output tokens per call. +- `float temperature() -> float` : Returns the sampling temperature. +- `int threads() -> int` : Returns the number of CPU threads. +- `float topP() -> float` : Returns the nucleus-sampling probability threshold. +- `int topK() -> int` : Returns the top-k sampling limit. +- `float repeatPenalty() -> float` : Returns the repetition penalty. +- `boolean chatTemplateEnableThinking() -> boolean` : Returns whether chat-template thinking mode is enabled. +- `List stopStrings() -> List` : Returns an unmodifiable view of the configured stop strings. + +#### Dependencies +- `java.util.Collections` +- `java.util.List` +- `java.util.Objects` +- `lombok.EqualsAndHashCode` +- `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord` + +#### Exceptions / Errors +- `NullPointerException` when `modelPath` is `null`. + +#### Concurrency +- Immutable, thread-safe. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..28207db --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,46 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:46:40Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a mock implementation of the `AiGenerationProvider` interface for testing purposes. + +#### Purpose +- Returns a mock summary for an AI generation request, used for testing. + +#### Type +- Class +- Public +- Implements `AiGenerationProvider` +- Annotated with `@ToString` + +#### Input +- `AiGenerationRequest request` (constructor parameter) +- Consumed field: `sourceFile()` from `AiGenerationRequest` + +#### Output +- Returns a string: "Mock summary for [filename]" + +#### Core logic +- Extracts the file name from the `sourceFile()` in the `AiGenerationRequest` +- Returns a mock summary string using the file name + +#### Public API +- `MockAiGenerationProvider() -> void` - Creates a new `MockAiGenerationProvider`. +- `generate(AiGenerationRequest request) -> String` - Generates a mock summary for the provided request. + +#### Dependencies +- `java.io.IOException` +- `java.nio.file.Path` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `lombok.ToString` + +#### Exceptions / Errors +- Throws `IOException` if an I/O error occurs while accessing the file name + +#### Concurrency +- No concurrency concerns; the implementation is stateless and thread-safe diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..8231c45 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,50 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:53:20Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> This package provides a suite of classes and interfaces for handling AI text generation, including parsing raw completion text, generating text based on requests, and selecting appropriate generation providers. + +#### Purpose +- Parses raw LLM completion text to extract model answers. +- Provides a pluggable interface for AI text generation. +- Selects and instantiates AI generation providers based on configuration. + +#### Responsibilities +- **Text Parsing**: Responsible for cleaning raw LLM completion text by removing internal thinking blocks and storing the cleaned answer in an AI index file. +- **Text Generation**: Defines contracts for generating text from AI requests, supporting both default and temperature-overridden generations. +- **Provider Selection**: Selects and instantiates appropriate AI generation providers based on configuration. + +#### Key units +- **AiCompletionParser**: Parses raw LLM completion text to extract the model answer by stripping any internal thinking block. +- **AiGenerationProvider**: Defines a contract for generating text from AI requests, supporting both default and temperature-overridden generations. +- **AiGenerationProviderFactory**: Selects and instantiates an `AiGenerationProvider` based on the provided name. +- **LlamaCppJniAiGenerationProvider**: Implements an AI generation provider using the llama.cpp JNI binding to generate text based on prompts. +- **LlamaCppJniConfig**: Provides immutable configuration for the llama.cpp JNI provider. + +#### Data flow +- **Input**: Raw LLM completion text or AI generation requests. +- **Process**: Parsing, generation, and provider selection. +- **Output**: Cleaned answer text or generated text based on requests. + +#### Dependencies +- **Internal Collaborations**: + - `AiCompletionParser` depends on `java.io.IOException`. + - `AiGenerationProviderFactory` depends on `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`. + - `LlamaCppJniAiGenerationProvider` depends on various classes from the `net.ladenthin.llama` package and other utilities. +- **External Modules/Tables**: None noted. + +#### Cross-cutting +- **Shared Types/Interfaces**: `AiGenerationProvider`. +- **Exception/Errors**: `IOException` is thrown in several places for handling errors during text generation. +- **Concurrency**: Not explicitly handled in the provided source. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..28138fc --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,40 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:59:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. + +#### Purpose +- Handles the configuration and management of AI models and operations within a Maven project. +- Provides mechanisms for selecting and applying AI configurations based on file types. +- Facilitates the execution of AI operations such as generating fields for source files or packages. + +#### Responsibilities +- **AI Configuration Management**: Defines and manages parameters for AI generation steps, including model settings and generation parameters. +- **Configuration Resolution**: Resolves and validates AI model definitions to generate ready-to-use configurations. +- **Field Generation Configuration**: Manages the configuration for associating prompt templates with AI models for field generation. +- **File Extension-based Selection**: Selects appropriate AI field generation settings based on file extensions. + +#### Key Units +- **AiGenerationConfig**: Manages all parameters for an AI generation step, ensuring they are correctly configured and transported between layers. +- **AiModelDefinition**: Represents a configuration POJO for AI model definitions, storing parameters that can be used across multiple field-generation entries. +- **AiFieldGenerationConfig**: Holds configuration for associating prompt templates with AI models for field generation, used within a list in the plugin configuration. +- **AiFieldGenerationSelector**: Selects the appropriate AI field generation settings for source files based on their extensions, ensuring that the correct configurations are applied. + +#### Data Flow +- Configuration data flows from the Maven plugin configuration to `AiModelDefinition` and `AiGenerationConfig`, where it is validated and stored. +- When a source file needs to be processed, the `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on the file's extension, and the `AiGenerationConfig` is used to execute the AI operations. + +#### Dependencies +- **Internal Collaborations**: + - `AiModelDefinitionSupport`: Provides a lookup table for AI model configurations and converts them into ready-to-use generation configurations. + - `Java8CompatibilityHelper`: Ensures compatibility with Java 8 features. + +#### Cross-cutting +- **Common Exception/Error Handling**: Handles `NullPointerException` and `IllegalArgumentException` for invalid configurations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..0b79500 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,40 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:01:38Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. + +#### Purpose +- Handles the configuration and management of AI models and operations within a Maven project. +- Provides mechanisms for selecting and applying AI configurations based on file types. +- Facilitates the execution of AI operations such as generating fields for source files or packages. + +#### Responsibilities +- **AI Configuration Management**: Defines and manages parameters for AI generation steps, including model settings and generation parameters. +- **Configuration Resolution**: Resolves and validates AI model definitions to generate ready-to-use configurations. +- **Field Generation Configuration**: Manages the configuration for associating prompt templates with AI models for field generation. +- **File Extension-based Selection**: Selects appropriate AI field generation settings based on file extensions. + +#### Key Units +- **AiGenerationConfig**: Manages all parameters for an AI generation step, ensuring they are correctly configured and transported between layers. +- **AiModelDefinition**: Represents a configuration POJO for AI model definitions, storing parameters that can be used across multiple field-generation entries. +- **AiFieldGenerationConfig**: Holds configuration for associating prompt templates with AI models for field generation, used within a list in the plugin configuration. +- **AiFieldGenerationSelector**: Selects the appropriate AI field generation settings for source files based on their extensions, ensuring that the correct configurations are applied. + +#### Data Flow +- Configuration data flows from the Maven plugin configuration to `AiModelDefinition` and `AiGenerationConfig`, where it is validated and stored. +- When a source file needs to be processed, the `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on the file's extension, and the `AiGenerationConfig` is used to execute the AI operations. + +#### Dependencies +- **Internal Collaborations**: + - `AiModelDefinitionSupport`: Provides a lookup table for AI model configurations and converts them into ready-to-use generation configurations. + - `Java8CompatibilityHelper`: Ensures compatibility with Java 8 features. + +#### Cross-cutting +- **Common Exception/Error Handling**: Handles `NullPointerException` and `IllegalArgumentException` for invalid configurations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..53ae45c --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,40 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:03:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. + +#### Purpose +- Handles the configuration and management of AI models and operations within a Maven project. +- Provides mechanisms for selecting and applying AI configurations based on file types. +- Facilitates the execution of AI operations such as generating fields for source files or packages. + +#### Responsibilities +- **AI Configuration Management**: Defines and manages parameters for AI generation steps, including model settings and generation parameters. +- **Configuration Resolution**: Resolves and validates AI model definitions to generate ready-to-use configurations. +- **Field Generation Configuration**: Manages the configuration for associating prompt templates with AI models for field generation. +- **File Extension-based Selection**: Selects appropriate AI field generation settings based on file extensions. + +#### Key Units +- **AiGenerationConfig**: Manages all parameters for an AI generation step, ensuring they are correctly configured and transported between layers. +- **AiModelDefinition**: Represents a configuration POJO for AI model definitions, storing parameters that can be used across multiple field-generation entries. +- **AiFieldGenerationConfig**: Holds configuration for associating prompt templates with AI models for field generation, used within a list in the plugin configuration. +- **AiFieldGenerationSelector**: Selects the appropriate AI field generation settings for source files based on their extensions, ensuring that the correct configurations are applied. + +#### Data Flow +- Configuration data flows from the Maven plugin configuration to `AiModelDefinition` and `AiGenerationConfig`, where it is validated and stored. +- When a source file needs to be processed, the `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on the file's extension, and the `AiGenerationConfig` is used to execute the AI operations. + +#### Dependencies +- **Internal Collaborations**: + - `AiModelDefinitionSupport`: Provides a lookup table for AI model configurations and converts them into ready-to-use generation configurations. + - `Java8CompatibilityHelper`: Ensures compatibility with Java 8 features. + +#### Cross-cutting +- **Common Exception/Error Handling**: Handles `NullPointerException` and `IllegalArgumentException` for invalid configurations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/package.ai.md new file mode 100644 index 0000000..745a930 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/net/package.ai.md @@ -0,0 +1,40 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:05:03Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. + +#### Purpose +- Handles the configuration and management of AI models and operations within a Maven project. +- Provides mechanisms for selecting and applying AI configurations based on file types. +- Facilitates the execution of AI operations such as generating fields for source files or packages. + +#### Responsibilities +- **AI Configuration Management**: Defines and manages parameters for AI generation steps, including model settings and generation parameters. +- **Configuration Resolution**: Resolves and validates AI model definitions to generate ready-to-use configurations. +- **Field Generation Configuration**: Manages the configuration for associating prompt templates with AI models for field generation. +- **File Extension-based Selection**: Selects appropriate AI field generation settings based on file extensions. + +#### Key Units +- **AiGenerationConfig**: Manages all parameters for an AI generation step, ensuring they are correctly configured and transported between layers. +- **AiModelDefinition**: Represents a configuration POJO for AI model definitions, storing parameters that can be used across multiple field-generation entries. +- **AiFieldGenerationConfig**: Holds configuration for associating prompt templates with AI models for field generation, used within a list in the plugin configuration. +- **AiFieldGenerationSelector**: Selects the appropriate AI field generation settings for source files based on their extensions, ensuring that the correct configurations are applied. + +#### Data Flow +- Configuration data flows from the Maven plugin configuration to `AiModelDefinition` and `AiGenerationConfig`, where it is validated and stored. +- When a source file needs to be processed, the `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on the file's extension, and the `AiGenerationConfig` is used to execute the AI operations. + +#### Dependencies +- **Internal Collaborations**: + - `AiModelDefinitionSupport`: Provides a lookup table for AI model configurations and converts them into ready-to-use generation configurations. + - `Java8CompatibilityHelper`: Ensures compatibility with Java 8 features. + +#### Cross-cutting +- **Common Exception/Error Handling**: Handles `NullPointerException` and `IllegalArgumentException` for invalid configurations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/package.ai.md new file mode 100644 index 0000000..216bd1b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/java/package.ai.md @@ -0,0 +1,40 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:06:45Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. + +#### Purpose +- Handles the configuration and management of AI models and operations within a Maven project. +- Provides mechanisms for selecting and applying AI configurations based on file types. +- Facilitates the execution of AI operations such as generating fields for source files or packages. + +#### Responsibilities +- **AI Configuration Management**: Defines and manages parameters for AI generation steps, including model settings and generation parameters. +- **Configuration Resolution**: Resolves and validates AI model definitions to generate ready-to-use configurations. +- **Field Generation Configuration**: Manages the configuration for associating prompt templates with AI models for field generation. +- **File Extension-based Selection**: Selects appropriate AI field generation settings based on file extensions. + +#### Key Units +- **AiGenerationConfig**: Manages all parameters for an AI generation step, ensuring they are correctly configured and transported between layers. +- **AiModelDefinition**: Represents a configuration POJO for AI model definitions, storing parameters that can be used across multiple field-generation entries. +- **AiFieldGenerationConfig**: Holds configuration for associating prompt templates with AI models for field generation, used within a list in the plugin configuration. +- **AiFieldGenerationSelector**: Selects the appropriate AI field generation settings for source files based on their extensions, ensuring that the correct configurations are applied. + +#### Data Flow +- Configuration data flows from the Maven plugin configuration to `AiModelDefinition` and `AiGenerationConfig`, where it is validated and stored. +- When a source file needs to be processed, the `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on the file's extension, and the `AiGenerationConfig` is used to execute the AI operations. + +#### Dependencies +- **Internal Collaborations**: + - `AiModelDefinitionSupport`: Provides a lookup table for AI model configurations and converts them into ready-to-use generation configurations. + - `Java8CompatibilityHelper`: Ensures compatibility with Java 8 features. + +#### Cross-cutting +- **Common Exception/Error Handling**: Handles `NullPointerException` and `IllegalArgumentException` for invalid configurations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/package.ai.md new file mode 100644 index 0000000..2a21b39 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/main/package.ai.md @@ -0,0 +1,40 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:08:39Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. + +#### Purpose +- Handles the configuration and management of AI models and operations within a Maven project. +- Provides mechanisms for selecting and applying AI configurations based on file types. +- Facilitates the execution of AI operations such as generating fields for source files or packages. + +#### Responsibilities +- **AI Configuration Management**: Defines and manages parameters for AI generation steps, including model settings and generation parameters. +- **Configuration Resolution**: Resolves and validates AI model definitions to generate ready-to-use configurations. +- **Field Generation Configuration**: Manages the configuration for associating prompt templates with AI models for field generation. +- **File Extension-based Selection**: Selects appropriate AI field generation settings based on file extensions. + +#### Key Units +- **AiGenerationConfig**: Manages all parameters for an AI generation step, ensuring they are correctly configured and transported between layers. +- **AiModelDefinition**: Represents a configuration POJO for AI model definitions, storing parameters that can be used across multiple field-generation entries. +- **AiFieldGenerationConfig**: Holds configuration for associating prompt templates with AI models for field generation, used within a list in the plugin configuration. +- **AiFieldGenerationSelector**: Selects the appropriate AI field generation settings for source files based on their extensions, ensuring that the correct configurations are applied. + +#### Data Flow +- Configuration data flows from the Maven plugin configuration to `AiModelDefinition` and `AiGenerationConfig`, where it is validated and stored. +- When a source file needs to be processed, the `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on the file's extension, and the `AiGenerationConfig` is used to execute the AI operations. + +#### Dependencies +- **Internal Collaborations**: + - `AiModelDefinitionSupport`: Provides a lookup table for AI model configurations and converts them into ready-to-use generation configurations. + - `Java8CompatibilityHelper`: Ensures compatibility with Java 8 features. + +#### Cross-cutting +- **Common Exception/Error Handling**: Handles `NullPointerException` and `IllegalArgumentException` for invalid configurations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/package.ai.md new file mode 100644 index 0000000..09c0e37 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/package.ai.md @@ -0,0 +1,40 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:10:22Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. + +#### Purpose +- Handles the configuration and management of AI models and operations within a Maven project. +- Provides mechanisms for selecting and applying AI configurations based on file types. +- Facilitates the execution of AI operations such as generating fields for source files or packages. + +#### Responsibilities +- **AI Configuration Management**: Defines and manages parameters for AI generation steps, including model settings and generation parameters. +- **Configuration Resolution**: Resolves and validates AI model definitions to generate ready-to-use configurations. +- **Field Generation Configuration**: Manages the configuration for associating prompt templates with AI models for field generation. +- **File Extension-based Selection**: Selects appropriate AI field generation settings based on file extensions. + +#### Key Units +- **AiGenerationConfig**: Manages all parameters for an AI generation step, ensuring they are correctly configured and transported between layers. +- **AiModelDefinition**: Represents a configuration POJO for AI model definitions, storing parameters that can be used across multiple field-generation entries. +- **AiFieldGenerationConfig**: Holds configuration for associating prompt templates with AI models for field generation, used within a list in the plugin configuration. +- **AiFieldGenerationSelector**: Selects the appropriate AI field generation settings for source files based on their extensions, ensuring that the correct configurations are applied. + +#### Data Flow +- Configuration data flows from the Maven plugin configuration to `AiModelDefinition` and `AiGenerationConfig`, where it is validated and stored. +- When a source file needs to be processed, the `AiFieldGenerationSelector` selects the appropriate `AiFieldGenerationConfig` based on the file's extension, and the `AiGenerationConfig` is used to execute the AI operations. + +#### Dependencies +- **Internal Collaborations**: + - `AiModelDefinitionSupport`: Provides a lookup table for AI model configurations and converts them into ready-to-use generation configurations. + - `Java8CompatibilityHelper`: Ensures compatibility with Java 8 features. + +#### Cross-cutting +- **Common Exception/Error Handling**: Handles `NullPointerException` and `IllegalArgumentException` for invalid configurations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/project.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/project.ai.md new file mode 100644 index 0000000..d38e0c5 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v1/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: 9AD3E89B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:12:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The `llamacpp-ai-index-maven-plugin` project is structured around managing AI-related configurations and operations within a Maven plugin. It includes packages for configuration management, text generation provider handling, and model definition support. The main subsystems work together to provide comprehensive AI functionalities, enabling developers to integrate advanced AI capabilities into their Maven-based projects efficiently. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Manages AI-related configurations and operations in a Maven plugin, including field generation, model definitions, and configuration support. +- main/java/net/ladenthin/maven/llamacpp/aiindex — Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — This package provides a suite of classes and interfaces for handling AI text generation, including parsing raw completion text, generating text based on requests, and selecting appropriate generation providers. +- main/java/net/ladenthin/maven/llamacpp — Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. +- main/java/net/ladenthin/maven — Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. +- main/java/net/ladenthin — Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. +- main/java/net — Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. +- main/java — Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. +- main — Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. +- . — Manages AI-related configurations and operations within a Maven plugin, including field generation, model definitions, and configuration support. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..907db0d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,48 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:12:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Represents a configuration for an AI field generation step within a Maven plugin, associating a prompt template and AI model definition. + +#### Purpose +- Holds configuration for a single field-generation step in an AI-based Maven plugin. +- Used to define the prompt template and AI model for generating content in files based on specified criteria. + +#### Type +`public class AiFieldGenerationConfig` + +#### Input +- `promptKey`: Key that references an `AiModelDefinition` registered in the plugin configuration. +- `aiDefinitionKey`: Key that references the AI model definition to use. +- `fileExtensions`: Optional list of file extensions that select this field generation for specific files. + +#### Output +- Returns the prompt template key, AI model definition key, and source file extensions. + +#### Core logic +- Initializes with default values. +- Provides setters and getters for `promptKey`, `aiDefinitionKey`, and `fileExtensions`. + +#### Public API +- `AiFieldGenerationConfig()`: Creates a new `AiFieldGenerationConfig` instance. +- `String getPromptKey()`: Returns the prompt template key. +- `void setPromptKey(String promptKey)`: Sets the prompt template key. +- `String getAiDefinitionKey()`: Returns the AI model definition key. +- `void setAiDefinitionKey(String aiDefinitionKey)`: Sets the AI model definition key. +- `@Nullable List getFileExtensions()`: Returns the source file extensions that select this entry. +- `void setFileExtensions(@Nullable Collection fileExtensions)`: Sets the source file extensions that select this entry. + +#### Dependencies +- `AiModelDefinition` +- `AiPromptDefinition` + +#### Exceptions / Errors +- None explicitly handled; relies on Lombok annotations for null handling. + +#### Concurrency +- Not applicable; mutable JavaBean designed for reflection-based configuration injection. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..a8a4d41 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,44 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:15:30Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the `AiFieldGenerationConfig` that applies to a given source file based on file extensions. + +#### Purpose +- Configures the selection of AI field generation settings for different file types. + +#### Type +- `public final class` + `@ToString` + +#### Input +- `configs`: Iterable of `AiFieldGenerationConfig` entries. +- `fileName`: The source file name. + +#### Output +- Returns the first `AiFieldGenerationConfig` whose non-empty extension list matches the file name, or the first fallback entry if no match is found, or `null` if no entries are configured and no fallback is set. + +#### Core logic +- Iterates over the `configs`. +- Skips any `null` entries. +- Checks each `AiFieldGenerationConfig`'s `fileExtensions`. +- Returns the first matching config based on file extension. +- If no match, returns the first fallback config (if any). +- Returns `null` if no match and no fallback is configured. + +#### Public API +- `selectForFileName(final Iterable configs, final String fileName) -> @Nullable AiFieldGenerationConfig`: Returns the `AiFieldGenerationConfig` for the given file name. + +#### Dependencies +- `AiFieldGenerationConfig` +- `@Nullable` + +#### Exceptions / Errors +- Throws no exceptions; handles `null` entries in `configs`. + +#### Concurrency +- Not applicable. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..3fa4122 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,71 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:16:49Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Manages configuration parameters for AI generation steps between Maven and AI provider implementations. + +#### Purpose +- Carries parameters for a single AI generation step. +- Provides getters/setters for configuration properties. +- Implements `toString` using Lombok for diagnostics. +- Ensures instances are mutable JavaBeans managed by identity. + +#### Type +```java +public class AiGenerationConfig +``` + +#### Core logic +- Initializes default values for various AI generation parameters. +- Provides getter and setter methods for each parameter. + +#### Public API +- `AiGenerationConfig()` -> Creates a new configuration with default values. +- `getModelPath() -> String` -> Returns the model file path. +- `setModelPath(String)` -> Sets the model file path. +- `getContextSize() -> int` -> Returns the context window size. +- `setContextSize(int)` -> Sets the context window size. +- `getMaxOutputTokens() -> int` -> Returns the maximum number of output tokens. +- `setMaxOutputTokens(int)` -> Sets the maximum number of output tokens. +- `getTemperature() -> float` -> Returns the sampling temperature. +- `setTemperature(float)` -> Sets the sampling temperature. +- `getThreads() -> int` -> Returns the number of CPU threads. +- `setThreads(int)` -> Sets the number of CPU threads. +- `getCharsPerToken() -> int` -> Returns the number of characters per token. +- `setCharsPerToken(int)` -> Sets the number of characters per token. +- `getMaxInputChars() -> int` -> Returns the maximum number of input characters. +- `setMaxInputChars(int)` -> Sets the maximum number of input characters. +- `isWarnOnTrim() -> boolean` -> Returns whether to warn on trim. +- `setWarnOnTrim(boolean)` -> Sets whether to warn on trim. +- `getMaxRetries() -> int` -> Returns the maximum number of retries. +- `setMaxRetries(int)` -> Sets the maximum number of retries. +- `getRetryTemperatureIncrement() -> float` -> Returns the retry temperature increment. +- `setRetryTemperatureIncrement(float)` -> Sets the retry temperature increment. +- `getTopP() -> float` -> Returns the nucleus-sampling probability threshold. +- `setTopP(float)` -> Sets the nucleus-sampling probability threshold. +- `getTopK() -> int` -> Returns the top-k sampling limit. +- `setTopK(int)` -> Sets the top-k sampling limit. +- `getRepeatPenalty() -> float` -> Returns the repetition penalty. +- `setRepeatPenalty(float)` -> Sets the repetition penalty. +- `isChatTemplateEnableThinking() -> boolean` -> Returns whether chat-template thinking mode is enabled. +- `setChatTemplateEnableThinking(boolean)` -> Sets whether chat-template thinking mode is enabled. +- `getStopStrings() -> List` -> Returns an unmodifiable list of stop strings. +- `setStopStrings(List)` -> Sets the list of stop strings. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collections` +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- None + +#### Concurrency +- None diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..40494b9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,23 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:22:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Identifies whether an AI generation operates on a single source file or a whole package. + +#### Purpose +- Enumerates the kinds of AI generation steps. +- Defines constants for summarizing individual files and packages. + +#### Type +```java +enum AiGenerationKind +``` + +#### Core logic +- `FILE_SUMMARY`: Indicates that the AI generation step produces fields for a single source file. +- `PACKAGE_SUMMARY`: Indicates that the AI generation step produces fields for a package aggregate. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..b200146 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,89 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:23:10Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Represents a Maven plugin configuration POJO that pairs a lookup key with a complete set of AI model parameters. + +#### Purpose +- Holds the configuration for an AI model definition. +- Used in a Maven plugin to manage and reuse AI model configurations across multiple field-generation entries and goals. + +#### Type +```java +public class AiModelDefinition +``` + +#### Input +- `key` (String): Unique lookup key for this definition. +- `modelPath` (String): Path to the GGUF model file. +- `contextSize` (int): Context window size (in tokens). +- `maxOutputTokens` (int): Maximum number of output tokens per inference call. +- `temperature` (float): Base sampling temperature. +- `threads` (int): Number of CPU threads for inference. +- `charsPerToken` (int): Number of characters per token. +- `warnOnTrim` (boolean): Whether to emit a warning when source text is trimmed. +- `maxRetries` (int): Maximum number of retry attempts. +- `retryTemperatureIncrement` (float): Temperature increment applied on each successive retry attempt. +- `topP` (float): Nucleus-sampling probability threshold. +- `topK` (int): Top-k sampling limit. +- `repeatPenalty` (float): Repetition penalty. +- `chatTemplateEnableThinking` (boolean): Whether the model's chat-template thinking mode is enabled. +- `stopStrings` (List): List of stop strings that terminate generation when encountered. + +#### Output +- None + +#### Core logic +- Manages and stores configuration for AI model definitions. +- Provides getters and setters for all configuration fields. + +#### Public API +- `getKey() -> String`: Returns the unique lookup key for this definition. +- `getModelPath() -> String`: Returns the path to the GGUF model file. +- `getContextSize() -> int`: Returns the context window size (in tokens). +- `getMaxOutputTokens() -> int`: Returns the maximum number of output tokens per inference call. +- `getTemperature() -> float`: Returns the base sampling temperature. +- `getThreads() -> int`: Returns the number of CPU threads for inference. +- `getCharsPerToken() -> int`: Returns the number of characters per token. +- `isWarnOnTrim() -> boolean`: Returns whether to emit a warning when source text is trimmed. +- `getMaxRetries() -> int`: Returns the maximum number of retry attempts. +- `getRetryTemperatureIncrement() -> float`: Returns the temperature increment applied on each successive retry attempt. +- `getTopP() -> float`: Returns the nucleus-sampling probability threshold. +- `getTopK() -> int`: Returns the top-k sampling limit. +- `getRepeatPenalty() -> float`: Returns the repetition penalty. +- `isChatTemplateEnableThinking() -> boolean`: Returns whether the model's chat-template thinking mode is enabled. +- `getStopStrings() -> List`: Returns the list of stop strings that terminate generation when encountered. +- `setKey(String key)`: Sets the unique lookup key for this definition. +- `setModelPath(String modelPath)`: Sets the path to the GGUF model file. +- `setContextSize(int contextSize)`: Sets the context window size (in tokens). +- `setMaxOutputTokens(int maxOutputTokens)`: Sets the maximum number of output tokens per inference call. +- `setTemperature(float temperature)`: Sets the base sampling temperature. +- `setThreads(int threads)`: Sets the number of CPU threads for inference. +- `setCharsPerToken(int charsPerToken)`: Sets the number of characters per token. +- `setWarnOnTrim(boolean warnOnTrim)`: Sets whether to emit a warning when source text is trimmed. +- `setMaxRetries(int maxRetries)`: Sets the maximum number of retry attempts. +- `setRetryTemperatureIncrement(float retryTemperatureIncrement)`: Sets the temperature increment applied on each successive retry attempt. +- `setTopP(float topP)`: Sets the nucleus-sampling probability threshold. +- `setTopK(int topK)`: Sets the top-k sampling limit. +- `setRepeatPenalty(float repeatPenalty)`: Sets the repetition penalty. +- `setChatTemplateEnableThinking(boolean chatTemplateEnableThinking)`: Sets whether the model's chat-template thinking mode is enabled. +- `setStopStrings(Collection stopStrings)`: Sets the list of stop strings that terminate generation when encountered. + +#### Dependencies +- `java.util.ArrayList` +- `java.util.Collection` +- `java.util.Collections` +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- None + +#### Concurrency +- Not applicable diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..cf8a004 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,53 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:29:24Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key, returning corresponding generation configurations. + +#### Purpose +- Lookup table for converting `AiModelDefinition` entries to `AiGenerationConfig` objects. +- Ensures non-null keys and throws exceptions for misconfigured entries. +- Provides a method to retrieve `AiGenerationConfig` based on a key. + +#### Type +- `public final class` +- Implements none + +#### Input +- `List definitions`: List of AI model definitions. + +#### Output +- Returns `AiGenerationConfig` associated with the given key. +- Throws `NullPointerException` if any entry has a `null` key. +- Throws `IllegalArgumentException` if no definition is registered for the key. + +#### Core logic +- Initializes a `HashMap` to store `AiGenerationConfig` objects. +- Iterates over the list of `AiModelDefinition` entries, converting each to an `AiGenerationConfig`. +- Validates non-null keys and throws exceptions for invalid entries. +- Provides a method to retrieve an `AiGenerationConfig` by key. + +#### Public API +- `AiModelDefinitionSupport(List definitions) -> Constructs a new AiModelDefinitionSupport from the supplied definitions list.` +- `AiGenerationConfig getConfig(String key) -> Returns the AiGenerationConfig associated with the given key.` + +#### Dependencies +- `java.util.HashMap` +- `java.util.List` +- `java.util.Map` +- `java.util.Objects` +- `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper` +- `net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinition` +- `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig` + +#### Exceptions / Errors +- Throws `NullPointerException` if any entry has a `null` key. +- Throws `IllegalArgumentException` if no definition is registered for the key. + +#### Concurrency +- Not applicable diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..bfc5b22 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,46 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:40:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. + +#### Responsibilities +- **Configuration Management**: Holds and manages configuration parameters for AI generation steps. +- **Selection Logic**: Selects appropriate AI field generation configurations based on file extensions. +- **Model Definition Support**: Resolves AI model definitions to their corresponding generation configurations. + +#### Key Units +- `AiFieldGenerationConfig`: Represents configuration for a single AI field generation step. +- `AiFieldGenerationSelector`: Selects the appropriate AI field generation configuration for a given source file. +- `AiGenerationConfig`: Manages parameters for a single AI generation step. +- `AiModelDefinition`: Holds the configuration for an AI model definition. +- `AiModelDefinitionSupport`: Resolves AI model definitions to their corresponding generation configurations. + +#### Data Flow +1. **Input**: `AiFieldGenerationConfig` and `AiModelDefinition` instances are configured. +2. **Processing**: + - `AiFieldGenerationSelector` iterates over `AiFieldGenerationConfig` entries to select the most appropriate configuration based on file extensions. + - `AiModelDefinitionSupport` resolves an `AiModelDefinition` key to an `AiGenerationConfig`. +3. **Output**: Selected `AiFieldGenerationConfig` and resolved `AiGenerationConfig`. + +#### Dependencies +- **Internal Collaborations**: + - `AiFieldGenerationConfig` depends on `AiPromptDefinition`. + - `AiFieldGenerationSelector` depends on `AiFieldGenerationConfig`. + - `AiModelDefinitionSupport` depends on `AiModelDefinition` and `AiGenerationConfig`. +- **External Modules**: None explicitly mentioned. + +#### Cross-cutting +- **Configuration Management**: Uses Lombok for JavaBean design and easy configuration management. +- **Null Handling**: Handles null entries gracefully using Lombok and manual checks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..4fc60c7 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,46 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:49:54Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. + +#### Purpose +- Configures and selects AI generation parameters based on file types. +- Integrates with AI model definitions to produce summaries. + +#### Responsibilities +- **Configuration Management**: Holds and manages configuration parameters for AI generation steps. +- **Selection Logic**: Selects appropriate AI field generation configurations based on file extensions. +- **Model Definition Support**: Resolves AI model definitions to their corresponding generation configurations. + +#### Key Units +- `AiFieldGenerationConfig`: Manages configuration for a single AI field generation step. +- `AiFieldGenerationSelector`: Chooses the most suitable AI field generation config based on file types. +- `AiGenerationConfig`: Stores parameters for a single AI generation step. +- `AiModelDefinition`: Contains the configuration for an AI model definition. +- `AiModelDefinitionSupport`: Resolves AI model definitions to their corresponding generation configs. + +#### Data Flow +1. **Input**: `AiFieldGenerationConfig` and `AiModelDefinition` instances are configured. +2. **Processing**: + - `AiFieldGenerationSelector` iterates over `AiFieldGenerationConfig` entries to select the most appropriate config based on file extensions. + - `AiModelDefinitionSupport` resolves an `AiModelDefinition` key to an `AiGenerationConfig`. +3. **Output**: Selected `AiFieldGenerationConfig` and resolved `AiGenerationConfig`. + +#### Dependencies +- **Internal Collaborations**: + - `AiFieldGenerationConfig` depends on `AiPromptDefinition`. + - `AiFieldGenerationSelector` depends on `AiFieldGenerationConfig`. + - `AiModelDefinitionSupport` depends on `AiModelDefinition` and `AiGenerationConfig`. +- **External Modules**: None explicitly mentioned. + +#### Cross-cutting +- **Configuration Management**: Uses Lombok for JavaBean design and easy configuration management. +- **Null Handling**: Handles null entries gracefully using Lombok and manual checks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..112b7e9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,40 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:31:35Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before the result is stored in an AI index file. + +#### Purpose +- Parses LLM completion text to isolate the actual model answer. +- Strips internal reasoning blocks to ensure only the final answer is retained. +- Handles edge cases where the token budget is exhausted or no markers are present. + +#### Type +public class AiCompletionParser + +#### Input +- `response` (String): The raw completion text from the model, may be `null`. + +#### Output +- Returns the cleaned answer text as a String, never `null`. +- Throws `IOException` if a thinking block was started but not completed. + +#### Core logic +- Trims the input `response` if it is `null`. +- Searches for `THINKING_BLOCK_END_MARKER` to remove internal reasoning. +- If `THINKING_BLOCK_START_MARKER` is found without `THINKING_BLOCK_END_MARKER`, throws `IOException`. +- Returns the trimmed text after `THINKING_BLOCK_END_MARKER`. + +#### Public API +- `parseCompletion(final String response) -> String`: Strips any Gemma-4 thinking block from the response and returns the clean answer text. + +#### Dependencies +- `java.io.IOException` + +#### Exceptions / Errors +- Throws `IOException` if the token budget is exhausted inside a thinking block. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..4ff04ee --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,42 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:33:05Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a pluggable AI backend for generating text from an `AiGenerationRequest`, supporting default and temperature-override generation. + +#### Purpose +- Interface for AI backend implementations that can generate text based on a request. +- Allows for local execution (e.g., llama.cpp) or mock providers for testing. + +#### Type +- Interface + public; implements `AutoCloseable`; no generics; no notable annotations. + +#### Input +- `generate(AiGenerationRequest request)`: The generation request containing prompt, source file, source text, and current header. +- `generate(AiGenerationRequest request, float temperatureOverride)`: The generation request and a specified temperature override for sampling. + +#### Output +- `String`: Generated text; never `null`, may be blank if no tokens are produced. + +#### Core logic +- **generate(AiGenerationRequest request)**: Generates text using the provider's default sampling parameters. +- **generate(AiGenerationRequest request, float temperatureOverride)**: Delegates to `generate(AiGenerationRequest request)` by default. Implementations supporting per-call temperature overrides should override this method. + +#### Public API +- `generate(AiGenerationRequest request) -> String`: Generates text using the provider's default sampling parameters. +- `generate(AiGenerationRequest request, float temperatureOverride) -> String`: Generates text using a specified temperature override, or delegates to the default implementation. +- `close() -> void`: Closes the provider, throwing an `IOException` if the underlying provider fails. + +#### Dependencies +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` + +#### Exceptions / Errors +- Throws `IOException` if the underlying provider fails. + +#### Concurrency +- No specific concurrency notes; implementations should handle thread safety as needed. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..fc858f9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,24 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:34:26Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an `AiGenerationProvider` implementation by name. + +#### Purpose +- Factory for creating instances of different AI generation providers based on the provided name. + +#### Type +public class AiGenerationProviderFactory + +#### Core logic +- Determines which `AiGenerationProvider` to create based on the `providerName` parameter. +- Supports two provider types: "mock" and "llamacpp-jni". +- Returns a new instance of the selected provider or throws an exception if the provider is not recognized. + +#### Public API +- `create(final String providerName, final LlamaCppJniConfig llamaConfig, final AiPromptSupport promptSupport) -> AiGenerationProvider`: Creates an `AiGenerationProvider` for the given provider name. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..1e2dae8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,55 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:35:11Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides AI generation functionality using the Llama.cpp JNI binding. + +#### Purpose +- Implements `AiGenerationProvider` for generating AI text based on requests. +- Uses a native Llama model for inference. +- Supports lazy loading of the model to save memory and improve initialization performance. + +#### Type +```java +public final class LlamaCppJniAiGenerationProvider implements AiGenerationProvider, AutoCloseable +``` + +#### Input +- `config` (`LlamaCppJniConfig`): Configuration for Llama.cpp. +- `promptSupport` (`AiPromptSupport`): Support for building AI prompts. +- `request` (`AiGenerationRequest`): Request containing the text prompt and other parameters. + +#### Output +- Returns generated AI text as a `String`. + +#### Core logic +- **Initialization**: Stores configuration and prompt support in fields. +- **Model Loading**: Lazily loads the native Llama model on first use. +- **Text Generation**: Constructs a prompt, sets inference parameters, and generates completion using the model. +- **Resource Management**: Closes the model when the provider is closed. + +#### Public API +- `generate(AiGenerationRequest request) -> String`: Generates AI text using the default temperature. +- `generate(AiGenerationRequest request, float temperatureOverride) -> String`: Generates AI text with an overridden temperature. +- `close() -> void`: Closes the native Llama model. + +#### Dependencies +- `LlamaCppJniConfig` +- `AiPromptSupport` +- `AiCompletionParser` +- `LlamaModel` +- `InferenceParameters` +- `ModelParameters` +- `Pair` +- `AiGenerationRequest` + +#### Exceptions / Errors +- Throws `IOException` if an I/O error occurs during model loading or text generation. + +#### Concurrency +- The native model handle is lazily initialized, so the provider can be created without loading the model. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..b8d7011 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,72 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:37:19Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Immutable configuration for the llama.cpp JNI provider. + +#### Purpose +- Immutable data class to hold configuration parameters for the llama.cpp JNI provider. +- Provides methods to access individual configuration properties. + +#### Type +```java +public final class LlamaCppJniConfig implements java.io.Serializable { + // ... +} +``` + +#### Input +- Constructor parameters: + - `libraryPath`: native library path; may be `null` + - `modelPath`: path to the GGUF model file + - `contextSize`: context window size in tokens + - `maxOutputTokens`: maximum number of output tokens per call + - `temperature`: sampling temperature + - `threads`: number of CPU threads + - `topP`: nucleus-sampling probability threshold + - `topK`: top-k sampling limit + - `repeatPenalty`: repetition penalty + - `chatTemplateEnableThinking`: whether chat-template thinking mode is enabled + - `stopStrings`: stop strings; may be `null` (treated as empty) + +#### Output +- Return types: + - `libraryPath()`: native library path, or `null` to use the bundled library + - `modelPath()`: model file path + - `contextSize()`: context window size + - `maxOutputTokens()`: maximum output tokens + - `temperature()`: sampling temperature + - `threads()`: number of CPU threads + - `topP()`: nucleus-sampling probability threshold + - `topK()`: top-k sampling limit + - `repeatPenalty()`: repetition penalty + - `chatTemplateEnableThinking()`: whether chat-template thinking mode is enabled + - `stopStrings()`: unmodifiable list of stop strings + +#### Core logic +- Immutable configuration class with all fields marked as `final`. +- Constructor validates the `modelPath` parameter. +- Provides getter methods for each configuration property. + +#### Public API +- `LlamaCppJniConfig(String libraryPath, String modelPath, int contextSize, int maxOutputTokens, float temperature, int threads, float topP, int topK, float repeatPenalty, boolean chatTemplateEnableThinking, List stopStrings) -> Constructs a new configuration instance.` +- JavaBean getters/setters for: `libraryPath, modelPath, contextSize, maxOutputTokens, temperature, threads, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings` + +#### Dependencies +- `java.util.List` +- `java.util.Objects` +- `java.util.Collections` +- `lombok.EqualsAndHashCode` +- `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord` + +#### Exceptions / Errors +- `NullPointerException` if `modelPath` is `null`. + +#### Concurrency +- Thread-safe due to immutability. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..16dfd34 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,32 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:40:23Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a mock implementation of `AiGenerationProvider` for testing purposes. + +#### Purpose +- To provide a deterministic implementation of `AiGenerationProvider` that returns a mock summary for testing. + +#### Type +```java +public class MockAiGenerationProvider implements AiGenerationProvider +``` + +#### Core logic +- Creates a new `MockAiGenerationProvider`. +- Generates a mock summary for the given `AiGenerationRequest`. + +#### Public API +- `generate(AiGenerationRequest request) -> String` : Generates a mock summary for the given request. + +#### Dependencies +- `AiGenerationRequest` +- `Path` + +#### Exceptions / Errors +- Throws `IOException` if an I/O error occurs. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..2edf0d9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,44 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T20:46:25Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> This package provides the infrastructure and functionality for interacting with AI models, specifically focusing on text generation and parsing of model responses. It includes interfaces, factories, and implementations for generating AI text using different backends, as well as utilities for configuring and parsing the responses. + +#### Responsibilities +- **AI Generation**: Interface and implementation for generating text based on requests. +- **Configuration**: Immutable configuration class for setting up the AI model. +- **Parsing**: Utility for extracting the actual model answer from raw completion text. +- **Mock Implementation**: A mock provider for testing purposes. + +#### Key Units +- **AiGenerationProvider**: Interface for pluggable AI backend implementations. +- **LlamaCppJniAiGenerationProvider**: Provides AI generation functionality using the Llama.cpp JNI binding. +- **MockAiGenerationProvider**: Mock implementation of `AiGenerationProvider` for testing. +- **AiCompletionParser**: Parses raw LLM completion text to extract the model answer. + +#### Data Flow +1. **Input**: An `AiGenerationRequest` containing the prompt and other parameters. +2. **Processing**: + - The request is passed to an `AiGenerationProvider` implementation, which generates text using a specific backend. + - The generated text may be processed by `AiCompletionParser` to remove any internal reasoning blocks. +3. **Output**: The cleaned answer text as a String. + +#### Dependencies +- Internal collaborations: `AiGenerationRequest`, `LlamaCppJniConfig`, `AiPromptSupport`, and other components within the package. +- External dependencies: `java.io.IOException`. + +#### Cross-cutting +- **Concurrency**: No specific concurrency notes; implementations should handle thread safety as needed. +- **Configuration**: Managed through the `LlamaCppJniConfig` class. +- **Error Handling**: Exceptions like `IOException` are handled in various components. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..7d150a8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:52:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. + +#### Purpose +- Configures and selects AI generation parameters based on file types. +- Integrates with AI model definitions to produce summaries. + +#### Responsibilities +- **Configuration Management**: Holds and manages configuration parameters for AI generation steps. +- **Selection Logic**: Selects appropriate AI field generation configurations based on file extensions. +- **Model Definition Support**: Resolves AI model definitions to their corresponding generation configurations. + +#### Key Units +- `AiFieldGenerationConfig`: Manages configuration for a single AI field generation step. +- `AiFieldGenerationSelector`: Chooses the most suitable AI field generation config based on file types. +- `AiGenerationConfig`: Stores parameters for a single AI generation step. +- `AiModelDefinition`: Contains the configuration for an AI model definition. +- `AiModelDefinitionSupport`: Resolves AI model definitions to their corresponding generation configs. + +#### Data Flow +1. **Input**: `AiFieldGenerationConfig` and `AiModelDefinition` instances are configured. +2. **Processing**: + - `AiFieldGenerationSelector` iterates over `AiFieldGenerationConfig` entries to select the most appropriate config based on file extensions. + - `AiModelDefinitionSupport` resolves an `AiModelDefinition` key to an `AiGenerationConfig`. +3. **Output**: Selected `AiFieldGenerationConfig` and resolved `AiGenerationConfig`. + +#### Dependencies +- **Internal Collaborations**: + - `AiFieldGenerationConfig` depends on `AiPromptDefinition`. + - `AiFieldGenerationSelector` depends on `AiFieldGenerationConfig`. + - `AiModelDefinitionSupport` depends on `AiModelDefinition` and `AiGenerationConfig`. +- **External Modules**: None explicitly mentioned. + +#### Cross-cutting +- **Configuration Management**: Uses Lombok for JavaBean design and easy configuration management. +- **Null Handling**: Handles null entries gracefully using Lombok and manual checks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..8343b5e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:53:42Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. + +#### Purpose +- Configures and selects AI generation parameters based on file types. +- Integrates with AI model definitions to produce summaries. + +#### Responsibilities +- **Configuration Management**: Holds and manages configuration parameters for AI generation steps. +- **Selection Logic**: Selects appropriate AI field generation configurations based on file extensions. +- **Model Definition Support**: Resolves AI model definitions to their corresponding generation configurations. + +#### Key Units +- `AiFieldGenerationConfig`: Manages configuration for a single AI field generation step. +- `AiFieldGenerationSelector`: Chooses the most suitable AI field generation config based on file types. +- `AiGenerationConfig`: Stores parameters for a single AI generation step. +- `AiModelDefinition`: Contains the configuration for an AI model definition. +- `AiModelDefinitionSupport`: Resolves AI model definitions to their corresponding generation configs. + +#### Data Flow +1. **Input**: `AiFieldGenerationConfig` and `AiModelDefinition` instances are configured. +2. **Processing**: + - `AiFieldGenerationSelector` iterates over `AiFieldGenerationConfig` entries to select the most appropriate config based on file extensions. + - `AiModelDefinitionSupport` resolves an `AiModelDefinition` key to an `AiGenerationConfig`. +3. **Output**: Selected `AiFieldGenerationConfig` and resolved `AiGenerationConfig`. + +#### Dependencies +- **Internal Collaborations**: + - `AiFieldGenerationConfig` depends on `AiPromptDefinition`. + - `AiFieldGenerationSelector` depends on `AiFieldGenerationConfig`. + - `AiModelDefinitionSupport` depends on `AiModelDefinition` and `AiGenerationConfig`. +- **External Modules**: None explicitly mentioned. + +#### Cross-cutting +- **Configuration Management**: Uses Lombok for JavaBean design and easy configuration management. +- **Null Handling**: Handles null entries gracefully using Lombok and manual checks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..1636c2b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:55:15Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. + +#### Purpose +- Configures and selects AI generation parameters based on file types. +- Integrates with AI model definitions to produce summaries. + +#### Responsibilities +- **Configuration Management**: Holds and manages configuration parameters for AI generation steps. +- **Selection Logic**: Selects appropriate AI field generation configurations based on file extensions. +- **Model Definition Support**: Resolves AI model definitions to their corresponding generation configurations. + +#### Key Units +- `AiFieldGenerationConfig`: Manages configuration for a single AI field generation step. +- `AiFieldGenerationSelector`: Chooses the most suitable AI field generation config based on file types. +- `AiGenerationConfig`: Stores parameters for a single AI generation step. +- `AiModelDefinition`: Contains the configuration for an AI model definition. +- `AiModelDefinitionSupport`: Resolves AI model definitions to their corresponding generation configs. + +#### Data Flow +1. **Input**: `AiFieldGenerationConfig` and `AiModelDefinition` instances are configured. +2. **Processing**: + - `AiFieldGenerationSelector` iterates over `AiFieldGenerationConfig` entries to select the most appropriate config based on file extensions. + - `AiModelDefinitionSupport` resolves an `AiModelDefinition` key to an `AiGenerationConfig`. +3. **Output**: Selected `AiFieldGenerationConfig` and resolved `AiGenerationConfig`. + +#### Dependencies +- **Internal Collaborations**: + - `AiFieldGenerationConfig` depends on `AiPromptDefinition`. + - `AiFieldGenerationSelector` depends on `AiFieldGenerationConfig`. + - `AiModelDefinitionSupport` depends on `AiModelDefinition` and `AiGenerationConfig`. +- **External Modules**: None explicitly mentioned. + +#### Cross-cutting +- **Configuration Management**: Uses Lombok for JavaBean design and easy configuration management. +- **Null Handling**: Handles null entries gracefully using Lombok and manual checks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/package.ai.md new file mode 100644 index 0000000..8e7f411 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/net/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:56:45Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. + +#### Purpose +- Configures and selects AI generation parameters based on file types. +- Integrates with AI model definitions to produce summaries. + +#### Responsibilities +- **Configuration Management**: Holds and manages configuration parameters for AI generation steps. +- **Selection Logic**: Selects appropriate AI field generation configurations based on file extensions. +- **Model Definition Support**: Resolves AI model definitions to their corresponding generation configurations. + +#### Key Units +- `AiFieldGenerationConfig`: Manages configuration for a single AI field generation step. +- `AiFieldGenerationSelector`: Chooses the most suitable AI field generation config based on file types. +- `AiGenerationConfig`: Stores parameters for a single AI generation step. +- `AiModelDefinition`: Contains the configuration for an AI model definition. +- `AiModelDefinitionSupport`: Resolves AI model definitions to their corresponding generation configs. + +#### Data Flow +1. **Input**: `AiFieldGenerationConfig` and `AiModelDefinition` instances are configured. +2. **Processing**: + - `AiFieldGenerationSelector` iterates over `AiFieldGenerationConfig` entries to select the most appropriate config based on file extensions. + - `AiModelDefinitionSupport` resolves an `AiModelDefinition` key to an `AiGenerationConfig`. +3. **Output**: Selected `AiFieldGenerationConfig` and resolved `AiGenerationConfig`. + +#### Dependencies +- **Internal Collaborations**: + - `AiFieldGenerationConfig` depends on `AiPromptDefinition`. + - `AiFieldGenerationSelector` depends on `AiFieldGenerationConfig`. + - `AiModelDefinitionSupport` depends on `AiModelDefinition` and `AiGenerationConfig`. +- **External Modules**: None explicitly mentioned. + +#### Cross-cutting +- **Configuration Management**: Uses Lombok for JavaBean design and easy configuration management. +- **Null Handling**: Handles null entries gracefully using Lombok and manual checks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/package.ai.md new file mode 100644 index 0000000..a93935d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/java/package.ai.md @@ -0,0 +1,45 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:58:16Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. + +#### Purpose +- Configures and selects AI generation parameters based on file types. +- Integrates with AI model definitions to produce summaries. + +#### Responsibilities +- **Configuration Management**: Holds and manages configuration parameters for AI generation steps. +- **Selection Logic**: Selects appropriate AI field generation configurations based on file extensions. +- **Model Definition Support**: Resolves AI model definitions to their corresponding generation configurations. + +#### Key Units +- `AiFieldGenerationConfig`: Manages configuration for a single AI field generation step. +- `AiFieldGenerationSelector`: Chooses the most suitable AI field generation config based on file types. +- `AiGenerationConfig`: Stores parameters for a single AI generation step. +- `AiModelDefinition`: Contains the configuration for an AI model definition. +- `AiModelDefinitionSupport`: Resolves AI model definitions to their corresponding generation configs. + +#### Data Flow +1. **Input**: `AiFieldGenerationConfig` and `AiModelDefinition` instances are configured. +2. **Processing**: + - `AiFieldGenerationSelector` iterates over `AiFieldGenerationConfig` entries to select the most appropriate config based on file extensions. + - `AiModelDefinitionSupport` resolves an `AiModelDefinition` key to an `AiGenerationConfig`. +3. **Output**: Selected `AiFieldGenerationConfig` and resolved `AiGenerationConfig`. + +#### Dependencies +- **Internal Collaborations**: + - `AiFieldGenerationConfig` depends on `AiPromptDefinition`. + - `AiFieldGenerationSelector` depends on `AiFieldGenerationConfig`. + - `AiModelDefinitionSupport` depends on `AiModelDefinition` and `AiGenerationConfig`. +- **External Modules**: None explicitly mentioned. + +#### Cross-cutting +- **Configuration Management**: Uses Lombok for JavaBean design and easy configuration management. +- **Null Handling**: Handles null entries gracefully using Lombok and manual checks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/package.ai.md new file mode 100644 index 0000000..c9fe859 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/main/package.ai.md @@ -0,0 +1,45 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T20:59:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. + +#### Purpose +- Configures and selects AI generation parameters based on file types. +- Integrates with AI model definitions to produce summaries. + +#### Responsibilities +- **Configuration Management**: Holds and manages configuration parameters for AI generation steps. +- **Selection Logic**: Selects appropriate AI field generation configurations based on file extensions. +- **Model Definition Support**: Resolves AI model definitions to their corresponding generation configurations. + +#### Key Units +- `AiFieldGenerationConfig`: Manages configuration for a single AI field generation step. +- `AiFieldGenerationSelector`: Chooses the most suitable AI field generation config based on file types. +- `AiGenerationConfig`: Stores parameters for a single AI generation step. +- `AiModelDefinition`: Contains the configuration for an AI model definition. +- `AiModelDefinitionSupport`: Resolves AI model definitions to their corresponding generation configs. + +#### Data Flow +1. **Input**: `AiFieldGenerationConfig` and `AiModelDefinition` instances are configured. +2. **Processing**: + - `AiFieldGenerationSelector` iterates over `AiFieldGenerationConfig` entries to select the most appropriate config based on file extensions. + - `AiModelDefinitionSupport` resolves an `AiModelDefinition` key to an `AiGenerationConfig`. +3. **Output**: Selected `AiFieldGenerationConfig` and resolved `AiGenerationConfig`. + +#### Dependencies +- **Internal Collaborations**: + - `AiFieldGenerationConfig` depends on `AiPromptDefinition`. + - `AiFieldGenerationSelector` depends on `AiFieldGenerationConfig`. + - `AiModelDefinitionSupport` depends on `AiModelDefinition` and `AiGenerationConfig`. +- **External Modules**: None explicitly mentioned. + +#### Cross-cutting +- **Configuration Management**: Uses Lombok for JavaBean design and easy configuration management. +- **Null Handling**: Handles null entries gracefully using Lombok and manual checks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/package.ai.md new file mode 100644 index 0000000..0099fb3 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/package.ai.md @@ -0,0 +1,45 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:01:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. + +#### Purpose +- Configures and selects AI generation parameters based on file types. +- Integrates with AI model definitions to produce summaries. + +#### Responsibilities +- **Configuration Management**: Holds and manages configuration parameters for AI generation steps. +- **Selection Logic**: Selects appropriate AI field generation configurations based on file extensions. +- **Model Definition Support**: Resolves AI model definitions to their corresponding generation configurations. + +#### Key Units +- `AiFieldGenerationConfig`: Manages configuration for a single AI field generation step. +- `AiFieldGenerationSelector`: Chooses the most suitable AI field generation config based on file types. +- `AiGenerationConfig`: Stores parameters for a single AI generation step. +- `AiModelDefinition`: Contains the configuration for an AI model definition. +- `AiModelDefinitionSupport`: Resolves AI model definitions to their corresponding generation configs. + +#### Data Flow +1. **Input**: `AiFieldGenerationConfig` and `AiModelDefinition` instances are configured. +2. **Processing**: + - `AiFieldGenerationSelector` iterates over `AiFieldGenerationConfig` entries to select the most appropriate config based on file extensions. + - `AiModelDefinitionSupport` resolves an `AiModelDefinition` key to an `AiGenerationConfig`. +3. **Output**: Selected `AiFieldGenerationConfig` and resolved `AiGenerationConfig`. + +#### Dependencies +- **Internal Collaborations**: + - `AiFieldGenerationConfig` depends on `AiPromptDefinition`. + - `AiFieldGenerationSelector` depends on `AiFieldGenerationConfig`. + - `AiModelDefinitionSupport` depends on `AiModelDefinition` and `AiGenerationConfig`. +- **External Modules**: None explicitly mentioned. + +#### Cross-cutting +- **Configuration Management**: Uses Lombok for JavaBean design and easy configuration management. +- **Null Handling**: Handles null entries gracefully using Lombok and manual checks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/project.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/project.ai.md new file mode 100644 index 0000000..7670d35 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen25coder-7b__v2/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: D3AA3C76 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T21:02:50Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The `llamacpp-ai-index-maven-plugin` project is a comprehensive suite of Java packages designed to integrate AI-driven content generation into Maven projects. At its core, the plugin manages configuration and selection logic for AI field generation steps, seamlessly integrating with various AI model definitions. The `provider` package extends this functionality by offering the necessary infrastructure and utilities for interacting with AI models, specifically tailored for text generation and response parsing. Together, these subsystems enable developers to automatically generate summaries for individual files or entire packages, leveraging advanced AI capabilities within their Maven environments. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. +- main/java/net/ladenthin/maven/llamacpp/aiindex — Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — This package provides the infrastructure and functionality for interacting with AI models, specifically focusing on text generation and parsing of model responses. It includes interfaces, factories, and implementations for generating AI text using different backends, as well as utilities for configuring and parsing the responses. +- main/java/net/ladenthin/maven/llamacpp — Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. +- main/java/net/ladenthin/maven — Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. +- main/java/net/ladenthin — Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. +- main/java/net — Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. +- main/java — Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. +- main — Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. +- . — Manages configuration and selection logic for AI field generation steps within Maven projects, integrating with AI model definitions and providing mechanisms to generate summaries for individual files or entire packages. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..618d90b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,57 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:42:19Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Associates a prompt template with an AI model definition to generate field values for specific file types in Maven plugin processing + +#### Purpose +- Defines a mapping between a prompt template and an AI model for field generation per file type +- Enables selective AI processing based on source file extensions + +#### Type +class, public, final none; @ToString; implements none; extends none; generics: none +key annotations: @ToString, @Nullable (on fields), @SuppressWarnings("NullAway.Init", "initialization.fields.uninitialized") + +#### Input +- Constructor: no parameters +- Method parameters: promptKey (String), aiDefinitionKey (String), fileExtensions (Collection) +- Injected via Maven plugin reflection through setters + +#### Output +- Returns promptKey (String) +- Returns aiDefinitionKey (String) +- Returns fileExtensions (List or null) as unmodifiable view +- Produces immutable list when fileExtensions is set + +#### Core logic +- Maps a prompt key to an AI model definition by key +- Applies field generation only to files matching specified extensions +- Uses fallback behavior when no extensions are defined +- Defensively copies fileExtensions list to prevent external modification + +#### Public API +- getPromptKey() → String (returns prompt template key) +- setPromptKey(String) → void (sets prompt template key) +- getAiDefinitionKey() → String (returns AI model definition key) +- setAiDefinitionKey(String) → void (sets AI model definition key) +- getFileExtensions() → List or null (returns file extensions or fallback) +- setFileExtensions(Collection) → void (sets file extensions; null = fallback) + +#### Dependencies +AiModelDefinition, AiPromptDefinition, Collection, List, ArrayList, Collections, lombok.ToString + +#### Exceptions / Errors +- No explicit exceptions thrown +- Null handling via @Nullable on fileExtensions and method parameters +- Null values are allowed and treated as fallback + +#### Concurrency +- Immutable output for fileExtensions after set +- No thread-safety or synchronization annotations +- Safe for concurrent access due to defensive copying of list +- Mutable state only in setter methods, not exposed externally diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..18f571e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,53 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:43:39Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the AI field generation config based on file extension, using a priority order of matching rules and fallback + +#### Purpose +- Determines which AI prompt configuration to apply to a source file by file extension +- Supports fallback logic for files without matching extensions + +#### Type +- final class with public constructor +- implements no interfaces +- extends no classes +- key generics: Iterable +- annotations: @ToString, @Nullable (on return type) + +#### Input +- configs: Iterable of AiFieldGenerationConfig entries in declaration order; null entries are skipped +- fileName: source file name (e.g. "Foo.java") + +#### Output +- AiFieldGenerationConfig instance matching the file extension, or null if no match and no fallback + +#### Core logic +- Iterates over configured AI generation rules in order +- Skips null config entries +- For each config, checks if its non-empty extensions list matches the file name via endsWith +- Returns first matching config immediately +- If no match, retains first config with empty or absent extension list as fallback +- Returns null if no valid config and no fallback is defined + +#### Public API +- selectForFileName(Iterable, String) → AiFieldGenerationConfig (returns matching config or fallback, or null) + +#### Dependencies +- java.util.List +- java.lang.Iterable +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- No exceptions thrown; handles null inputs gracefully by skipping null configs +- Returns null when no match and no fallback exists + +#### Concurrency +- Thread-safe by design due to immutable state and pure logic (no shared mutable state) +- No synchronization or concurrent access required diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..7061f04 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,64 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:44:23Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines default and mutable parameters for AI model inference in Maven-based AI generation steps + +#### Purpose +- Configures sampling, context, and retry behavior for AI model inference +- Bridges Maven plugin configuration with llama.cpp inference parameters + +#### Type +class, public, mutable, final fields, Lombok @ToString, static defaults + +#### Input +- Constructor: no input +- Method parameters: modelPath (String), contextSize (int), temperature (float), threads (int), charsPerToken (int), maxInputChars (int), warnOnTrim (boolean), maxRetries (int), retryTemperatureIncrement (float), topP (float), topK (int), repeatPenalty (float), chatTemplateEnableThinking (boolean), stopStrings (List) + +#### Output +- Returns configured values via getter methods +- Produces immutable list of stop strings when requested +- Updates internal state via setters (mutable) + +#### Core logic +- Stores model-specific inference parameters in a mutable object +- Uses static defaults for all fields to provide consistent baseline behavior +- Automatically calculates maxInputChars from context size, output tokens, and safety margin when charsPerToken > 0 +- Implements retry logic with temperature increment per attempt to improve model response quality +- Supports chat-template thinking mode control to suppress or enable chain-of-thought reasoning + +#### Public API +- getModelPath() → String (get model file path) +- getContextSize() → int (get context window size) +- getMaxOutputTokens() → int (get max output tokens) +- getTemperature() → float (get sampling temperature) +- getThreads() → int (get CPU threads) +- getCharsPerToken() → int (get chars per token) +- getMaxInputChars() → int (get max input characters) +- isWarnOnTrim() → boolean (check trim warning status) +- getMaxRetries() → int (get retry count) +- getRetryTemperatureIncrement() → float (get retry temp increment) +- getTopP() → float (get top-p sampling) +- getTopK() → int (get top-k sampling) +- getRepeatPenalty() → float (get repetition penalty) +- isChatTemplateEnableThinking() → boolean (check thinking mode) +- getStopStrings() → List (get stop strings, immutable) + +#### Dependencies +- java.util.List, java.util.ArrayList, java.util.Collections +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- No explicit exceptions thrown; null handling via nullable fields and defensive checks in setters +- null modelPath allowed; null stopStrings resets to empty list + +#### Concurrency +- Immutable getters; mutable state only updated via setters +- Thread-safe access via immutable views (e.g. getStopStrings returns unmodifiable list) +- No synchronization or shared state; safe for concurrent reads diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..a6924bb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,40 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:47:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines whether AI generation targets individual source files or entire packages + +#### Purpose +- Specifies scope of AI-generated content: per-file or per-package +- Enables routing of generation steps based on context size and output type + +#### Type +public enum AiGenerationKind + +#### Input +None + +#### Output +None + +#### Core logic +- No computation; only provides named constants for scope selection +- Values are statically defined and immutably accessible + +#### Public API +- FILE_SUMMARY(file) → void — generates fields for a single source file +- PACKAGE_SUMMARY(pkg) → void — generates fields for a package aggregate + +#### Dependencies +AiGenerationKind, net.ladenthin.maven.llamacpp.aiindex.config + +#### Exceptions / Errors +None thrown; no runtime error handling + +#### Concurrency +Immutable and thread-safe by design diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..e8c5bfc --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,86 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:47:23Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines AI model parameters by key for reuse in field generation configurations + +#### Purpose +- Stores AI model configuration parameters (e.g., context size, temperature) tied to a unique lookup key +- Enables reusable model settings across multiple field-generation entries + +#### Type +- class: public, final (not final), mutable JavaBean +- implements: none +- extends: none +- generics: none +- annotations: @ToString, @Nullable, @SuppressWarnings("NullAway.Init", "initialization.fields.uninitialized") + +#### Input +- constructor: default values from AiGenerationConfig +- parameters: key (String), modelPath (String), and various numeric/boolean fields via setters +- injected dependencies: none directly; relies on external configuration via reflection + +#### Output +- returns: key, model path, and all model-specific parameters (e.g., context size, temperature) +- produces: immutable view of stopStrings list via unmodifiableList +- side effects: sets internal state through setters; no mutations beyond field assignment + +#### Core logic +- Defines a reusable AI model configuration with default values from AiGenerationConfig +- Uses key-based lookup for reference in field-generation configs +- All numeric and boolean fields inherit defaults from AiGenerationConfig +- stopStrings are managed as a nullable list, converted to immutable view on access +- setters update internal state; no validation or transformation logic + +#### Public API +- getKey() → String (returns unique model key) +- setKey(String) → void (assigns key for lookup) +- getModelPath() → String (returns model file path) +- setModelPath(String) → void (sets GGUF model path) +- getContextSize() → int (returns context window size) +- setContextSize(int) → void (configures input tokens) +- getMaxOutputTokens() → int (returns max output tokens) +- setMaxOutputTokens(int) → void (limits generated output) +- getTemperature() → float (returns sampling temperature) +- setTemperature(float) → void (controls randomness) +- getThreads() → int (returns CPU threads for inference) +- setThreads(int) → void (configures parallelism) +- getCharsPerToken() → int (returns chars per token for input trimming) +- setCharsPerToken(int) → void (enables dynamic max input calculation) +- isWarnOnTrim() → boolean (checks trim warning flag) +- setWarnOnTrim(boolean) → void (toggles input trim warning) +- getMaxRetries() → int (returns retry attempts on empty response) +- setMaxRetries(int) → void (configures retry policy) +- getRetryTemperatureIncrement() → float (returns retry temp increment) +- setRetryTemperatureIncrement(float) → void (adjusts temperature on retries) +- getTopP() → float (returns nucleus sampling threshold) +- setTopP(float) → void (configures top-p filtering) +- getTopK() → int (returns top-k token limit) +- setTopK(int) → void (limits sampling to top-k tokens) +- getRepeatPenalty() → float (returns repetition penalty) +- setRepeatPenalty(float) → void (penalizes repeated tokens) +- isChatTemplateEnableThinking() → boolean (checks thinking mode enable) +- setChatTemplateEnableThinking(boolean) → void (controls chain-of-thought reasoning) +- getStopStrings() → List (returns stop strings, null if not set) +- setStopStrings(Collection) → void (configures generation termination strings) + +#### Dependencies +- AiGenerationConfig +- java.util.List, java.util.Collections, java.util.ArrayList +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- no explicit throws; no error handling or validation logic +- null fields allowed via @Nullable; stopStrings may be null +- defaults used for all fields; no bounds checking or input sanitization + +#### Concurrency +- thread-safe by design: immutable views (e.g., stopStrings) and state updates via setters +- no synchronization or shared mutable state +- safe for concurrent access due to immutability of returned values and no shared state mutations diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..16f6b9b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,52 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:50:30Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key to produce ready-to-use generation configurations + +#### Purpose +- Acts as a lookup table to convert AI model keys into full generation configurations +- Enforces configuration validity at build time by validating non-null keys and missing definitions + +#### Type +- final class with @ToString annotation +- implements no interfaces, extends no type +- generic: none +- key dependencies: AiModelDefinition → AiGenerationConfig via key lookup + +#### Input +- List definitions (may be null or empty) +- Individual entries must have non-null key; null key triggers immediate NullPointerException + +#### Output +- Map internal state (immutable after construction) +- Returns AiGenerationConfig on lookup by key +- Throws IllegalArgumentException for missing keys + +#### Core logic +- Presizes map to avoid rehashing during bulk population +- Validates each definition's key at insertion time and enforces non-null requirement +- Converts each AiModelDefinition into a full AiGenerationConfig via field-by-field copy +- Returns null-config if key not found, then throws IllegalArgumentException with descriptive message + +#### Public API +- AiModelDefinitionSupport(List definitions) → void (builds lookup map from list) +- getConfig(String key) → AiGenerationConfig (returns config for given key or throws error) + +#### Dependencies +AiModelDefinition, AiGenerationConfig, Java8CompatibilityHelper, Objects + +#### Exceptions / Errors +- NullPointerException if any entry has null key (with index and entry detail) +- IllegalArgumentException if key not found in map (with prefix message) +- Null key in getConfig() throws IllegalArgumentException + +#### Concurrency +- Immutable state after construction +- No shared mutable state; thread-safe via final fields and immutable config objects +- Safe for concurrent access without synchronization diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..f0f2881 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,49 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:56:58Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> This package enables AI-driven field generation in Maven plugin workflows by defining model configurations, prompt mappings, and execution scopes tailored to source file types. + +#### Purpose +- Configures AI model parameters and inference behavior for Maven-based source processing +- Maps AI prompt templates to specific file extensions to enable per-file or per-package field generation + +#### Responsibilities +- AI model configuration management (parameters, context, retries) +- Prompt/template routing based on file extension +- Scope definition: individual files vs. entire packages +- Model lookup and validation via key-based configuration + +#### Key units +- `AiFieldGenerationConfig`: maps prompt and model keys to file extensions for selective AI field generation +- `AiFieldGenerationSelector`: selects the appropriate generation config by file extension with fallback logic +- `AiGenerationConfig`: holds mutable inference parameters (temperature, context size, retries, stop strings) +- `AiModelDefinition`: stores reusable AI model settings keyed by identifier +- `AiModelDefinitionSupport`: resolves model keys to full generation configs with validation and error handling +- `AiGenerationKind`: defines scope of AI output as file-level or package-level + +#### Data flow +Input file name → `AiFieldGenerationSelector` matches extension → selects `AiFieldGenerationConfig` → retrieves associated prompt and model key → `AiModelDefinitionSupport` resolves model key to full `AiGenerationConfig` → applies model parameters to generate field values via AI inference pipeline + +#### Dependencies +- Internal: `AiModelDefinition`, `AiGenerationConfig`, `AiFieldGenerationConfig`, `AiGenerationKind`, `Collection`, `List`, `Iterable`, `Map`, `Objects` +- External: Maven plugin reflection, llama.cpp inference engine (via model paths), Java 8+ features + +#### Cross-cutting +- Immutable output views for lists and configs (e.g., `getStopStrings()` returns unmodifiable list) +- Null handling via `@Nullable` annotations and fallback behavior for missing values +- Thread-safe by design due to immutability and no shared mutable state +- Lombok `@ToString` used across all classes for debugging and logging +- Static defaults in `AiGenerationConfig` provide baseline inference behavior +- Error handling: explicit `NullPointerException` on null keys, `IllegalArgumentException` on missing definitions or invalid inputs diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..e603f94 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,52 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:01:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> This package enables AI-driven field generation and text inference in Maven plugin workflows by configuring and executing local LLMs (like llama.cpp) to generate source metadata based on file type and prompt templates. + +#### Purpose +- Configures AI model behavior and prompt routing for per-file or per-package field generation in Maven-based source processing +- Provides a pluggable, testable pipeline for AI text generation using local LLMs or mock providers + +#### Responsibilities +- AI model configuration and parameter management (temperature, context size, retries) +- Prompt/template selection based on file extension or type +- Scope definition: file-level vs. package-level field generation +- Real-time AI inference via llama.cpp or deterministic mock execution +- Input parsing and output cleaning to extract final responses from raw LLM outputs + +#### Key units +- `AiFieldGenerationConfig`: maps prompt templates and model keys to file extensions for selective field generation +- `AiFieldGenerationSelector`: selects config by file extension with fallback logic +- `AiGenerationConfig`: holds mutable inference parameters (temperature, context size, stop strings) +- `AiModelDefinition`: stores reusable AI model settings by identifier +- `AiModelDefinitionSupport`: resolves model keys to full configs with validation and error handling +- `AiGenerationKind`: defines scope of AI output as file-level or package-level +- `AiGenerationProvider`: abstract interface for pluggable AI generation backends +- `LlamaCppJniAiGenerationProvider`: executes GGUF models via llama.cpp JNI with lazy loading +- `LlamaCppJniConfig`: immutable config object defining model path, context, temperature, stop strings +- `AiCompletionParser`: strips internal reasoning blocks from raw LLM output to extract final answer +- `MockAiGenerationProvider`: generates deterministic, testable responses for isolation and testing + +#### Data flow +Input file name → `AiFieldGenerationSelector` matches extension → selects `AiFieldGenerationConfig` → retrieves prompt and model key → `AiModelDefinitionSupport` resolves key to full `AiGenerationConfig` → applies parameters to AI provider → provider generates text (real or mock) → raw output passed to `AiCompletionParser` → final clean response stored + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`, `AiGenerationKind`, `Collection`, `List`, `Map`, `Objects`, `AiGenerationRequest`, `AiPromptSupport` +- External: Maven plugin reflection, llama.cpp inference engine (via GGUF models), Java 8+ features + +#### Cross-cutting +- Immutable configuration and state objects (e.g., `LlamaCppJniConfig`, `AiGenerationConfig`) for thread safety and concurrent access +- Null handling via `@Nullable` annotations and fallback logic for missing values +- Stateless, thread-safe providers with no shared mutable state +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`, `@ConvertToRecord`) used across all classes for immutability and debugging +- Explicit error handling: `NullPointerException` on null keys, `IllegalArgumentException` on invalid inputs or missing definitions +- Deterministic output patterns in mock provider and parser for consistent test behavior +- Static defaults in `AiGenerationConfig` provide baseline inference parameters diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..856cfca --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,46 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:51:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Extracts the model's final answer from raw LLM completion text by removing internal reasoning blocks + +#### Purpose +- Strips internal chain-of-thought reasoning from LLM responses +- Ensures only the final model output is stored in AI index files + +#### Type +class, public, non-final, @ToString +implements none, extends none +generics: none + +#### Input +- raw completion text from an LLM (String), may be null + +#### Output +- cleaned final answer text (String), never null + +#### Core logic +- If input is null, return empty string +- Find position of thinking block end marker +- If end marker found, return text after it, trimmed +- If start marker present but end marker absent, throw IOException with actionable message +- Otherwise, return trimmed original input + +#### Public API +- parseCompletion(String) -> String: extracts final model answer by removing internal reasoning + +#### Dependencies +- java.io.IOException +- lombok.ToString + +#### Exceptions / Errors +- Throws IOException if thinking block start is found without corresponding end marker +- Handles null input by treating it as empty string + +#### Concurrency +- No thread safety concerns; stateless, immutable operations diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..8cb3820 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,48 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:52:23Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates AI text from a document request using configurable sampling parameters + +#### Purpose +- Enables pluggable AI backends (e.g., llama.cpp or mock providers) to produce text from document prompts +- Supports per-call temperature overrides to avoid early termination and empty responses + +#### Type +- interface +- extends AutoCloseable +- key generics: none +- notable annotations: none + +#### Input +- AiGenerationRequest containing: prompt key, source file, source text, current header +- temperatureOverride (float) for override-based generation + +#### Output +- String with generated text; never null, may be blank if no tokens produced + +#### Core logic +- Uses default sampling parameters when no temperature override is provided +- On temperature override, temporarily overrides provider’s internal temperature setting +- Delegates to base generate() method in default implementation +- Handles I/O errors from underlying AI provider + +#### Public API +- generate(AiGenerationRequest) → String (generates text with default settings) +- generate(AiGenerationRequest, float) → String (overrides temperature for retry resilience) + +#### Dependencies +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest + +#### Exceptions / Errors +- Throws IOException if provider fails during generation or I/O operations +- No null inputs; request is guaranteed to be non-null + +#### Concurrency +- Not thread-safe; no synchronization or concurrency handling +- Designed for single-threaded AI generation calls diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..4452b15 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,50 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:53:03Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an AI generation provider based on configuration name + +#### Purpose +- Creates and returns an AI generation provider instance by provider name +- Supports fallback to mock provider when name is missing or invalid + +#### Type +- class: public, final (not explicitly marked), non-sealed +- implements: none +- extends: none +- generics: none +- annotations: @ToString + +#### Input +- providerName: String, provider key (e.g. "mock", "llamacpp-jni") +- llamaConfig: LlamaCppJniConfig, configuration for JNI-based provider +- promptSupport: AiPromptSupport, prompt handling support for providers that need it + +#### Output +- AiGenerationProvider instance: new provider object based on providerName + +#### Core logic +- Returns mock provider if providerName is null or blank +- Uses switch statement to select provider by name: "mock" → MockAiGenerationProvider; "llamacpp-jni" → LlamaCppJniAiGenerationProvider +- Throws IllegalArgumentException for unrecognized provider names + +#### Public API +- create(String, LlamaCppJniConfig, AiPromptSupport) → AiGenerationProvider (instantiates provider by name) + +#### Dependencies +- Java8CompatibilityHelper +- AiPromptSupport +- LlamaCppJniConfig +- MockAiGenerationProvider +- LlamaCppJniAiGenerationProvider + +#### Exceptions / Errors +- IllegalArgumentException if providerName is unknown or unsupported + +#### Concurrency +- No thread safety concerns; stateless, single-threaded creation logic diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..94fe8f1 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,63 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:53:43Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates AI responses from GGUF models using llama.cpp via JNI, with lazy loading and prompt templating + +#### Purpose +- Executes AI text generation using local GGUF models via llama.cpp JNI binding +- Delays model loading until first generation to reduce startup overhead + +#### Type +- final class implements AiGenerationProvider, AutoCloseable +- extends none, implements AiGenerationProvider, AutoCloseable +- generics: none +- key annotations: @ToString, @Nullable, Lombok @ToString.Exclude + +#### Input +- LlamaCppJniConfig (model path, context size, threads, temperature, etc.) +- AiPromptSupport (for building prompts from request) +- AiGenerationRequest (input prompt and metadata) +- float temperatureOverride (optional override for generation temperature) + +#### Output +- String (generated AI response text) +- Model closed on dispose (native resources freed) + +#### Core logic +- Lazily loads GGUF model on first generate() call using provided config +- Builds prompt from request via prompt support +- Constructs chat message list with user prompt +- Sets inference parameters: temperature, max tokens, top-p, top-k, stop strings +- Executes chat completion via native llama.cpp model +- Parses and returns generated response text + +#### Public API +- generate(AiGenerationRequest) -> String (generates response using default temperature) +- generate(AiGenerationRequest, float) -> String (generates with custom temperature) +- close() -> void (releases native model handle) + +#### Dependencies +- net.ladenthin.llama.LlamaModel +- net.ladenthin.llama.parameters.InferenceParameters +- net.ladenthin.llama.parameters.ModelParameters +- net.ladenthin.llama.value.Pair +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiCompletionParser + +#### Exceptions / Errors +- Throws IOException on model load or generation failure +- Null checks on config and promptSupport at construction +- No explicit error handling beyond standard JNI/IO exceptions + +#### Concurrency +- Thread-safe only via lazy initialization and model caching +- No shared state; each generate() call is independent +- Model loaded per instance, not shared across threads +- Immutable inference parameters prevent mutation during use diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..550ed01 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,83 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:55:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines immutable configuration for llama.cpp JNI-based AI model inference + +#### Purpose +- Configures runtime parameters for llama.cpp JNI-based LLM inference +- Encapsulates model and execution settings in a thread-safe, immutable format + +#### Type +- final class +- extends: none +- implements: none +- generics: none +- annotations: @ConvertToRecord, @ToString, @EqualsAndHashCode + +#### Input +- libraryPath (native library path; may be null) +- modelPath (path to GGUF model file) +- contextSize (context window size in tokens) +- maxOutputTokens (max output tokens per call) +- temperature (sampling temperature) +- threads (CPU thread count) +- topP (nucleus sampling threshold) +- topK (top-k sampling limit) +- repeatPenalty (repetition penalty) +- chatTemplateEnableThinking (boolean for thinking mode) +- stopStrings (list of stop strings; null → empty list) + +#### Output +- libraryPath (native library path) +- modelPath (model file path) +- contextSize (context window size) +- maxOutputTokens (max output tokens) +- temperature (sampling temperature) +- threads (thread count) +- topP (nucleus sampling threshold) +- topK (top-k limit) +- repeatPenalty (repetition penalty) +- chatTemplateEnableThinking (thinking mode enabled) +- stopStrings (unmodifiable list of stop strings) + +#### Core logic +- Requires non-null modelPath at construction +- Null stopStrings default to empty list +- All fields are final and initialized in constructor +- All accessors return immutable, defensive copies +- Lombok generates equals, hashCode, toString with bit-level float comparison + +#### Public API +- libraryPath() → String (native library path) +- modelPath() → String (model file path) +- contextSize() → int (context window size) +- maxOutputTokens() → int (max output tokens) +- temperature() → float (sampling temperature) +- threads() → int (CPU thread count) +- topP() → float (top-p threshold) +- topK() → int (top-k limit) +- repeatPenalty() → float (repetition penalty) +- chatTemplateEnableThinking() → boolean (thinking mode enabled) +- stopStrings() → List (unmodifiable stop strings) + +#### Dependencies +- java.util.Collections +- java.util.List +- java.util.Objects +- lombok.EqualsAndHashCode +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord + +#### Exceptions / Errors +- Throws NullPointerException if modelPath is null + +#### Concurrency +- Immutable state; thread-safe by design +- No shared mutable fields or synchronization needed +- All accessors return defensive copies of internal state diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..1283fe2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,40 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:56:35Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a deterministic mock summary for AI generation testing + +#### Purpose +- Generates testable, predictable summaries for AI document processing +- Replaces real AI generation in unit and integration tests + +#### Type +class, public, final, implements AiGenerationProvider + +#### Input +- AiGenerationRequest (sourceFile) → Path object + +#### Output +- String (mock summary of the input file name) + +#### Core logic +- Extracts source file name from request +- Constructs a deterministic mock summary using the filename +- Returns the summary without external dependencies or side effects + +#### Public API +- generate(AiGenerationRequest request) → String (creates mock summary from file name) + +#### Dependencies +AiGenerationRequest, Path, IOException + +#### Exceptions +- Throws IOException on failure (no actual I/O performed) + +#### Concurrency +- Immutable state, thread-safe by design — no shared mutable state or synchronization needed diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..17f4382 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,59 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T05:59:19Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> This package enables pluggable, configurable AI text generation from document prompts using local LLMs like llama.cpp, with support for mocking and deterministic testing of AI response pipelines. + +#### Purpose +- Provides a modular, extensible pipeline for generating AI responses from document inputs using configurable backends +- Supports both real (llama.cpp JNI) and mock-based AI generation for testing and fallback scenarios + +#### Responsibilities +- AI generation execution via provider interfaces (e.g., llama.cpp or mock) +- Configuration management for LLM inference parameters +- Parsing raw LLM output to extract final answers by removing internal reasoning blocks +- Provider instantiation and selection based on configuration name +- Deterministic mock generation for test environments + +#### Key units +- `AiGenerationProvider`: abstracts AI text generation with pluggable backends; supports temperature overrides and I/O error handling +- `LlamaCppJniAiGenerationProvider`: executes GGUF model inference via llama.cpp JNI with lazy loading and prompt templating +- `LlamaCppJniConfig`: immutable configuration object defining model path, context size, temperature, top-p/k, stop strings +- `AiCompletionParser`: extracts final model output from raw completion text by removing internal thinking blocks +- `MockAiGenerationProvider`: generates deterministic, testable summaries from file names to simulate AI responses in isolation +- `AiGenerationProviderFactory`: creates and returns an instance of an AI provider based on configuration name with fallback to mock + +#### Data flow +- A document request is processed into an `AiGenerationRequest` object containing prompt and metadata +- The `AiGenerationProviderFactory` selects a provider (real or mock) by name and instantiates it +- The selected provider generates text via `generate()` using configured or overridden temperature parameters +- For real providers, the model is lazily loaded and inference parameters are set; output is parsed and returned +- For mock providers, a deterministic summary derived from the input file name is returned +- Raw completion text (if generated) is passed to `AiCompletionParser` to strip internal reasoning blocks before storage + +#### Dependencies +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiCompletionParser` +- `net.ladenthin.llama.LlamaModel`, `InferenceParameters`, `ModelParameters` +- `java.io.IOException` +- `java.util.List`, `java.util.Collections` +- `lombok.ToString`, `@EqualsAndHashCode`, `@ConvertToRecord` + +#### Cross-cutting +- All providers are stateless and thread-safe, with no shared mutable state +- Immutable configuration objects (`LlamaCppJniConfig`) used throughout to ensure safe concurrent access +- Common exception handling: `IOException` thrown on I/O failures or null model paths +- Deterministic output patterns in mock provider and parser for consistent test behavior +- Use of Lombok annotations for immutability, toString, equals, and hash code generation across units diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..5194a66 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,51 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:03:12Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> This package enables AI-driven source metadata generation in Maven plugin workflows by routing file-specific prompts to local LLMs or mock providers for dynamic field creation based on file type. + +#### Purpose +- Configures AI model behavior and prompt routing for per-file or per-package field generation in Maven-based source processing +- Provides a pluggable, testable pipeline for AI text generation using local LLMs or mock providers + +#### Responsibilities +- AI model configuration and parameter management (temperature, context size, retries) +- Prompt/template selection based on file extension or type +- Scope definition: file-level vs. package-level field generation +- Real-time AI inference via llama.cpp or deterministic mock execution +- Input parsing and output cleaning to extract final responses from raw LLM outputs + +#### Key units +- `AiFieldGenerationConfig`: maps prompt templates and model keys to file extensions for selective field generation +- `AiFieldGenerationSelector`: selects config by file extension with fallback logic +- `AiGenerationConfig`: holds mutable inference parameters (temperature, context size, stop strings) +- `AiModelDefinition`: stores reusable AI model settings by identifier +- `AiModelDefinitionSupport`: resolves model keys to full configs with validation and error handling +- `AiGenerationKind`: defines scope of AI output as file-level or package-level +- `AiGenerationProvider`: abstract interface for pluggable AI generation backends +- `LlamaCppJniAiGenerationProvider`: executes GGUF models via llama.cpp JNI with lazy loading +- `LlamaCppJniConfig`: immutable config object defining model path, context, temperature, stop strings +- `AiCompletionParser`: strips internal reasoning blocks from raw LLM output to extract final answer +- `MockAiGenerationProvider`: generates deterministic, testable responses for isolation and testing + +#### Data flow +Input file name → `AiFieldGenerationSelector` matches extension → selects `AiFieldGenerationConfig` → retrieves prompt and model key → `AiModelDefinitionSupport` resolves key to full `AiGenerationConfig` → applies parameters to AI provider → provider generates text (real or mock) → raw output passed to `AiCompletionParser` → final clean response stored + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`, `AiGenerationKind`, `Collection`, `List`, `Map`, `Objects`, `AiGenerationRequest`, `AiPromptSupport` +- External: Maven plugin reflection, llama.cpp inference engine (via GGUF models), Java 8+ features + +#### Cross-cutting +- Immutable configuration and state objects (e.g., `LlamaCppJniConfig`, `AiGenerationConfig`) for thread safety and concurrent access +- Null handling via `@Nullable` annotations and fallback logic for missing values +- Stateless, thread-safe providers with no shared mutable state +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`, `@ConvertToRecord`) used across all classes for immutability and debugging +- Explicit error handling: `NullPointerException` on null keys, `IllegalArgumentException` on invalid inputs or missing definitions +- Deterministic output patterns in mock provider and parser for consistent test behavior +- Static defaults in `AiGenerationConfig` provide baseline inference parameters diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..5cfa8b1 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,50 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:04:37Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> This package enables AI-driven source metadata generation in Maven plugin workflows by routing file-specific prompts to local LLMs or mock providers for dynamic field creation based on file type. + +#### Purpose +- Configures AI model behavior and prompt routing for per-file or per-package field generation in Maven-based source processing +- Provides a pluggable, testable pipeline for AI text generation using local LLMs or mock providers + +#### Responsibilities +- AI model configuration and parameter management (temperature, context size, retries) +- Prompt/template selection based on file extension or type +- Scope definition: file-level vs. package-level field generation +- Real-time AI inference via llama.cpp or deterministic mock execution +- Input parsing and output cleaning to extract final responses from raw LLM outputs + +#### Key units +- `AiFieldGenerationConfig`: maps prompt templates and model keys to file extensions for selective field generation +- `AiFieldGenerationSelector`: selects config by file extension with fallback logic +- `AiGenerationConfig`: holds mutable inference parameters (temperature, context size, stop strings) +- `AiModelDefinition`: stores reusable AI model settings by identifier +- `AiModelDefinitionSupport`: resolves model keys to full configs with validation and error handling +- `AiGenerationKind`: defines scope of AI output as file-level or package-level +- `AiGenerationProvider`: abstract interface for pluggable AI generation backends +- `LlamaCppJniAiGenerationProvider`: executes GGUF models via llama.cpp JNI with lazy loading +- `LlamaCppJniConfig`: immutable config object defining model path, context, temperature, stop strings +- `AiCompletionParser`: strips internal reasoning blocks from raw LLM output to extract final answer + +#### Data flow +Input file name → `AiFieldGenerationSelector` matches extension → selects `AiFieldGenerationConfig` → retrieves prompt and model key → `AiModelDefinitionSupport` resolves key to full `AiGenerationConfig` → applies parameters to AI provider → provider generates text (real or mock) → raw output passed to `AiCompletionParser` → final clean response stored + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`, `AiGenerationKind`, `Collection`, `List`, `Map`, `Objects`, `AiGenerationRequest`, `AiPromptSupport` +- External: Maven plugin reflection, llama.cpp inference engine (via GGUF models), Java 8+ features + +#### Cross-cutting +- Immutable configuration and state objects (e.g., `LlamaCppJniConfig`, `AiGenerationConfig`) for thread safety and concurrent access +- Null handling via `@Nullable` annotations and fallback logic for missing values +- Stateless, thread-safe providers with no shared mutable state +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`, `@ConvertToRecord`) used across all classes for immutability and debugging +- Explicit error handling: `NullPointerException` on null keys, `IllegalArgumentException` on invalid inputs or missing definitions +- Deterministic output patterns in mock provider and parser for consistent test behavior +- Static defaults in `AiGenerationConfig` provide baseline inference parameters diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..809e30f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,50 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:05:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> This package enables AI-driven source metadata generation in Maven plugin workflows by routing file-specific prompts to local LLMs or mock providers for dynamic field creation based on file type. + +#### Purpose +- Configures AI model behavior and prompt routing for per-file or per-package field generation in Maven-based source processing +- Provides a pluggable, testable pipeline for AI text generation using local LLMs or mock providers + +#### Responsibilities +- AI model configuration and parameter management (temperature, context size, retries) +- Prompt/template selection based on file extension or type +- Scope definition: file-level vs. package-level field generation +- Real-time AI inference via llama.cpp or deterministic mock execution +- Input parsing and output cleaning to extract final responses from raw LLM outputs + +#### Key units +- `AiFieldGenerationConfig`: maps prompt templates and model keys to file extensions for selective field generation +- `AiFieldGenerationSelector`: selects config by file extension with fallback logic +- `AiGenerationConfig`: holds mutable inference parameters (temperature, context size, stop strings) +- `AiModelDefinition`: stores reusable AI model settings by identifier +- `AiModelDefinitionSupport`: resolves model keys to full configs with validation and error handling +- `AiGenerationKind`: defines scope of AI output as file-level or package-level +- `AiGenerationProvider`: abstract interface for pluggable AI generation backends +- `LlamaCppJniAiGenerationProvider`: executes GGUF models via llama.cpp JNI with lazy loading +- `LlamaCppJniConfig`: immutable config object defining model path, context, temperature, stop strings +- `AiCompletionParser`: strips internal reasoning blocks from raw LLM output to extract final answer + +#### Data flow +Input file name → `AiFieldGenerationSelector` matches extension → selects `AiFieldGenerationConfig` → retrieves prompt and model key → `AiModelDefinitionSupport` resolves key to full `AiGenerationConfig` → applies parameters to AI provider → provider generates text (real or mock) → raw output passed to `AiCompletionParser` → final clean response stored + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`, `AiGenerationKind`, `Collection`, `List`, `Map`, `Objects`, `AiGenerationRequest`, `AiPromptSupport` +- External: Maven plugin reflection, llama.cpp inference engine (via GGUF models), Java 8+ features + +#### Cross-cutting +- Immutable configuration and state objects (e.g., `LlamaCppJniConfig`, `AiGenerationConfig`) for thread safety and concurrent access +- Null handling via `@Nullable` annotations and fallback logic for missing values +- Stateless, thread-safe providers with no shared mutable state +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`, `@ConvertToRecord`) used across all classes for immutability and debugging +- Explicit error handling: `NullPointerException` on null keys, `IllegalArgumentException` on invalid inputs or missing definitions +- Deterministic output patterns in mock provider and parser for consistent test behavior +- Static defaults in `AiGenerationConfig` provide baseline inference parameters diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/package.ai.md new file mode 100644 index 0000000..60a9423 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/net/package.ai.md @@ -0,0 +1,50 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:07:20Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> This package enables AI-driven source metadata generation in Maven plugin workflows by routing file-specific prompts to local LLMs or mock providers for dynamic field creation based on file type. + +#### Purpose +- Configures AI model behavior and prompt routing for per-file or per-package field generation in Maven-based source processing +- Provides a pluggable, testable pipeline for AI text generation using local LLMs or mock providers + +#### Responsibilities +- AI model configuration and parameter management (temperature, context size, retries) +- Prompt/template selection based on file extension or type +- Scope definition: file-level vs. package-level field generation +- Real-time AI inference via llama.cpp or deterministic mock execution +- Input parsing and output cleaning to extract final responses from raw LLM outputs + +#### Key units +- `AiFieldGenerationConfig`: maps prompt templates and model keys to file extensions for selective field generation +- `AiFieldGenerationSelector`: selects config by file extension with fallback logic +- `AiGenerationConfig`: holds mutable inference parameters (temperature, context size, stop strings) +- `AiModelDefinition`: stores reusable AI model settings by identifier +- `AiModelDefinitionSupport`: resolves model keys to full configs with validation and error handling +- `AiGenerationKind`: defines scope of AI output as file-level or package-level +- `AiGenerationProvider`: abstract interface for pluggable AI generation backends +- `LlamaCppJniAiGenerationProvider`: executes GGUF models via llama.cpp JNI with lazy loading +- `LlamaCppJniConfig`: immutable config object defining model path, context, temperature, stop strings +- `AiCompletionParser`: strips internal reasoning blocks from raw LLM output to extract final answer + +#### Data flow +Input file name → `AiFieldGenerationSelector` matches extension → selects `AiFieldGenerationConfig` → retrieves prompt and model key → `AiModelDefinitionSupport` resolves key to full `AiGenerationConfig` → applies parameters to AI provider → provider generates text (real or mock) → raw output passed to `AiCompletionParser` → final clean response stored + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`, `AiGenerationKind`, `Collection`, `List`, `Map`, `Objects`, `AiGenerationRequest`, `AiPromptSupport` +- External: Maven plugin reflection, llama.cpp inference engine (via GGUF models), Java 8+ features + +#### Cross-cutting +- Immutable configuration and state objects (e.g., `LlamaCppJniConfig`, `AiGenerationConfig`) for thread safety and concurrent access +- Null handling via `@Nullable` annotations and fallback logic for missing values +- Stateless, thread-safe providers with no shared mutable state +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`, `@ConvertToRecord`) used across all classes for immutability and debugging +- Explicit error handling: `NullPointerException` on null keys, `IllegalArgumentException` on invalid inputs or missing definitions +- Deterministic output patterns in mock provider and parser for consistent test behavior +- Static defaults in `AiGenerationConfig` provide baseline inference parameters diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/package.ai.md new file mode 100644 index 0000000..ffc04a8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/java/package.ai.md @@ -0,0 +1,50 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:08:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> This package enables AI-driven metadata generation for source files in Maven plugin workflows by dynamically creating field definitions based on file type using local LLMs or mock providers. + +#### Purpose +- Configures AI model behavior and prompt routing for per-file or per-package field generation in Maven-based source processing +- Provides a pluggable, testable pipeline for AI text generation using local LLMs or mock providers + +#### Responsibilities +- AI model configuration and parameter management (temperature, context size, retries) +- Prompt/template selection based on file extension or type +- Scope definition: file-level vs. package-level field generation +- Real-time AI inference via llama.cpp or deterministic mock execution +- Input parsing and output cleaning to extract final responses from raw LLM outputs + +#### Key units +- `AiFieldGenerationConfig`: maps prompt templates and model keys to file extensions for selective field generation +- `AiFieldGenerationSelector`: selects config by file extension with fallback logic +- `AiGenerationConfig`: holds mutable inference parameters (temperature, context size, stop strings) +- `AiModelDefinition`: stores reusable AI model settings by identifier +- `AiModelDefinitionSupport`: resolves model keys to full configs with validation and error handling +- `AiGenerationKind`: defines scope of AI output as file-level or package-level +- `AiGenerationProvider`: abstract interface for pluggable AI generation backends +- `LlamaCppJniAiGenerationProvider`: executes GGUF models via llama.cpp JNI with lazy loading +- `LlamaCppJniConfig`: immutable config object defining model path, context, temperature, stop strings +- `AiCompletionParser`: strips internal reasoning blocks from raw LLM output to extract final answer + +#### Data flow +Input file name → `AiFieldGenerationSelector` matches extension → selects `AiFieldGenerationConfig` → retrieves prompt and model key → `AiModelDefinitionSupport` resolves key to full `AiGenerationConfig` → applies parameters to AI provider → provider generates text (real or mock) → raw output passed to `AiCompletionParser` → final clean response stored + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`, `AiGenerationKind`, `Collection`, `List`, `Map`, `Objects`, `AiGenerationRequest`, `AiPromptSupport` +- External: Maven plugin reflection, llama.cpp inference engine (via GGUF models), Java 8+ features + +#### Cross-cutting +- Immutable configuration and state objects (e.g., `LlamaCppJniConfig`, `AiGenerationConfig`) for thread safety and concurrent access +- Null handling via `@Nullable` annotations and fallback logic for missing values +- Stateless, thread-safe providers with no shared mutable state +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`, `@ConvertToRecord`) used across all classes for immutability and debugging +- Explicit error handling: `NullPointerException` on null keys, `IllegalArgumentException` on invalid inputs or missing definitions +- Deterministic output patterns in mock provider and parser for consistent test behavior +- Static defaults in `AiGenerationConfig` provide baseline inference parameters diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/package.ai.md new file mode 100644 index 0000000..43824f8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/main/package.ai.md @@ -0,0 +1,50 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:10:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> This package enables AI-driven metadata generation for source files in Maven plugin workflows by dynamically creating field definitions based on file type using local LLMs or mock providers. + +#### Purpose +- Configures AI model behavior and prompt routing for per-file or per-package field generation in Maven-based source processing +- Provides a pluggable, testable pipeline for AI text generation using local LLMs or mock providers + +#### Responsibilities +- AI model configuration and parameter management (temperature, context size, retries) +- Prompt/template selection based on file extension or type +- Scope definition: file-level vs. package-level field generation +- Real-time AI inference via llama.cpp or deterministic mock execution +- Input parsing and output cleaning to extract final responses from raw LLM outputs + +#### Key units +- `AiFieldGenerationConfig`: maps prompt templates and model keys to file extensions for selective field generation +- `AiFieldGenerationSelector`: selects config by file extension with fallback logic +- `AiGenerationConfig`: holds mutable inference parameters (temperature, context size, stop strings) +- `AiModelDefinition`: stores reusable AI model settings by identifier +- `AiModelDefinitionSupport`: resolves model keys to full configs with validation and error handling +- `AiGenerationKind`: defines scope of AI output as file-level or package-level +- `AiGenerationProvider`: abstract interface for pluggable AI generation backends +- `LlamaCppJniAiGenerationProvider`: executes GGUF models via llama.cpp JNI with lazy loading +- `LlamaCppJniConfig`: immutable config object defining model path, context, temperature, stop strings +- `AiCompletionParser`: strips internal reasoning blocks from raw LLM output to extract final answer + +#### Data flow +Input file name → `AiFieldGenerationSelector` matches extension → selects `AiFieldGenerationConfig` → retrieves prompt and model key → `AiModelDefinitionSupport` resolves key to full `AiGenerationConfig` → applies parameters to AI provider → provider generates text (real or mock) → raw output passed to `AiCompletionParser` → final clean response stored + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`, `AiGenerationKind`, `Collection`, `List`, `Map`, `Objects`, `AiGenerationRequest`, `AiPromptSupport` +- External: Maven plugin reflection, llama.cpp inference engine (via GGUF models), Java 8+ features + +#### Cross-cutting +- Immutable configuration and state objects (e.g., `LlamaCppJniConfig`, `AiGenerationConfig`) for thread safety and concurrent access +- Null handling via `@Nullable` annotations and fallback logic for missing values +- Stateless, thread-safe providers with no shared mutable state +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`, `@ConvertToRecord`) used across all classes for immutability and debugging +- Explicit error handling: `NullPointerException` on null keys, `IllegalArgumentException` on invalid inputs or missing definitions +- Deterministic output patterns in mock provider and parser for consistent test behavior +- Static defaults in `AiGenerationConfig` provide baseline inference parameters diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/package.ai.md new file mode 100644 index 0000000..4a1a576 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/package.ai.md @@ -0,0 +1,50 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:11:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> This package enables AI-driven metadata generation for source files in Maven plugin workflows by dynamically creating field definitions based on file type using local LLMs or mock providers. + +#### Purpose +- Configures AI model behavior and prompt routing for per-file or per-package field generation in Maven-based source processing +- Provides a pluggable, testable pipeline for AI text generation using local LLMs or mock providers + +#### Responsibilities +- AI model configuration and parameter management (temperature, context size, retries) +- Prompt/template selection based on file extension or type +- Scope definition: file-level vs. package-level field generation +- Real-time AI inference via llama.cpp or deterministic mock execution +- Input parsing and output cleaning to extract final responses from raw LLM outputs + +#### Key units +- `AiFieldGenerationConfig`: maps prompt templates and model keys to file extensions for selective field generation +- `AiFieldGenerationSelector`: selects config by file extension with fallback logic +- `AiGenerationConfig`: holds mutable inference parameters (temperature, context size, stop strings) +- `AiModelDefinition`: stores reusable AI model settings by identifier +- `AiModelDefinitionSupport`: resolves model keys to full configs with validation and error handling +- `AiGenerationKind`: defines scope of AI output as file-level or package-level +- `AiGenerationProvider`: abstract interface for pluggable AI generation backends +- `LlamaCppJniAiGenerationProvider`: executes GGUF models via llama.cpp JNI with lazy loading +- `LlamaCppJniConfig`: immutable config object defining model path, context, temperature, stop strings +- `AiCompletionParser`: strips internal reasoning blocks from raw LLM output to extract final answer + +#### Data flow +Input file name → `AiFieldGenerationSelector` matches extension → selects `AiFieldGenerationConfig` → retrieves prompt and model key → `AiModelDefinitionSupport` resolves key to full `AiGenerationConfig` → applies parameters to AI provider → provider generates text (real or mock) → raw output passed to `AiCompletionParser` → final clean response stored + +#### Dependencies +- Internal: `AiFieldGenerationConfig`, `AiGenerationConfig`, `AiModelDefinition`, `AiGenerationKind`, `Collection`, `List`, `Map`, `Objects`, `AiGenerationRequest`, `AiPromptSupport` +- External: Maven plugin reflection, llama.cpp inference engine (via GGUF models), Java 8+ features + +#### Cross-cutting +- Immutable configuration and state objects (e.g., `LlamaCppJniConfig`, `AiGenerationConfig`) for thread safety and concurrent access +- Null handling via `@Nullable` annotations and fallback logic for missing values +- Stateless, thread-safe providers with no shared mutable state +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`, `@ConvertToRecord`) used across all classes for immutability and debugging +- Explicit error handling: `NullPointerException` on null keys, `IllegalArgumentException` on invalid inputs or missing definitions +- Deterministic output patterns in mock provider and parser for consistent test behavior +- Static defaults in `AiGenerationConfig` provide baseline inference parameters diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/project.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/project.ai.md new file mode 100644 index 0000000..239b24c --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v1/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: 7529C57E +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:12:45Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The project implements an AI-driven metadata generation pipeline for Maven plugin workflows, where source files are analyzed by type to trigger dynamic field creation. Core functionality is centered around AI text inference via local LLMs such as llama.cpp, with prompt configurations and execution scopes tailored per file type. A pluggable provider architecture enables flexible integration of AI generation pipelines, including mock providers for deterministic testing. The system organizes these capabilities into layered components: from high-level routing and configuration to low-level model execution and prompt mapping. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — This package enables AI-driven field generation in Maven plugin workflows by defining model configurations, prompt mappings, and execution scopes tailored to source file types. +- main/java/net/ladenthin/maven/llamacpp/aiindex — This package enables AI-driven field generation and text inference in Maven plugin workflows by configuring and executing local LLMs (like llama.cpp) to generate source metadata based on file type and prompt templates. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — This package enables pluggable, configurable AI text generation from document prompts using local LLMs like llama.cpp, with support for mocking and deterministic testing of AI response pipelines. +- main/java/net/ladenthin/maven/llamacpp — This package enables AI-driven source metadata generation in Maven plugin workflows by routing file-specific prompts to local LLMs or mock providers for dynamic field creation based on file type. +- main/java/net/ladenthin/maven — This package enables AI-driven source metadata generation in Maven plugin workflows by routing file-specific prompts to local LLMs or mock providers for dynamic field creation based on file type. +- main/java/net/ladenthin — This package enables AI-driven source metadata generation in Maven plugin workflows by routing file-specific prompts to local LLMs or mock providers for dynamic field creation based on file type. +- main/java/net — This package enables AI-driven source metadata generation in Maven plugin workflows by routing file-specific prompts to local LLMs or mock providers for dynamic field creation based on file type. +- main/java — This package enables AI-driven metadata generation for source files in Maven plugin workflows by dynamically creating field definitions based on file type using local LLMs or mock providers. +- main — This package enables AI-driven metadata generation for source files in Maven plugin workflows by dynamically creating field definitions based on file type using local LLMs or mock providers. +- . — This package enables AI-driven metadata generation for source files in Maven plugin workflows by dynamically creating field definitions based on file type using local LLMs or mock providers. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..7e60f10 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,50 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:13:14Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI prompt and model keys for field generation by file extension in Maven plugin + +#### Purpose +- Defines mapping between prompt templates and AI models for field generation +- Enables selective application based on source file extensions + +#### Type +class @ToString public mutable JavaBean with setters; key generics: none; notable annotations: @ToString, @Nullable + +#### Input +- promptKey (String): key to prompt template +- aiDefinitionKey (String): key to AI model definition +- fileExtensions (List): optional list of file extensions to match + +#### Output +- promptKey (String) – retrieved from config +- aiDefinitionKey (String) – retrieved from config +- fileExtensions (List) – returned as unmodifiable view or null + +#### Core logic +- Stores prompt and model keys for AI field generation +- Uses file extensions to filter which files trigger generation +- Defensively copies fileExtensions list on set to prevent mutation +- Returns immutable view of fileExtensions when queried + +#### Public API +- getPromptKey() -> String: returns prompt template key +- setPromptKey(String) -> void: sets prompt template key +- getAiDefinitionKey() -> String: returns AI model definition key +- setAiDefinitionKey(String) -> void: sets AI model definition key +- getFileExtensions() -> List (nullable): returns file extensions list or null +- setFileExtensions(Collection) -> void: sets file extensions; null/empty makes it fallback + +#### Dependencies +AiModelDefinition, AiPromptDefinition, AiFieldGenerationSelector + +#### Exceptions / Errors +None explicitly thrown; null handling via @Nullable and defensive copying + +#### Concurrency +Immutable output view; no thread-safety guarantees; mutable state only in instance fields diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..51668f8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,44 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:14:27Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects AI field generation config by file extension to enable language-specific prompts + +#### Purpose +- Chooses AI configuration based on file extension match +- Provides fallback for files without matching extensions + +#### Type +class @ToString final public in net.ladenthin.maven.llamacpp.aiindex.config + +#### Input +- configs: Iterable (in declaration order, null entries skipped) +- fileName: String (e.g. "Foo.java") + +#### Output +- AiFieldGenerationConfig (first match by extension, fallback if none, null if no config matches) + +#### Core logic +- Iterates over configs in order +- Skips null entries +- For each config, checks if its extensions list is empty: if so, records it as fallback +- Otherwise, checks if file name ends with any extension in the list; returns first match +- Returns fallback if no extension match found and fallback was set +- Returns null if no config matches and no fallback exists + +#### Public API +selectForFileName(Iterable, String) -> AiFieldGenerationConfig: selects config by file extension or fallback + +#### Dependencies +AiFieldGenerationConfig + +#### Exceptions / Errors +None thrown; handles null inputs gracefully via null checks + +#### Concurrency +Immutable state; thread-safe due to final class and no shared mutable state diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..a41016b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,70 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:15:05Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines configuration parameters for AI generation steps in a Maven plugin using llama.cpp, including model settings, sampling behavior, and input/output limits. + +#### Purpose +- Configures AI generation parameters such as temperature, max tokens, context size, and retry policies. +- Manages prompt trimming, stop sequences, and model-specific thinking modes. + +#### Type +class AiGenerationConfig + modifiers; extends/implements: none; generics: none; annotations: @ToString, @Nullable, @SuppressWarnings("NullAway.Init", "initialization.fields.uninitialized") + +#### Input +- Model path (String), context size (int), output tokens (int), temperature (float), threads (int), chars per token (int), max input chars (int), retry settings (int/float), stop strings (List) + +#### Output +- Configured generation parameters via getters; mutable state updated through setters; unmodifiable stop string list returned + +#### Core logic +- Holds all AI inference configuration fields with defaults. +- Automatically calculates maxInputChars based on context size, output tokens, chars per token, and safety margin when charsPerToken > 0. +- Uses Lombok's @ToString for readable instance representation. +- Provides immutability for stopStrings via unmodifiableList wrapper. + +#### Public API +getModelPath() -> String: returns model path +setModelPath(String) -> void: sets model path +getContextSize() -> int: returns context size +setContextSize(int) -> void: sets context size +getMaxOutputTokens() -> int: returns max output tokens +setMaxOutputTokens(int) -> void: sets max output tokens +getTemperature() -> float: returns sampling temperature +setTemperature(float) -> void: sets sampling temperature +getThreads() -> int: returns thread count +setThreads(int) -> void: sets thread count +getCharsPerToken() -> int: returns chars per token +setCharsPerToken(int) -> void: sets chars per token +getMaxInputChars() -> int: returns max input characters +setMaxInputChars(int) -> void: sets max input characters +isWarnOnTrim() -> boolean: checks trim warning setting +setWarnOnTrim(boolean) -> void: enables/disables trim warnings +getMaxRetries() -> int: returns retry count +setMaxRetries(int) -> void: sets retry count +getRetryTemperatureIncrement() -> float: returns retry temperature increment +setRetryTemperatureIncrement(float) -> void: sets retry temperature increment +getTopP() -> float: returns top-p value +setTopP(float) -> void: sets top-p value +getTopK() -> int: returns top-k limit +setTopK(int) -> void: sets top-k limit +getRepeatPenalty() -> float: returns repetition penalty +setRepeatPenalty(float) -> void: sets repetition penalty +isChatTemplateEnableThinking() -> boolean: checks thinking mode +setChatTemplateEnableThinking(boolean) -> void: enables/disables thinking mode +getStopStrings() -> List: returns stop strings (null-safe) +setStopStrings(List) -> void: sets or clears stop strings + +#### Dependencies +net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- No exceptions thrown; null handling via @Nullable and defensive checks in setters. + +#### Concurrency +- Immutable stopStrings list; all fields are mutable but no concurrent access or synchronization shown. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..c6cd842 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,40 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:17:54Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines whether AI generates per-file or per-package summaries + +#### Purpose +- Specifies scope of AI-generated code summaries +- Distinguishes between file-level and package-level generation + +#### Type +enum public AiGenerationKind + +#### Input +none + +#### Output +none + +#### Core logic +- Provides two distinct values for generation scope: FILE_SUMMARY and PACKAGE_SUMMARY +- No computation or state transformation; purely a domain enum + +#### Public API +FILE_SUMMARY() -> void: Represents per-file AI summary generation +PACKAGE_SUMMARY() -> void: Represents per-package AI summary generation + +#### Dependencies +none + +#### Exceptions / Errors +none + +#### Concurrency +none diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..af95096 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,55 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:18:09Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines AI model configurations for reuse across field-generation tasks in a Maven plugin + +#### Purpose +- Stores AI model parameters with a unique key for lookup and reuse +- Enables consistent, configurable model behavior via defaults inherited from AiGenerationConfig + +#### Type +class public @ToString + +#### Input +- None (initialized via constructor or setters) + +#### Output +- Key, model path, and all model-specific parameters (context size, temperature, threads, etc.) +- Unmodifiable stop strings list on access + +#### Core logic +- Provides default values from AiGenerationConfig for all numeric and boolean fields +- Ensures immutability of stopStrings via unmodifiableList wrapper +- Supports dynamic configuration through public setters with defaults applied + +#### Public API +setKey(String) → void: sets unique lookup key +setModelPath(String) → void: sets GGUF model file path +setContextSize(int) → void: sets context window size in tokens +setMaxOutputTokens(int) → void: sets max output tokens per call +setTemperature(float) → void: sets base sampling temperature +setThreads(int) → void: sets CPU threads for inference +setCharsPerToken(int) → void: configures chars per token for input trimming +setWarnOnTrim(boolean) → void: enables warnings on input trim +setMaxRetries(int) → void: sets max retry attempts on empty responses +setRetryTemperatureIncrement(float) → void: increments temperature on retries +setTopP(float) → void: sets nucleus sampling threshold +setTopK(int) → void: sets top-k token sampling limit +setRepeatPenalty(float) → void: applies repetition penalty +setChatTemplateEnableThinking(boolean) → void: enables/disable thinking mode in chat templates +setStopStrings(Collection) → void: sets generation stop strings + +#### Dependencies +AiGenerationConfig + +#### Exceptions / Errors +- None explicitly thrown; null handling via @Nullable and defensive checks on stopStrings + +#### Concurrency +- Immutable fields except for mutable stopStrings (thread-safe if accessed via immutable views) diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..6aeb081 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,43 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:19:56Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key to generate configuration objects in the AI modeling domain + +#### Purpose +- Acts as a lookup table for converting AI model definitions into runtime generation configurations +- Enforces validation of non-null keys during initialization to prevent silent configuration failures + +#### Type +class final public @ToString + implements none; extends none; generics: Map; notable annotations: @ToString + +#### Input +- List definitions (may be null or empty) + +#### Output +- AiGenerationConfig object for a given key; throws IllegalArgumentException on missing key + +#### Core logic +- Initializes map with presized capacity to avoid rehashing during bulk insertion +- Validates each definition's key at insertion, throwing NullPointerException if null +- Converts each AiModelDefinition into an AiGenerationConfig via field copying +- Returns config on lookup; throws IllegalArgumentException if key not found + +#### Public API +getConfig(String key) -> AiGenerationConfig: returns generation config by key; throws if missing +toConfig(AiModelDefinition) -> AiGenerationConfig: converts definition to config (private) + +#### Dependencies +AiModelDefinition, AiGenerationConfig, Java8CompatibilityHelper + +#### Exceptions / Errors +- NullPointerException if any entry has null key (with index and entry details) +- IllegalArgumentException if lookup key not found in map + +#### Concurrency +Immutable state; no shared mutable state; thread-safe via final fields and immutable config objects diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..64b3275 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,50 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:25:13Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> This package configures and orchestrates AI-driven field generation and model settings for Maven plugins using llama.cpp, enabling language-specific prompts and per-file or per-package summarization. + +#### Purpose +- Defines AI configuration for field generation based on file extensions +- Manages model parameters and generation behavior (temperature, context size, retries) +- Supports both per-file and per-package AI summary scopes + +#### Responsibilities +- Field generation configuration via file extension matching +- Model-specific AI parameter definitions and lookup +- Generation parameter tuning and validation +- Scope selection for AI summaries (file-level vs package-level) + +#### Key units +- **AiFieldGenerationConfig**: maps prompt and model keys to file extensions for selective field generation +- **AiFieldGenerationSelector**: selects the appropriate config by file extension, with fallback support +- **AiGenerationConfig**: holds core AI inference settings like temperature, max tokens, stop strings +- **AiModelDefinition**: stores reusable model configurations with defaults from AiGenerationConfig +- **AiModelDefinitionSupport**: resolves model definitions by key to generate runtime AI configs + +#### Data flow +Input file name → matched against file extensions in AiFieldGenerationConfig → selected via AiFieldGenerationSelector → resolved into AiGenerationConfig via AiModelDefinitionSupport → used for AI prompt generation and inference + +#### Dependencies +- AiFieldGenerationSelector depends on AiFieldGenerationConfig +- AiGenerationConfig depends on AiModelDefinition and Llama model parameters +- AiModelDefinitionSupport uses AiModelDefinition and AiGenerationConfig for conversion +- Cross-package: net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Immutable stop strings via unmodifiableList wrappers +- Null safety enforced with @Nullable and defensive checks in setters +- Immutability of output views (fileExtensions, stopStrings) +- Final classes (AiFieldGenerationSelector, AiModelDefinitionSupport) ensure thread safety +- Uniform use of @ToString for readable instance representation across classes diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..7faa618 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,63 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:28:36Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> This package enables AI-driven source code field generation and summarization in Maven plugins using llama.cpp, configuring model parameters and orchestrating local LLM inference through pluggable providers. + +#### Purpose +- Defines AI configuration for field generation based on file extensions +- Manages model parameters and generation behavior (temperature, context size, retries) +- Supports both per-file and per-package AI summary scopes + +#### Responsibilities +- Field generation configuration via file extension matching +- Model-specific AI parameter definitions and lookup +- Generation parameter tuning and validation +- Scope selection for AI summaries (file-level vs package-level) +- AI text generation orchestration through pluggable backends +- Local LLM inference via llama.cpp JNI bindings +- Parsing of model outputs to extract final answers from reasoning chains +- Test simulation using deterministic mock providers + +#### Key units +- **AiFieldGenerationConfig**: maps prompt and model keys to file extensions for selective field generation +- **AiFieldGenerationSelector**: selects the appropriate config by file extension, with fallback support +- **AiGenerationConfig**: holds core AI inference settings like temperature, max tokens, stop strings +- **AiModelDefinition**: stores reusable model configurations with defaults from AiGenerationConfig +- **AiModelDefinitionSupport**: resolves model definitions by key to generate runtime AI configs +- **AiGenerationProvider**: abstracts AI text generation across backends +- **LlamaCppJniAiGenerationProvider**: implements local GGUF model inference via llama.cpp JNI +- **AiCompletionParser**: extracts final answer from raw completion text containing reasoning blocks +- **LlamaCppJniConfig**: immutable configuration for model and inference settings +- **AiGenerationProviderFactory**: selects and instantiates provider based on name + +#### Data flow +Input file name → matched against file extensions in AiFieldGenerationConfig → selected via AiFieldGenerationSelector → resolved into AiGenerationConfig via AiModelDefinitionSupport → used to build prompt (via AiPromptSupport) → passed to AiGenerationProviderFactory → provider selected and executed → LlamaCppJniAiGenerationProvider runs inference → raw output processed by AiCompletionParser → final answer extracted and returned + +#### Dependencies +- AiFieldGenerationSelector depends on AiFieldGenerationConfig +- AiGenerationConfig depends on AiModelDefinition and Llama model parameters +- AiModelDefinitionSupport uses AiModelDefinition and AiGenerationConfig for conversion +- LlamaCppJniAiGenerationProvider depends on LlamaCppJniConfig and AiPromptSupport +- AiCompletionParser depends on raw output and prompt context +- AiGenerationProviderFactory selects from AiGenerationProvider and MockAiGenerationProvider +- Cross-package: net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Immutable stop strings via unmodifiableList wrappers +- Null safety enforced with @Nullable and defensive checks in setters +- Immutability of output views (fileExtensions, stopStrings) +- Final classes (AiFieldGenerationSelector, AiModelDefinitionSupport) ensure thread safety +- Uniform use of @ToString for readable instance representation across classes +- Immutable configuration via record-like design (LlamaCppJniConfig) +- Shared error handling: IOException for provider failures or parsing issues +- Deterministic mock behavior for testing +- Temperature override during retries to avoid empty responses +- Thread safety in immutable units; model loading is lazy but not synchronized, risking concurrent access issues diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..9ab9f16 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,42 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:20:53Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Extracts the final AI model answer from raw completion text by stripping internal reasoning blocks + +#### Purpose +- Strips internal model thinking blocks to isolate the final answer +- Validates token budget exhaustion in chain-of-thought reasoning + +#### Type +class @ToString public non-final + +#### Input +- response: raw model completion text (may be null) + +#### Output +- cleaned, trimmed final answer text (never null) + +#### Core logic +- If input is null, return empty string +- Find position of closing thinking block marker +- If found, return text after the marker (trimmed) +- If start marker present but end marker missing, throw IOException with actionable message +- Otherwise return trimmed input + +#### Public API +parseCompletion(String response) -> String: Extracts final answer from raw model output + +#### Dependencies +THINKING_BLOCK_START_MARKER, THINKING_BLOCK_END_MARKER + +#### Exceptions / Errors +- IOException if thinking block start found but end not found (with diagnostic message) + +#### Concurrency +none diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..0af5856 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,41 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:21:30Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides text generation for AI requests via pluggable backend implementations + +#### Purpose +- Enables local or mock-based AI text generation from source code prompts +- Supports temperature override during retries to avoid early EOS failures + +#### Type +interface AiGenerationProvider extends AutoCloseable + +#### Input +- AiGenerationRequest (prompt key, source file, source text, current header) + +#### Output +- String (generated text; never null, may be blank) + +#### Core logic +- Generates text using default sampling parameters +- Overrides temperature per-call to break retry loops that produce empty responses +- Delegates temperature override to default implementation if not implemented + +#### Public API +generate(AiGenerationRequest) -> String: Generate text with default settings +generate(AiGenerationRequest, float) -> String: Generate text with overridden temperature + +#### Dependencies +AiGenerationRequest + +#### Exceptions / Errors +- IOException on provider failure; no null inputs allowed + +#### Concurrency +none diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..01a0eb0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,43 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:21:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an AI generation provider based on a name + +#### Purpose +- Creates and returns an AI generation provider instance by provider name +- Falls back to mock provider if name is missing or invalid + +#### Type +class public net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProviderFactory + +#### Input +- providerName (String): key for provider selection; defaults to "mock" if null/blank +- llamaConfig (LlamaCppJniConfig): config for llama.cpp JNI provider +- promptSupport (AiPromptSupport): prompt lookup support for providers needing it + +#### Output +- AiGenerationProvider: a newly instantiated provider instance + +#### Core logic +- Returns mock provider if providerName is null or blank +- Uses switch to select provider based on providerName +- Returns LlamaCppJniAiGenerationProvider for "llamacpp-jni" +- Throws IllegalArgumentException for unrecognized provider names + +#### Public API +create(String, LlamaCppJniConfig, AiPromptSupport) -> AiGenerationProvider: instantiates provider by name + +#### Dependencies +LlamaCppJniConfig, AiPromptSupport, MockAiGenerationProvider, LlamaCppJniAiGenerationProvider + +#### Exceptions / Errors +- IllegalArgumentException when providerName is unrecognized + +#### Concurrency +none diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..89c11fd --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,48 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:22:33Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Enables local AI text generation using GGUF models via llama.cpp JNI bindings in a Maven-based indexing pipeline. + +#### Purpose +- Provides lazy-loaded, local AI text generation using llama.cpp JNI bindings. +- Integrates prompt rendering and completion parsing for structured AI response handling. + +#### Type +class final LlamaCppJniAiGenerationProvider implements AiGenerationProvider, AutoCloseable + +#### Input +- LlamaCppJniConfig (model path, context size, threads, etc.) +- AiPromptSupport (for building prompts from request) + +#### Output +- String (generated AI response text) +- Native model handle closed on shutdown + +#### Core logic +- Lazily loads GGUF model on first generate() call to minimize startup cost. +- Constructs inference parameters from config and request with temperature, stop strings, top-p/k, and context settings. +- Builds prompt chain using user message and system message (optional). +- Invokes native chat completion via model().chatCompleteText(). +- Parses output using completion parser. + +#### Public API +generate(AiGenerationRequest) -> String: generates response from request +generate(AiGenerationRequest, float) -> String: generates with override temperature +close() -> void: releases native model resources + +#### Dependencies +LlamaModel, InferenceParameters, ModelParameters, Pair, AiPromptSupport, AiCompletionParser, LlamaCppJniConfig + +#### Exceptions / Errors +- IOException on model loading or native call failure +- Null handling via requireNonNull on config and promptSupport + +#### Concurrency +- Immutable inference parameters; thread-safe only if model access is serialized (not explicitly guarded) +- Model loaded lazily; concurrent calls may result in duplicated model creation unless synchronized — not observed here diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..a01f47e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,75 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:23:31Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines immutable configuration for llama.cpp JNI-based AI model inference + +#### Purpose +- Configures runtime parameters for llama.cpp JNI-based LLM inference +- Encapsulates model, library, and generation settings with value semantics + +#### Type +class final public @ConvertToRecord @ToString @EqualsAndHashCode + +#### Input +- libraryPath (String): native library path or null +- modelPath (String): GGUF model file path +- contextSize (int): context window size in tokens +- maxOutputTokens (int): max output tokens per call +- temperature (float): sampling temperature +- threads (int): CPU thread count +- topP (float): nucleus-sampling threshold +- topK (int): top-k sampling limit +- repeatPenalty (float): repetition penalty +- chatTemplateEnableThinking (boolean): enables thinking mode in chat templates +- stopStrings (List): list of stop strings; null treated as empty + +#### Output +- libraryPath() → String +- modelPath() → String +- contextSize() → int +- maxOutputTokens() → int +- temperature() → float +- threads() → int +- topP() → float +- topK() → int +- repeatPenalty() → float +- chatTemplateEnableThinking() → boolean +- stopStrings() → List (unmodifiable) + +#### Core logic +- Validates modelPath at construction +- Null stopStrings is converted to empty list +- All fields are final and immutable +- Lombok generates equals, hashCode, toString with bit-level float precision + +#### Public API +- libraryPath() → String: native library path +- modelPath() → String: GGUF model file path +- contextSize() → int: context window size +- maxOutputTokens() → int: max output tokens +- temperature() → float: sampling temperature +- threads() → int: CPU thread count +- topP() → float: nucleus-sampling threshold +- topK() → int: top-k limit +- repeatPenalty() → float: repetition penalty +- chatTemplateEnableThinking() → boolean: enables thinking mode +- stopStrings() → List: unmodifiable stop strings + +#### Dependencies +- java.util.Collections +- java.util.Objects +- lombok.EqualsAndHashCode +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord + +#### Exceptions / Errors +- Throws IllegalArgumentException if modelPath is null + +#### Concurrency +- Immutable; thread-safe by design due to final fields and no mutable state diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..dbc9495 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,40 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:24:52Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides deterministic mock summaries for AI generation testing. + +#### Purpose +- Implements a testable AI generation provider that returns fixed, predictable outputs. +- Used to simulate AI response behavior during unit and integration tests. + +#### Type +class MockAiGenerationProvider implements AiGenerationProvider + +#### Input +- AiGenerationRequest request (sourceFile()) + +#### Output +- String (mock summary of the source file) + +#### Core logic +- Extracts source file name from request. +- Constructs a deterministic mock summary using the file name. +- Returns the generated summary string. + +#### Public API +generate(AiGenerationRequest request) -> String: Generates mock summary from input file name + +#### Dependencies +AiGenerationRequest + +#### Exceptions / Errors +- Throws IOException on generation failure (per contract) + +#### Concurrency +- Not applicable (stateless, single-threaded operation) diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..485ceeb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,49 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T06:27:08Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> Enables local AI text generation and response parsing in a Maven-based indexing pipeline using llama.cpp JNI bindings or mock providers + +#### Purpose +- Facilitates AI-driven source code summarization via pluggable generation backends +- Supports both real-time LLM inference (via llama.cpp) and deterministic testing (via mock provider) + +#### Responsibilities +- AI generation orchestration through provider factory and interface abstraction +- Local model execution via llama.cpp JNI bindings with configurable inference parameters +- Parsing of raw model outputs to extract final answers from reasoning chains +- Test simulation through a mock provider with predictable, deterministic responses + +#### Key units +- `AiGenerationProvider`: abstracts AI text generation across backends +- `LlamaCppJniAiGenerationProvider`: implements local GGUF model inference via llama.cpp JNI +- `AiCompletionParser`: extracts final answer from raw completion text containing reasoning blocks +- `LlamaCppJniConfig`: immutable configuration for model and inference settings +- `AiGenerationProviderFactory`: selects and instantiates provider based on name + +#### Data flow +AiGenerationRequest → AiGenerationProviderFactory (selects provider) → Provider.generate() → LlamaCppJniAiGenerationProvider (loads model, runs inference) → Native chat completion → AiCompletionParser (strips thinking blocks) → Final answer output + +#### Dependencies +- `LlamaCppJniConfig` for model and generation parameters +- `AiPromptSupport` to build prompts from source context +- `MockAiGenerationProvider` as fallback/test provider +- `AiCompletionParser` to validate and clean response outputs + +#### Cross-cutting +- Immutable configuration via record-like design (LlamaCppJniConfig) +- Shared error handling: IOException for provider failures or parsing issues +- Deterministic mock behavior for testing +- Temperature override during retries to avoid empty responses +- Thread safety in immutable units; model loading is lazy but not synchronized, risking concurrent access issues diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..3f87dab --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,61 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:30:13Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. + +#### Purpose +- Defines AI configuration for field generation based on file extensions +- Manages model parameters and generation behavior (temperature, context size, retries) + +#### Responsibilities +- Field generation configuration via file extension matching +- Model-specific AI parameter definitions and lookup +- Generation parameter tuning and validation +- Scope selection for AI summaries (file-level vs package-level) +- AI text generation orchestration through pluggable backends +- Local LLM inference via llama.cpp JNI bindings +- Parsing of model outputs to extract final answers from reasoning chains +- Test simulation using deterministic mock providers + +#### Key units +- **AiFieldGenerationConfig**: maps prompt and model keys to file extensions for selective field generation +- **AiFieldGenerationSelector**: selects the appropriate config by file extension, with fallback support +- **AiGenerationConfig**: holds core AI inference settings like temperature, max tokens, stop strings +- **AiModelDefinition**: stores reusable model configurations with defaults from AiGenerationConfig +- **AiModelDefinitionSupport**: resolves model definitions by key to generate runtime AI configs +- **AiGenerationProvider**: abstracts AI text generation across backends +- **LlamaCppJniAiGenerationProvider**: implements local GGUF model inference via llama.cpp JNI +- **AiCompletionParser**: extracts final answer from raw completion text containing reasoning blocks +- **LlamaCppJniConfig**: immutable configuration for model and inference settings +- **AiGenerationProviderFactory**: selects and instantiates provider based on name + +#### Data flow +Input file name → matched against file extensions in AiFieldGenerationConfig → selected via AiFieldGenerationSelector → resolved into AiGenerationConfig via AiModelDefinitionSupport → used to build prompt (via AiPromptSupport) → passed to AiGenerationProviderFactory → provider selected and executed → LlamaCppJniAiGenerationProvider runs inference → raw output processed by AiCompletionParser → final answer extracted and returned + +#### Dependencies +- AiFieldGenerationSelector depends on AiFieldGenerationConfig +- AiGenerationConfig depends on AiModelDefinition and Llama model parameters +- AiModelDefinitionSupport uses AiModelDefinition and AiGenerationConfig for conversion +- LlamaCppJniAiGenerationProvider depends on LlamaCppJniConfig and AiPromptSupport +- AiCompletionParser depends on raw output and prompt context +- AiGenerationProviderFactory selects from AiGenerationProvider and MockAiGenerationProvider +- Cross-package: net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Immutable stop strings via unmodifiableList wrappers +- Null safety enforced with @Nullable and defensive checks in setters +- Immutability of output views (fileExtensions, stopStrings) +- Final classes (AiFieldGenerationSelector, AiModelDefinitionSupport) ensure thread safety +- Uniform use of @ToString for readable instance representation across classes +- Immutable configuration via record-like design (LlamaCppJniConfig) +- Shared error handling: IOException for provider failures or parsing issues +- Deterministic mock behavior for testing +- Temperature override during retries to avoid empty responses +- Thread safety in immutable units; model loading is lazy but not synchronized, risking concurrent access issues diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..546acae --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,61 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:31:42Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. + +#### Purpose +- Defines AI configuration for field generation based on file extensions +- Manages model parameters and generation behavior (temperature, context size, retries) + +#### Responsibilities +- Field generation configuration via file extension matching +- Model-specific AI parameter definitions and lookup +- Generation parameter tuning and validation +- Scope selection for AI summaries (file-level vs package-level) +- AI text generation orchestration through pluggable backends +- Local LLM inference via llama.cpp JNI bindings +- Parsing of model outputs to extract final answers from reasoning chains +- Test simulation using deterministic mock providers + +#### Key units +- **AiFieldGenerationConfig**: maps prompt and model keys to file extensions for selective field generation +- **AiFieldGenerationSelector**: selects the appropriate config by file extension, with fallback support +- **AiGenerationConfig**: holds core AI inference settings like temperature, max tokens, stop strings +- **AiModelDefinition**: stores reusable model configurations with defaults from AiGenerationConfig +- **AiModelDefinitionSupport**: resolves model definitions by key to generate runtime AI configs +- **AiGenerationProvider**: abstracts AI text generation across backends +- **LlamaCppJniAiGenerationProvider**: implements local GGUF model inference via llama.cpp JNI +- **AiCompletionParser**: extracts final answer from raw completion text containing reasoning blocks +- **LlamaCppJniConfig**: immutable configuration for model and inference settings +- **AiGenerationProviderFactory**: selects and instantiates provider based on name + +#### Data flow +Input file name → matched against file extensions in AiFieldGenerationConfig → selected via AiFieldGenerationSelector → resolved into AiGenerationConfig via AiModelDefinitionSupport → used to build prompt (via AiPromptSupport) → passed to AiGenerationProviderFactory → provider selected and executed → LlamaCppJniAiGenerationProvider runs inference → raw output processed by AiCompletionParser → final answer extracted and returned + +#### Dependencies +- AiFieldGenerationSelector depends on AiFieldGenerationConfig +- AiGenerationConfig depends on AiModelDefinition and Llama model parameters +- AiModelDefinitionSupport uses AiModelDefinition and AiGenerationConfig for conversion +- LlamaCppJniAiGenerationProvider depends on LlamaCppJniConfig and AiPromptSupport +- AiCompletionParser depends on raw output and prompt context +- AiGenerationProviderFactory selects from AiGenerationProvider and MockAiGenerationProvider +- Cross-package: net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Immutable stop strings via unmodifiableList wrappers +- Null safety enforced with @Nullable and defensive checks in setters +- Immutability of output views (fileExtensions, stopStrings) +- Final classes (AiFieldGenerationSelector, AiModelDefinitionSupport) ensure thread safety +- Uniform use of @ToString for readable instance representation across classes +- Immutable configuration via record-like design (LlamaCppJniConfig) +- Shared error handling: IOException for provider failures or parsing issues +- Deterministic mock behavior for testing +- Temperature override during retries to avoid empty responses +- Thread safety in immutable units; model loading is lazy but not synchronized, risking concurrent access issues diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..763aff3 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,61 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:33:10Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. + +#### Purpose +- Defines AI configuration for field generation based on file extensions +- Manages model parameters and generation behavior (temperature, context size, retries) + +#### Responsibilities +- Field generation configuration via file extension matching +- Model-specific AI parameter definitions and lookup +- Generation parameter tuning and validation +- Scope selection for AI summaries (file-level vs package-level) +- AI text generation orchestration through pluggable backends +- Local LLM inference via llama.cpp JNI bindings +- Parsing of model outputs to extract final answers from reasoning chains +- Test simulation using deterministic mock providers + +#### Key units +- **AiFieldGenerationConfig**: maps prompt and model keys to file extensions for selective field generation +- **AiFieldGenerationSelector**: selects the appropriate config by file extension, with fallback support +- **AiGenerationConfig**: holds core AI inference settings like temperature, max tokens, stop strings +- **AiModelDefinition**: stores reusable model configurations with defaults from AiGenerationConfig +- **AiModelDefinitionSupport**: resolves model definitions by key to generate runtime AI configs +- **AiGenerationProvider**: abstracts AI text generation across backends +- **LlamaCppJniAiGenerationProvider**: implements local GGUF model inference via llama.cpp JNI +- **AiCompletionParser**: extracts final answer from raw completion text containing reasoning blocks +- **LlamaCppJniConfig**: immutable configuration for model and inference settings +- **AiGenerationProviderFactory**: selects and instantiates provider based on name + +#### Data flow +Input file name → matched against file extensions in AiFieldGenerationConfig → selected via AiFieldGenerationSelector → resolved into AiGenerationConfig via AiModelDefinitionSupport → used to build prompt (via AiPromptSupport) → passed to AiGenerationProviderFactory → provider selected and executed → LlamaCppJniAiGenerationProvider runs inference → raw output processed by AiCompletionParser → final answer extracted and returned + +#### Dependencies +- AiFieldGenerationSelector depends on AiFieldGenerationConfig +- AiGenerationConfig depends on AiModelDefinition and Llama model parameters +- AiModelDefinitionSupport uses AiModelDefinition and AiGenerationConfig for conversion +- LlamaCppJniAiGenerationProvider depends on LlamaCppJniConfig and AiPromptSupport +- AiCompletionParser depends on raw output and prompt context +- AiGenerationProviderFactory selects from AiGenerationProvider and MockAiGenerationProvider +- Cross-package: net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Immutable stop strings via unmodifiableList wrappers +- Null safety enforced with @Nullable and defensive checks in setters +- Immutability of output views (fileExtensions, stopStrings) +- Final classes (AiFieldGenerationSelector, AiModelDefinitionSupport) ensure thread safety +- Uniform use of @ToString for readable instance representation across classes +- Immutable configuration via record-like design (LlamaCppJniConfig) +- Shared error handling: IOException for provider failures or parsing issues +- Deterministic mock behavior for testing +- Temperature override during retries to avoid empty responses +- Thread safety in immutable units; model loading is lazy but not synchronized, risking concurrent access issues diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/package.ai.md new file mode 100644 index 0000000..44afc75 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/net/package.ai.md @@ -0,0 +1,61 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:34:37Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. + +#### Purpose +- Defines AI configuration for field generation based on file extensions +- Manages model parameters and generation behavior (temperature, context size, retries) + +#### Responsibilities +- Field generation configuration via file extension matching +- Model-specific AI parameter definitions and lookup +- Generation parameter tuning and validation +- Scope selection for AI summaries (file-level vs package-level) +- AI text generation orchestration through pluggable backends +- Local LLM inference via llama.cpp JNI bindings +- Parsing of model outputs to extract final answers from reasoning chains +- Test simulation using deterministic mock providers + +#### Key units +- **AiFieldGenerationConfig**: maps prompt and model keys to file extensions for selective field generation +- **AiFieldGenerationSelector**: selects the appropriate config by file extension, with fallback support +- **AiGenerationConfig**: holds core AI inference settings like temperature, max tokens, stop strings +- **AiModelDefinition**: stores reusable model configurations with defaults from AiGenerationConfig +- **AiModelDefinitionSupport**: resolves model definitions by key to generate runtime AI configs +- **AiGenerationProvider**: abstracts AI text generation across backends +- **LlamaCppJniAiGenerationProvider**: implements local GGUF model inference via llama.cpp JNI +- **AiCompletionParser**: extracts final answer from raw completion text containing reasoning blocks +- **LlamaCppJniConfig**: immutable configuration for model and inference settings +- **AiGenerationProviderFactory**: selects and instantiates provider based on name + +#### Data flow +Input file name → matched against file extensions in AiFieldGenerationConfig → selected via AiFieldGenerationSelector → resolved into AiGenerationConfig via AiModelDefinitionSupport → used to build prompt (via AiPromptSupport) → passed to AiGenerationProviderFactory → provider selected and executed → LlamaCppJniAiGenerationProvider runs inference → raw output processed by AiCompletionParser → final answer extracted and returned + +#### Dependencies +- AiFieldGenerationSelector depends on AiFieldGenerationConfig +- AiGenerationConfig depends on AiModelDefinition and Llama model parameters +- AiModelDefinitionSupport uses AiModelDefinition and AiGenerationConfig for conversion +- LlamaCppJniAiGenerationProvider depends on LlamaCppJniConfig and AiPromptSupport +- AiCompletionParser depends on raw output and prompt context +- AiGenerationProviderFactory selects from AiGenerationProvider and MockAiGenerationProvider +- Cross-package: net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Immutable stop strings via unmodifiableList wrappers +- Null safety enforced with @Nullable and defensive checks in setters +- Immutability of output views (fileExtensions, stopStrings) +- Final classes (AiFieldGenerationSelector, AiModelDefinitionSupport) ensure thread safety +- Uniform use of @ToString for readable instance representation across classes +- Immutable configuration via record-like design (LlamaCppJniConfig) +- Shared error handling: IOException for provider failures or parsing issues +- Deterministic mock behavior for testing +- Temperature override during retries to avoid empty responses +- Thread safety in immutable units; model loading is lazy but not synchronized, risking concurrent access issues diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/package.ai.md new file mode 100644 index 0000000..2b41825 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/java/package.ai.md @@ -0,0 +1,61 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:36:04Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. + +#### Purpose +- Defines AI configuration for field generation based on file extensions +- Manages model parameters and generation behavior (temperature, context size, retries) + +#### Responsibilities +- Field generation configuration via file extension matching +- Model-specific AI parameter definitions and lookup +- Generation parameter tuning and validation +- Scope selection for AI summaries (file-level vs package-level) +- AI text generation orchestration through pluggable backends +- Local LLM inference via llama.cpp JNI bindings +- Parsing of model outputs to extract final answers from reasoning chains +- Test simulation using deterministic mock providers + +#### Key units +- **AiFieldGenerationConfig**: maps prompt and model keys to file extensions for selective field generation +- **AiFieldGenerationSelector**: selects the appropriate config by file extension, with fallback support +- **AiGenerationConfig**: holds core AI inference settings like temperature, max tokens, stop strings +- **AiModelDefinition**: stores reusable model configurations with defaults from AiGenerationConfig +- **AiModelDefinitionSupport**: resolves model definitions by key to generate runtime AI configs +- **AiGenerationProvider**: abstracts AI text generation across backends +- **LlamaCppJniAiGenerationProvider**: implements local GGUF model inference via llama.cpp JNI +- **AiCompletionParser**: extracts final answer from raw completion text containing reasoning blocks +- **LlamaCppJniConfig**: immutable configuration for model and inference settings +- **AiGenerationProviderFactory**: selects and instantiates provider based on name + +#### Data flow +Input file name → matched against file extensions in AiFieldGenerationConfig → selected via AiFieldGenerationSelector → resolved into AiGenerationConfig via AiModelDefinitionSupport → used to build prompt (via AiPromptSupport) → passed to AiGenerationProviderFactory → provider selected and executed → LlamaCppJniAiGenerationProvider runs inference → raw output processed by AiCompletionParser → final answer extracted and returned + +#### Dependencies +- AiFieldGenerationSelector depends on AiFieldGenerationConfig +- AiGenerationConfig depends on AiModelDefinition and Llama model parameters +- AiModelDefinitionSupport uses AiModelDefinition and AiGenerationConfig for conversion +- LlamaCppJniAiGenerationProvider depends on LlamaCppJniConfig and AiPromptSupport +- AiCompletionParser depends on raw output and prompt context +- AiGenerationProviderFactory selects from AiGenerationProvider and MockAiGenerationProvider +- Cross-package: net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Immutable stop strings via unmodifiableList wrappers +- Null safety enforced with @Nullable and defensive checks in setters +- Immutability of output views (fileExtensions, stopStrings) +- Final classes (AiFieldGenerationSelector, AiModelDefinitionSupport) ensure thread safety +- Uniform use of @ToString for readable instance representation across classes +- Immutable configuration via record-like design (LlamaCppJniConfig) +- Shared error handling: IOException for provider failures or parsing issues +- Deterministic mock behavior for testing +- Temperature override during retries to avoid empty responses +- Thread safety in immutable units; model loading is lazy but not synchronized, risking concurrent access issues diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/package.ai.md new file mode 100644 index 0000000..7d5d161 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/main/package.ai.md @@ -0,0 +1,61 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:37:31Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. + +#### Purpose +- Defines AI configuration for field generation based on file extensions +- Manages model parameters and generation behavior (temperature, context size, retries) + +#### Responsibilities +- Field generation configuration via file extension matching +- Model-specific AI parameter definitions and lookup +- Generation parameter tuning and validation +- Scope selection for AI summaries (file-level vs package-level) +- AI text generation orchestration through pluggable backends +- Local LLM inference via llama.cpp JNI bindings +- Parsing of model outputs to extract final answers from reasoning chains +- Test simulation using deterministic mock providers + +#### Key units +- **AiFieldGenerationConfig**: maps prompt and model keys to file extensions for selective field generation +- **AiFieldGenerationSelector**: selects the appropriate config by file extension, with fallback support +- **AiGenerationConfig**: holds core AI inference settings like temperature, max tokens, stop strings +- **AiModelDefinition**: stores reusable model configurations with defaults from AiGenerationConfig +- **AiModelDefinitionSupport**: resolves model definitions by key to generate runtime AI configs +- **AiGenerationProvider**: abstracts AI text generation across backends +- **LlamaCppJniAiGenerationProvider**: implements local GGUF model inference via llama.cpp JNI +- **AiCompletionParser**: extracts final answer from raw completion text containing reasoning blocks +- **LlamaCppJniConfig**: immutable configuration for model and inference settings +- **AiGenerationProviderFactory**: selects and instantiates provider based on name + +#### Data flow +Input file name → matched against file extensions in AiFieldGenerationConfig → selected via AiFieldGenerationSelector → resolved into AiGenerationConfig via AiModelDefinitionSupport → used to build prompt (via AiPromptSupport) → passed to AiGenerationProviderFactory → provider selected and executed → LlamaCppJniAiGenerationProvider runs inference → raw output processed by AiCompletionParser → final answer extracted and returned + +#### Dependencies +- AiFieldGenerationSelector depends on AiFieldGenerationConfig +- AiGenerationConfig depends on AiModelDefinition and Llama model parameters +- AiModelDefinitionSupport uses AiModelDefinition and AiGenerationConfig for conversion +- LlamaCppJniAiGenerationProvider depends on LlamaCppJniConfig and AiPromptSupport +- AiCompletionParser depends on raw output and prompt context +- AiGenerationProviderFactory selects from AiGenerationProvider and MockAiGenerationProvider +- Cross-package: net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Immutable stop strings via unmodifiableList wrappers +- Null safety enforced with @Nullable and defensive checks in setters +- Immutability of output views (fileExtensions, stopStrings) +- Final classes (AiFieldGenerationSelector, AiModelDefinitionSupport) ensure thread safety +- Uniform use of @ToString for readable instance representation across classes +- Immutable configuration via record-like design (LlamaCppJniConfig) +- Shared error handling: IOException for provider failures or parsing issues +- Deterministic mock behavior for testing +- Temperature override during retries to avoid empty responses +- Thread safety in immutable units; model loading is lazy but not synchronized, risking concurrent access issues diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/package.ai.md new file mode 100644 index 0000000..3e17695 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/package.ai.md @@ -0,0 +1,61 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:38:58Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. + +#### Purpose +- Defines AI configuration for field generation based on file extensions +- Manages model parameters and generation behavior (temperature, context size, retries) + +#### Responsibilities +- Field generation configuration via file extension matching +- Model-specific AI parameter definitions and lookup +- Generation parameter tuning and validation +- Scope selection for AI summaries (file-level vs package-level) +- AI text generation orchestration through pluggable backends +- Local LLM inference via llama.cpp JNI bindings +- Parsing of model outputs to extract final answers from reasoning chains +- Test simulation using deterministic mock providers + +#### Key units +- **AiFieldGenerationConfig**: maps prompt and model keys to file extensions for selective field generation +- **AiFieldGenerationSelector**: selects the appropriate config by file extension, with fallback support +- **AiGenerationConfig**: holds core AI inference settings like temperature, max tokens, stop strings +- **AiModelDefinition**: stores reusable model configurations with defaults from AiGenerationConfig +- **AiModelDefinitionSupport**: resolves model definitions by key to generate runtime AI configs +- **AiGenerationProvider**: abstracts AI text generation across backends +- **LlamaCppJniAiGenerationProvider**: implements local GGUF model inference via llama.cpp JNI +- **AiCompletionParser**: extracts final answer from raw completion text containing reasoning blocks +- **LlamaCppJniConfig**: immutable configuration for model and inference settings +- **AiGenerationProviderFactory**: selects and instantiates provider based on name + +#### Data flow +Input file name → matched against file extensions in AiFieldGenerationConfig → selected via AiFieldGenerationSelector → resolved into AiGenerationConfig via AiModelDefinitionSupport → used to build prompt (via AiPromptSupport) → passed to AiGenerationProviderFactory → provider selected and executed → LlamaCppJniAiGenerationProvider runs inference → raw output processed by AiCompletionParser → final answer extracted and returned + +#### Dependencies +- AiFieldGenerationSelector depends on AiFieldGenerationConfig +- AiGenerationConfig depends on AiModelDefinition and Llama model parameters +- AiModelDefinitionSupport uses AiModelDefinition and AiGenerationConfig for conversion +- LlamaCppJniAiGenerationProvider depends on LlamaCppJniConfig and AiPromptSupport +- AiCompletionParser depends on raw output and prompt context +- AiGenerationProviderFactory selects from AiGenerationProvider and MockAiGenerationProvider +- Cross-package: net.ladenthin.llama.parameters.ModelParameters, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Immutable stop strings via unmodifiableList wrappers +- Null safety enforced with @Nullable and defensive checks in setters +- Immutability of output views (fileExtensions, stopStrings) +- Final classes (AiFieldGenerationSelector, AiModelDefinitionSupport) ensure thread safety +- Uniform use of @ToString for readable instance representation across classes +- Immutable configuration via record-like design (LlamaCppJniConfig) +- Shared error handling: IOException for provider failures or parsing issues +- Deterministic mock behavior for testing +- Temperature override during retries to avoid empty responses +- Thread safety in immutable units; model loading is lazy but not synchronized, risking concurrent access issues diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/project.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/project.ai.md new file mode 100644 index 0000000..5a60a69 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3-4b-2507__v2/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: C0C95CB3 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T06:40:27Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The project implements an AI-driven source code indexing pipeline for Maven plugins, centered around local Llama.cpp inference for field generation and code summarization. Core functionality is organized into a provider layer that handles text generation and response parsing via llama.cpp JNI bindings or mock implementations, enabling pluggable backends. Configuration and orchestration of model settings, language-specific prompts, and per-file or per-package summarization are managed through the AI index configuration subsystem, which integrates with the main execution flow to drive AI-driven field creation. Together, these components form a modular, extensible pipeline for AI-powered source code analysis within Maven-based builds. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — This package configures and orchestrates AI-driven field generation and model settings for Maven plugins using llama.cpp, enabling language-specific prompts and per-file or per-package summarization. +- main/java/net/ladenthin/maven/llamacpp/aiindex — This package enables AI-driven source code field generation and summarization in Maven plugins using llama.cpp, configuring model parameters and orchestrating local LLM inference through pluggable providers. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Enables local AI text generation and response parsing in a Maven-based indexing pipeline using llama.cpp JNI bindings or mock providers +- main/java/net/ladenthin/maven/llamacpp — Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. +- main/java/net/ladenthin/maven — Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. +- main/java/net/ladenthin — Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. +- main/java/net — Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. +- main/java — Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. +- main — Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. +- . — Enables AI-driven field generation and source code summarization in Maven plugins using local Llama.cpp inference with configurable model parameters and pluggable generation backends. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..5879e1a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,59 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:05:26Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI field generation steps by linking prompt templates to model definitions and optional file extension filters. + +#### Purpose +* Defines a mutable POJO for mapping prompt keys to AI model definitions within Maven plugin configuration. +* Selects field-generation operations based on source file extensions or as a fallback for all files. + +#### Type +* Class: `AiFieldGenerationConfig` +* Annotations: `@ToString`, `@SuppressWarnings("NullAway.Init", "initialization.fields.uninitialized")` +* Fields: `private String promptKey`, `private String aiDefinitionKey`, `private @Nullable List fileExtensions` + +#### Input +* `String promptKey`: Key referencing an `AiPromptDefinition`. +* `String aiDefinitionKey`: Key referencing an `AiModelDefinition` for model parameters. +* `Collection fileExtensions`: Optional list of file extensions (e.g., `.java`) to target. + +#### Output +* `String promptKey`: Returns the configured prompt template key. +* `String aiDefinitionKey`: Returns the configured AI model definition key. +* `List fileExtensions`: Returns an unmodifiable view or null for extension filtering. +* `void setFileExtensions(Collection)`: Mutates internal list with defensive copy. + +#### Core logic +* Associates a prompt template key with an AI model definition for single field-generation steps. +* Applies selection logic to files based on matching extensions or acts as a global fallback. +* Ensures immutability of returned lists via `Collections.unmodifiableList` and defensive copying during mutation. + +#### Public API +* `getPromptKey() -> String`: Retrieves prompt template identifier. +* `setPromptKey(String) -> void`: Updates prompt template identifier. +* `getAiDefinitionKey() -> String`: Retrieves AI model definition identifier. +* `setAiDefinitionKey(String) -> void`: Updates AI model definition identifier. +* `getFileExtensions() -> List`: Retrieves file extension filter list. +* `setFileExtensions(Collection) -> void`: Sets file extension filter list with safety copy. + +#### Dependencies +* `net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig` +* `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition` +* `net.ladenthin.maven.llamacpp.aiindex.AiModelDefinition` +* `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List` +* `lombok.ToString` +* `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +* Handles null inputs gracefully in `setFileExtensions` by allowing null to become a fallback. +* No explicit exceptions thrown; relies on caller to provide valid keys and collection types. + +#### Concurrency +* Thread-safe for read operations due to return of unmodifiable views or null. +* Mutable state in fields requires external synchronization if accessed concurrently by plugin framework. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..dc1dce6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,46 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:07:09Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the appropriate AI field generation configuration for a source file based on file extension matching rules. + +#### Purpose +- Applies language-specific or generic AI prompts to source files by matching extensions. +- Enables dynamic prompt variation per file while keeping a single loaded AI model active. + +#### Type +class; final; extends Object; implements none; annotated with @ToString; key generics none; type bounds none; notable annotations @lombok.ToString, @jspecify.annotations.Nullable. + +#### Input +- Iterable configs: list of configured field generation rules. +- String fileName: the name of the source file being processed. +- Injected dependencies none; consumed fields none; read resources none. + +#### Output +- AiFieldGenerationConfig: the selected configuration instance matching the file extension or fallback rule. +- Produced state none; mutated fields none; written resources none; side effects none. + +#### Core logic +- Iterates through configured field generation configs in declaration order. +- Skips null entries and identifies extension-agnostic fallbacks (null or empty extension lists). +- Matches the input fileName against specific file extensions defined in each config using endsWith. +- Returns the first matching config immediately upon finding a match. +- Returns the last identified fallback config if no specific extension matches. +- Returns null if no config matches and no fallback is configured. + +#### Public API +- selectForFileName(Iterable configs, String fileName) -> @Nullable AiFieldGenerationConfig: selects matching config by extension. + +#### Dependencies +AiFieldGenerationConfig, Iterable, List, String, AiFieldGenerationSelector. + +#### Exceptions / Errors +No exceptions thrown; null input handled gracefully via skip logic and return value. + +#### Concurrency +Immutability ensures thread-safety; no synchronization required as stateless selection logic. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..bef740f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,82 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:08:11Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI generation parameters including model paths, sampling rates, and retry policies for Llama.cpp inference. + +#### Purpose +* Holds mutable configuration for AI model inference steps including context size, temperature, and token limits. +* Provides JavaBean setters for Maven plugin injection and log diagnostics via Lombok. + +#### Type +* `public class AiGenerationConfig` with `@ToString` annotation. +* Contains 25 default constant fields (`DEFAULT_*`) and 16 mutable instance fields. +* Uses `List` for stop strings without custom collection management. + +#### Input +* Constructor: None (uses defaults). +* Setters: Accepts `String` (model path), `int` (context size, max output tokens, threads, chars per token, max input chars, retries, top k), `float` (temperature, retry increment, top p, repeat penalty), `boolean` (warn on trim, chat template thinking), and `List` (stop strings). + +#### Output +* Returns: `String`, `int`, `float`, `boolean`, or `List` via getter methods. +* State: Mutates internal fields directly without validation or side effects. +* Resources: None produced or consumed within this class scope. + +#### Core logic +* Initializes all instance fields with corresponding static default constants on construction. +* Allows external configuration via setter methods for model path, sampling parameters, and retry policies. +* Calculates maximum input characters dynamically if `charsPerToken` is non-zero using a safety margin formula. +* Returns unmodifiable list views of stop strings to prevent runtime modification. + +#### Public API +* `getModelPath()` -> String (returns model file path) +* `setModelPath(String)` -> void (sets GGUF model file path) +* `getContextSize()` -> int (returns context window size in tokens) +* `setContextSize(int)` -> void (sets context window size in tokens) +* `getMaxOutputTokens()` -> int (returns max output tokens per call) +* `setMaxOutputTokens(int)` -> void (sets max output tokens per call) +* `getTemperature()` -> float (returns sampling temperature value) +* `setTemperature(float)` -> void (sets sampling temperature value) +* `getThreads()` -> int (returns number of CPU threads for inference) +* `setThreads(int)` -> void (sets number of CPU threads for inference) +* `getCharsPerToken()` -> int (returns chars per token ratio) +* `setCharsPerToken(int)` -> void (sets chars per token ratio) +* `getMaxInputChars()` -> int (returns max input characters limit) +* `setMaxInputChars(int)` -> void (sets max input characters limit) +* `isWarnOnTrim()` -> boolean (returns trim warning enabled status) +* `setWarnOnTrim(boolean)` -> void (sets trim warning enabled status) +* `getMaxRetries()` -> int (returns max retry attempts count) +* `setMaxRetries(int)` -> void (sets max retry attempts count) +* `getRetryTemperatureIncrement()` -> float (returns temp increment per retry) +* `setRetryTemperatureIncrement(float)` -> void (sets temp increment per retry) +* `getTopP()` -> float (returns top-p sampling threshold) +* `setTopP(float)` -> void (sets top-p sampling threshold) +* `getTopK()` -> int (returns top-k sampling limit) +* `setTopK(int)` -> void (sets top-k sampling limit) +* `getRepeatPenalty()` -> float (returns repetition penalty value) +* `setRepeatPenalty(float)` -> void (sets repetition penalty value) +* `isChatTemplateEnableThinking()` -> boolean (returns thinking mode enabled status) +* `setChatTemplateEnableThinking(boolean)` -> void (sets chat-template thinking mode) +* `getStopStrings()` -> List (returns unmodifiable stop strings list) +* `setStopStrings(List)` -> void (sets list of stop strings) + +#### Dependencies +* `java.util.ArrayList`, `java.util.Collections`, `java.util.List` +* `lombok.ToString` +* `org.jspecify.annotations.Nullable` +* `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig` + +#### Exceptions / Errors +* No explicit exceptions thrown by methods. +* Handles null input in `setStopStrings` by resetting to empty list. +* Allows null model path return via getter if not set. + +#### Concurrency +* Not thread-safe; fields are mutable and accessed via setters. +* Designed for single-instance use managed by Maven plugin framework. +* No synchronization or immutability guarantees provided. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..83d5e28 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,33 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:11:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines enumeration values to distinguish between AI generation operations on individual source files versus entire packages. + +#### Purpose +- Identifies single-file summary generation steps. +- Identifies package-aggregate summary generation steps. + +#### Type +Enum with no modifiers. No extends or implements. No annotations. + +#### Input +None. + +#### Output +None. + +#### Core logic +None. Enum values are constant identifiers for generation scope. + +#### Public API +`FILE_SUMMARY` -> constant (single-file scope) +`PACKAGE_SUMMARY` -> constant (package-aggregate scope) + +#### Dependencies +net.ladenthin.maven.llamacpp.aiindex.config diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..624c8b0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,88 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:12:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures LLM inference parameters for Maven plugin field generation by defining a reusable POJO for model paths, context sizes, and sampling algorithms. + +#### Purpose +* Defines a single-source configuration object for AI model parameters used in Java-based field generation within Maven plugins. +* Supports reusability across multiple generation goals via a unique lookup key mechanism. + +#### Type +* Class: `public class AiModelDefinition` +* Annotations: `@ToString`, `@SuppressWarnings` +* Fields: Mutable JavaBean with getters/setters; uses `java.util.List` (via `ArrayList`/`Collections`) for stop strings. + +#### Input +* Constructor: None (default constructor applies). +* Parameters: `String key`, `String modelPath`, `int contextSize`, `int maxOutputTokens`, `float temperature`, `int threads`, `int charsPerToken`, `boolean warnOnTrim`, `int maxRetries`, `float retryTemperatureIncrement`, `float topP`, `int topK`, `float repeatPenalty`, `boolean chatTemplateEnableThinking`, `Collection stopStrings`. + +#### Output +* Returns: String (key, modelPath), Int (contextSize, maxOutputTokens, threads, charsPerToken, maxRetries, topK), Float (temperature, retryTemperatureIncrement, topP, repeatPenalty), Boolean (warnOnTrim, chatTemplateEnableThinking), List (stopStrings). +* State: Mutable fields updated via setters to configure LLM behavior. + +#### Core logic +* Initializes numeric fields with defaults from `AiGenerationConfig` unless explicitly overridden. +* Stores a unique string key for mapping between field-generation configs and this model definition. +* Tracks the file path to the GGUF model binary for inference execution. +* Configures context window size to limit input token consumption. +* Sets sampling parameters (temperature, top-p, top-k) to control generation randomness and diversity. +* Defines retry logic thresholds including maximum attempts and temperature increments per failure. +* Calculates automatic max input character limits based on `charsPerToken` ratio for source code trimming. +* Manages stop sequences to terminate generation upon specific string patterns. + +#### Public API +* `getKey() -> String`: Retrieves unique model identifier. +* `setKey(String) -> void`: Assigns unique model identifier. +* `getModelPath() -> String`: Retrieves GGUF model file path. +* `setModelPath(String) -> void`: Assigns GGUF model file path. +* `getContextSize() -> int`: Retrieves context window size in tokens. +* `setContextSize(int) -> void`: Sets context window size in tokens. +* `getMaxOutputTokens() -> int`: Retrieves max output token limit. +* `setMaxOutputTokens(int) -> void`: Sets max output token limit. +* `getTemperature() -> float`: Retrieves base sampling temperature. +* `setTemperature(float) -> void`: Sets base sampling temperature. +* `getThreads() -> int`: Retrieves CPU thread count for inference. +* `setThreads(int) -> void`: Sets CPU thread count for inference. +* `getCharsPerToken() -> int`: Retrieves chars-per-token ratio for input calculation. +* `setCharsPerToken(int) -> void`: Sets chars-per-token ratio for input calculation. +* `isWarnOnTrim() -> boolean`: Checks warning flag on source trimming. +* `setWarnOnTrim(boolean) -> void`: Enables/disables warning on source trimming. +* `getMaxRetries() -> int`: Retrieves max retry attempt count. +* `setMaxRetries(int) -> void`: Sets max retry attempt count. +* `getRetryTemperatureIncrement() -> float`: Retrieves temp increment per retry. +* `setRetryTemperatureIncrement(float) -> void`: Sets temp increment per retry. +* `getTopP() -> float`: Retrieves nucleus sampling threshold. +* `setTopP(float) -> void`: Sets nucleus sampling threshold. +* `getTopK() -> int`: Retrieves top-k sampling limit. +* `setTopK(int) -> void`: Sets top-k sampling limit. +* `getRepeatPenalty() -> float`: Retrieves repetition penalty factor. +* `setRepeatPenalty(float) -> void`: Sets repetition penalty factor. +* `isChatTemplateEnableThinking() -> boolean`: Checks chat template thinking mode. +* `setChatTemplateEnableThinking(boolean) -> void`: Toggles chat template thinking mode. +* `getStopStrings() -> List`: Retrieves list of generation stop strings. +* `setStopStrings(Collection) -> void`: Sets list of generation stop strings. + +#### Dependencies +* `java.util.ArrayList` +* `java.util.Collection` +* `java.util.Collections` +* `java.util.List` +* `lombok.ToString` +* `org.jspecify.annotations.Nullable` +* `AiGenerationConfig` +* `net.ladenthin.llama.parameters.ModelParameters` + +#### Exceptions / Errors +* Throws: None declared. +* Null Handling: Allows null for key, modelPath, stopStrings; returns unmodifiable lists for safe access. +* Error Conditions: Relies on defaults from `AiGenerationConfig` if fields are unset. + +#### Concurrency +* Thread Safety: Not explicitly synchronized; assumes configuration is set before use by inference engine. +* Immutability: Mutable state via setters; `getStopStrings()` returns unmodifiable view to prevent runtime mutation. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..ab653bc --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,47 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:15:37Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key to generate ready-to-use configuration objects for plugin goals. + +#### Purpose +* Converts `AiModelDefinition` entries from Maven POM configuration into `AiGenerationConfig` instances. +* Enforces strict contract validation on definition keys to fail fast at build time. + +#### Type +`public final class AiModelDefinitionSupport` extends `Object`. Annotations: `@ToString`. Fields: `private final Map configs`. + +#### Input +* Constructor parameter: `List definitions` (may be null or empty). +* Internal state: Presized `HashMap` populated from input list. + +#### Output +* Method return: `AiGenerationConfig` object for a given key via `getConfig()`. +* Side effects: Mutates internal `configs` map during construction; creates new config objects in `toConfig()`. + +#### Core logic +* Validates every `AiModelDefinition` entry has a non-null `key`, throwing `NullPointerException` with index details on failure. +* Presizes internal HashMap capacity to optimize insertion performance. +* Iterates definitions, calls `toConfig()` for each, storing result in key-value map. +* `toConfig()` clones all parameters (model path, context size, tokens, temperature, etc.) into a new `AiGenerationConfig`. +* Lookup retrieves config via key; throws `IllegalArgumentException` if key missing to ensure eager error detection. + +#### Public API +* `AiModelDefinitionSupport(List) -> void`: Constructs lookup table from definitions. +* `getConfig(String) -> AiGenerationConfig`: Retrieves configuration by definition key. + +#### Dependencies +`java.util.HashMap`, `java.util.List`, `java.util.Map`, `java.util.Objects`, `lombok.ToString`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`. Referenced types: `AiModelDefinition`, `AiGenerationConfig`. + +#### Exceptions / Errors +* Throws `NullPointerException` if any definition key is null during construction. +* Throws `IllegalArgumentException` if requested key is not found in the map. +* Null definitions list or empty list handled gracefully (initialized with zero capacity). + +#### Concurrency +* Thread-safe via immutable internal state; `configs` map populated once in constructor and never modified after creation. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..18ecd04 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,51 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:23:44Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Provides Llama.cpp inference configuration and field generation selection logic for Maven plugins, mapping file extensions to AI models while managing context windows, sampling parameters, and retry policies. + +#### Purpose +* Defines POJOs for configuring AI model paths, sampling algorithms (temperature, top-p), and inference limits for Java source code processing. +* Implements a selector mechanism to dynamically assign AI generation rules based on source file extensions or fallback to global defaults. + +#### Responsibilities +* **AI Generation Configuration**: Manages mutable settings for context size, token limits, threading, and sampling parameters (temperature, top-p, top-k) within `AiGenerationConfig` and `AiModelDefinition`. +* **Field Generation Selection**: Filters and selects specific AI prompt templates based on source file extensions using `AiFieldGenerationSelector`. +* **Definition Resolution**: Converts Maven POM `AiModelDefinition` entries into executable `AiGenerationConfig` instances via `AiModelDefinitionSupport`. + +#### Key units +* `AiGenerationConfig`: Holds 25+ constants and 16 mutable fields for model paths, context sizes, sampling rates, and retry policies. +* `AiModelDefinition`: Defines reusable parameters including GGUF model paths, token limits, and stop strings with a unique lookup key. +* `AiFieldGenerationConfig`: Maps prompt keys to model definitions and optional file extension filters (e.g., `.java`). +* `AiFieldGenerationSelector`: Iterates through configs to select the appropriate generation rule for a given source filename. +* `AiModelDefinitionSupport`: Validates definition keys and resolves `AiModelDefinition` entries into ready-to-use `AiGenerationConfig` objects. +* `AiGenerationKind`: Enumerates scope types (`FILE_SUMMARY`, `PACKAGE_SUMMARY`) for generation operations. + +#### Data flow +* Maven POM configuration provides a list of `AiModelDefinition` objects. +* `AiModelDefinitionSupport` validates these definitions and populates an internal map, converting each to a new `AiGenerationConfig`. +* The plugin framework queries `AiModelDefinitionSupport.getConfig()` using a specific key to retrieve active inference parameters. +* `AiFieldGenerationSelector` receives the list of `AiFieldGenerationConfig` rules and iterates them against a source file name. +* If a file extension matches a rule, that rule's prompt and model definition are applied; otherwise, a fallback rule or null is returned. + +#### Dependencies +* **Internal**: `AiGenerationConfig`, `AiModelDefinition`, `AiFieldGenerationConfig`, `AiFieldGenerationSelector`, `AiModelDefinitionSupport`. +* **External Modules/Types**: `net.ladenthin.llama.parameters.ModelParameters`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +* **Java Standard Libs**: `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.HashMap`, `java.util.List`, `java.util.Map`. + +#### Cross-cutting +* **Immutability Patterns**: Public getters for lists (e.g., `getStopStrings()`) return unmodifiable views to prevent runtime mutation, while internal state remains mutable for configuration updates. +* **Null Handling**: Default constructors rely on static constants; null inputs in setters often trigger graceful resets (e.g., empty lists) or allow null fallbacks rather than throwing exceptions immediately. +* **Thread Safety**: Configuration objects are generally designed for single-instance use within the plugin lifecycle, though `AiFieldGenerationSelector` is stateless and thread-safe. Concurrent access to mutable fields requires external synchronization outside these classes. +* **Error Strategy**: Fail-fast validation on definition keys during construction (`NullPointerException`), with runtime errors primarily manifested as missing key lookups (`IllegalArgumentException`). diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..85ea11f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,47 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:29:22Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> Provides local AI document indexing via JNI-backed Llama.cpp inference, configuring model paths, sampling parameters, and field-specific generation rules for Java source code processing. + +#### Purpose +* Orchestrates local LLM text generation using native llama.cpp bindings to index and summarize source files. +* Bridges Maven POM definitions with runtime inference configurations while supporting deterministic mock testing. + +#### Responsibilities +* **Native Inference Management**: Loads GGUF models via JNI, manages chat context windows, and executes token generation with configurable sampling (temperature, top-p). +* **Configuration Resolution**: Maps Maven `AiModelDefinition` entries to executable `AiGenerationConfig` objects and selects file-specific prompt templates. +* **Prompt Construction & Parsing**: Builds chat messages from source files and parses raw model outputs to strip reasoning markers and extract clean answers. +* **Provider Abstraction**: Offers a unified interface for switching between native Llama.cpp inference and deterministic mock providers. + +#### Key units +* `AiGenerationProvider`: Defines the contract for generating text from prompts and source file paths. +* `LlamaCppJniAiGenerationProvider`: Implements native inference via JNI, handling lazy initialization of `LlamaModel` and chat message construction. +* `LlamaCppJniConfig`: Immutable record holding model paths, context limits, sampling parameters, and stop strings. +* `AiCompletionParser`: Extracts clean text from raw completion strings by removing reasoning block markers and handling budget exhaustion. +* `AiGenerationProviderFactory`: Instantiates specific providers (`Mock` or `LlamaCppJni`) based on configuration names. +* `AiModelDefinitionSupport`: Resolves Maven POM `AiModelDefinition` entries into active inference configurations. + +#### Data flow +1. **Configuration Load**: Maven POM defines `AiModelDefinition` objects; `AiModelDefinitionSupport` validates keys and converts them to `AiGenerationConfig` instances. +2. **Provider Selection**: The framework queries `AiGenerationProviderFactory` or directly instantiates `LlamaCppJniAiGenerationProvider` using the resolved config. +3. **Inference Execution**: For a given source file, `AiPromptSupport` constructs a chat message including headers and content; the native backend executes `chatCompleteText`. +4. **Response Processing**: Raw output is passed to `AiCompletionParser` to remove `THINKING_BLOCK_START/END_MARKERS`, returning a clean string or raising an exception on malformed reasoning blocks. + +#### Dependencies +* **Internal Modules**: `net.ladenthin.llama.parameters.ModelParameters`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +* **Native Bindings**: JNI wrappers for llama.cpp (`libllama`), native memory management, and GGUF model loading. +* **Standard Library**: `java.nio.file.Path`, `java.io.IOException`, `java.util.HashMap`, `java.util.List`. + +#### Cross-cutting +* **Immutability Strategy**: Configuration objects (e.g., `LlamaCppJniConfig`) use immutable records to ensure thread-safety without external locks. +* **Null Safety**: Default constructors rely on static constants; null inputs in setters trigger graceful resets rather than immediate exceptions. +* **Error Handling**: Standardizes `IOException` for native failures and reasoning block mismatches; zero-token outputs return blank strings instead of nulls. +* **Testing Strategy**: Includes `MockAiGenerationProvider` to decouple unit tests from native dependencies, ensuring deterministic behavior during development. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..99ec4b0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,41 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:17:03Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +`). + +#### Input +* `response`: Raw completion string from the model (may be null). +* Constants: Defined markers for Gemma-4 reasoning blocks. + +#### Output +* `String`: Cleaned answer text following the closing marker or trimmed original input. +* Side effects: Throws `IOException` if start marker exists without end marker. +* State: Mutates no state; returns new string. + +#### Core logic +* Returns empty string if input is null. +* Finds last occurrence of `THINKING_BLOCK_END_MARKER` to truncate reasoning. +* Throws `IOException` if `THINKING_BLOCK_START_MARKER` appears but end marker is missing (budget exhaustion). +* Returns trimmed original response if no markers are detected. + +#### Public API +`parseCompletion(String response) -> String`: Extracts clean answer from raw completion. + +#### Dependencies +* `java.io.IOException` +* `lombok.ToString` +* Constants: `THINKING_BLOCK_START_MARKER`, `THINKING_BLOCK_END_MARKER`. + +#### Exceptions / Errors +* Throws `IOException` when thinking block is started but not closed (token budget exhausted). +* Handles null input gracefully as empty string. + +#### Concurrency +* Thread-safe via pure functional logic and immutability of returned strings. +* No synchronization required. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..a23cc7f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,48 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:18:11Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a pluggable AI backend interface for generating text responses from local LLMs (llama.cpp) or mock providers based on input requests. + +#### Purpose +* Defines the contract for generating AI text from prompts, source files, and headers via `AiGenerationRequest`. +* Supports configurable sampling parameters like temperature to resolve generation failures. + +#### Type +Kind: interface; extends AutoCloseable; implements default methods for fallback logic. + +#### Input +* `AiGenerationRequest`: Contains prompt key, source file path, source text, and current header context. +* `float temperatureOverride`: Optional sampling parameter to override provider configuration during retry logic. + +#### Output +* `String`: Generated text response (never null, may be blank if model produces no tokens). +* Side effect: Closes underlying resource on invocation of `close()` method. + +#### Core logic +* Validates `AiGenerationRequest` parameters for prompt construction and header injection. +* Applies optional `temperatureOverride` to sampling configuration before invoking the generation engine. +* Executes model inference locally via llama.cpp or mock fallback to produce text output. +* Handles resource cleanup automatically via `AutoCloseable` contract implementation. + +#### Public API +* `generate(request) -> String`: Generates text using default provider parameters. +* `generate(request, temperatureOverride) -> String`: Generates text with forced temperature override for retry logic. +* `close() -> void`: Releases underlying AI backend resources safely. + +#### Dependencies +* `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +* `java.io.IOException` + +#### Exceptions / Errors +* Throws `IOException` if the underlying AI provider fails during text generation. +* Returns blank strings instead of null if the model produces zero tokens. + +#### Concurrency +* Stateless interface design ensures thread-safety across concurrent requests. +* No internal synchronization required; relies on external resource management. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..3e4e060 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,41 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:19:11Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Factory selects and instantiates an AI generation provider implementation by name for integration into the Llama.cpp AI index system. + +#### Purpose +* Instantiates `AiGenerationProvider` instances for `mock` or `llamacpp-jni` modes within the AI index module. +* Validates provider names and returns configured `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. + +#### Type +Class `AiGenerationProviderFactory` with `@ToString` annotation; final field `Java8CompatibilityHelper`. + +#### Input +Constructor takes no parameters; `create` method accepts `String providerName`, `LlamaCppJniConfig llamaConfig`, and `AiPromptSupport promptSupport`. + +#### Output +Returns `AiGenerationProvider` instance (`MockAiGenerationProvider` or `LlamaCppJniAiGenerationProvider`); throws `IllegalArgumentException` on invalid names. + +#### Core logic +* Initializes internal `Java8CompatibilityHelper` for string validation. +* Checks if `providerName` is null or blank to default to `mock` mode. +* Switches on `providerName` string value to instantiate specific provider types. +* Throws error for unrecognized provider keys in `llamacpp-jni` AI index context. + +#### Public API +`create(String, LlamaCppJniConfig, AiPromptSupport) -> AiGenerationProvider`: creates provider instance. + +#### Dependencies +`AiGenerationProvider`, `AiPromptSupport`, `LlamaCppJniConfig`, `MockAiGenerationProvider`, `LlamaCppJniAiGenerationProvider`, `Java8CompatibilityHelper`. + +#### Exceptions / Errors +Throws `IllegalArgumentException` when `providerName` is unrecognized or invalid string. + +#### Concurrency +No concurrency concerns; uses single-threaded instantiation logic with immutability for internal helpers. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..63265b2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,52 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:20:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides local LLM text generation via JNI-backed llama.cpp for AI index document processing. + +#### Purpose +- Implements `AiGenerationProvider` interface for generating AI completions using local GGUF models. +- Manages lifecycle of native llama.cpp instance including lazy initialization and cleanup. + +#### Type +Class: `final`, extends `Object`, implements `AiGenerationProvider` and `AutoCloseable`. Fields annotated with `@ToString.Exclude` and `@Nullable`. Lombok `@ToString` applied. + +#### Input +- Constructor parameters: `LlamaCppJniConfig`, `AiPromptSupport`. +- Method parameters: `AiGenerationRequest`, `float temperatureOverride`. +- Consumed fields: `config`, `promptSupport`, internal `model` handle, `completionParser`. +- Resources read: configuration values (model path, context size, threads), prompt templates. + +#### Output +- Return type: `String` containing generated AI completion text. +- Produced state: Cached `LlamaModel` instance after first generation. +- Side effects: Native memory allocation for model loading, potential native pointer access. + +#### Core logic +- Lazily initializes native `LlamaModel` from GGUF file on first `generate()` call using configuration parameters. +- Constructs chat messages list from request and prompt support template. +- Configures inference parameters (temperature, tokens, top-p/k, repeat penalty) before calling native `chatCompleteText`. +- Parses raw completion output into structured text via `AiCompletionParser`. + +#### Public API +- `generate(AiGenerationRequest) -> String`: Generates text using default temperature. +- `generate(AiGenerationRequest, float) -> String`: Generates text with overridden temperature. +- `close() -> void`: Releases native model resources and closes handle. + +#### Dependencies +`net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniConfig`, `AiPromptSupport`, `AiGenerationRequest`, `LlamaModel`, `InferenceParameters`, `AiCompletionParser`, `java.util.List`, `java.io.IOException`. + +#### Exceptions / Errors +- Throws `IOException` from `generate()` and `close()` methods. +- Validates input arguments via `Objects.requireNonNull` in constructor. +- Handles null model gracefully during close operation. + +#### Concurrency +- Single-threaded design assuming sequential access to shared `model` state. +- Lazy initialization ensures native resources are not shared across threads without synchronization. +- Immutable inference parameters prevent race conditions during configuration assembly. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..7179d84 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,55 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:21:31Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures native llama.cpp inference parameters for Java AI indexing providers. + +#### Purpose +* Immutable configuration holder for llama.cpp JNI provider settings. +* Defines model paths, sampling parameters, and thread counts for LLM execution. + +#### Type +Class: `final` with Lombok-generated `equals`, `hashCode`, `toString`. +Fields: 11 private final fields (`libraryPath`, `modelPath`, numeric configs). +Annotations: `@ConvertToRecord`, `@ToString`, `@EqualsAndHashCode`. + +#### Input +Constructor parameters: `String libraryPath`, `String modelPath` (required), `int contextSize`, `int maxOutputTokens`, `float temperature`, `int threads`, `float topP`, `int topK`, `float repeatPenalty`, `boolean chatTemplateEnableThinking`, `List stopStrings`. + +#### Output +Return types: 11 getter methods returning respective config values (`String`, `int`, `float`, `boolean`, `List`). +Side effects: Validates `modelPath` non-null; converts null `stopStrings` to empty list. + +#### Core logic +* Validates `modelPath` is not null during construction. +* Initializes immutable fields with provided configuration values. +* Converts null `stopStrings` to an unmodifiable empty list for safety. +* Generates value-based equality and hash code via Lombok over all fields. + +#### Public API +`libraryPath() -> String` (native lib path or null) +`modelPath() -> String` (GGUF model file path) +`contextSize() -> int` (context window token count) +`maxOutputTokens() -> int` (max output token limit) +`temperature() -> float` (sampling temperature factor) +`threads() -> int` (CPU thread count) +`topP() -> float` (nucleus sampling threshold) +`topK() -> int` (top-k sampling limit) +`repeatPenalty() -> float` (repetition penalty weight) +`chatTemplateEnableThinking() -> boolean` (thinking mode flag) +`stopStrings() -> List` (unmodifiable stop tokens list) + +#### Dependencies +`java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.EqualsAndHashCode`, `lombok.ToString`, `net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord`. + +#### Exceptions / Errors +Throws `NullPointerException` if `modelPath` is null. +Handles null `stopStrings` gracefully by converting to empty list. + +#### Concurrency +Thread-safe due to immutability; no synchronization required. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..66aa0e6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,43 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:23:03Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a deterministic mock implementation of AI generation summaries for testing purposes without external dependencies. + +#### Purpose +- Replaces real AI generation with static mock summaries during unit testing. +- Simulates the `AiGenerationProvider` interface for deterministic validation. + +#### Type +Class implementing `AiGenerationProvider`, annotated with `@ToString`. + +#### Input +- `AiGenerationRequest` containing a `Path` source file representing the document to process. + +#### Output +- Returns a `String` formatted as "Mock summary for [filename]". + +#### Core logic +- Extracts filename from `sourceFile()` parameter of the request. +- Fallbacks to full path string if filename extraction fails or returns null. +- Concatenates static prefix with filename to generate mock response. + +#### Public API +- `generate(AiGenerationRequest) -> String` + generates mock summary for requested file. + +#### Dependencies +- `AiGenerationProvider` interface. +- `AiGenerationRequest` request container. +- `java.nio.file.Path` for file path handling. + +#### Exceptions / Errors +- Throws `IOException` on method execution (mock implementation ignores actual I/O errors). +- Handles null filename gracefully by falling back to full path string representation. + +#### Concurrency +- Thread-safe via immutability; no shared mutable state or synchronization required. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..56a471d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,52 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:27:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> Provides a pluggable local LLM inference backend using JNI-backed llama.cpp for AI document processing, supporting deterministic mock testing and configurable sampling parameters. + +#### Purpose +* Implements local AI text generation for AI index documents via native llama.cpp or fallback mock providers. +* Manages lifecycle of native resources (models, contexts) and provides a clean interface for prompt-based completion. + +#### Responsibilities +* **Native LLM Inference**: Handles GGUF model loading, chat message construction, and token generation using JNI. +* **Configuration Management**: Stores immutable inference parameters (context size, temperature, threads, stop strings). +* **Response Parsing**: Extracts clean answer text from raw model outputs by truncating reasoning blocks. +* **Factory & Abstraction**: Provides interfaces for provider selection and mock implementations for testing. + +#### Key units +* `AiGenerationProvider`: Interface defining the contract for generating text from prompts and source files. +* `LlamaCppJniAiGenerationProvider`: Implements native inference via JNI, managing lazy initialization of `LlamaModel`. +* `LlamaCppJniConfig`: Immutable holder for model paths, context sizes, sampling settings (temperature, top-p/k), and stop strings. +* `AiCompletionParser`: Utility to parse raw completion strings, removing reasoning markers and handling budget exhaustion errors. +* `AiGenerationProviderFactory`: Factory class instantiating specific provider types (`Mock` or `LlamaCppJni`) based on name. +* `MockAiGenerationProvider`: Deterministic test implementation returning static summaries based on file paths. + +#### Data flow +1. **Request**: `AiGenerationRequest` containing prompt, source file path, and header context enters the system. +2. **Configuration**: `LlamaCppJniConfig` supplies model path, context limits, and sampling parameters to the provider. +3. **Inference**: `LlamaCppJniAiGenerationProvider` constructs chat messages using `AiPromptSupport`, calls native `chatCompleteText`, and receives raw output. +4. **Parsing**: Raw output is fed into `AiCompletionParser` to strip reasoning blocks (`THINKING_BLOCK_START/END_MARKERS`). +5. **Output**: Cleaned string is returned; if markers are incomplete, an `IOException` indicates token budget exhaustion. + +#### Dependencies +* **Internal**: `AiPromptSupport`, `LlamaModel`, `InferenceParameters`, `Java8CompatibilityHelper`. +* **External**: JNI bindings for llama.cpp (`libllama`, native memory), `java.nio.file.Path`, `java.io.IOException`. +* **Data**: GGUF model files, configuration strings, stop token lists. + +#### Cross-cutting +* **Immutability**: `LlamaCppJniConfig` uses `@ConvertToRecord` for thread-safe configuration storage. +* **Error Handling**: Standardizes `IOException` for native failures and reasoning block mismatches; returns blank strings on zero-token outputs instead of nulls. +* **Concurrency**: Relies on lazy initialization and immutability; native resources are not shared across threads without explicit synchronization. +* **Testing**: Includes a `MockAiGenerationProvider` to decouple unit tests from native dependencies. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..be80760 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,46 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:31:22Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> Provides local AI document indexing via JNI-backed Llama.cpp inference, configuring model paths, sampling parameters, and field-specific generation rules for Java source code processing. + +#### Purpose +* Orchestrates local LLM text generation using native llama.cpp bindings to index and summarize source files. +* Bridges Maven POM definitions with runtime inference configurations while supporting deterministic mock testing. + +#### Responsibilities +* **Native Inference Management**: Loads GGUF models via JNI, manages chat context windows, and executes token generation with configurable sampling (temperature, top-p). +* **Configuration Resolution**: Maps Maven `AiModelDefinition` entries to executable `AiGenerationConfig` objects and selects file-specific prompt templates. +* **Prompt Construction & Parsing**: Builds chat messages from source files and parses raw model outputs to strip reasoning markers and extract clean answers. +* **Provider Abstraction**: Offers a unified interface for switching between native Llama.cpp inference and deterministic mock providers. + +#### Key units +* `AiGenerationProvider`: Defines the contract for generating text from prompts and source file paths. +* `LlamaCppJniAiGenerationProvider`: Implements native inference via JNI, handling lazy initialization of `LlamaModel` and chat message construction. +* `LlamaCppJniConfig`: Immutable record holding model paths, context limits, sampling parameters, and stop strings. +* `AiCompletionParser`: Extracts clean text from raw completion strings by removing reasoning block markers and handling budget exhaustion. +* `AiGenerationProviderFactory`: Instantiates specific providers (`Mock` or `LlamaCppJni`) based on configuration names. +* `AiModelDefinitionSupport`: Resolves Maven POM `AiModelDefinition` entries into active inference configurations. + +#### Data flow +1. **Configuration Load**: Maven POM defines `AiModelDefinition` objects; `AiModelDefinitionSupport` validates keys and converts them to `AiGenerationConfig` instances. +2. **Provider Selection**: The framework queries `AiGenerationProviderFactory` or directly instantiates `LlamaCppJniAiGenerationProvider` using the resolved config. +3. **Inference Execution**: For a given source file, `AiPromptSupport` constructs a chat message including headers and content; the native backend executes `chatCompleteText`. +4. **Response Processing**: Raw output is passed to `AiCompletionParser` to remove `THINKING_BLOCK_START/END_MARKERS`, returning a clean string or raising an exception on malformed reasoning blocks. + +#### Dependencies +* **Internal Modules**: `net.ladenthin.llama.parameters.ModelParameters`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +* **Native Bindings**: JNI wrappers for llama.cpp (`libllama`), native memory management, and GGUF model loading. +* **Standard Library**: `java.nio.file.Path`, `java.io.IOException`, `java.util.HashMap`, `java.util.List`. + +#### Cross-cutting +* **Immutability Strategy**: Configuration objects (e.g., `LlamaCppJniConfig`) use immutable records to ensure thread-safety without external locks. +* **Null Safety**: Default constructors rely on static constants; null inputs in setters trigger graceful resets rather than immediate exceptions. +* **Error Handling**: Standardizes `IOException` for native failures and reasoning block mismatches; zero-token outputs return blank strings instead of nulls. +* **Testing Strategy**: Includes `MockAiGenerationProvider` to decouple unit tests from native dependencies, ensuring deterministic behavior during development. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..03e89c8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,46 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:33:06Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> Provides local AI document indexing via JNI-backed Llama.cpp inference, configuring model paths, sampling parameters, and field-specific generation rules for Java source code processing. + +#### Purpose +* Orchestrates local LLM text generation using native llama.cpp bindings to index and summarize source files. +* Bridges Maven POM definitions with runtime inference configurations while supporting deterministic mock testing. + +#### Responsibilities +* **Native Inference Management**: Loads GGUF models via JNI, manages chat context windows, and executes token generation with configurable sampling (temperature, top-p). +* **Configuration Resolution**: Maps Maven `AiModelDefinition` entries to executable `AiGenerationConfig` objects and selects file-specific prompt templates. +* **Prompt Construction & Parsing**: Builds chat messages from source files and parses raw model outputs to strip reasoning markers and extract clean answers. +* **Provider Abstraction**: Offers a unified interface for switching between native Llama.cpp inference and deterministic mock providers. + +#### Key units +* `AiGenerationProvider`: Defines the contract for generating text from prompts and source file paths. +* `LlamaCppJniAiGenerationProvider`: Implements native inference via JNI, handling lazy initialization of `LlamaModel` and chat message construction. +* `LlamaCppJniConfig`: Immutable record holding model paths, context limits, sampling parameters, and stop strings. +* `AiCompletionParser`: Extracts clean text from raw completion strings by removing reasoning block markers and handling budget exhaustion. +* `AiGenerationProviderFactory`: Instantiates specific providers (`Mock` or `LlamaCppJni`) based on configuration names. +* `AiModelDefinitionSupport`: Resolves Maven POM `AiModelDefinition` entries into active inference configurations. + +#### Data flow +1. **Configuration Load**: Maven POM defines `AiModelDefinition` objects; `AiModelDefinitionSupport` validates keys and converts them to `AiGenerationConfig` instances. +2. **Provider Selection**: The framework queries `AiGenerationProviderFactory` or directly instantiates `LlamaCppJniAiGenerationProvider` using the resolved config. +3. **Inference Execution**: For a given source file, `AiPromptSupport` constructs a chat message including headers and content; the native backend executes `chatCompleteText`. +4. **Response Processing**: Raw output is passed to `AiCompletionParser` to remove `THINKING_BLOCK_START/END_MARKERS`, returning a clean string or raising an exception on malformed reasoning blocks. + +#### Dependencies +* **Internal Modules**: `net.ladenthin.llama.parameters.ModelParameters`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +* **Native Bindings**: JNI wrappers for llama.cpp (`libllama`), native memory management, and GGUF model loading. +* **Standard Library**: `java.nio.file.Path`, `java.io.IOException`, `java.util.HashMap`, `java.util.List`. + +#### Cross-cutting +* **Immutability Strategy**: Configuration objects (e.g., `LlamaCppJniConfig`) use immutable records to ensure thread-safety without external locks. +* **Null Safety**: Default constructors rely on static constants; null inputs in setters trigger graceful resets rather than immediate exceptions. +* **Error Handling**: Standardizes `IOException` for native failures and reasoning block mismatches; zero-token outputs return blank strings instead of nulls. +* **Testing Strategy**: Includes `MockAiGenerationProvider` to decouple unit tests from native dependencies, ensuring deterministic behavior during development. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..8dd0050 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,46 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:34:50Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> Orchestrates local LLM text generation using native llama.cpp bindings to index and summarize source files, bridging Maven POM definitions with runtime inference configurations. + +#### Purpose +* Orchestrates local LLM text generation using native llama.cpp bindings to index and summarize source files. +* Bridges Maven POM definitions with runtime inference configurations while supporting deterministic mock testing. + +#### Responsibilities +* **Native Inference Management**: Loads GGUF models via JNI, manages chat context windows, and executes token generation with configurable sampling (temperature, top-p). +* **Configuration Resolution**: Maps Maven `AiModelDefinition` entries to executable `AiGenerationConfig` objects and selects file-specific prompt templates. +* **Prompt Construction & Parsing**: Builds chat messages from source files and parses raw model outputs to strip reasoning markers and extract clean answers. +* **Provider Abstraction**: Offers a unified interface for switching between native Llama.cpp inference and deterministic mock providers. + +#### Key units +* `AiGenerationProvider`: Defines the contract for generating text from prompts and source file paths. +* `LlamaCppJniAiGenerationProvider`: Implements native inference via JNI, handling lazy initialization of `LlamaModel` and chat message construction. +* `LlamaCppJniConfig`: Immutable record holding model paths, context limits, sampling parameters, and stop strings. +* `AiCompletionParser`: Extracts clean text from raw completion strings by removing reasoning block markers and handling budget exhaustion. +* `AiGenerationProviderFactory`: Instantiates specific providers (`Mock` or `LlamaCppJni`) based on configuration names. +* `AiModelDefinitionSupport`: Resolves Maven POM `AiModelDefinition` entries into active inference configurations. + +#### Data flow +1. **Configuration Load**: Maven POM defines `AiModelDefinition` objects; `AiModelDefinitionSupport` validates keys and converts them to `AiGenerationConfig` instances. +2. **Provider Selection**: The framework queries `AiGenerationProviderFactory` or directly instantiates `LlamaCppJniAiGenerationProvider` using the resolved config. +3. **Inference Execution**: For a given source file, `AiPromptSupport` constructs a chat message including headers and content; the native backend executes `chatCompleteText`. +4. **Response Processing**: Raw output is passed to `AiCompletionParser` to remove `THINKING_BLOCK_START/END_MARKERS`, returning a clean string or raising an exception on malformed reasoning blocks. + +#### Dependencies +* **Internal Modules**: `net.ladenthin.llama.parameters.ModelParameters`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +* **Native Bindings**: JNI wrappers for llama.cpp (`libllama`), native memory management, and GGUF model loading. +* **Standard Library**: `java.nio.file.Path`, `java.io.IOException`, `java.util.HashMap`, `java.util.List`. + +#### Cross-cutting +* **Immutability Strategy**: Configuration objects (e.g., `LlamaCppJniConfig`) use immutable records to ensure thread-safety without external locks. +* **Null Safety**: Default constructors rely on static constants; null inputs in setters trigger graceful resets rather than immediate exceptions. +* **Error Handling**: Standardizes `IOException` for native failures and reasoning block mismatches; zero-token outputs return blank strings instead of nulls. +* **Testing Strategy**: Includes `MockAiGenerationProvider` to decouple unit tests from native dependencies, ensuring deterministic behavior during development. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/package.ai.md new file mode 100644 index 0000000..e50d403 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/net/package.ai.md @@ -0,0 +1,46 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:36:33Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> Orchestrates local LLM text generation using native llama.cpp bindings to index and summarize source files, bridging Maven POM definitions with runtime inference configurations. + +#### Purpose +* Manages native Java-GGUF inference via JNI to generate text from source files with configurable sampling parameters. +* Resolves Maven `AiModelDefinition` entries into executable `AiGenerationConfig` objects while supporting deterministic mock testing. + +#### Responsibilities +* **Native Inference Management**: Loads GGUF models via JNI, manages chat context windows, and executes token generation with configurable temperature and top-p settings. +* **Configuration Resolution**: Maps Maven `AiModelDefinition` entries to `AiGenerationConfig` instances and selects file-specific prompt templates. +* **Prompt Construction & Parsing**: Builds chat messages from source files and parses raw model outputs to strip reasoning markers and extract clean answers. +* **Provider Abstraction**: Provides a unified interface for switching between native Llama.cpp inference and deterministic mock providers. + +#### Key units +* `AiGenerationProvider`: Defines the contract for generating text from prompts and source file paths. +* `LlamaCppJniAiGenerationProvider`: Implements native inference via JNI, handling lazy initialization of `LlamaModel` and chat message construction. +* `LlamaCppJniConfig`: Immutable record holding model paths, context limits, sampling parameters, and stop strings. +* `AiCompletionParser`: Extracts clean text from raw completion strings by removing reasoning block markers and handling budget exhaustion. +* `AiGenerationProviderFactory`: Instantiates specific providers (`Mock` or `LlamaCppJni`) based on configuration names. +* `AiModelDefinitionSupport`: Resolves Maven POM `AiModelDefinition` entries into active inference configurations. + +#### Data flow +1. **Configuration Load**: Maven POM defines `AiModelDefinition` objects; `AiModelDefinitionSupport` validates keys and converts them to `AiGenerationConfig` instances. +2. **Provider Selection**: The framework queries `AiGenerationProviderFactory` or directly instantiates `LlamaCppJniAiGenerationProvider` using the resolved config. +3. **Inference Execution**: For a given source file, `AiPromptSupport` constructs a chat message including headers and content; the native backend executes `chatCompleteText`. +4. **Response Processing**: Raw output is passed to `AiCompletionParser` to remove `THINKING_BLOCK_START/END_MARKERS`, returning a clean string or raising an exception on malformed reasoning blocks. + +#### Dependencies +* **Internal Modules**: `net.ladenthin.llama.parameters.ModelParameters`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +* **Native Bindings**: JNI wrappers for llama.cpp (`libllama`), native memory management, and GGUF model loading. +* **Standard Library**: `java.nio.file.Path`, `java.io.IOException`, `java.util.HashMap`, `java.util.List`. + +#### Cross-cutting +* **Immutability Strategy**: Configuration objects (e.g., `LlamaCppJniConfig`) use immutable records to ensure thread-safety without external locks. +* **Null Safety**: Default constructors rely on static constants; null inputs in setters trigger graceful resets rather than immediate exceptions. +* **Error Handling**: Standardizes `IOException` for native failures and reasoning block mismatches; zero-token outputs return blank strings instead of nulls. +* **Testing Strategy**: Includes `MockAiGenerationProvider` to decouple unit tests from native dependencies, ensuring deterministic behavior during development. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/package.ai.md new file mode 100644 index 0000000..d1a40f2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/java/package.ai.md @@ -0,0 +1,46 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:38:18Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> Manages native Java-GGUF inference via JNI to generate text from source files with configurable sampling parameters. + +#### Purpose +* Orchestrates local LLM text generation using native `llama.cpp` bindings to index and summarize source files. +* Bridges Maven POM definitions (`AiModelDefinition`) with runtime inference configurations (`AiGenerationConfig`). + +#### Responsibilities +* **Native Inference Management**: Loads GGUF models via JNI, manages chat context windows, and executes token generation with configurable temperature and top-p settings. +* **Configuration Resolution**: Maps Maven `AiModelDefinition` entries to `AiGenerationConfig` instances and selects file-specific prompt templates. +* **Prompt Construction & Parsing**: Builds chat messages from source files and parses raw model outputs to strip reasoning markers and extract clean answers. +* **Provider Abstraction**: Provides a unified interface for switching between native Llama.cpp inference and deterministic mock providers. + +#### Key units +* `AiGenerationProvider`: Defines the contract for generating text from prompts and source file paths. +* `LlamaCppJniAiGenerationProvider`: Implements native inference via JNI, handling lazy initialization of `LlamaModel` and chat message construction. +* `LlamaCppJniConfig`: Immutable record holding model paths, context limits, sampling parameters, and stop strings. +* `AiCompletionParser`: Extracts clean text from raw completion strings by removing reasoning block markers and handling budget exhaustion. +* `AiGenerationProviderFactory`: Instantiates specific providers (`Mock` or `LlamaCppJni`) based on configuration names. +* `AiModelDefinitionSupport`: Resolves Maven POM `AiModelDefinition` entries into active inference configurations. + +#### Data flow +1. **Configuration Load**: Maven POM defines `AiModelDefinition` objects; `AiModelDefinitionSupport` validates keys and converts them to `AiGenerationConfig` instances. +2. **Provider Selection**: The framework queries `AiGenerationProviderFactory` or directly instantiates `LlamaCppJniAiGenerationProvider` using the resolved config. +3. **Inference Execution**: For a given source file, `AiPromptSupport` constructs a chat message including headers and content; the native backend executes `chatCompleteText`. +4. **Response Processing**: Raw output is passed to `AiCompletionParser` to remove `THINKING_BLOCK_START/END_MARKERS`, returning a clean string or raising an exception on malformed reasoning blocks. + +#### Dependencies +* **Internal Modules**: `net.ladenthin.llama.parameters.ModelParameters`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +* **Native Bindings**: JNI wrappers for llama.cpp (`libllama`), native memory management, and GGUF model loading. +* **Standard Library**: `java.nio.file.Path`, `java.io.IOException`, `java.util.HashMap`, `java.util.List`. + +#### Cross-cutting +* **Immutability Strategy**: Configuration objects (e.g., `LlamaCppJniConfig`) use immutable records to ensure thread-safety without external locks. +* **Null Safety**: Default constructors rely on static constants; null inputs in setters trigger graceful resets rather than immediate exceptions. +* **Error Handling**: Standardizes `IOException` for native failures and reasoning block mismatches; zero-token outputs return blank strings instead of nulls. +* **Testing Strategy**: Includes `MockAiGenerationProvider` to decouple unit tests from native dependencies, ensuring deterministic behavior during development. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/package.ai.md new file mode 100644 index 0000000..f76b3b7 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/main/package.ai.md @@ -0,0 +1,46 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:40:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Orchestrates local Large Language Model (LLM) text generation and summarization using native C++ bindings via JNI, bridging Maven model definitions with runtime inference configurations. + +#### Purpose +* Provides a unified interface for generating text from source files using configurable native `llama.cpp` inference or deterministic mock providers. +* Resolves Maven `AiModelDefinition` entries into runtime `AiGenerationConfig` and manages chat context windows and sampling parameters. + +#### Responsibilities +* **Native Inference Management**: Loads GGUF models via JNI, initializes `LlamaModel`, and executes token generation with dynamic temperature and top-p settings. +* **Configuration Resolution**: Maps Maven POM artifacts to immutable inference configs and selects file-specific prompt templates. +* **Prompt Engineering & Parsing**: Constructs chat messages from source content and strips reasoning block markers (`THINKING_BLOCK_START/END_MARKERS`) from raw outputs. +* **Provider Abstraction**: Switches between native `LlamaCppJni` and `Mock` providers based on configuration names without changing the application logic. + +#### Key units +* `AiGenerationProvider`: Core interface defining contracts for prompt execution, source file paths, and output extraction. +* `LlamaCppJniAiGenerationProvider`: Implements native inference logic, handling lazy initialization of `LlamaModel` and chat message construction. +* `LlamaCppJniConfig`: Immutable record specifying model paths, context limits, sampling parameters, and stop strings. +* `AiCompletionParser`: Extracts clean text by removing reasoning markers and handling budget exhaustion or malformed blocks. +* `AiGenerationProviderFactory`: Factory class instantiating specific providers (`Mock` or `LlamaCppJni`) based on configuration keys. +* `AiModelDefinitionSupport`: Utility resolving Maven `AiModelDefinition` entries into active inference configurations. + +#### Data flow +1. **Configuration Initialization**: Maven POM defines `AiModelDefinition` objects; `AiModelDefinitionSupport` validates keys and converts them to `AiGenerationConfig`. +2. **Provider Instantiation**: Framework queries `AiGenerationProviderFactory` or directly constructs `LlamaCppJniAiGenerationProvider` using the resolved config. +3. **Inference Execution**: `AiPromptSupport` builds chat messages with headers and source content; native backend calls `chatCompleteText`. +4. **Output Extraction**: Raw completion string flows to `AiCompletionParser`, which removes reasoning block markers and returns a clean string or raises an exception on errors. + +#### Dependencies +* **Native Bindings**: JNI wrappers for `libllama` (llama.cpp), native memory management, and GGUF model loading libraries. +* **Internal Modules**: `net.ladenthin.llama.parameters.ModelParameters`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +* **Standard Library**: `java.nio.file.Path`, `java.io.IOException`, `java.util.HashMap`, `java.util.List`. + +#### Cross-cutting +* **Immutability & Thread Safety**: Configuration objects (e.g., `LlamaCppJniConfig`) utilize immutable records to ensure thread-safety without external locks. +* **Null Safety Patterns**: Default constructors rely on static constants; null inputs in setters trigger graceful resets rather than immediate exceptions. +* **Error Handling Strategy**: Standardizes `IOException` for native failures and reasoning block mismatches; zero-token outputs return blank strings instead of nulls. +* **Testing Architecture**: Includes `MockAiGenerationProvider` to decouple unit tests from native dependencies, ensuring deterministic behavior during development. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/package.ai.md new file mode 100644 index 0000000..32deb30 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/package.ai.md @@ -0,0 +1,46 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:41:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Orchestrates local Large Language Model (LLM) text generation and summarization using native C++ bindings via JNI, bridging Maven model definitions with runtime inference configurations. + +#### Purpose +* Provides a unified interface for generating text from source files using configurable native `llama.cpp` inference or deterministic mock providers. +* Resolves Maven `AiModelDefinition` entries into runtime `AiGenerationConfig` and manages chat context windows and sampling parameters. + +#### Responsibilities +* **Native Inference Management**: Loads GGUF models via JNI, initializes `LlamaModel`, and executes token generation with dynamic temperature and top-p settings. +* **Configuration Resolution**: Maps Maven POM artifacts to immutable inference configs and selects file-specific prompt templates. +* **Prompt Engineering & Parsing**: Constructs chat messages from source content and strips reasoning block markers (`THINKING_BLOCK_START/END_MARKERS`) from raw outputs. +* **Provider Abstraction**: Switches between native `LlamaCppJni` and `Mock` providers based on configuration names without changing the application logic. + +#### Key units +* `AiGenerationProvider`: Core interface defining contracts for prompt execution, source file paths, and output extraction. +* `LlamaCppJniAiGenerationProvider`: Implements native inference logic, handling lazy initialization of `LlamaModel` and chat message construction. +* `LlamaCppJniConfig`: Immutable record specifying model paths, context limits, sampling parameters, and stop strings. +* `AiCompletionParser`: Extracts clean text by removing reasoning markers and handling budget exhaustion or malformed blocks. +* `AiGenerationProviderFactory`: Factory class instantiating specific providers (`Mock` or `LlamaCppJni`) based on configuration keys. +* `AiModelDefinitionSupport`: Utility resolving Maven `AiModelDefinition` entries into active inference configurations. + +#### Data flow +1. **Configuration Initialization**: Maven POM defines `AiModelDefinition` objects; `AiModelDefinitionSupport` validates keys and converts them to `AiGenerationConfig`. +2. **Provider Instantiation**: Framework queries `AiGenerationProviderFactory` or directly constructs `LlamaCppJniAiGenerationProvider` using the resolved config. +3. **Inference Execution**: `AiPromptSupport` builds chat messages with headers and source content; native backend calls `chatCompleteText`. +4. **Output Extraction**: Raw completion string flows to `AiCompletionParser`, which removes reasoning block markers and returns a clean string or raises an exception on errors. + +#### Dependencies +* **Native Bindings**: JNI wrappers for `libllama` (llama.cpp), native memory management, and GGUF model loading libraries. +* **Internal Modules**: `net.ladenthin.llama.parameters.ModelParameters`, `lombok.ToString`, `org.jspecify.annotations.Nullable`. +* **Standard Library**: `java.nio.file.Path`, `java.io.IOException`, `java.util.HashMap`, `java.util.List`. + +#### Cross-cutting +* **Immutability & Thread Safety**: Configuration objects (e.g., `LlamaCppJniConfig`) utilize immutable records to ensure thread-safety without external locks. +* **Null Safety Patterns**: Default constructors rely on static constants; null inputs in setters trigger graceful resets rather than immediate exceptions. +* **Error Handling Strategy**: Standardizes `IOException` for native failures and reasoning block mismatches; zero-token outputs return blank strings instead of nulls. +* **Testing Architecture**: Includes `MockAiGenerationProvider` to decouple unit tests from native dependencies, ensuring deterministic behavior during development. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/project.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/project.ai.md new file mode 100644 index 0000000..f1e3ad7 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v1/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: 632FEE1C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:43:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The project orchestrates local Large Language Model text generation using native C++ bindings via JNI to index and summarize Java source files while bridging Maven POM definitions with runtime inference configurations. This architecture manages native Java-GGUF inference through a pluggable Llama.cpp backend that enforces deterministic mock testing and supports configurable sampling parameters alongside context window management. Field-specific generation rules are applied during the processing of Java code to produce accurate summaries, ensuring seamless integration between model definitions and file extension mappings for AI document indexing. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Provides Llama.cpp inference configuration and field generation selection logic for Maven plugins, mapping file extensions to AI models while managing context windows, sampling parameters, and retry policies. +- main/java/net/ladenthin/maven/llamacpp/aiindex — Provides local AI document indexing via JNI-backed Llama.cpp inference, configuring model paths, sampling parameters, and field-specific generation rules for Java source code processing. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Provides a pluggable local LLM inference backend using JNI-backed llama.cpp for AI document processing, supporting deterministic mock testing and configurable sampling parameters. +- main/java/net/ladenthin/maven/llamacpp — Provides local AI document indexing via JNI-backed Llama.cpp inference, configuring model paths, sampling parameters, and field-specific generation rules for Java source code processing. +- main/java/net/ladenthin/maven — Provides local AI document indexing via JNI-backed Llama.cpp inference, configuring model paths, sampling parameters, and field-specific generation rules for Java source code processing. +- main/java/net/ladenthin — Orchestrates local LLM text generation using native llama.cpp bindings to index and summarize source files, bridging Maven POM definitions with runtime inference configurations. +- main/java/net — Orchestrates local LLM text generation using native llama.cpp bindings to index and summarize source files, bridging Maven POM definitions with runtime inference configurations. +- main/java — Manages native Java-GGUF inference via JNI to generate text from source files with configurable sampling parameters. +- main — Orchestrates local Large Language Model (LLM) text generation and summarization using native C++ bindings via JNI, bridging Maven model definitions with runtime inference configurations. +- . — Orchestrates local Large Language Model (LLM) text generation and summarization using native C++ bindings via JNI, bridging Maven model definitions with runtime inference configurations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..8250329 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,48 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:44:05Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines a mutable Maven plugin configuration POJO linking a prompt template key to an AI model definition for single-field-generation steps in the Llama.cpp index builder. + +#### Purpose +- Represents configuration for one field-generation step within the `` list of the Maven plugin POM. +- Associates a specific prompt template (`promptKey`) with an AI model definition (`aiDefinitionKey`) to drive generation calls on indexed files or packages. + +#### Type +public class AiFieldGenerationConfig extends Object; annotated with @ToString; uses JavaBeans pattern with mutable fields and setters for Maven reflection injection. + +#### Input +- `String promptKey`: Key referencing a prompt template in `AiPromptDefinition`. +- `String aiDefinitionKey`: Key referencing an AI model definition in `AiModelDefinition`. +- `Collection fileExtensions`: Optional list of source file extensions (.java, .sql) that restrict applicability; null or empty acts as fallback. + +#### Output +- Modifies internal state: `promptKey`, `aiDefinitionKey`, and `fileExtensions` fields. +- Returns unmodifiable `List` for `getFileExtensions()` if the list is not null. + +#### Core logic +- Validates and stores prompt template key, AI model definition key, and optional file extension filters. +- Ensures immutability of returned collection via `Collections.unmodifiableList`. +- Converts input `Collection` to `ArrayList` defensively during `setFileExtensions`. + +#### Public API +- `getPromptKey()`: Retrieves the prompt template identifier. +- `setPromptKey(String)`: Assigns a new prompt template identifier. +- `getAiDefinitionKey()`: Retrieves the AI model definition identifier. +- `setAiDefinitionKey(String)`: Assigns a new AI model definition identifier. +- `getFileExtensions()`: Retrieves the list of file extensions or null for fallback. +- `setFileExtensions(Collection)`: Updates the list of file extensions, creating a defensive copy. + +#### Dependencies +- AiModelDefinition +- AiPromptDefinition +- AiFieldGenerationSelector +- java.util.ArrayList +- java.util.Collection +- java.util.Collections +- java.util.List diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..229db60 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,44 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T18:45:32Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the appropriate AI field generation configuration for a given source file based on its extension or a configured fallback. + +#### Purpose +- Maps source file names (e.g., `.java`, `.sql`) to specific `AiFieldGenerationConfig` instances. +- Supports language-specific prompts while maintaining a single loaded AI model. + +#### Type +public final class AiFieldGenerationSelector; @ToString annotation. + +#### Input +- `Iterable configs`: Ordered list of configured field generations (null entries skipped). +- `String fileName`: Source file name (e.g., `Foo.java`). + +#### Output +- `@Nullable AiFieldGenerationConfig`: The first extension-matching config, or the first extension-agnostic fallback, or `null` if none match. + +#### Core logic +- Iterates through `configs` in declaration order. +- Skips null entries. +- Checks if an entry has non-empty file extensions; if yes, returns the first entry where `fileName.endsWith(extension)`. +- If no extension matches, stores the entry as a fallback if not already set. +- Returns the stored fallback only if the loop completes without finding an extension match. + +#### Public API +`selectForFileName(Iterable configs, String fileName) -> @Nullable AiFieldGenerationConfig` — selects matching config or fallback. + +#### Dependencies +`AiFieldGenerationConfig`, `List`, `String`, `Iterable`. + +#### Exceptions / Errors +- Returns `null` if no config matches and no fallback is configured. +- Handles null entries in the `configs` list by skipping them. + +#### Concurrency +None; logic is single-threaded and stateless. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..e0dc5bc --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,76 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:46:32Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Mutable configuration carrier for AI generation parameters including model paths, sampling settings, retry policies, and input limits between Maven plugin and AI provider. + +#### Purpose +- Holds all configurable parameters for a single AI generation step (model path, sampling, retries, input limits). +- Provides Lombok-generated `toString()` for build logs while remaining mutable via setters managed by the Maven plugin. + +#### Type +- public class; extends Object; implements nothing; annotated with @ToString; fields initialized to DEFAULT_* constants. + +#### Input +- Constructor arguments: none (no-arg constructor uses defaults). +- Setter parameters: modelPath (String), contextSize (int), maxOutputTokens (int), temperature (float), threads (int), charsPerToken (int), maxInputChars (int), warnOnTrim (boolean), maxRetries (int), retryTemperatureIncrement (float), topP (float), topK (int), repeatPenalty (float), chatTemplateEnableThinking (boolean), stopStrings (@Nullable List). + +#### Output +- Getter returns: modelPath, contextSize, maxOutputTokens, temperature, threads, charsPerToken, maxInputChars, warnOnTrim, maxRetries, retryTemperatureIncrement, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings (unmodifiable view). +- State mutations via setters; no resource writes or side effects. + +#### Core logic +- Defaults for all numeric and boolean fields are initialized to static final constants upon instantiation. +- `getStopStrings()` safely returns an unmodifiable list or null based on `stopStrings` state. +- `setStopStrings()` normalizes null input to an empty ArrayList before assignment. +- No algorithmic computation; pure data storage and retrieval. + +#### Public API +- getModelPath() -> String: GGUF model file path. +- setModelPath(String) -> void: sets GGUF model file path. +- getContextSize() -> int: context window size in tokens. +- setContextSize(int) -> void: sets context window size in tokens. +- getMaxOutputTokens() -> int: max output tokens per inference call. +- setMaxOutputTokens(int) -> void: sets max output tokens per inference call. +- getTemperature() -> float: sampling temperature (lower = deterministic). +- setTemperature(float) -> void: sets sampling temperature. +- getThreads() -> int: CPU threads for llama.cpp inference. +- setThreads(int) -> void: sets CPU threads for inference. +- getCharsPerToken() -> int: chars per token ratio; 0 disables auto calc. +- setCharsPerToken(int) -> void: sets chars per token (0 disables auto calc). +- getMaxInputChars() -> int: max input characters fed to prompt. +- setMaxInputChars(int) -> void: sets max input characters fed to prompt. +- isWarnOnTrim() -> boolean: whether trim warnings are emitted. +- setWarnOnTrim(boolean) -> void: enables/disables trim warnings. +- getMaxRetries() -> int: max retry attempts on empty-body responses. +- setMaxRetries(int) -> void: sets max retry attempts on empty-body responses. +- getRetryTemperatureIncrement() -> float: temp increment per retry attempt. +- setRetryTemperatureIncrement(float) -> void: sets temp increment per retry attempt. +- getTopP() -> float: nucleus-sampling probability threshold. +- setTopP(float) -> void: sets nucleus-sampling probability threshold. +- getTopK() -> int: top-k sampling limit. +- setTopK(int) -> void: sets top-k sampling limit. +- getRepeatPenalty() -> float: repetition penalty factor. +- setRepeatPenalty(float) -> void: sets repetition penalty factor. +- isChatTemplateEnableThinking() -> boolean: whether chat-template thinking mode is enabled. +- setChatTemplateEnableThinking(boolean) -> void: enables/disables chat-template thinking mode. +- getStopStrings() -> List: unmodifiable list of stop strings. +- setStopStrings(List) -> void: sets list of stop strings (null clears). + +#### Dependencies +- java.util.ArrayList +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- None; no checked exceptions or null-handling logic beyond standard field assignment. + +#### Concurrency +- Mutable state; not thread-safe; managed by Maven plugin framework via setters. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..fc162cb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,38 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:49:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines enumeration values distinguishing AI generation scope between a single source file and an entire package. + +#### Purpose +- Represents operation modes for generating field summaries in AI processing. +- Differentiates granularity: `FILE_SUMMARY` for individual files vs `PACKAGE_SUMMARY` for packages. + +#### Type +enum; no extends/implements; notable annotations (Javadoc). + +#### Input +None. + +#### Output +None. + +#### Core logic +None. + +#### Public API +None. + +#### Dependencies +None. + +#### Exceptions / Errors +None. + +#### Concurrency +None. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..db526f7 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,76 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:50:13Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures LLM model parameters for a Maven plugin to define reusable AI generation settings. + +#### Purpose +- Defines a mutable JavaBean POJO to hold a unique key and all configurable parameters for a specific LLM model in the plugin system. +- Serves as a single source of truth that can be reused across multiple field-generation entries and plugin goals. + +#### Type +Class; extends `Object`; implements no interfaces; annotated with `@ToString` and `@Nullable` for fields; mutable via reflection-safe setters. + +#### Input +Constructor parameters: None (defaults applied). +Fields: `key`, `modelPath`, `contextSize`, `maxOutputTokens`, `temperature`, `threads`, `charsPerToken`, `warnOnTrim`, `maxRetries`, `retryTemperatureIncrement`, `topP`, `topK`, `repeatPenalty`, `chatTemplateEnableThinking`, `stopStrings`. + +#### Output +Returns: String (key, modelPath), int/float (contextSize, maxOutputTokens, temperature, threads, charsPerToken, maxRetries, retryTemperatureIncrement, topP, topK, repeatPenalty, chatTemplateEnableThinking), boolean (warnOnTrim, chatTemplateEnableThinking), List (stopStrings). +State: Modifies internal fields via setters; no external resources written or consumed. + +#### Core logic +- Initializes instance variables with default values from `AiGenerationConfig` if not explicitly set by the user. +- Stores unique identifiers (`key`) and file paths (`modelPath`) for model resolution. +- Manages inference tuning parameters including context window, output limits, sampling strategies (temperature, top-p, top-k), and repetition penalties. +- Configures runtime behavior regarding source code trimming warnings, retry logic for empty responses, and chat-template thinking mode. +- Handles stop strings by converting collections to unmodifiable lists upon retrieval to prevent external modification. + +#### Public API +`getKey() -> String`: Retrieves the unique lookup identifier. +`setKey(String) -> void`: Assigns a new unique identifier. +`getModelPath() -> String`: Retrieves the path to the GGUF model file. +`setModelPath(String) -> void`: Sets the path to the model file. +`getContextSize() -> int`: Retrieves the context window size in tokens. +`setContextSize(int) -> void`: Sets the context window size. +`getMaxOutputTokens() -> int`: Retrieves max output tokens per inference call. +`setMaxOutputTokens(int) -> void`: Sets max output tokens limit. +`getTemperature() -> float`: Retrieves base sampling temperature. +`setTemperature(float) -> void`: Sets base sampling temperature. +`getThreads() -> int`: Retrieves CPU thread count for inference. +`setThreads(int) -> void`: Sets number of threads for llama.cpp inference. +`getCharsPerToken() -> int`: Retrieves characters per token ratio for auto-calculation. +`setCharsPerToken(int) -> void`: Sets chars per token ratio (0 disables auto-calc). +`isWarnOnTrim() -> boolean`: Checks if warnings are emitted on source trimming. +`setWarnOnTrim(boolean) -> void`: Enables or disables trim warnings. +`getMaxRetries() -> int`: Retrieves max retry attempts for empty bodies. +`setMaxRetries(int) -> void`: Sets max retries (0 disables). +`getRetryTemperatureIncrement() -> float`: Gets temperature increment per retry. +`setRetryTemperatureIncrement(float) -> void`: Sets retry temperature increment. +`getTopP() -> float`: Retrieves nucleus-sampling probability threshold. +`setTopP(float) -> void`: Sets top-p sampling threshold. +`getTopK() -> int`: Retrieves top-k sampling limit. +`setTopK(int) -> void`: Sets top-k sampling limit. +`getRepeatPenalty() -> float`: Retrieves repetition penalty factor. +`setRepeatPenalty(float) -> void`: Sets repetition penalty. +`isChatTemplateEnableThinking() -> boolean`: Checks if chat-template thinking mode is enabled. +`setChatTemplateEnableThinking(boolean) -> void`: Toggles chat-template thinking mode. +`getStopStrings() -> List`: Retrieves immutable list of generation stop strings. +`setStopStrings(Collection) -> void`: Sets collection of stop strings. + +#### Dependencies +`AiGenerationConfig`, `AiModelDefinitionSupport`, `net.ladenthin.llama.parameters.ModelParameters`. + +#### Exceptions / Errors +- Returns `null` for optional fields (`key`, `modelPath`, `stopStrings`) if not set. +- No checked exceptions thrown; unchecked exceptions handled internally or propagated by caller. +- Null checks performed on `stopStrings` before conversion to unmodifiable list. + +#### Concurrency +- Mutable state managed via setters; safe for single-threaded configuration injection by Maven plugin framework. +- `getStopStrings()` returns an unmodifiable view to prevent concurrent modification from external code. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..a704d7e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,44 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:53:20Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key into ready-to-use generation configurations for Maven Mojo execution. + +#### Purpose +* Converts `AiModelDefinition` entries from plugin configuration into executable `AiGenerationConfig` objects. +* Enforces strict validation that every definition key is non-null to fail fast at build time. + +#### Type +public final class AiModelDefinitionSupport; extends Object; implements none; annotated with @ToString; uses Lombok. + +#### Input +Constructor parameter: `List definitions` (may be null or empty). + +#### Output +Returns `AiGenerationConfig` objects for lookup by key; constructs new instances via internal conversion logic. + +#### Core logic +* Validates that all `AiModelDefinition` entries in the input list have non-null keys, throwing `NullPointerException` if not. +* Presizes an internal `HashMap` to avoid rehashing during population. +* Iterates through definitions, extracting values via `toConfig()` which clones fields into a new `AiGenerationConfig`. +* Performs key-based lookup in the map, throwing `IllegalArgumentException` if a requested key is missing. + +#### Public API +`AiModelDefinitionSupport(List definitions) -> void` - Constructs lookup table from definitions. +`AiGenerationConfig getConfig(String key) -> AiGenerationConfig` - Retrieves config for a specific model key. + +#### Dependencies +`AiModelDefinition`, `AiGenerationConfig`, `Java8CompatibilityHelper`, `HashMap`, `List`, `Map`, `Objects`. + +#### Exceptions / Errors +* Throws `NullPointerException` if any definition entry has a null key (contract enforcement). +* Throws `IllegalArgumentException` with message "Missing AI model definition for key: " if lookup fails. +* Null input list is handled gracefully, resulting in an empty map. + +#### Concurrency +No explicit concurrency logic; uses mutable HashMap populated in constructor (thread-safety not guaranteed during construction or concurrent access). diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..a9ac684 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,50 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:00:38Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Executes AI-driven field generation for Maven plugin builds by mapping source file extensions to prompt templates and model configurations. + +#### Purpose +- Orchestrates Llama.cpp-based code analysis by resolving file extensions to specific AI generation prompts and model parameters. +- Manages configuration lifecycles for single-field steps, distinguishing between file-level and package-level generation scopes. + +#### Responsibilities +- **Configuration Management**: Stores and validates prompt keys, model definitions, and extension filters within `AiFieldGenerationConfig`. +- **Selector Logic**: Maps source file names to appropriate generation configurations via `AiFieldGenerationSelector`, handling fallbacks for unlisted extensions. +- **Parameter Resolution**: Converts high-level `AiModelDefinition` entries into executable inference parameters via `AiModelDefinitionSupport`. +- **Scope Definition**: Enumerates generation granularity modes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`) to control output scope. + +#### Key units +- `AiFieldGenerationConfig`: Links prompt templates and model definitions to specific file extension filters. +- `AiFieldGenerationSelector`: Selects the correct generation config based on source file extension or fallback rules. +- `AiGenerationConfig`: Holds mutable runtime parameters for inference (context size, temperature, threads). +- `AiModelDefinition`: Defines reusable model settings keyed by unique identifiers for plugin reflection. +- `AiModelDefinitionSupport`: Resolves definition keys to active generation configurations via a lookup map. +- `AiGenerationKind`: Enumerates operation scopes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +- User POM configuration defines `AiFieldGenerationConfig` entries mapping extensions to prompts/models. +- `AiFieldGenerationSelector` iterates these configs during build execution to match incoming source files. +- Matching files trigger generation calls using parameters resolved from `AiModelDefinition` via `AiModelDefinitionSupport`. +- Output is determined by the scope defined in `AiGenerationKind` (file vs package). + +#### Dependencies +- Internal: `AiPromptDefinition`, `net.ladenthin.llama.parameters.ModelParameters`, `Java8CompatibilityHelper`. +- External: Maven Plugin reflection framework, Llama.cpp native bindings (via model paths), standard Java collections. + +#### Cross-cutting +- **Immutable Views**: All collection outputs (`getFileExtensions()`, `getStopStrings()`) return unmodifiable lists to prevent external mutation. +- **Defensive Copying**: List modifications (e.g., `setFileExtensions`) create defensive copies before assignment. +- **Null Safety**: Selectors and configs handle null entries in configuration lists gracefully by skipping or falling back. +- **Thread-Safety**: Configuration objects are mutable but managed by the single-threaded Maven Mojo lifecycle; no explicit locking required. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..78b1b8f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:05:31Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> Orchestrates local Llama.cpp inference and field generation for Maven plugin builds by mapping source files to AI prompts and sanitizing reasoning outputs. + +#### Purpose +- Enables local LLM inference via JNI using GGUF models while stripping internal chain-of-thought reasoning for clean indexing. +- Orchestrates AI-driven field generation for Maven builds by resolving file extensions to prompt templates and model configurations. + +#### Responsibilities +- **Local Inference Engine**: Executes text generation through `LlamaCppJniAiGenerationProvider` using native bindings, handling lazy model loading and parameter construction. +- **Prompt & Model Management**: Maps source file extensions to specific prompts via `AiFieldGenerationSelector` and resolves model definitions for inference parameters. +- **Data Sanitization**: Parses raw completion text to remove internal thinking blocks before storage or indexing. +- **Configuration Lifecycle**: Manages runtime settings for context size, temperature, and threads across file-level and package-level generation scopes. + +#### Key units +- `LlamaCppJniAiGenerationProvider`: Implements native inference via `LlamaModel` and `InferenceParameters`. +- `AiCompletionParser`: Strips `THINKING_BLOCK` markers from raw responses to return clean answers. +- `AiFieldGenerationConfig`: Links prompt templates and model definitions to file extension filters. +- `AiGenerationProviderFactory`: Selects and instantiates providers (`Mock`, `LlamaCppJni`) by name string. +- `AiModelDefinitionSupport`: Resolves definition keys to active generation configurations via lookup maps. +- `AiGenerationKind`: Enumerates operation scopes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +1. User POM configuration defines `AiFieldGenerationConfig` mapping extensions to prompts/models. +2. `AiFieldGenerationSelector` matches incoming source files against configs during build execution. +3. `AiGenerationProviderFactory` selects the appropriate provider (e.g., `LlamaCppJni`) based on request settings. +4. Native inference executes via `chatCompleteText()`, producing raw completion containing potential reasoning blocks. +5. `AiCompletionParser` sanitizes the output by stripping internal thinking markers. +6. Cleaned text is returned for AI indexing or stored in the package index. + +#### Dependencies +- **Internal**: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `LlamaCppJniConfig`, `AiPromptSupport`. +- **External Modules**: `net.ladenthin.llama.parameters.ModelParameters`, native `LlamaModel` (GGUF), `Java8CompatibilityHelper`, standard Java collections. + +#### Cross-cutting +- **Immutability**: Configuration records (`LlamaCppJniConfig`) use final fields and defensive copying to ensure thread safety. +- **Null Safety**: Selectors handle null entries in configuration lists gracefully by skipping or falling back. +- **Resource Management**: Native model handles are released via `AutoCloseable` pattern using `close()`. +- **Error Handling**: Centralized usage of `IOException` for native failures and incomplete thinking blocks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..12d3ab4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,42 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:54:38Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract the model answer by stripping Gemma-4 internal thinking blocks before storing in an AI index file. + +#### Purpose +* Strips internal reasoning from Gemma-4 chain-of-thought responses. +* Returns clean model answers for AI index persistence. + +#### Type +Class; extends Object; uses @ToString annotation. + +#### Input +String response (raw completion text, may be null). + +#### Output +String cleaned answer text; throws IOException on incomplete thinking blocks. + +#### Core logic +* Checks if input response is null and returns empty string. +* Searches for THINKING_BLOCK_END_MARKER to locate end of internal reasoning. +* If end marker found, returns substring after it trimmed. +* If start marker exists but end marker is missing, throws IOException. +* If no markers found, returns trimmed original response. + +#### Public API +parseCompletion(String) -> String <=6-word purpose clause: Strips thinking block and returns clean answer. + +#### Dependencies +java.io.IOException, net.ladenthin.maven.llamacpp.aiindex.provider.AiCompletionParser. + +#### Exceptions / Errors +IOException thrown if THINKING_BLOCK_START_MARKER appears without THINKING_BLOCK_END_MARKER due to token budget exhaustion. + +#### Concurrency +Non-final class designed for subclassing and mocking; logic is stateless and thread-safe. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..1dc2d0f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,46 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:55:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a pluggable interface for generating AI text from requests, supporting local models and test mocks. + +#### Purpose +- Defines the contract for generating text from `AiGenerationRequest` objects. +- Supports both live backend implementations and mock providers for testing. + +#### Type +Interface; extends `AutoCloseable`. + +#### Input +- `AiGenerationRequest`: Contains prompt key, source file, source text, and current header. +- `float temperatureOverride`: Sampling temperature parameter (optional). + +#### Output +- `String`: Generated text (never null, may be blank). +- Side effect: Resources released via `close()`. + +#### Core logic +- Delegates `generate(AiGenerationRequest)` to underlying backend or mock implementation. +- Applies optional `temperatureOverride` if implemented; otherwise ignores it. +- Handles cleanup and error propagation via `AutoCloseable` contract. + +#### Public API +- `generate(AiGenerationRequest request) -> String`: Generates text using default parameters. +- `generate(AiGenerationRequest request, float temperatureOverride) -> String`: Generates text with overridden temperature. +- `close()`: Releases resources. + +#### Dependencies +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `java.io.IOException` + +#### Exceptions / Errors +- Throws `IOException` if underlying provider fails or during closure. +- Returns blank string if model produces no tokens. + +#### Concurrency +- Interface does not explicitly declare thread-safety; implementations must ensure safety. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..4e8c5cc --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,44 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:56:25Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an `AiGenerationProvider` implementation by name string within the Llama.cpp AI indexing domain. + +#### Purpose +- Instantiates either a `MockAiGenerationProvider` or `LlamaCppJniAiGenerationProvider` based on provider key. +- Validates provider names and handles default fallback behavior for blank inputs. + +#### Type +public class AiGenerationProviderFactory; extends Object; implements none; annotated with @ToString. + +#### Input +- `providerName`: String (key identifier, defaults to "mock" if null/blank). +- `llamaConfig`: `LlamaCppJniConfig` object for JNI provider configuration. +- `promptSupport`: `AiPromptSupport` object for prompt lookup support. + +#### Output +- Returns an `AiGenerationProvider` instance (`MockAiGenerationProvider` or `LlamaCppJniAiGenerationProvider`). +- Throws `IllegalArgumentException` if `providerName` is unrecognized. + +#### Core logic +- Checks if `providerName` is null or blank; if so, instantiates `MockAiGenerationProvider`. +- Switches on `providerName`: returns `MockAiGenerationProvider` for "mock". +- Switches on `providerName`: instantiates `LlamaCppJniAiGenerationProvider` with provided `llamaConfig` and `promptSupport`. +- Throws exception in default case for unsupported names. + +#### Public API +`create(String providerName, LlamaCppJniConfig llamaConfig, AiPromptSupport promptSupport) -> AiGenerationProvider` + +#### Dependencies +`AiGenerationProvider`, `MockAiGenerationProvider`, `LlamaCppJniAiGenerationProvider`, `Java8CompatibilityHelper`, `LlamaCppJniConfig`, `AiPromptSupport`. + +#### Exceptions / Errors +- Throws `IllegalArgumentException` with message "Unsupported AI provider: " + providerName. + +#### Concurrency +No concurrency indicators; uses standard single-threaded instantiation logic. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..dee4644 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,57 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:57:23Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides a local Java implementation for generating text using GGUF models via the llama.cpp JNI backend. + +#### Purpose +- Implements `AiGenerationProvider` to run LLM inference locally. +- Manages lazy loading and caching of native GGUF model handles. + +#### Type +Final class; implements `AiGenerationProvider` and `AutoCloseable`; annotated with `@ToString`. + +#### Input +- `LlamaCppJniConfig`: model path, context size, threads, chat template settings. +- `AiPromptSupport`: prompt builder for request rendering. +- `AiGenerationRequest`: input data for generation. +- `float temperatureOverride`: optional temperature override (defaulting to config). + +#### Output +- `String`: generated text completion. +- Side effect: loads native `LlamaModel` handle on first use if not cached; releases handle in `close()`. + +#### Core logic +- Validates and stores configuration and prompt support. +- Lazily instantiates `LlamaModel` using config parameters only when `generate()` is called. +- Constructs inference parameters (messages, chat template, temperature, topP, topK, stop strings) from request and config. +- Executes `model().chatCompleteText()` to obtain completion tokens. +- Parses the raw completion text via `AiCompletionParser` into a clean string result. + +#### Public API +- `LlamaCppJniAiGenerationProvider(LlamaCppJniConfig, AiPromptSupport)`: creates provider with config and prompt support. +- `String generate(AiGenerationRequest)`: generates text using default temperature. +- `String generate(AiGenerationRequest, float)`: generates text with optional temperature override. +- `void close()`: releases native model resources. + +#### Dependencies +- `LlamaCppJniConfig` +- `AiPromptSupport` +- `AiCompletionParser` +- `LlamaModel` +- `InferenceParameters` +- `AiGenerationRequest` +- `Pair` + +#### Exceptions / Errors +- Throws `IOException` during generation if native call fails. +- Throws `NullPointerException` if config or prompt support is null (via `Objects.requireNonNull`). + +#### Concurrency +- Not thread-safe; `LlamaModel` handle must be accessed sequentially. +- Uses immutable builder pattern for inference parameters to avoid concurrency issues during configuration setup. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..854ac5a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,50 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T18:58:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Immutable configuration record for llama.cpp JNI provider settings including library paths, model selection, sampling parameters, and chat template options. + +#### Purpose +- Encapsulates all runtime configuration parameters for the LlamaCppJniProvider. +- Provides immutable accessors for native library paths, model files, and inference tuning values. + +#### Type +Record (final class) with Lombok annotations; extends none; implements none; key generics: List. + +#### Input +Constructor accepts: libraryPath, modelPath, contextSize, maxOutputTokens, temperature, threads, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings. + +#### Output +Returns field values via getters; returns unmodifiable List for stopStrings; no external resources written. + +#### Core logic +- Validates that modelPath is not null during construction. +- Converts null stopStrings to an empty list via Collections.emptyList(). +- Stores all parameters as final fields to ensure immutability. + +#### Public API +libraryPath() -> String <= native library path +modelPath() -> String <= GGUF model file path +contextSize() -> int <= context window size +maxOutputTokens() -> int <= max output tokens +temperature() -> float <= sampling temperature +threads() -> int <= CPU thread count +topP() -> float <= nucleus-sampling threshold +topK() -> int <= top-k limit +repeatPenalty() -> float <= repetition penalty +chatTemplateEnableThinking() -> boolean <= thinking mode enabled +stopStrings() -> List <= unmodifiable stop strings + +#### Dependencies +net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord, java.util.Collections, java.util.List, java.util.Objects, lombok.EqualsAndHashCode, lombok.ToString. + +#### Exceptions / Errors +Throws NullPointerException if modelPath is null; otherwise no exceptions thrown. + +#### Concurrency +Thread-safe due to immutability and final fields; no synchronization required. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..d3b4a72 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,40 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:00:03Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> A deterministic mock provider generating static summaries for testing AI generation logic. + +#### Purpose +- Provides a no-op implementation of AiGenerationProvider for unit testing. +- Returns a predictable string based on the input file name instead of real processing. + +#### Type +Class; implements AiGenerationProvider; annotated with @ToString; public constructor. + +#### Input +AiGenerationRequest request containing sourceFile path; derived file name from Path object. + +#### Output +String summary formatted as "Mock summary for ". + +#### Core logic +- Extracts fileName from request.sourceFile(). +- Handles null file name fallback by converting full path to string. +- Concatenates static text with fileName to return mock result. + +#### Public API +generate(request) -> String: Creates a deterministic mock summary string. + +#### Dependencies +AiGenerationProvider, AiGenerationRequest, java.io.IOException, java.nio.file.Path. + +#### Exceptions / Errors +Throws IOException; no explicit null checks beyond basic Path utility usage. + +#### Concurrency +Synchronous method with no concurrency concerns. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..1e39de2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,54 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T19:03:13Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> Provides a pluggable local LLM inference engine via llama.cpp JNI, extracting clean model answers by stripping internal reasoning blocks for AI indexing. + +#### Purpose +* Enables local text generation using GGUF models through the llama.cpp native backend. +* Ensures clean data persistence by stripping internal chain-of-thought reasoning before indexing. + +#### Responsibilities +* **Provider Interface**: Defines contracts for generating text from requests, supporting live and mock implementations. +* **Factory & Configuration**: Manages instantiation of providers based on name keys and immutable runtime settings (paths, sampling params). +* **Native Inference**: Executes local LLM inference via JNI, handling lazy model loading and parameter construction. +* **Data Sanitization**: Parses raw completion text to remove internal thinking blocks before storage. +* **Testing Support**: Provides deterministic mock implementations for unit testing generation logic. + +#### Key units +* `AiGenerationProvider`: Interface defining the contract for generating text from `AiGenerationRequest` objects. +* `LlamaCppJniAiGenerationProvider`: Final class implementing local inference via `LlamaModel` and `InferenceParameters`. +* `LlamaCppJniConfig`: Immutable record holding native library paths, model files, and sampling parameters (temperature, topP, threads). +* `AiCompletionParser`: Utility stripping `THINKING_BLOCK` markers from raw responses to return clean answers. +* `AiGenerationProviderFactory`: Factory selecting and instantiating providers (`Mock`, `LlamaCppJni`) by name string. + +#### Data flow +1. **Request Ingestion**: `AiGenerationRequest` (prompt key, source text) enters the system. +2. **Provider Selection**: `AiGenerationProviderFactory` selects implementation (`Mock` or `LlamaCppJni`) based on `providerName`. +3. **Inference Execution**: + * `LlamaCppJniAiGenerationProvider` lazily loads `LlamaModel` if needed. + * Constructs `InferenceParameters` (messages, chat template) from `LlamaCppJniConfig` and request. + * Calls native `chatCompleteText()` to get raw completion. +4. **Sanitization**: Raw output passed to `AiCompletionParser` to strip internal reasoning blocks. +5. **Output**: Cleaned string returned to caller or stored in AI index. + +#### Dependencies +* **Internal**: `LlamaCppJniConfig`, `AiPromptSupport`, `AiGenerationRequest`, `InferenceParameters`, `Pair`. +* **External Modules**: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, native `LlamaModel` (GGUF), `java.io.IOException`, `java.nio.file.Path`. + +#### Cross-cutting +* **Immutability**: `LlamaCppJniConfig` uses final fields and Lombok annotations to ensure thread-safe configuration. +* **Null Safety**: Critical checks for `modelPath` in config and request parameters; throws `NullPointerException` if null. +* **Error Handling**: Centralized `IOException` usage for native failures and incomplete thinking blocks. +* **Resource Management**: `AutoCloseable` pattern ensures native model handles are released via `close()`. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..4f0f491 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,47 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:07:20Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. + +#### Purpose +- Enables local LLM inference via JNI using GGUF models while stripping internal chain-of-thought reasoning for clean indexing. +- Orchestrates AI-driven field generation for Maven builds by resolving file extensions to prompt templates and model configurations. + +#### Responsibilities +- **Local Inference Engine**: Executes text generation through `LlamaCppJniAiGenerationProvider` using native bindings, handling lazy model loading and parameter construction. +- **Prompt & Model Management**: Maps source file extensions to specific prompts via `AiFieldGenerationSelector` and resolves model definitions for inference parameters. +- **Data Sanitization**: Parses raw completion text to remove internal thinking blocks before storage or indexing. +- **Configuration Lifecycle**: Manages runtime settings for context size, temperature, and threads across file-level and package-level generation scopes. + +#### Key units +- `LlamaCppJniAiGenerationProvider`: Implements native inference via `LlamaModel` and `InferenceParameters`. +- `AiCompletionParser`: Strips `THINKING_BLOCK` markers from raw responses to return clean answers. +- `AiFieldGenerationConfig`: Links prompt templates and model definitions to file extension filters. +- `AiGenerationProviderFactory`: Selects and instantiates providers (`Mock`, `LlamaCppJni`) by name string. +- `AiModelDefinitionSupport`: Resolves definition keys to active generation configurations via lookup maps. +- `AiGenerationKind`: Enumerates operation scopes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +1. User POM configuration defines `AiFieldGenerationConfig` mapping extensions to prompts/models. +2. `AiFieldGenerationSelector` matches incoming source files against configs during build execution. +3. `AiGenerationProviderFactory` selects the appropriate provider (e.g., `LlamaCppJni`) based on request settings. +4. Native inference executes via `chatCompleteText()`, producing raw completion containing potential reasoning blocks. +5. `AiCompletionParser` sanitizes the output by stripping internal thinking markers. +6. Cleaned text is returned for AI indexing or stored in the package index. + +#### Dependencies +- **Internal**: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `LlamaCppJniConfig`, `AiPromptSupport`. +- **External Modules**: `net.ladenthin.llama.parameters.ModelParameters`, native `LlamaModel` (GGUF), `Java8CompatibilityHelper`, standard Java collections. + +#### Cross-cutting +- **Immutability**: Configuration records (`LlamaCppJniConfig`) use final fields and defensive copying to ensure thread safety. +- **Null Safety**: Selectors handle null entries in configuration lists gracefully by skipping or falling back. +- **Resource Management**: Native model handles are released via `AutoCloseable` pattern using `close()`. +- **Error Handling**: Centralized usage of `IOException` for native failures and incomplete thinking blocks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..d3610ce --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,47 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:08:54Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. + +#### Purpose +- Enables local LLM inference via JNI using GGUF models while stripping internal chain-of-thought reasoning for clean indexing. +- Orchestrates AI-driven field generation for Maven builds by resolving file extensions to prompt templates and model configurations. + +#### Responsibilities +- **Local Inference Engine**: Executes text generation through `LlamaCppJniAiGenerationProvider` using native bindings, handling lazy model loading and parameter construction. +- **Prompt & Model Management**: Maps source file extensions to specific prompts via `AiFieldGenerationSelector` and resolves model definitions for inference parameters. +- **Data Sanitization**: Parses raw completion text to remove internal thinking blocks before storage or indexing. +- **Configuration Lifecycle**: Manages runtime settings for context size, temperature, and threads across file-level and package-level generation scopes. + +#### Key units +- `LlamaCppJniAiGenerationProvider`: Implements native inference via `LlamaModel` and `InferenceParameters`. +- `AiCompletionParser`: Strips `THINKING_BLOCK` markers from raw responses to return clean answers. +- `AiFieldGenerationConfig`: Links prompt templates and model definitions to file extension filters. +- `AiGenerationProviderFactory`: Selects and instantiates providers (`Mock`, `LlamaCppJni`) by name string. +- `AiModelDefinitionSupport`: Resolves definition keys to active generation configurations via lookup maps. +- `AiGenerationKind`: Enumerates operation scopes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +1. User POM configuration defines `AiFieldGenerationConfig` mapping extensions to prompts/models. +2. `AiFieldGenerationSelector` matches incoming source files against configs during build execution. +3. `AiGenerationProviderFactory` selects the appropriate provider (e.g., `LlamaCppJni`) based on request settings. +4. Native inference executes via `chatCompleteText()`, producing raw completion containing potential reasoning blocks. +5. `AiCompletionParser` sanitizes the output by stripping internal thinking markers. +6. Cleaned text is returned for AI indexing or stored in the package index. + +#### Dependencies +- **Internal**: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `LlamaCppJniConfig`, `AiPromptSupport`. +- **External Modules**: `net.ladenthin.llama.parameters.ModelParameters`, native `LlamaModel` (GGUF), `Java8CompatibilityHelper`, standard Java collections. + +#### Cross-cutting +- **Immutability**: Configuration records (`LlamaCppJniConfig`) use final fields and defensive copying to ensure thread safety. +- **Null Safety**: Selectors handle null entries in configuration lists gracefully by skipping or falling back. +- **Resource Management**: Native model handles are released via `AutoCloseable` pattern using `close()`. +- **Error Handling**: Centralized usage of `IOException` for native failures and incomplete thinking blocks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..9a69404 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,47 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:10:27Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. + +#### Purpose +- Enables local LLM inference via JNI using GGUF models while stripping internal chain-of-thought reasoning for clean indexing. +- Orchestrates AI-driven field generation for Maven builds by resolving file extensions to prompt templates and model configurations. + +#### Responsibilities +- **Local Inference Engine**: Executes text generation through `LlamaCppJniAiGenerationProvider` using native bindings, handling lazy model loading and parameter construction. +- **Prompt & Model Management**: Maps source file extensions to specific prompts via `AiFieldGenerationSelector` and resolves model definitions for inference parameters. +- **Data Sanitization**: Parses raw completion text to remove internal thinking blocks before storage or indexing. +- **Configuration Lifecycle**: Manages runtime settings for context size, temperature, and threads across file-level and package-level generation scopes. + +#### Key units +- `LlamaCppJniAiGenerationProvider`: Implements native inference via `LlamaModel` and `InferenceParameters`. +- `AiCompletionParser`: Strips `THINKING_BLOCK` markers from raw responses to return clean answers. +- `AiFieldGenerationConfig`: Links prompt templates and model definitions to file extension filters. +- `AiGenerationProviderFactory`: Selects and instantiates providers (`Mock`, `LlamaCppJni`) by name string. +- `AiModelDefinitionSupport`: Resolves definition keys to active generation configurations via lookup maps. +- `AiGenerationKind`: Enumerates operation scopes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +1. User POM configuration defines `AiFieldGenerationConfig` mapping extensions to prompts/models. +2. `AiFieldGenerationSelector` matches incoming source files against configs during build execution. +3. `AiGenerationProviderFactory` selects the appropriate provider (e.g., `LlamaCppJni`) based on request settings. +4. Native inference executes via `chatCompleteText()`, producing raw completion containing potential reasoning blocks. +5. `AiCompletionParser` sanitizes the output by stripping internal thinking markers. +6. Cleaned text is returned for AI indexing or stored in the package index. + +#### Dependencies +- **Internal**: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `LlamaCppJniConfig`, `AiPromptSupport`. +- **External Modules**: `net.ladenthin.llama.parameters.ModelParameters`, native `LlamaModel` (GGUF), `Java8CompatibilityHelper`, standard Java collections. + +#### Cross-cutting +- **Immutability**: Configuration records (`LlamaCppJniConfig`) use final fields and defensive copying to ensure thread safety. +- **Null Safety**: Selectors handle null entries in configuration lists gracefully by skipping or falling back. +- **Resource Management**: Native model handles are released via `AutoCloseable` pattern using `close()`. +- **Error Handling**: Centralized usage of `IOException` for native failures and incomplete thinking blocks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/package.ai.md new file mode 100644 index 0000000..e0b8993 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/net/package.ai.md @@ -0,0 +1,47 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:12:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. + +#### Purpose +- Enables local LLM inference via JNI using GGUF models while stripping internal chain-of-thought reasoning for clean indexing. +- Orchestrates AI-driven field generation for Maven builds by resolving file extensions to prompt templates and model configurations. + +#### Responsibilities +- **Local Inference Engine**: Executes text generation through `LlamaCppJniAiGenerationProvider` using native bindings, handling lazy model loading and parameter construction. +- **Prompt & Model Management**: Maps source file extensions to specific prompts via `AiFieldGenerationSelector` and resolves model definitions for inference parameters. +- **Data Sanitization**: Parses raw completion text to remove internal thinking blocks before storage or indexing. +- **Configuration Lifecycle**: Manages runtime settings for context size, temperature, and threads across file-level and package-level generation scopes. + +#### Key units +- `LlamaCppJniAiGenerationProvider`: Implements native inference via `LlamaModel` and `InferenceParameters`. +- `AiCompletionParser`: Strips `THINKING_BLOCK` markers from raw responses to return clean answers. +- `AiFieldGenerationConfig`: Links prompt templates and model definitions to file extension filters. +- `AiGenerationProviderFactory`: Selects and instantiates providers (`Mock`, `LlamaCppJni`) by name string. +- `AiModelDefinitionSupport`: Resolves definition keys to active generation configurations via lookup maps. +- `AiGenerationKind`: Enumerates operation scopes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +1. User POM configuration defines `AiFieldGenerationConfig` mapping extensions to prompts/models. +2. `AiFieldGenerationSelector` matches incoming source files against configs during build execution. +3. `AiGenerationProviderFactory` selects the appropriate provider (e.g., `LlamaCppJni`) based on request settings. +4. Native inference executes via `chatCompleteText()`, producing raw completion containing potential reasoning blocks. +5. `AiCompletionParser` sanitizes the output by stripping internal thinking markers. +6. Cleaned text is returned for AI indexing or stored in the package index. + +#### Dependencies +- **Internal**: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `LlamaCppJniConfig`, `AiPromptSupport`. +- **External Modules**: `net.ladenthin.llama.parameters.ModelParameters`, native `LlamaModel` (GGUF), `Java8CompatibilityHelper`, standard Java collections. + +#### Cross-cutting +- **Immutability**: Configuration records (`LlamaCppJniConfig`) use final fields and defensive copying to ensure thread safety. +- **Null Safety**: Selectors handle null entries in configuration lists gracefully by skipping or falling back. +- **Resource Management**: Native model handles are released via `AutoCloseable` pattern using `close()`. +- **Error Handling**: Centralized usage of `IOException` for native failures and incomplete thinking blocks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/package.ai.md new file mode 100644 index 0000000..321d159 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/java/package.ai.md @@ -0,0 +1,47 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:13:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. + +#### Purpose +- Enables local LLM inference via JNI using GGUF models while stripping internal chain-of-thought reasoning for clean indexing. +- Orchestrates AI-driven field generation for Maven builds by resolving file extensions to prompt templates and model configurations. + +#### Responsibilities +- **Local Inference Engine**: Executes text generation through `LlamaCppJniAiGenerationProvider` using native bindings, handling lazy model loading and parameter construction. +- **Prompt & Model Management**: Maps source file extensions to specific prompts via `AiFieldGenerationSelector` and resolves model definitions for inference parameters. +- **Data Sanitization**: Parses raw completion text to remove internal thinking blocks before storage or indexing. +- **Configuration Lifecycle**: Manages runtime settings for context size, temperature, and threads across file-level and package-level generation scopes. + +#### Key units +- `LlamaCppJniAiGenerationProvider`: Implements native inference via `LlamaModel` and `InferenceParameters`. +- `AiCompletionParser`: Strips `THINKING_BLOCK` markers from raw responses to return clean answers. +- `AiFieldGenerationConfig`: Links prompt templates and model definitions to file extension filters. +- `AiGenerationProviderFactory`: Selects and instantiates providers (`Mock`, `LlamaCppJni`) by name string. +- `AiModelDefinitionSupport`: Resolves definition keys to active generation configurations via lookup maps. +- `AiGenerationKind`: Enumerates operation scopes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +1. User POM configuration defines `AiFieldGenerationConfig` mapping extensions to prompts/models. +2. `AiFieldGenerationSelector` matches incoming source files against configs during build execution. +3. `AiGenerationProviderFactory` selects the appropriate provider (e.g., `LlamaCppJni`) based on request settings. +4. Native inference executes via `chatCompleteText()`, producing raw completion containing potential reasoning blocks. +5. `AiCompletionParser` sanitizes the output by stripping internal thinking markers. +6. Cleaned text is returned for AI indexing or stored in the package index. + +#### Dependencies +- **Internal**: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `LlamaCppJniConfig`, `AiPromptSupport`. +- **External Modules**: `net.ladenthin.llama.parameters.ModelParameters`, native `LlamaModel` (GGUF), `Java8CompatibilityHelper`, standard Java collections. + +#### Cross-cutting +- **Immutability**: Configuration records (`LlamaCppJniConfig`) use final fields and defensive copying to ensure thread safety. +- **Null Safety**: Selectors handle null entries in configuration lists gracefully by skipping or falling back. +- **Resource Management**: Native model handles are released via `AutoCloseable` pattern using `close()`. +- **Error Handling**: Centralized usage of `IOException` for native failures and incomplete thinking blocks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/package.ai.md new file mode 100644 index 0000000..9b12f11 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/main/package.ai.md @@ -0,0 +1,47 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:15:08Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. + +#### Purpose +- Enables local LLM inference via JNI using GGUF models while stripping internal chain-of-thought reasoning for clean indexing. +- Orchestrates AI-driven field generation for Maven builds by resolving file extensions to prompt templates and model configurations. + +#### Responsibilities +- **Local Inference Engine**: Executes text generation through `LlamaCppJniAiGenerationProvider` using native bindings, handling lazy model loading and parameter construction. +- **Prompt & Model Management**: Maps source file extensions to specific prompts via `AiFieldGenerationSelector` and resolves model definitions for inference parameters. +- **Data Sanitization**: Parses raw completion text to remove internal thinking blocks before storage or indexing. +- **Configuration Lifecycle**: Manages runtime settings for context size, temperature, and threads across file-level and package-level generation scopes. + +#### Key units +- `LlamaCppJniAiGenerationProvider`: Implements native inference via `LlamaModel` and `InferenceParameters`. +- `AiCompletionParser`: Strips `THINKING_BLOCK` markers from raw responses to return clean answers. +- `AiFieldGenerationConfig`: Links prompt templates and model definitions to file extension filters. +- `AiGenerationProviderFactory`: Selects and instantiates providers (`Mock`, `LlamaCppJni`) by name string. +- `AiModelDefinitionSupport`: Resolves definition keys to active generation configurations via lookup maps. +- `AiGenerationKind`: Enumerates operation scopes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +1. User POM configuration defines `AiFieldGenerationConfig` mapping extensions to prompts/models. +2. `AiFieldGenerationSelector` matches incoming source files against configs during build execution. +3. `AiGenerationProviderFactory` selects the appropriate provider (e.g., `LlamaCppJni`) based on request settings. +4. Native inference executes via `chatCompleteText()`, producing raw completion containing potential reasoning blocks. +5. `AiCompletionParser` sanitizes the output by stripping internal thinking markers. +6. Cleaned text is returned for AI indexing or stored in the package index. + +#### Dependencies +- **Internal**: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `LlamaCppJniConfig`, `AiPromptSupport`. +- **External Modules**: `net.ladenthin.llama.parameters.ModelParameters`, native `LlamaModel` (GGUF), `Java8CompatibilityHelper`, standard Java collections. + +#### Cross-cutting +- **Immutability**: Configuration records (`LlamaCppJniConfig`) use final fields and defensive copying to ensure thread safety. +- **Null Safety**: Selectors handle null entries in configuration lists gracefully by skipping or falling back. +- **Resource Management**: Native model handles are released via `AutoCloseable` pattern using `close()`. +- **Error Handling**: Centralized usage of `IOException` for native failures and incomplete thinking blocks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/package.ai.md new file mode 100644 index 0000000..c015213 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/package.ai.md @@ -0,0 +1,47 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:16:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. + +#### Purpose +- Enables local LLM inference via JNI using GGUF models while stripping internal chain-of-thought reasoning for clean indexing. +- Orchestrates AI-driven field generation for Maven builds by resolving file extensions to prompt templates and model configurations. + +#### Responsibilities +- **Local Inference Engine**: Executes text generation through `LlamaCppJniAiGenerationProvider` using native bindings, handling lazy model loading and parameter construction. +- **Prompt & Model Management**: Maps source file extensions to specific prompts via `AiFieldGenerationSelector` and resolves model definitions for inference parameters. +- **Data Sanitization**: Parses raw completion text to remove internal thinking blocks before storage or indexing. +- **Configuration Lifecycle**: Manages runtime settings for context size, temperature, and threads across file-level and package-level generation scopes. + +#### Key units +- `LlamaCppJniAiGenerationProvider`: Implements native inference via `LlamaModel` and `InferenceParameters`. +- `AiCompletionParser`: Strips `THINKING_BLOCK` markers from raw responses to return clean answers. +- `AiFieldGenerationConfig`: Links prompt templates and model definitions to file extension filters. +- `AiGenerationProviderFactory`: Selects and instantiates providers (`Mock`, `LlamaCppJni`) by name string. +- `AiModelDefinitionSupport`: Resolves definition keys to active generation configurations via lookup maps. +- `AiGenerationKind`: Enumerates operation scopes (`FILE_SUMMARY`, `PACKAGE_SUMMARY`). + +#### Data flow +1. User POM configuration defines `AiFieldGenerationConfig` mapping extensions to prompts/models. +2. `AiFieldGenerationSelector` matches incoming source files against configs during build execution. +3. `AiGenerationProviderFactory` selects the appropriate provider (e.g., `LlamaCppJni`) based on request settings. +4. Native inference executes via `chatCompleteText()`, producing raw completion containing potential reasoning blocks. +5. `AiCompletionParser` sanitizes the output by stripping internal thinking markers. +6. Cleaned text is returned for AI indexing or stored in the package index. + +#### Dependencies +- **Internal**: `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest`, `LlamaCppJniConfig`, `AiPromptSupport`. +- **External Modules**: `net.ladenthin.llama.parameters.ModelParameters`, native `LlamaModel` (GGUF), `Java8CompatibilityHelper`, standard Java collections. + +#### Cross-cutting +- **Immutability**: Configuration records (`LlamaCppJniConfig`) use final fields and defensive copying to ensure thread safety. +- **Null Safety**: Selectors handle null entries in configuration lists gracefully by skipping or falling back. +- **Resource Management**: Native model handles are released via `AutoCloseable` pattern using `close()`. +- **Error Handling**: Centralized usage of `IOException` for native failures and incomplete thinking blocks. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/project.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/project.ai.md new file mode 100644 index 0000000..741b579 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen35-4b__v2/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: 07339891 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T19:18:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The `llamacpp-ai-index-maven-plugin` subsystems orchestrate a localized Llama.cpp inference pipeline within Maven builds to generate AI-driven code indices. Core components handle the mapping of source file extensions to custom prompt templates and execute native GGUF model generation for field extraction. The architecture includes a pluggable provider layer that sanitizes raw reasoning outputs from the model, ensuring clean, indexed data while maintaining extensible configuration for different build contexts. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Executes AI-driven field generation for Maven plugin builds by mapping source file extensions to prompt templates and model configurations. +- main/java/net/ladenthin/maven/llamacpp/aiindex — Orchestrates local Llama.cpp inference and field generation for Maven plugin builds by mapping source files to AI prompts and sanitizing reasoning outputs. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Provides a pluggable local LLM inference engine via llama.cpp JNI, extracting clean model answers by stripping internal reasoning blocks for AI indexing. +- main/java/net/ladenthin/maven/llamacpp — Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. +- main/java/net/ladenthin/maven — Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. +- main/java/net/ladenthin — Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. +- main/java/net — Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. +- main/java — Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. +- main — Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. +- . — Orchestrates local Llama.cpp inference for Maven builds by mapping source files to AI prompts, executing native GGUF generation, and sanitizing reasoning outputs before indexing. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..265ed15 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,49 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:39:52Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI-driven field generation by linking prompt templates and model definitions for Maven plugin execution. + +#### Purpose +- Associates AI prompt templates with model configurations for field generation. +- Supports file extension-based selection of generation rules. + +#### Type +Class, final. Implements no interfaces. Uses Lombok @ToString annotation. Generics: none. Type bounds: none. + +#### Input +- Constructor takes no parameters. +- Setters accept: String promptKey, String aiDefinitionKey, @Nullable Collection fileExtensions. +- Dependencies: java.util.ArrayList, java.util.Collection, java.util.Collections, java.util.List, org.jspecify.annotations.Nullable, lombok.ToString. + +#### Output +- Getters return: String promptKey, String aiDefinitionKey, @Nullable List fileExtensions. +- Setters mutate internal fields: promptKey, aiDefinitionKey, fileExtensions. +- Defensive copy in setFileExtensions ensures immutability of returned list. + +#### Core logic +- Maps a prompt template key to an AI model definition key for field generation. +- Filters files by optional extensions; fallback behavior when no match. +- Maven plugin configuration object for declarative field generation. + +#### Public API +- getPromptKey() -> String: Retrieves the prompt template identifier. +- setPromptKey(String): Sets the prompt template identifier. +- getAiDefinitionKey() -> String: Retrieves the AI model definition identifier. +- setAiDefinitionKey(String): Sets the AI model definition identifier. +- getFileExtensions() -> @Nullable List: Returns file extension filter list. +- setFileExtensions(@Nullable Collection): Assigns file extension filter. + +#### Dependencies +java.util.ArrayList, java.util.Collection, java.util.Collections, java.util.List, lombok.ToString, org.jspecify.annotations.Nullable + +#### Exceptions / Errors +No explicit throws. Defensive copying prevents external mutation of fileExtensions list. + +#### Concurrency +No concurrency handling; class is not thread-safe. Intended for Maven plugin configuration use only. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..4bcb8ef --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,53 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:41:44Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects appropriate AI field generation configuration based on file extensions and fallback rules. + +#### Purpose +- Matches source files to AI prompt configurations by file extension. +- Provides fallback behavior when no matching extension is found. + +#### Type +Class, final. No extends or implements. Uses @ToString annotation. Generic type: Iterable. + +#### Input +- Constructor takes no parameters. +- Method `selectForFileName` consumes: + - configs: Iterable of AiFieldGenerationConfig, may contain nulls + - fileName: String representing a file name (e.g., "Foo.java") + +#### Output +- Method returns @Nullable AiFieldGenerationConfig. +- Returns first matching config by extension or first fallback config if none match. +- Returns null when no match and no fallback is present. + +#### Core logic +- Iterates through configured AiFieldGenerationConfig entries. +- Skips null configs in the input iterable. +- For each config, checks if it has an empty or absent file extension list; tracks first such entry as fallback. +- For non-empty extension lists, checks if fileName ends with any of those extensions. +- Returns matching config immediately upon first match. +- Falls back to tracked fallback config if no extension matches. +- Returns null if no match and no fallback exists. + +#### Public API +- `selectForFileName(configs, fileName) -> AiFieldGenerationConfig` selects configuration by file name + +#### Dependencies +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable +- AiFieldGenerationConfig + +#### Exceptions / Errors +- Null handling: skips null entries in configs iterable. +- Returns null when no matching config and no fallback is configured. + +#### Concurrency +- No concurrency concerns; class is stateless and method is pure. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..8c30edb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,84 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:42:30Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures parameters for AI model inference steps including context size, sampling, retries, and input limits. + +#### Purpose +- Carries AI generation settings between Maven plugin and provider implementations. +- Manages mutable configuration state for llama.cpp inference parameters. + +#### Type +class public final +extends Object +implements + +#### Input +- Constructor takes no parameters; initializes defaults. +- Setters accept primitive types, strings, lists, and nullables. +- Dependencies: Lombok for `@ToString`, `org.jspecify.annotations.Nullable`. + +#### Output +- Getters return fields directly or unmodifiable views of collections. +- Side effects: mutation of instance state via setters. + +#### Core logic +- Holds mutable configuration fields for AI inference parameters. +- Provides default constants for context size, output tokens, temperature, threads, etc. +- Manages automatic input character calculation based on token ratios. +- Supports retry logic with incremental temperature adjustments. +- Controls stop strings and chat template thinking mode. + +#### Public API +- getModelPath() -> String +- setModelPath(String) -> void +- getContextSize() -> int +- setContextSize(int) -> void +- getMaxOutputTokens() -> int +- setMaxOutputTokens(int) -> void +- getTemperature() -> float +- setTemperature(float) -> void +- getThreads() -> int +- setThreads(int) -> void +- getCharsPerToken() -> int +- setCharsPerToken(int) -> void +- getMaxInputChars() -> int +- setMaxInputChars(int) -> void +- isWarnOnTrim() -> boolean +- setWarnOnTrim(boolean) -> void +- getMaxRetries() -> int +- setMaxRetries(int) -> void +- getRetryTemperatureIncrement() -> float +- setRetryTemperatureIncrement(float) -> void +- getTopP() -> float +- setTopP(float) -> void +- getTopK() -> int +- setTopK(int) -> void +- getRepeatPenalty() -> float +- setRepeatPenalty(float) -> void +- isChatTemplateEnableThinking() -> boolean +- setChatTemplateEnableThinking(boolean) -> void +- getStopStrings() -> List +- setStopStrings(List) -> void + +#### Dependencies +- java.util.ArrayList +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- No explicit throws. +- Null handling via `@Nullable` annotation on `stopStrings`. +- Default values prevent null pointer access. + +#### Concurrency +- Instance is mutable and not thread-safe. +- Intended for use in single-threaded Maven plugin context. +- Fields are accessed directly without synchronization. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..7bea948 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,40 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:45:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Identifies the scope of AI generation tasks for source files or packages + +#### Purpose +- Distinguishes AI generation modes for individual files vs. package-level aggregates +- Supports configuration of AI processing workflows + +#### Type +Enum, final. No extends or implements clauses. + +#### Input +None directly consumed. Enum constants defined statically. + +#### Output +None produced. Constants serve as labeled identifiers. + +#### Core logic +- Defines two distinct AI generation modes: FILE_SUMMARY and PACKAGE_SUMMARY +- Represents discrete processing scopes for automated code analysis + +#### Public API +- FILE_SUMMARY() -> AiGenerationKind - single file analysis mode +- PACKAGE_SUMMARY() -> AiGenerationKind - package aggregate analysis mode + +#### Dependencies +None imported. No external type references. + +#### Exceptions / Errors +None thrown or caught. No null handling required. + +#### Concurrency +No concurrency concerns. Enum constants are immutable and thread-safe by design. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..83cac88 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,81 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:45:35Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines reusable AI model configurations for Maven plugin field generation. + +#### Purpose +- Stores AI model parameters for reuse across multiple field-generation tasks. +- Maps configuration entries to lookup keys for reference by other plugin components. + +#### Type +Class, final. Implements no interfaces. Uses Lombok @ToString annotation. Fields are private with public getters/setters. + +#### Input +- Constructor accepts no arguments; defaults initialized from AiGenerationConfig. +- Setters accept parameters to configure model-specific properties including key, modelPath, contextSize, maxOutputTokens, temperature, threads, charsPerToken, warnOnTrim, maxRetries, retryTemperatureIncrement, topP, topK, repeatPenalty, chatTemplateEnableThinking, and stopStrings. + +#### Output +- Getters return internal state values or unmodifiable views of collections. +- Setters mutate internal fields; stopStrings is copied to new ArrayList before assignment. + +#### Core logic +- Provides a JavaBean configuration object for Maven plugin AI model settings. +- Supports default value inheritance from AiGenerationConfig constants. +- Enables lookup by key from AiFieldGenerationConfig. +- Manages mutable state through standard getter/setter accessors. + +#### Public API +- getKey() -> String +- setKey(String) -> void +- getModelPath() -> String +- setModelPath(String) -> void +- getContextSize() -> int +- setContextSize(int) -> void +- getMaxOutputTokens() -> int +- setMaxOutputTokens(int) -> void +- getTemperature() -> float +- setTemperature(float) -> void +- getThreads() -> int +- setThreads(int) -> void +- getCharsPerToken() -> int +- setCharsPerToken(int) -> void +- isWarnOnTrim() -> boolean +- setWarnOnTrim(boolean) -> void +- getMaxRetries() -> int +- setMaxRetries(int) -> void +- getRetryTemperatureIncrement() -> float +- setRetryTemperatureIncrement(float) -> void +- getTopP() -> float +- setTopP(float) -> void +- getTopK() -> int +- setTopK(int) -> void +- getRepeatPenalty() -> float +- setRepeatPenalty(float) -> void +- isChatTemplateEnableThinking() -> boolean +- setChatTemplateEnableThinking(boolean) -> void +- getStopStrings() -> List +- setStopStrings(Collection) -> void + +#### Dependencies +- java.util.ArrayList +- java.util.Collection +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable +- net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig +- net.ladenthin.llama.parameters.ModelParameters + +#### Exceptions / Errors +- Null handling for stopStrings; null-checks and defensive copying applied. +- No explicit exception throwing. + +#### Concurrency +- Not thread-safe due to mutable state. +- Designed for single-threaded use during Maven plugin configuration phase. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..274a9da --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,42 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:48:08Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key to produce generation configurations for use in field generation tasks. + +#### Purpose +- Maps AI model definition keys to ready-to-use generation configs. +- Enforces required fields and validates configuration at build time. + +#### Type +Final class extending no types; implements no interfaces. Generics: none. Annotations: @ToString. + +#### Input +Constructor takes List; throws NullPointerException for null keys. getConfig method takes String key. + +#### Output +getConfig returns AiGenerationConfig; toConfig produces AiGenerationConfig from AiModelDefinition. Side effect: throws IllegalArgumentException for missing keys. + +#### Core logic +- Builds internal HashMap from list of AiModelDefinition entries using their keys. +- Validates each definition has a non-null key during construction. +- Converts each AiModelDefinition into an AiGenerationConfig via field copying. +- Looks up AiGenerationConfig by key; throws exception if not found. + +#### Public API +getConfig(key) -> AiGenerationConfig: retrieves generation config by key +toConfig(definition) -> AiGenerationConfig: converts definition to config + +#### Dependencies +Imports: java.util.HashMap, java.util.List, java.util.Map, java.util.Objects, lombok.ToString, net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper, net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinition, net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig + +#### Exceptions / Errors +Throws NullPointerException for null keys in definitions list. Throws IllegalArgumentException for missing keys during lookup. + +#### Concurrency +No concurrency controls; class is immutable after construction. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..1655104 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,49 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:54:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Configures and manages AI-driven code generation workflows for Maven plugins, enabling field-level analysis and summarization of source files using customizable model parameters and prompt templates. + +#### Purpose +- Defines AI model configurations and generation parameters for Maven plugin execution. +- Supports declarative setup of AI inference settings with fallback behaviors. + +#### Responsibilities +- **Configuration Management**: Handles AI model definitions, generation configs, and field generation rules. +- **File Selection Logic**: Matches source files to appropriate AI processing configurations based on extensions. +- **Inference Parameters**: Manages mutable settings for context size, sampling, retries, and input limits used in llama.cpp inference. + +#### Key units +- AiFieldGenerationConfig: Maps prompt templates to model definitions with file extension filters. +- AiFieldGenerationSelector: Selects appropriate config by file name using extension matching and fallback rules. +- AiGenerationConfig: Carries mutable AI inference parameters like context size, temperature, and stop strings. +- AiGenerationKind: Enum distinguishing FILE_SUMMARY and PACKAGE_SUMMARY processing modes. +- AiModelDefinition: Reusable model configuration with key-based lookup support. +- AiModelDefinitionSupport: Resolves model definitions into generation configs with validation. + +#### Data flow +- Maven plugin reads AiFieldGenerationConfig entries to determine which prompt/template to apply per file. +- AiFieldGenerationSelector matches input file names against configured extensions and selects the appropriate config. +- Selected config references an AiModelDefinition through aiDefinitionKey, which is resolved via AiModelDefinitionSupport into a concrete AiGenerationConfig. +- AiGenerationConfig carries inference parameters used by the llama.cpp backend for AI processing. + +#### Dependencies +- Internal: AiFieldGenerationConfig, AiFieldGenerationSelector, AiGenerationConfig, AiGenerationKind, AiModelDefinition, AiModelDefinitionSupport +- External: Lombok (@ToString), org.jspecify.annotations.Nullable, java.util packages + +#### Cross-cutting +- Defensive copying in setters ensures immutability of returned collections. +- Null handling via @Nullable annotations and explicit null checks. +- Thread safety considerations: classes are not thread-safe; intended for single-threaded Maven plugin use only. +- Configuration validation at construction time (e.g., null keys in AiModelDefinitionSupport). diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..dd65091 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,49 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:58:42Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. + +#### Purpose +- Configures AI workflows for analyzing and summarizing Java source files. +- Enables flexible, pluggable text generation backends including local llama.cpp models and mock responses. + +#### Responsibilities +- **Configuration Management**: Defines AI model settings, prompt templates, and file selection rules. +- **Inference Execution**: Provides local GGUF model support via JNI and deterministic mocking for testing. +- **Output Processing**: Cleans AI completions by removing internal reasoning blocks for clean indexing. + +#### Key units +- AiFieldGenerationConfig: Maps file extensions to prompt templates and model definitions. +- AiFieldGenerationSelector: Matches input files to appropriate generation configurations. +- AiGenerationConfig: Carries mutable inference parameters for llama.cpp. +- AiGenerationProvider: Interface for AI text generation implementations. +- LlamaCppJniAiGenerationProvider: Implements native GGUF model inference using JNI. +- MockAiGenerationProvider: Supplies deterministic mock responses for testing. +- AiCompletionParser: Strips reasoning blocks from raw AI outputs. + +#### Data flow +- Maven plugin loads AiFieldGenerationConfig entries to match files with prompt templates. +- AiFieldGenerationSelector resolves the correct config by file extension. +- Config references an AiModelDefinition, resolved into AiGenerationConfig via AiModelDefinitionSupport. +- AiGenerationProviderFactory selects between LlamaCppJniAiGenerationProvider or MockAiGenerationProvider. +- Input prompts are processed through AiPromptSupport, native inference is called, and output is cleaned by AiCompletionParser. + +#### Dependencies +- Internal: AiFieldGenerationConfig, AiFieldGenerationSelector, AiGenerationConfig, AiModelDefinition, AiModelDefinitionSupport, AiGenerationProviderFactory, LlamaCppJniAiGenerationProvider, MockAiGenerationProvider, AiCompletionParser +- External: Native llama.cpp via JNI bindings, Lombok annotations, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Defensive copying in setters ensures immutability of collections. +- Null handling with @Nullable and explicit checks across configuration classes. +- Thread safety: Not thread-safe; designed for single-threaded Maven plugin use. +- Immutable configuration objects (`LlamaCppJniConfig`) enforce consistency. +- Stateful lazy initialization in `LlamaCppJniAiGenerationProvider`. +- Shared exception handling via IOException. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..b85ec4f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,43 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:49:11Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract and clean model answers by removing internal reasoning blocks. + +#### Purpose +- Strips Gemma-4 thinking blocks from model responses. +- Provides cleaned answer text for AI index storage. + +#### Type +Class, non-final. Implements no interfaces. Uses @ToString annotation. + +#### Input +- Constructor takes no parameters. +- Method parseCompletion(String) consumes raw completion text (may be null). + +#### Output +- Returns cleaned string with internal reasoning removed. +- Throws IOException when token budget is exhausted inside a thinking block. + +#### Core logic +- Checks for presence of THINKING_BLOCK_END_MARKER in input. +- If found, removes everything up to and including the end marker. +- If THINKING_BLOCK_START_MARKER exists without END_MARKER, throws IOException. +- Otherwise returns trimmed input string. + +#### Public API +parseCompletion(response) -> String Cleans model response by stripping reasoning blocks. + +#### Dependencies +java.io.IOException, lombok.ToString + +#### Exceptions / Errors +Throws IOException when THINKING_BLOCK_START_MARKER is present but END_MARKER is missing due to token limit exhaustion. + +#### Concurrency +No concurrency concerns; stateless class with immutable constants. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..bb5e158 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,46 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:49:53Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides pluggable text generation for AI inference requests, supporting local and mock backends. + +#### Purpose +- Defines a contract for generating text from AI prompts. +- Enables flexible backend implementations for inference tasks. + +#### Type +Interface, no modifiers. Implements AutoCloseable. + +#### Input +- `AiGenerationRequest` object containing prompt key, source file, source text, and current header. +- Optional `float temperatureOverride` parameter in overloaded method. + +#### Output +- Generated text as `String`; never null. +- Throws `IOException` on failure. + +#### Core logic +- Generates textual output based on input request. +- Supports overriding sampling temperature for retry strategies. +- Delegates to default implementation if not overridden. + +#### Public API +- `generate(AiGenerationRequest) -> String` produces text from request. +- `generate(AiGenerationRequest, float) -> String` overrides temperature for a single call. + +#### Dependencies +- `AiGenerationRequest` +- `IOException` +- `AutoCloseable` + +#### Exceptions / Errors +- Throws `IOException` on backend failure. +- Guarantees non-null return value. + +#### Concurrency +- No explicit concurrency handling; assumes thread-safe usage of implementations. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..cfd575b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,53 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:50:26Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an AI text generation provider implementation based on a name identifier. + +#### Purpose +- Instantiates AI generation providers +- Maps provider names to concrete implementations + +#### Type +class public final +extends Object +implements no interfaces +generics no type bounds +annotations @ToString + +#### Input +- Constructor: no parameters +- Method create: providerName (String), llamaConfig (LlamaCppJniConfig), promptSupport (AiPromptSupport) + +#### Output +- Return type: AiGenerationProvider +- Side effects: none +- State mutation: none + +#### Core logic +- Checks if providerName is null or blank, returns MockAiGenerationProvider +- Uses switch statement to match providerName against "mock" or "llamacpp-jni" +- Throws IllegalArgumentException for unrecognized provider names + +#### Public API +create(providerName, llamaConfig, promptSupport) -> AiGenerationProvider selects and creates AI provider instance + +#### Dependencies +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport +- net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper +- net.ladenthin.maven.llamacpp.aiindex.provider.MockAiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniAiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniConfig + +#### Exceptions / Errors +- IllegalArgumentException thrown when providerName is not recognized +- Null handling for providerName parameter + +#### Concurrency +No concurrency considerations noted diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..33d506b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,57 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:51:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates AI responses using a local GGUF model via JNI bindings, supporting customizable inference parameters and prompt templating. + +#### Purpose +- Provides AI text generation using a native llama.cpp backend. +- Supports dynamic configuration of inference parameters and prompt rendering. + +#### Type +Final class implementing `AiGenerationProvider` and `AutoCloseable`. Uses Lombok's `@ToString` with `@ToString.Exclude` for native model handle. + +#### Input +- Constructor accepts `LlamaCppJniConfig` and `AiPromptSupport`. +- `generate` methods take `AiGenerationRequest` and optional `temperatureOverride`. +- Reads model path, context size, thread count, and other config from `LlamaCppJniConfig`. + +#### Output +- Returns generated AI text as a `String`. +- Mutates internal `model` field on first use. +- Closes native `LlamaModel` handle during `close()`. + +#### Core logic +- Lazily initializes native `LlamaModel` on first `generate()` call. +- Builds prompt using `AiPromptSupport`. +- Configures inference parameters via `InferenceParameters` chain. +- Invokes `chatCompleteText` on the model with configured parameters. +- Parses output using `AiCompletionParser`. + +#### Public API +- `generate(AiGenerationRequest) -> String` Generates AI text with default temperature. +- `generate(AiGenerationRequest, float) -> String` Generates AI text with custom temperature. +- `close() -> void` Releases native model resources. + +#### Dependencies +- `LlamaCppJniConfig` +- `AiPromptSupport` +- `AiCompletionParser` +- `LlamaModel` +- `InferenceParameters` +- `ModelParameters` +- `Pair` +- `AiGenerationRequest` + +#### Exceptions / Errors +- Throws `IOException` during model inference or prompt building. +- Null checks on constructor parameters and prompt support. + +#### Concurrency +- Not thread-safe; native `LlamaModel` is not marked as thread-safe. +- Lazy initialization uses double-checked locking pattern for model. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..89d5919 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,51 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:52:15Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures native llama.cpp inference parameters for AI model execution. + +#### Purpose +- Encapsulates immutable settings for JNI-based llama.cpp model invocation. +- Provides a structured interface for configuring model behavior and resource limits. + +#### Type +Final class implementing value semantics via Lombok annotations. Implements `equals`, `hashCode`, and `toString`. Fields are private and final; accessors follow record-style naming. + +#### Input +Constructor accepts 11 parameters including `libraryPath`, `modelPath`, `contextSize`, `maxOutputTokens`, `temperature`, `threads`, `topP`, `topK`, `repeatPenalty`, `chatTemplateEnableThinking`, and `stopStrings`. `modelPath` is required; `stopStrings` may be null, treated as empty list. + +#### Output +Accessors return field values directly. `stopStrings()` returns an immutable view of the internal list. No mutation or side effects occur during access. + +#### Core logic +- Validates that `modelPath` is not null. +- Assigns constructor parameters to private fields. +- Converts null `stopStrings` to empty immutable list. +- Exposes all configuration values through getter-style methods. + +#### Public API +- `libraryPath() -> String` retrieves native library path. +- `modelPath() -> String` retrieves GGUF model file path. +- `contextSize() -> int` retrieves context window size. +- `maxOutputTokens() -> int` retrieves maximum output tokens. +- `temperature() -> float` retrieves sampling temperature. +- `threads() -> int` retrieves CPU thread count. +- `topP() -> float` retrieves nucleus-sampling threshold. +- `topK() -> int` retrieves top-k sampling limit. +- `repeatPenalty() -> float` retrieves repetition penalty. +- `chatTemplateEnableThinking() -> boolean` retrieves thinking mode flag. +- `stopStrings() -> List` retrieves immutable stop strings. + +#### Dependencies +java.util.Collections, java.util.List, java.util.Objects, lombok.EqualsAndHashCode, lombok.ToString, net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord + +#### Exceptions / Errors +Throws `NullPointerException` if `modelPath` is null. Null `stopStrings` results in empty list, not exception. + +#### Concurrency +Immutable design ensures thread safety. No synchronization required. All fields are final and accessed via immutable views. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..17a1aa2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,47 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:53:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides deterministic mock AI summaries for testing purposes. + +#### Purpose +- Supplies fake AI-generated content for unit tests. +- Enables isolated testing of components dependent on AI generation. + +#### Type +- Class, final +- Implements AiGenerationProvider +- Uses Lombok @ToString annotation + +#### Input +- Constructor takes no parameters +- Method generate() consumes AiGenerationRequest with sourceFile Path + +#### Output +- Returns String summary prefixed with "Mock summary for " +- Side effect: none + +#### Core logic +- Extracts filename from request's source file path +- Constructs deterministic mock response using filename + +#### Public API +- generate(request) → String Generates mock AI summary for given request + +#### Dependencies +- java.io.IOException +- java.nio.file.Path +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider + +#### Exceptions / Errors +- Throws IOException from generate method (not handled internally) + +#### Concurrency +- No concurrency considerations; stateless implementation diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..ee69311 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,56 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T22:56:51Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> Enables pluggable local and mock AI text generation for code indexing, with support for native llama.cpp inference and reasoning block parsing. + +#### Purpose +- Provides flexible AI inference backends for generating code summaries. +- Supports both local GGUF model execution and deterministic mock responses for testing. + +#### Responsibilities +- AI text generation via JNI-bound llama.cpp models +- Mock AI response generation for unit testing +- Parsing of LLM completion outputs to remove internal reasoning +- Configuration management for native inference parameters + +#### Key units +- **AiCompletionParser** cleans model outputs by stripping thinking blocks +- **AiGenerationProvider** defines the contract for text generation +- **AiGenerationProviderFactory** selects and instantiates AI providers +- **LlamaCppJniAiGenerationProvider** implements local GGUF model inference +- **LlamaCppJniConfig** holds immutable configuration for llama.cpp invocation +- **MockAiGenerationProvider** supplies deterministic mock summaries + +#### Data flow +1. Input request with prompt and source file is passed to `AiGenerationProvider` +2. Factory selects appropriate provider (`LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`) +3. Provider builds prompt using `AiPromptSupport`, configures inference, and calls native model +4. Raw completion text is processed by `AiCompletionParser` to remove reasoning blocks +5. Cleaned output is returned for indexing + +#### Dependencies +- Native llama.cpp library via JNI bindings +- `AiPromptSupport` for prompt templating +- `LlamaModel` and related inference classes from native bindings +- `AiGenerationRequest` for input structure +- `ConvertToRecord` for configuration value semantics + +#### Cross-cutting +- All providers implement `AiGenerationProvider` interface +- Shared exception handling via `IOException` +- Lombok annotations (`@ToString`, `@EqualsAndHashCode`) for boilerplate +- Immutable configuration objects (`LlamaCppJniConfig`) +- Stateful lazy initialization in `LlamaCppJniAiGenerationProvider` +- Thread safety considerations noted for native model usage diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..7e71b93 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T22:59:54Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. + +#### Purpose +- Configures AI workflows for analyzing and summarizing Java source files. +- Enables flexible, pluggable text generation backends including local llama.cpp models and mock responses. + +#### Responsibilities +- **Configuration Management**: Defines AI model settings, prompt templates, and file selection rules. +- **Inference Execution**: Provides local GGUF model support via JNI and deterministic mocking for testing. +- **Output Processing**: Cleans AI completions by removing internal reasoning blocks for clean indexing. + +#### Key units +- AiFieldGenerationConfig: Maps file extensions to prompt templates and model definitions. +- AiFieldGenerationSelector: Matches input files to appropriate generation configurations. +- AiGenerationConfig: Carries mutable inference parameters for llama.cpp. +- AiGenerationProvider: Interface for AI text generation implementations. +- LlamaCppJniAiGenerationProvider: Implements native GGUF model inference using JNI. +- MockAiGenerationProvider: Supplies deterministic mock responses for testing. +- AiCompletionParser: Strips reasoning blocks from raw AI outputs. + +#### Data flow +- Maven plugin loads AiFieldGenerationConfig entries to match files with prompt templates. +- AiFieldGenerationSelector resolves the correct config by file extension. +- Config references an AiModelDefinition, resolved into AiGenerationConfig via AiModelDefinitionSupport. +- AiGenerationProviderFactory selects between LlamaCppJniAiGenerationProvider or MockAiGenerationProvider. +- Input prompts are processed through AiPromptSupport, native inference is called, and output is cleaned by AiCompletionParser. + +#### Dependencies +- Internal: AiFieldGenerationConfig, AiFieldGenerationSelector, AiGenerationConfig, AiModelDefinition, AiModelDefinitionSupport, AiGenerationProviderFactory, LlamaCppJniAiGenerationProvider, MockAiGenerationProvider, AiCompletionParser +- External: Native llama.cpp via JNI bindings, Lombok annotations, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Defensive copying in setters ensures immutability of collections. +- Null handling with @Nullable and explicit checks across configuration classes. +- Thread safety: Not thread-safe; designed for single-threaded Maven plugin use. +- Immutable configuration objects (`LlamaCppJniConfig`) enforce consistency. +- Stateful lazy initialization in `LlamaCppJniAiGenerationProvider`. +- Shared exception handling via IOException. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..88b309b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:00:54Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. + +#### Purpose +- Configures AI workflows for analyzing and summarizing Java source files. +- Enables flexible, pluggable text generation backends including local llama.cpp models and mock responses. + +#### Responsibilities +- **Configuration Management**: Defines AI model settings, prompt templates, and file selection rules. +- **Inference Execution**: Provides local GGUF model support via JNI and deterministic mocking for testing. +- **Output Processing**: Cleans AI completions by removing internal reasoning blocks for clean indexing. + +#### Key units +- AiFieldGenerationConfig: Maps file extensions to prompt templates and model definitions. +- AiFieldGenerationSelector: Matches input files to appropriate generation configurations. +- AiGenerationConfig: Carries mutable inference parameters for llama.cpp. +- AiGenerationProvider: Interface for AI text generation implementations. +- LlamaCppJniAiGenerationProvider: Implements native GGUF model inference using JNI. +- MockAiGenerationProvider: Supplies deterministic mock responses for testing. +- AiCompletionParser: Strips reasoning blocks from raw AI outputs. + +#### Data flow +- Maven plugin loads AiFieldGenerationConfig entries to match files with prompt templates. +- AiFieldGenerationSelector resolves the correct config by file extension. +- Config references an AiModelDefinition, resolved into AiGenerationConfig via AiModelDefinitionSupport. +- AiGenerationProviderFactory selects between LlamaCppJniAiGenerationProvider or MockAiGenerationProvider. +- Input prompts are processed through AiPromptSupport, native inference is called, and output is cleaned by AiCompletionParser. + +#### Dependencies +- Internal: AiFieldGenerationConfig, AiFieldGenerationSelector, AiGenerationConfig, AiModelDefinition, AiModelDefinitionSupport, AiGenerationProviderFactory, LlamaCppJniAiGenerationProvider, MockAiGenerationProvider, AiCompletionParser +- External: Native llama.cpp via JNI bindings, Lombok annotations, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Defensive copying in setters ensures immutability of collections. +- Null handling with @Nullable and explicit checks across configuration classes. +- Thread safety: Not thread-safe; designed for single-threaded Maven plugin use. +- Immutable configuration objects (`LlamaCppJniConfig`) enforce consistency. +- Stateful lazy initialization in `LlamaCppJniAiGenerationProvider`. +- Shared exception handling via IOException. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..154236b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:01:53Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. + +#### Purpose +- Configures AI workflows for analyzing and summarizing Java source files. +- Enables flexible, pluggable text generation backends including local llama.cpp models and mock responses. + +#### Responsibilities +- **Configuration Management**: Defines AI model settings, prompt templates, and file selection rules. +- **Inference Execution**: Provides local GGUF model support via JNI and deterministic mocking for testing. +- **Output Processing**: Cleans AI completions by removing internal reasoning blocks for clean indexing. + +#### Key units +- AiFieldGenerationConfig: Maps file extensions to prompt templates and model definitions. +- AiFieldGenerationSelector: Matches input files to appropriate generation configurations. +- AiGenerationConfig: Carries mutable inference parameters for llama.cpp. +- AiGenerationProvider: Interface for AI text generation implementations. +- LlamaCppJniAiGenerationProvider: Implements native GGUF model inference using JNI. +- MockAiGenerationProvider: Supplies deterministic mock responses for testing. +- AiCompletionParser: Strips reasoning blocks from raw AI outputs. + +#### Data flow +- Maven plugin loads AiFieldGenerationConfig entries to match files with prompt templates. +- AiFieldGenerationSelector resolves the correct config by file extension. +- Config references an AiModelDefinition, resolved into AiGenerationConfig via AiModelDefinitionSupport. +- AiGenerationProviderFactory selects between LlamaCppJniAiGenerationProvider or MockAiGenerationProvider. +- Input prompts are processed through AiPromptSupport, native inference is called, and output is cleaned by AiCompletionParser. + +#### Dependencies +- Internal: AiFieldGenerationConfig, AiFieldGenerationSelector, AiGenerationConfig, AiModelDefinition, AiModelDefinitionSupport, AiGenerationProviderFactory, LlamaCppJniAiGenerationProvider, MockAiGenerationProvider, AiCompletionParser +- External: Native llama.cpp via JNI bindings, Lombok annotations, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Defensive copying in setters ensures immutability of collections. +- Null handling with @Nullable and explicit checks across configuration classes. +- Thread safety: Not thread-safe; designed for single-threaded Maven plugin use. +- Immutable configuration objects (`LlamaCppJniConfig`) enforce consistency. +- Stateful lazy initialization in `LlamaCppJniAiGenerationProvider`. +- Shared exception handling via IOException. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/package.ai.md new file mode 100644 index 0000000..d093d1b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/net/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:02:52Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. + +#### Purpose +- Configures AI workflows for analyzing and summarizing Java source files. +- Enables flexible, pluggable text generation backends including local llama.cpp models and mock responses. + +#### Responsibilities +- **Configuration Management**: Defines AI model settings, prompt templates, and file selection rules. +- **Inference Execution**: Provides local GGUF model support via JNI and deterministic mocking for testing. +- **Output Processing**: Cleans AI completions by removing internal reasoning blocks for clean indexing. + +#### Key units +- AiFieldGenerationConfig: Maps file extensions to prompt templates and model definitions. +- AiFieldGenerationSelector: Matches input files to appropriate generation configurations. +- AiGenerationConfig: Carries mutable inference parameters for llama.cpp. +- AiGenerationProvider: Interface for AI text generation implementations. +- LlamaCppJniAiGenerationProvider: Implements native GGUF model inference using JNI. +- MockAiGenerationProvider: Supplies deterministic mock responses for testing. +- AiCompletionParser: Strips reasoning blocks from raw AI outputs. + +#### Data flow +- Maven plugin loads AiFieldGenerationConfig entries to match files with prompt templates. +- AiFieldGenerationSelector resolves the correct config by file extension. +- Config references an AiModelDefinition, resolved into AiGenerationConfig via AiModelDefinitionSupport. +- AiGenerationProviderFactory selects between LlamaCppJniAiGenerationProvider or MockAiGenerationProvider. +- Input prompts are processed through AiPromptSupport, native inference is called, and output is cleaned by AiCompletionParser. + +#### Dependencies +- Internal: AiFieldGenerationConfig, AiFieldGenerationSelector, AiGenerationConfig, AiModelDefinition, AiModelDefinitionSupport, AiGenerationProviderFactory, LlamaCppJniAiGenerationProvider, MockAiGenerationProvider, AiCompletionParser +- External: Native llama.cpp via JNI bindings, Lombok annotations, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Defensive copying in setters ensures immutability of collections. +- Null handling with @Nullable and explicit checks across configuration classes. +- Thread safety: Not thread-safe; designed for single-threaded Maven plugin use. +- Immutable configuration objects (`LlamaCppJniConfig`) enforce consistency. +- Stateful lazy initialization in `LlamaCppJniAiGenerationProvider`. +- Shared exception handling via IOException. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/package.ai.md new file mode 100644 index 0000000..b69a9f4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/java/package.ai.md @@ -0,0 +1,48 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:03:51Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. + +#### Purpose +- Configures AI workflows for analyzing and summarizing Java source files. +- Enables flexible, pluggable text generation backends including local llama.cpp models and mock responses. + +#### Responsibilities +- **Configuration Management**: Defines AI model settings, prompt templates, and file selection rules. +- **Inference Execution**: Provides local GGUF model support via JNI and deterministic mocking for testing. +- **Output Processing**: Cleans AI completions by removing internal reasoning blocks for clean indexing. + +#### Key units +- AiFieldGenerationConfig: Maps file extensions to prompt templates and model definitions. +- AiFieldGenerationSelector: Matches input files to appropriate generation configurations. +- AiGenerationConfig: Carries mutable inference parameters for llama.cpp. +- AiGenerationProvider: Interface for AI text generation implementations. +- LlamaCppJniAiGenerationProvider: Implements native GGUF model inference using JNI. +- MockAiGenerationProvider: Supplies deterministic mock responses for testing. +- AiCompletionParser: Strips reasoning blocks from raw AI outputs. + +#### Data flow +- Maven plugin loads AiFieldGenerationConfig entries to match files with prompt templates. +- AiFieldGenerationSelector resolves the correct config by file extension. +- Config references an AiModelDefinition, resolved into AiGenerationConfig via AiModelDefinitionSupport. +- AiGenerationProviderFactory selects between LlamaCppJniAiGenerationProvider or MockAiGenerationProvider. +- Input prompts are processed through AiPromptSupport, native inference is called, and output is cleaned by AiCompletionParser. + +#### Dependencies +- Internal: AiFieldGenerationConfig, AiFieldGenerationSelector, AiGenerationConfig, AiModelDefinition, AiModelDefinitionSupport, AiGenerationProviderFactory, LlamaCppJniAiGenerationProvider, MockAiGenerationProvider, AiCompletionParser +- External: Native llama.cpp via JNI bindings, Lombok annotations, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Defensive copying in setters ensures immutability of collections. +- Null handling with @Nullable and explicit checks across configuration classes. +- Thread safety: Not thread-safe; designed for single-threaded Maven plugin use. +- Immutable configuration objects (`LlamaCppJniConfig`) enforce consistency. +- Stateful lazy initialization in `LlamaCppJniAiGenerationProvider`. +- Shared exception handling via IOException. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/package.ai.md new file mode 100644 index 0000000..a5d19e2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/main/package.ai.md @@ -0,0 +1,48 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:04:49Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. + +#### Purpose +- Configures AI workflows for analyzing and summarizing Java source files. +- Enables flexible, pluggable text generation backends including local llama.cpp models and mock responses. + +#### Responsibilities +- **Configuration Management**: Defines AI model settings, prompt templates, and file selection rules. +- **Inference Execution**: Provides local GGUF model support via JNI and deterministic mocking for testing. +- **Output Processing**: Cleans AI completions by removing internal reasoning blocks for clean indexing. + +#### Key units +- AiFieldGenerationConfig: Maps file extensions to prompt templates and model definitions. +- AiFieldGenerationSelector: Matches input files to appropriate generation configurations. +- AiGenerationConfig: Carries mutable inference parameters for llama.cpp. +- AiGenerationProvider: Interface for AI text generation implementations. +- LlamaCppJniAiGenerationProvider: Implements native GGUF model inference using JNI. +- MockAiGenerationProvider: Supplies deterministic mock responses for testing. +- AiCompletionParser: Strips reasoning blocks from raw AI outputs. + +#### Data flow +- Maven plugin loads AiFieldGenerationConfig entries to match files with prompt templates. +- AiFieldGenerationSelector resolves the correct config by file extension. +- Config references an AiModelDefinition, resolved into AiGenerationConfig via AiModelDefinitionSupport. +- AiGenerationProviderFactory selects between LlamaCppJniAiGenerationProvider or MockAiGenerationProvider. +- Input prompts are processed through AiPromptSupport, native inference is called, and output is cleaned by AiCompletionParser. + +#### Dependencies +- Internal: AiFieldGenerationConfig, AiFieldGenerationSelector, AiGenerationConfig, AiModelDefinition, AiModelDefinitionSupport, AiGenerationProviderFactory, LlamaCppJniAiGenerationProvider, MockAiGenerationProvider, AiCompletionParser +- External: Native llama.cpp via JNI bindings, Lombok annotations, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Defensive copying in setters ensures immutability of collections. +- Null handling with @Nullable and explicit checks across configuration classes. +- Thread safety: Not thread-safe; designed for single-threaded Maven plugin use. +- Immutable configuration objects (`LlamaCppJniConfig`) enforce consistency. +- Stateful lazy initialization in `LlamaCppJniAiGenerationProvider`. +- Shared exception handling via IOException. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/package.ai.md new file mode 100644 index 0000000..621ef30 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/package.ai.md @@ -0,0 +1,48 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:05:48Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Automates intelligent code summarization and indexing for Java projects using configurable AI backends. + +#### Purpose +- Configures AI workflows for analyzing and summarizing Java source files. +- Enables flexible, pluggable text generation backends including local llama.cpp models and mock responses. + +#### Responsibilities +- **Configuration Management**: Defines AI model settings, prompt templates, and file selection rules. +- **Inference Execution**: Provides local GGUF model support via JNI and deterministic mocking for testing. +- **Output Processing**: Cleans AI completions by removing internal reasoning blocks for clean indexing. + +#### Key units +- AiFieldGenerationConfig: Maps file extensions to prompt templates and model definitions. +- AiFieldGenerationSelector: Matches input files to appropriate generation configurations. +- AiGenerationConfig: Carries mutable inference parameters for llama.cpp. +- AiGenerationProvider: Interface for AI text generation implementations. +- LlamaCppJniAiGenerationProvider: Implements native GGUF model inference using JNI. +- MockAiGenerationProvider: Supplies deterministic mock responses for testing. +- AiCompletionParser: Strips reasoning blocks from raw AI outputs. + +#### Data flow +- Maven plugin loads AiFieldGenerationConfig entries to match files with prompt templates. +- AiFieldGenerationSelector resolves the correct config by file extension. +- Config references an AiModelDefinition, resolved into AiGenerationConfig via AiModelDefinitionSupport. +- AiGenerationProviderFactory selects between LlamaCppJniAiGenerationProvider or MockAiGenerationProvider. +- Input prompts are processed through AiPromptSupport, native inference is called, and output is cleaned by AiCompletionParser. + +#### Dependencies +- Internal: AiFieldGenerationConfig, AiFieldGenerationSelector, AiGenerationConfig, AiModelDefinition, AiModelDefinitionSupport, AiGenerationProviderFactory, LlamaCppJniAiGenerationProvider, MockAiGenerationProvider, AiCompletionParser +- External: Native llama.cpp via JNI bindings, Lombok annotations, org.jspecify.annotations.Nullable + +#### Cross-cutting +- Defensive copying in setters ensures immutability of collections. +- Null handling with @Nullable and explicit checks across configuration classes. +- Thread safety: Not thread-safe; designed for single-threaded Maven plugin use. +- Immutable configuration objects (`LlamaCppJniConfig`) enforce consistency. +- Stateful lazy initialization in `LlamaCppJniAiGenerationProvider`. +- Shared exception handling via IOException. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/project.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/project.ai.md new file mode 100644 index 0000000..17736f5 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: DB079F76 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:06:53Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +This Maven plugin automates AI-powered code summarization and indexing for Java projects through configurable inference backends. The core subsystem handles field-level analysis and source file summarization using customizable model parameters and prompt templates. The provider module enables pluggable local and mock AI text generation with support for native llama.cpp inference and reasoning block parsing. These components work together to deliver intelligent code indexing capabilities across the entire project structure. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Configures and manages AI-driven code generation workflows for Maven plugins, enabling field-level analysis and summarization of source files using customizable model parameters and prompt templates. +- main/java/net/ladenthin/maven/llamacpp/aiindex — Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Enables pluggable local and mock AI text generation for code indexing, with support for native llama.cpp inference and reasoning block parsing. +- main/java/net/ladenthin/maven/llamacpp — Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. +- main/java/net/ladenthin/maven — Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. +- main/java/net/ladenthin — Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. +- main/java/net — Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. +- main/java — Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. +- main — Automates AI-powered code summarization and indexing for Maven projects using configurable inference backends. +- . — Automates intelligent code summarization and indexing for Java projects using configurable AI backends. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..d53459d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,62 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T15:50:32Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI-driven field generation by linking prompt templates and model definitions for Maven plugin execution. + +#### Purpose +- Maps AI prompt templates to model configurations for field generation. +- Supports file extension filtering for targeted generation. + +#### Type +class public final +extends java.lang.Object +implements no interfaces +generics no type bounds +annotations @ToString, @SuppressWarnings + +#### Input +- Constructor: no parameters. +- Method parameters: setPromptKey(String), setAiDefinitionKey(String), setFileExtensions(Collection). +- Fields read: promptKey, aiDefinitionKey, fileExtensions. +- Dependencies injected via setters. + +#### Output +- Return types: getPromptKey(), getAiDefinitionKey(), getFileExtensions(). +- State mutated: promptKey, aiDefinitionKey, fileExtensions. +- Side effects: defensive copy in setFileExtensions(). + +#### Core logic +- Associates a prompt template key with an AI model definition key. +- Filters files by extension list or applies as fallback. +- Provides getter/setter access for configuration fields. + +#### Public API +- getPromptKey() -> String selects the prompt template. +- setPromptKey(String) -> void assigns the prompt template key. +- getAiDefinitionKey() -> String selects the AI model definition. +- setAiDefinitionKey(String) -> void assigns the AI model definition key. +- getFileExtensions() -> List filters files by extension. +- setFileExtensions(Collection) -> void sets file extension filter. + +#### Dependencies +- java.util.ArrayList +- java.util.Collection +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- No explicit throws. +- Null handling in getFileExtensions() and setFileExtensions(). +- Defensive copying prevents external mutation of fileExtensions. + +#### Concurrency +- Not thread-safe due to mutable fields. +- No synchronization mechanisms. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..727bc86 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,52 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T15:52:31Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects AI field generation configuration based on file extensions and fallback rules. + +#### Purpose +- Matches source files to AI prompt configurations by file extension. +- Provides fallback behavior when no extension matches. + +#### Type +Class, final. No extends or implements. Generics: Iterable. Annotations: @ToString. + +#### Input +- Constructor takes no parameters. +- Method `selectForFileName` consumes: + - configs: Iterable of AiFieldGenerationConfig, may contain nulls + - fileName: String, e.g. "Foo.java" + +#### Output +- Method returns @Nullable AiFieldGenerationConfig. +- Null when no matching config or fallback is found. + +#### Core logic +- Iterates through AiFieldGenerationConfig entries in order. +- Skips null configs. +- For each config: + - If file extensions list is empty/absent, stores as fallback if not already set. + - Otherwise checks if fileName ends with any extension in the list. + - Returns first matching config. +- Returns fallback if no match found. + +#### Public API +- `selectForFileName(configs, fileName) -> AiFieldGenerationConfig` selects config by file extension + +#### Dependencies +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable +- AiFieldGenerationConfig + +#### Exceptions / Errors +- Null handling: skips null configs in Iterable. +- Returns null when no match and no fallback. + +#### Concurrency +- No concurrency concerns; stateless class with immutable inputs. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..e8a92fc --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,85 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T15:53:23Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures parameters for AI model inference steps including context size, sampling settings, and retry logic. + +#### Purpose +- Carries AI generation parameters between Maven configuration and provider implementations. +- Supports mutable JavaBean style configuration through setters. + +#### Type +class public final +extends Object +implements + +#### Input +- Constructor parameters: none +- Method parameters: all setter methods accept primitive or collection types +- Dependencies: Lombok for `@ToString`, JSpecify for `@Nullable` + +#### Output +- Return types: primitives, String, List +- State mutations: fields modified by setters +- Side effects: none explicitly + +#### Core logic +- Holds mutable configuration state for AI inference +- Provides default values for all configurable parameters +- Manages automatic calculation of input character limits based on token counts +- Supports retry behavior with increasing temperature +- Exposes stop strings as an unmodifiable list + +#### Public API +- getModelPath() -> String +- setModelPath(String) -> void +- getContextSize() -> int +- setContextSize(int) -> void +- getMaxOutputTokens() -> int +- setMaxOutputTokens(int) -> void +- getTemperature() -> float +- setTemperature(float) -> void +- getThreads() -> int +- setThreads(int) -> void +- getCharsPerToken() -> int +- setCharsPerToken(int) -> void +- getMaxInputChars() -> int +- setMaxInputChars(int) -> void +- isWarnOnTrim() -> boolean +- setWarnOnTrim(boolean) -> void +- getMaxRetries() -> int +- setMaxRetries(int) -> void +- getRetryTemperatureIncrement() -> float +- setRetryTemperatureIncrement(float) -> void +- getTopP() -> float +- setTopP(float) -> void +- getTopK() -> int +- setTopK(int) -> void +- getRepeatPenalty() -> float +- setRepeatPenalty(float) -> void +- isChatTemplateEnableThinking() -> boolean +- setChatTemplateEnableThinking(boolean) -> void +- getStopStrings() -> List +- setStopStrings(List) -> void + +#### Dependencies +- java.util.ArrayList +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- No explicit exceptions thrown +- Null handling via `@Nullable` annotation on `getStopStrings()` and `setStopStrings()` +- Default values prevent null field access + +#### Concurrency +- Not thread-safe due to mutable state +- Intended for use in single-threaded Maven plugin context +- Identity-based equality used instead of generated equals/hashCode diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..adc3b7f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,36 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T15:56:25Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Determines whether AI generation processes individual files or entire packages + +#### Purpose +- Distinguishes AI processing scope for code analysis +- Supports configuration of generation strategies + +#### Type +Enum, final + +#### Core logic +- Defines two generation modes: FILE_SUMMARY and PACKAGE_SUMMARY +- Represents discrete AI processing strategies based on scope + +#### Public API +- FILE_SUMMARY() -> AiGenerationKind: Single file analysis mode +- PACKAGE_SUMMARY() -> AiGenerationKind: Package aggregate analysis mode + +#### Dependencies +- net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationKind + +#### Exceptions / Errors +- No explicit exceptions handled +- Null handling not applicable for enum values + +#### Concurrency +- Enum is inherently immutable and thread-safe +- No synchronization required for usage diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..8594a5f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,78 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T15:56:43Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines reusable AI model configurations for Maven plugin field generation. + +#### Purpose +- Stores AI model parameters for reuse across multiple generation tasks. +- Supports Maven plugin configuration via JavaBean setters. + +#### Type +Class, final. Implements no interfaces. Generics: none. Annotations: @ToString, @SuppressWarnings. + +#### Input +- Constructor: no parameters. +- Setters: key, modelPath, contextSize, maxOutputTokens, temperature, threads, charsPerToken, warnOnTrim, maxRetries, retryTemperatureIncrement, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings. +- Dependencies: AiGenerationConfig defaults. + +#### Output +- Getters return stored values or unmodifiable collections. +- State changes via setter methods. + +#### Core logic +- Holds configuration values for AI model inference. +- Provides default values from AiGenerationConfig. +- Supports immutable access to stopStrings list. +- Enables Maven plugin instantiation via reflection-based injection. + +#### Public API +- getKey() -> String +- setKey(String) +- getModelPath() -> String +- setModelPath(String) +- getContextSize() -> int +- setContextSize(int) +- getMaxOutputTokens() -> int +- setMaxOutputTokens(int) +- getTemperature() -> float +- setTemperature(float) +- getThreads() -> int +- setThreads(int) +- getCharsPerToken() -> int +- setCharsPerToken(int) +- isWarnOnTrim() -> boolean +- setWarnOnTrim(boolean) +- getMaxRetries() -> int +- setMaxRetries(int) +- getRetryTemperatureIncrement() -> float +- setRetryTemperatureIncrement(float) +- getTopP() -> float +- setTopP(float) +- getTopK() -> int +- setTopK(int) +- getRepeatPenalty() -> float +- setRepeatPenalty(float) +- isChatTemplateEnableThinking() -> boolean +- setChatTemplateEnableThinking(boolean) +- getStopStrings() -> List +- setStopStrings(Collection) + +#### Dependencies +- java.util.ArrayList, java.util.Collection, java.util.Collections, java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable +- net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig + +#### Exceptions / Errors +- Null handling: stopStrings may be null; returned list is unmodifiable. +- No explicit exceptions thrown. + +#### Concurrency +- Not thread-safe due to mutable state. +- No synchronization mechanisms. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..3271857 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,41 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T15:59:12Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key to provide configured generation settings for AI field generation. + +#### Purpose +- Maps AI model definition keys to ready-to-use generation configurations. +- Enforces required fields and validates configuration at build time. + +#### Type +Final class extending no types; implements no interfaces. Uses generics: Map. Key annotations: @ToString. + +#### Input +Constructor takes List; each definition must have a non-null key. Dependencies include Java8CompatibilityHelper. + +#### Output +Returns AiGenerationConfig for valid keys; throws IllegalArgumentException for missing keys. Produces HashMap of configs from definitions. + +#### Core logic +- Builds lookup map from input definitions, ensuring no null keys. +- Maps each definition to a generation config via field copying. +- Provides fast key-based retrieval with error handling for missing keys. + +#### Public API +getConfig(key) -> AiGenerationConfig: retrieves config by key +toConfig(definition) -> AiGenerationConfig: converts model def to gen config + +#### Dependencies +Imports: java.util.HashMap, java.util.List, java.util.Map, java.util.Objects, lombok.ToString, net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper, net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinition, net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig + +#### Exceptions / Errors +Throws NullPointerException for null keys in definitions; IllegalArgumentException for missing keys during lookup. + +#### Concurrency +No concurrency considerations noted. Class is immutable post-construction. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package-info.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package-info.java.ai.md new file mode 100644 index 0000000..5e447ba --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package-info.java.ai.md @@ -0,0 +1,42 @@ +### package-info.java +- H: 1.0 +- C: 119B56BD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:00:18Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines configuration and model lookup mechanisms for AI indexing in Maven projects. + +#### Purpose +- Configures generation parameters for AI-driven code indexing +- Provides model definitions and lookup utilities for LlamaCpp integration + +#### Type +package `net.ladenthin.maven.llamacpp.aiindex.config` + +#### Input +- Package-level documentation comments +- No constructor or method parameters +- No injected dependencies or consumed fields + +#### Output +- No return types or side effects +- No produced state or mutated fields + +#### Core logic +- Establishes package structure for AI indexing configuration +- Supports model definition and lookup functionality + +#### Public API +- No public/protected members + +#### Dependencies +- No imports or referenced types + +#### Exceptions / Errors +- No exceptions or null-handling mentioned + +#### Concurrency +- No concurrency considerations applicable diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..2834a4a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,54 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: D29D30C8 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:10:35Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +- F: [package-info.java](package-info.java.ai.md) +--- +> Configures and manages AI-driven code indexing and generation for Maven projects using model definitions, prompt templates, and generation parameters. + +#### Purpose +- Defines AI model configurations and generation parameters for Maven plugin execution. +- Supports field-level code generation based on file extensions and prompt templates. + +#### Responsibilities +- AI configuration management: encapsulates settings for AI inference including context size, sampling, and retry logic. +- Prompt and model mapping: links prompt templates to AI model definitions for targeted field generation. +- File extension filtering: selects appropriate configurations based on source file types. +- Model lookup and validation: resolves model definitions by key with build-time checks. + +#### Key units +- AiFieldGenerationConfig: maps prompt templates to model definitions and filters files by extension. +- AiFieldGenerationSelector: matches source files to field generation configurations using extension-based logic. +- AiGenerationConfig: carries AI inference parameters such as context size, temperature, and retry settings. +- AiGenerationKind: distinguishes between file-level and package-level AI processing scopes. +- AiModelDefinition: stores reusable AI model parameters for Maven plugin use. +- AiModelDefinitionSupport: resolves model definitions into ready-to-use generation configurations with key-based lookup. + +#### Data flow +- Input files are matched to AiFieldGenerationConfig entries by extension. +- Matching configs link to AiModelDefinition instances via keys. +- AiModelDefinitionSupport resolves these definitions into AiGenerationConfig objects. +- These configurations drive AI inference parameters for code analysis or generation tasks. + +#### Dependencies +- java.util.ArrayList, Collections, List +- lombok.ToString, @SuppressWarnings +- org.jspecify.annotations.Nullable +- AiGenerationConfig, AiModelDefinition +- Java8CompatibilityHelper + +#### Cross-cutting +- Shared use of Lombok annotations for boilerplate reduction. +- Null safety via @Nullable annotations and defensive copying in collections. +- Immutable access patterns for configuration lists like stopStrings. +- Thread-safety considerations: all classes are mutable and not thread-safe; intended for single-threaded Maven contexts. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiGenerationRequest.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiGenerationRequest.java.ai.md new file mode 100644 index 0000000..af05a00 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiGenerationRequest.java.ai.md @@ -0,0 +1,43 @@ +### AiGenerationRequest.java +- H: 1.0 +- C: BE482ECE +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:00:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Encapsulates input for AI content generation requests, including prompt template, source file, and header data. + +#### Purpose +- Carries immutable data for AI generation tasks. +- Supports mapping of source files to AI prompt templates and headers. + +#### Type +Final class implementing value semantics via Lombok annotations. Implements `EqualsAndHashCode`, `ToString`. No interfaces or generics. + +#### Input +Constructor takes: `String promptKey`, `Path sourceFile`, `String sourceText`, `AiMdHeader currentHeader`. All parameters are required and validated with `Objects.requireNonNull`. + +#### Output +Public accessors return: `promptKey`, `sourceFile`, `sourceText`, `currentHeader` as declared types. + +#### Core logic +- Constructs immutable request object from four fields. +- Provides record-style accessors for all fields. +- Enforces non-null inputs at construction time. + +#### Public API +- `promptKey() -> String` retrieves prompt template identifier +- `sourceFile() -> Path` retrieves source file path +- `sourceText() -> String` retrieves source file content +- `currentHeader() -> AiMdHeader` retrieves current AI markdown header + +#### Dependencies +Imports: `java.nio.file.Path`, `java.util.Objects`, `lombok.EqualsAndHashCode`, `lombok.ToString`, `net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord`, `net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader` + +#### Exceptions / Errors +Throws `NullPointerException` if any constructor argument is null. Null-checks enforced via `Objects.requireNonNull`. + +#### Concurrency +Immutable design ensures thread-safe usage without synchronization. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiGenerationResult.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiGenerationResult.java.ai.md new file mode 100644 index 0000000..360fdc6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiGenerationResult.java.ai.md @@ -0,0 +1,44 @@ +### AiGenerationResult.java +- H: 1.0 +- C: DE646195 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:01:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Represents the outcome of an AI-driven document field generation process, encapsulating the generated content as a structured, immutable value. + +#### Purpose +- Encapsulates AI-generated text output from field processing. +- Provides a stable, value-based representation for downstream use. + +#### Type +Final class implementing record-like behavior via Lombok annotations. Marked with `@ConvertToRecord` for future migration. No extends or implements clauses. + +#### Input +Constructor takes a `String body` parameter; enforced to be non-null via `Objects.requireNonNull`. + +#### Output +Public accessor method `body()` returns the immutable `String` field, which may be empty but never null. + +#### Core logic +- Validates input `body` is not null during construction. +- Stores AI-generated text in an immutable field. +- Exposes the stored text through a record-style getter method. + +#### Public API +- `AiGenerationResult(String body)` → constructor; initializes result with body text +- `String body()` → accessor; retrieves generated body content + +#### Dependencies +- `java.util.Objects` +- `lombok.EqualsAndHashCode` +- `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord` + +#### Exceptions / Errors +Throws `NullPointerException` if constructor argument `body` is null. + +#### Concurrency +Immutable design ensures thread-safe access to instance state. No synchronization required. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdChildEntryLineFormatter.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdChildEntryLineFormatter.java.ai.md new file mode 100644 index 0000000..096c562 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdChildEntryLineFormatter.java.ai.md @@ -0,0 +1,42 @@ +### AiMdChildEntryLineFormatter.java +- H: 1.0 +- C: 12412458 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:01:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates deterministic checksum lines for package-level manifest entries from child names and headers. + +#### Purpose +- Formats structured manifest lines for AI index package checksums. +- Supports aggregation of child entries in a deterministic order. + +#### Type +class AiMdChildEntryLineFormatter final + +#### Input +- Constructor: no parameters. +- Method format: name (String), childHeader (AiMdHeader). + +#### Output +- Return value: String with format `|||\n`. + +#### Core logic +- Concatenates child name and header fields (c, d, x) using a pipe separator. +- Appends newline character to form a complete manifest line. +- Ensures deterministic order via fixed field sequence. + +#### Public API +format(name, childHeader) -> String builds checksum line + +#### Dependencies +AiMdHeader +net.ladenthin.maven.llamacpp.aiindex.document.AiMdChildEntryLineFormatter + +#### Exceptions / Errors +No explicit exceptions. Null handling depends on input parameters. + +#### Concurrency +No concurrency concerns; stateless and immutable. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdDocument.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdDocument.java.ai.md new file mode 100644 index 0000000..36f7ca6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdDocument.java.ai.md @@ -0,0 +1,56 @@ +### AiMdDocument.java +- H: 1.0 +- C: 3B8113EA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:02:32Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Represents an immutable .ai.md document with structured metadata and content for AI indexing. + +#### Purpose +- Stores structured document data for AI processing +- Provides access to metadata and content separately + +#### Type +- final class +- Implements @ToString and @EqualsAndHashCode from Lombok +- Marked @ConvertToRecord for future migration + +#### Input +- Constructor requires AiMdHeader and String body parameters +- Both parameters must be non-null +- Header parameter is required to be non-null +- Body parameter is required to be non-null + +#### Output +- Returns AiMdHeader via header() accessor method +- Returns String body via body() accessor method +- Produces immutable instances with consistent state + +#### Core logic +- Validates constructor arguments for null values +- Stores header and body as final fields +- Provides record-style accessors for header and body fields + +#### Public API +- AiMdDocument(AiMdHeader, String) -> void Creates new document instance +- header() -> AiMdHeader Retrieves metadata header +- body() -> String Retrieves markdown content + +#### Dependencies +- java.util.Objects +- lombok.EqualsAndHashCode +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader + +#### Exceptions / Errors +- Throws NullPointerException if header or body parameters are null +- Null validation occurs in constructor + +#### Concurrency +- Immutable design ensures thread safety +- Final fields prevent modification after construction +- No synchronization required for instance usage diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdDocumentCodec.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdDocumentCodec.java.ai.md new file mode 100644 index 0000000..5cba4f4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdDocumentCodec.java.ai.md @@ -0,0 +1,52 @@ +### AiMdDocumentCodec.java +- H: 1.0 +- C: E353030C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:03:09Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Reads and writes structured markdown documents with metadata headers and bodies from disk. + +#### Purpose +- Parses .ai.md files into structured document objects. +- Serializes document objects back into .ai.md file format. + +#### Type +Class, final. Implements no interfaces. Uses generics: List, StringBuilder. Notable annotations: @ToString. + +#### Input +- Constructor: no parameters. +- read(Path): Path to .ai.md file. +- read(List): Lines of .ai.md content. +- write(AiMdDocument): Document object with header and body. +- write(Path, AiMdDocument): File path and document object. + +#### Output +- read(Path): AiMdDocument object. +- read(List): AiMdDocument object. +- write(AiMdDocument): String representation of .ai.md content. +- write(Path, AiMdDocument): writes UTF-8 file. + +#### Core logic +- Splits input lines into header and body sections based on separator line. +- Identifies header lines by prefix patterns (title, field). +- Skips blank lines before header ends. +- Parses header section using AiMdHeaderCodec. +- Serializes header and body with proper formatting and separator. + +#### Public API +- read(Path) -> AiMdDocument: Reads file to document object. +- write(Path, AiMdDocument) -> void: Writes document to UTF-8 file. + +#### Dependencies +Imports: java.io.IOException, java.nio.charset.StandardCharsets, java.nio.file.Files, java.nio.file.Path, java.util.ArrayList, java.util.List, lombok.ToString, net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper. + +Referenced types: AiMdDocument, AiMdHeaderCodec, AiMdHeader. + +#### Exceptions / Errors +Throws IOException when reading or writing files. Handles null or malformed input through compatibility helper and blank line checks. + +#### Concurrency +No explicit concurrency handling; assumes single-threaded file access. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdHeader.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdHeader.java.ai.md new file mode 100644 index 0000000..cc6d6f2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdHeader.java.ai.md @@ -0,0 +1,51 @@ +### AiMdHeader.java +- H: 1.0 +- C: C6F165E5 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:04:12Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines a structured header model for AI-generated Markdown documents, separating deterministic metadata from AI content for machine parsing. + +#### Purpose +- Represents metadata for .ai.md documents. +- Supports deterministic node comparison and navigation. + +#### Type +Class, final. Implements `EqualsAndHashCode`, `ToString`. Annotated with `@ConvertToRecord`. + +#### Input +Constructor parameters include title, h, c, d, t, g, a, x, and children. Dependencies: `Collection` for children, `String` fields. Injected or consumed fields: `title`, `h`, `c`, `d`, `t`, `g`, `a`, `x`, `children`. + +#### Output +Return types include `String` (title, h, c, d, t, g, a, x) and `List` (children). Mutated fields: `children` stored as unmodifiable list. Side effects: defensive copy of input collection. + +#### Core logic +- Enforces non-null constraints on all constructor parameters. +- Stores children in an immutable list after copying input. +- Provides accessor methods for each field. +- Ensures deterministic header comparison via structural fields. + +#### Public API +- `AiMdHeader(title, h, c, d, t, g, a, x, children)` → AiMdHeader: Creates header with child links. +- `AiMdHeader(title, h, c, d, t, g, a, x)` → AiMdHeader: Creates header without child links. +- `title()` → String: Returns display title. +- `h()` → String: Returns header version. +- `c()` → String: Returns checksum. +- `d()` → String: Returns source timestamp. +- `t()` → String: Returns generation timestamp. +- `g()` → String: Returns generator version. +- `a()` → String: Returns AI schema version. +- `x()` → String: Returns node type. +- `children()` → List: Returns unmodifiable child links. + +#### Dependencies +Imports: `java.util.ArrayList`, `java.util.Collection`, `java.util.Collections`, `java.util.List`, `java.util.Objects`, `lombok.EqualsAndHashCode`, `lombok.ToString`, `net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord`. + +#### Exceptions / Errors +Throws `NullPointerException` on null inputs. Defensive copying prevents external mutation of children list. + +#### Concurrency +No explicit concurrency handling; fields are final and immutable. Thread-safe for read-only access. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdHeaderCodec.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdHeaderCodec.java.ai.md new file mode 100644 index 0000000..233be5f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdHeaderCodec.java.ai.md @@ -0,0 +1,58 @@ +### AiMdHeaderCodec.java +- H: 1.0 +- C: 529B3335 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:06:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses and serializes metadata headers for AI index documents. + +#### Purpose +- Reads and writes structured metadata from AI index document files. +- Manages key-value fields and child-link references in document headers. + +#### Type +Class, final. Implements no interfaces. Uses Lombok @ToString annotation. + +#### Input +- Constructor: no parameters. +- read(List lines): list of text lines from a .ai.md file header. +- read(Path file): file path to an .ai.md file. +- write(AiMdHeader header): structured metadata object. + +#### Output +- read(List): AiMdHeader instance with parsed fields and children. +- write(AiMdHeader): serialized string representing the header. +- read(Path): AiMdHeader from file contents. + +#### Core logic +- Parses lines to extract title, scalar fields, and child links. +- Matches field keys against predefined constants for correct mapping. +- Formats output strings using fixed prefixes and field values. +- Collects multiple child-link entries into a list in encounter order. + +#### Public API +- read(List) -> AiMdHeader: parses header from text lines. +- write(AiMdHeader) -> String: serializes header to string. +- read(Path) -> AiMdHeader: reads and parses header from file. + +#### Dependencies +- java.io.IOException +- java.nio.charset.StandardCharsets +- java.nio.file.Files +- java.nio.file.Path +- java.util.ArrayList +- java.util.HashMap +- java.util.List +- java.util.Map +- net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader + +#### Exceptions / Errors +- IOException: thrown when reading file contents fails. +- Null handling: defaults missing scalar fields to empty string. + +#### Concurrency +- No explicit concurrency control; class is stateless and immutable. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdHeaderSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdHeaderSupport.java.ai.md new file mode 100644 index 0000000..8d23137 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdHeaderSupport.java.ai.md @@ -0,0 +1,54 @@ +### AiMdHeaderSupport.java +- H: 1.0 +- C: F47C5B40 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:07:47Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Determines if an .ai.md document header needs regeneration based on version, content, or structural differences. + +#### Purpose +- Compares document headers to decide whether to rewrite a file. +- Evaluates file existence, content, and header version for changes. + +#### Type +Class, final. Implements no interfaces. Uses Lombok @ToString annotation. + +#### Input +- Constructor: no parameters. +- Method `shouldWrite`: boolean force, Path targetFile, AiMdHeader expectedHeader. +- Dependencies: Java8CompatibilityHelper, AiMdDocumentCodec, AiMdHeaderCodec. +- Reads file content via Files.exists, Files.read. + +#### Output +- Returns boolean indicating whether to rewrite the file. +- Side effect: reads from filesystem at targetFile path. + +#### Core logic +- If force flag is true, always returns true. +- If target file does not exist, returns true. +- Parses existing document using AiMdDocumentCodec. +- Checks if header version matches HEADER_VERSION_1_0. +- Checks if body is blank using Java8CompatibilityHelper. +- Compares all fields of expectedHeader against actualHeader. + +#### Public API +- `shouldWrite(force, targetFile, expectedHeader) -> boolean` determines rewrite necessity. + +#### Dependencies +- java.io.IOException +- java.nio.file.Files +- java.nio.file.Path +- net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocumentCodec +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderCodec +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader + +#### Exceptions / Errors +- Throws IOException when file cannot be read. +- Null handling: assumes expectedHeader is not null. + +#### Concurrency +- No explicit concurrency control; class is stateless. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdLeadExtractor.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdLeadExtractor.java.ai.md new file mode 100644 index 0000000..9025657 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/AiMdLeadExtractor.java.ai.md @@ -0,0 +1,53 @@ +### AiMdLeadExtractor.java +- H: 1.0 +- C: 650CFCE3 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:08:36Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Extracts the first meaningful line from .ai.md document bodies, stripping blockquote markers to produce navigable package summaries. + +#### Purpose +- Parses markdown document bodies to isolate descriptive leads. +- Supports deterministic, marker-aware lead extraction for index generation. + +#### Type +class public final +implements no interfaces +generics no type bounds +annotations @ToString + +#### Input +- Constructor: no parameters +- Method extractLead: String body (required, not null) +- Field compatibilityHelper: Java8CompatibilityHelper instance + +#### Output +- Method extractLead returns String (trimmed lead line or empty string) +- Side effect: none +- State mutation: none + +#### Core logic +- Splits input body into lines using newline delimiter +- Skips blank lines until first non-blank line is found +- Trims first non-blank line +- Checks if trimmed line starts with blockquote marker (>) +- Strips marker and trims result if present; otherwise returns trimmed line +- Returns empty string if no non-blank line exists + +#### Public API +extractLead(body) -> String extracts the lead line from a markdown body + +#### Dependencies +- Java8CompatibilityHelper +- String (JDK) + +#### Exceptions / Errors +- Throws NullPointerException if body is null +- No explicit error handling for invalid input beyond null check + +#### Concurrency +- No concurrency concerns; stateless and immutable operation +- Thread-safe due to lack of shared mutable state diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/package-info.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/package-info.java.ai.md new file mode 100644 index 0000000..10cb4fb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/package-info.java.ai.md @@ -0,0 +1,41 @@ +### package-info.java +- H: 1.0 +- C: 94A5AB2C +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:09:18Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines the domain model and serialization logic for .ai.md documents. + +#### Purpose +- Models the structure of .ai.md files +- Provides encoding/decoding functionality for .ai.md content + +#### Type +Package `net.ladenthin.maven.llamacpp.aiindex.document` + +#### Input +- Package-level documentation comment +- No parameters or dependencies in package-info.java + +#### Output +- No return values or side effects +- Defines package scope and documentation + +#### Core logic +- Declares package namespace for document model +- Documents the purpose of .ai.md file handling + +#### Public API +- Package-level documentation only + +#### Dependencies +- None directly referenced + +#### Exceptions / Errors +- No exception handling or null checks + +#### Concurrency +- Not applicable to package-info.java diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/package.ai.md new file mode 100644 index 0000000..9a951f0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/document/package.ai.md @@ -0,0 +1,62 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/document +- H: 1.0 +- C: F4674983 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:13:22Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiGenerationRequest.java](AiGenerationRequest.java.ai.md) +- F: [AiGenerationResult.java](AiGenerationResult.java.ai.md) +- F: [AiMdChildEntryLineFormatter.java](AiMdChildEntryLineFormatter.java.ai.md) +- F: [AiMdDocument.java](AiMdDocument.java.ai.md) +- F: [AiMdDocumentCodec.java](AiMdDocumentCodec.java.ai.md) +- F: [AiMdHeader.java](AiMdHeader.java.ai.md) +- F: [AiMdHeaderCodec.java](AiMdHeaderCodec.java.ai.md) +- F: [AiMdHeaderSupport.java](AiMdHeaderSupport.java.ai.md) +- F: [AiMdLeadExtractor.java](AiMdLeadExtractor.java.ai.md) +- F: [package-info.java](package-info.java.ai.md) +--- +> This package manages the structured representation, parsing, and serialization of AI-generated Markdown (.ai.md) documents, enabling deterministic indexing and content processing. + +#### Purpose +- Defines the data model for AI index documents. +- Provides mechanisms to read, write, and validate .ai.md file formats. + +#### Responsibilities +- Document structure management: defines metadata headers and content bodies for .ai.md files. +- File I/O operations: reads and writes structured .ai.md documents from disk. +- Header parsing and serialization: extracts and formats document metadata. +- AI generation request/response handling: encapsulates inputs and outputs for AI processing tasks. +- Manifest line formatting: generates checksum lines for package-level indexing. +- Lead extraction: identifies descriptive summaries from document bodies. +- Change detection logic: determines when .ai.md files should be regenerated. + +#### Key units +- `AiGenerationRequest` carries immutable input data for AI generation tasks. +- `AiGenerationResult` encapsulates the output of AI-driven field processing. +- `AiMdDocument` stores structured metadata and content for AI indexing. +- `AiMdHeader` defines deterministic document metadata fields. +- `AiMdDocumentCodec` handles file-level read/write operations for .ai.md documents. +- `AiMdHeaderCodec` parses and serializes header sections of .ai.md files. +- `AiMdChildEntryLineFormatter` formats manifest lines for package checksums. +- `AiMdLeadExtractor` isolates descriptive leads from document bodies. +- `AiMdHeaderSupport` determines if a document needs regeneration based on version or content changes. + +#### Data flow +Input files are parsed by `AiMdDocumentCodec` into `AiMdDocument` objects, which contain an `AiMdHeader` and body text. These documents are processed through AI generation workflows using `AiGenerationRequest`, producing `AiGenerationResult`. The results may be written back to `.ai.md` files via `AiMdDocumentCodec`. Manifest lines are generated by `AiMdChildEntryLineFormatter` for package-level indexing. Descriptive leads are extracted from document bodies by `AiMdLeadExtractor`. + +#### Dependencies +Internal collaborations: +- `AiMdHeaderCodec` and `AiMdDocumentCodec` work together to parse and serialize headers and documents. +- `AiMdHeaderSupport` uses `AiMdDocumentCodec` and `AiMdHeaderCodec` for file comparison logic. +- `AiGenerationRequest` integrates with `AiMdHeader` and source text for AI processing. +External dependencies: +- `Java8CompatibilityHelper` used for compatibility handling in several components. + +#### Cross-cutting +- Immutable design across all core classes ensures thread safety without synchronization. +- Null validation is enforced via `Objects.requireNonNull` in constructors and method parameters. +- Lombok annotations (`@EqualsAndHashCode`, `@ToString`) are widely used for boilerplate code reduction. +- Consistent field ordering and formatting (e.g., pipe-separated manifest lines) support deterministic behavior. +- Shared exception handling through `NullPointerException` for invalid inputs. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupport.java.ai.md new file mode 100644 index 0000000..3843208 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupport.java.ai.md @@ -0,0 +1,57 @@ +### AiFieldGenerationSupport.java +- H: 1.0 +- C: 8B242F21 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:09:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates AI-powered field documentation by processing configuration lists, preparing prompts, and handling retry logic for failed generations. + +#### Purpose +- Processes AI field generation requests. +- Manages prompt preparation, retries, and trim warnings. + +#### Type +Class, final. Implements no interfaces. Uses Lombok @ToString. + +#### Input +- Constructor: Log, AiGenerationProvider, AiPromptPreparationSupport, AiModelDefinitionSupport. +- Method processFieldGenerations: List, Path, String, String, AiMdHeader. +- Dependencies: AiFieldGenerationConfig, AiGenerationConfig, AiGenerationRequest, AiPreparedPrompt. + +#### Output +- Return type: AiGenerationResult. +- Side effects: Log warnings for trimming and empty outputs; log retry attempts at INFO level. + +#### Core logic +- Iterates over field generation configurations. +- Prepares prompts using AiPromptPreparationSupport. +- Truncates source text if needed, logs warning when configured. +- Generates AI output via AiGenerationProvider. +- Retries up to maxRetries times with increasing temperature for blank outputs. +- Logs detailed calculations of max input characters per prompt configuration. + +#### Public API +- processFieldGenerations(fieldGenerations, contextFile, contextType, sourceText, baseHeader) -> AiGenerationResult + Generates and accumulates AI field documentation. + +#### Dependencies +- net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig +- net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationResult +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPreparedPrompt +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper +- org.apache.maven.plugin.logging.Log + +#### Exceptions / Errors +- Throws IOException if generation provider fails. +- IllegalArgumentException if AI definition key is not found. + +#### Concurrency +- No explicit concurrency handling. Uses thread-safe Map cache for maxInputChars. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/PackageIndexer.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/PackageIndexer.java.ai.md new file mode 100644 index 0000000..cb7ddb8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/PackageIndexer.java.ai.md @@ -0,0 +1,50 @@ +### PackageIndexer.java +- H: 1.0 +- C: 1E8F476A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:13:26Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Aggregates package-level AI index files by walking output directories, collecting child summaries, and generating consolidated package-level AI content. + +#### Purpose +- Builds package-level AI documentation from child entries. +- Integrates AI-generated summaries into structured markdown documents. + +#### Type +class final PackageIndexer extends Object implements Serializable + +#### Input +- Constructor parameters: Log, Path baseDirectory, Path outputRoot, String pluginVersion, String aiVersion, Collection sourceSubtrees, boolean force, AiGenerationProvider generationProvider, Collection fieldGenerations, AiPromptSupport promptSupport, AiModelDefinitionSupport modelDefinitionSupport +- Method parameters: Path rootDirectory in aggregate(), Path directory in writePackageFile(), collectContents(), collectChildLinks(), buildPackageSourceText(), calculatePackageChecksum(), calculatePackageDate() +- Dependencies: AiPathSupport, AiTimeSupport, AiChecksumSupport, AiMdHeaderSupport, AiMdChildEntryLineFormatter, AiMdDocumentCodec, AiMdHeaderCodec, Java8CompatibilityHelper, AiFieldGenerationSupport + +#### Output +- Return values: int from aggregate(), aggregateRecursive() +- Side effects: Writes .ai.md files to disk; logs messages via Log instance +- State mutations: Fields updated during processing, such as checksums and dates + +#### Core logic +- Traverses output directory tree recursively to find package directories. +- Determines whether a package file should be created or updated based on child content presence. +- Collects contents and child links for header metadata. +- Builds source text by embedding child summaries from .ai.md files. +- Generates AI content using configured field generation strategies. +- Calculates checksums and dates from child entries. +- Writes final markdown documents with headers and bodies. + +#### Public API +- aggregate(rootDirectory) -> int: Walks directory tree and aggregates package files. +- writePackageFile(directory) -> void: Writes a single package index file. + +#### Dependencies +net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig, net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport, net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationResult, net.ladenthin.maven.llamacpp.aiindex.document.AiMdChildEntryLineFormatter, net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocument, net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocumentCodec, net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader, net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderCodec, net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderSupport, net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport, net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport, net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider, net.ladenthin.maven.llamacpp.aiindex.support.AiChecksumSupport, net.ladenthin.maven.llamacpp.aiindex.support.AiPathSupport, net.ladenthin.maven.llamacpp.aiindex.support.AiTimeSupport, net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper, org.apache.maven.plugin.logging.Log + +#### Exceptions / Errors +- IOException: Thrown when reading or writing files fails. +- IllegalStateException: Thrown if Path.getFileName() returns null during sorting. + +#### Concurrency +No explicit concurrency mechanisms. All operations are synchronous and assume single-threaded use per instance. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/ProjectIndexer.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/ProjectIndexer.java.ai.md new file mode 100644 index 0000000..66f4f7c --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/ProjectIndexer.java.ai.md @@ -0,0 +1,68 @@ +### ProjectIndexer.java +- H: 1.0 +- C: D7879C38 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:34:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Builds a project-level AI index by aggregating package-level indexes into a single navigable markdown file. + +#### Purpose +- Aggregates package-level AI indexes into a project-level index. +- Generates optional AI overview paragraph from package leads. + +#### Type +Class, final. Implements no interfaces. Uses Lombok @ToString. + +#### Input +- Constructor: Log, projectTitle, pluginVersion, aiVersion, force, optional AiGenerationProvider, AiFieldGenerationConfig, AiPromptSupport, AiModelDefinitionSupport. +- Method aggregate: Path rootDirectory. +- Dependencies: AiMdDocumentCodec, AiMdLeadExtractor, AiChecksumSupport, AiTimeSupport, Java8CompatibilityHelper. + +#### Output +- Return value: int (1 if written, 0 if unchanged). +- Side effect: Writes project index file at rootDirectory + PROJECT_AI_MD_FILENAME. +- State mutation: None; immutable data structures used. + +#### Core logic +- Walks output tree for package.ai.md files. +- Reads each package index to extract lead and link. +- Builds deterministic body with package listing and leads. +- Calculates checksum including overview signature. +- Conditionally generates AI overview from package leads. +- Writes project index file with header and body. + +#### Public API +- aggregate(rootDirectory) -> int: Aggregates package indexes into project index. +- ProjectIndexer(log, title, version, force) -> ProjectIndexer: Constructs deterministic indexer. +- ProjectIndexer(log, title, version, force, provider, config, promptSupport, modelSupport) -> ProjectIndexer: Constructs AI-overview indexer. + +#### Dependencies +- java.io.IOException, java.nio.file.Files, java.nio.file.Path, java.util.ArrayList, java.util.Collections, java.util.Comparator, java.util.List, java.util.stream.Stream +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig +- net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationResult +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocument +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocumentCodec +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderCodec +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderSupport +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdLeadExtractor +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.support.AiChecksumSupport +- net.ladenthin.maven.llamacpp.aiindex.support.AiTimeSupport +- net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper +- org.apache.maven.plugin.logging.Log +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- Throws IOException when reading/writing files or during AI generation. +- Defensive copy of AiFieldGenerationConfig prevents external mutation. + +#### Concurrency +- No concurrency features. Uses immutable data structures and thread-safe helpers. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexer.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexer.java.ai.md new file mode 100644 index 0000000..76aa33c --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexer.java.ai.md @@ -0,0 +1,96 @@ +### SourceFileIndexer.java +- H: 1.0 +- C: 2126461D +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:41:20Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates AI-powered metadata index files for source code, summarizing content and extracting keywords per file. + +#### Purpose +- Creates structured markdown index files for Java source files. +- Populates AI-generated summaries and keyword fields in index documents. + +#### Type +class SourceFileIndexer +- final +- Implements no interfaces +- Notable annotations: @ToString + +#### Input +- Constructor parameters: + - Log log + - Path baseDirectory + - Path outputRoot + - Collection fileExtensions + - String pluginVersion + - String aiVersion + - Collection subtrees + - @Nullable Collection excludes + - boolean force + - AiGenerationProvider generationProvider + - @Nullable Collection fieldGenerations + - AiPromptSupport promptSupport + - AiModelDefinitionSupport modelDefinitionSupport + +#### Output +- Return type: int from indexSourceRoot(Path) +- Side effects: + - Writes .ai.md files to outputRoot directory + - Logs informational and debug messages via Log + +#### Core logic +- Walks source directories recursively using Files.walk +- Filters files by extension, subtree inclusion, and exclusion patterns +- Skips excluded files based on glob patterns relative to baseDirectory +- Generates AI index files with headers containing metadata like checksum and timestamps +- Uses field generation configurations to process source text and extract fields +- Writes final .ai.md documents using AiMdDocumentCodec + +#### Public API +- indexSourceRoot(Path) -> int: indexes files under a given root directory +- isExcluded(Path) -> boolean: checks if file matches exclusion patterns +- matchesExtension(Path) -> boolean: verifies file extension match +- writeAiFile(Path) -> void: generates and writes AI index for a single source file +- matchesSubtree(Path) -> boolean: determines if path is within configured subtrees + +#### Dependencies +Imports: +- java.io.IOException +- java.nio.file.Files +- java.nio.file.Path +- java.util.ArrayList +- java.util.Collection +- java.util.Collections +- java.util.List +- java.util.stream.Stream +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig +- net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationSelector +- net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationResult +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocument +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocumentCodec +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderCodec +- net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderSupport +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.support.AiChecksumSupport +- net.ladenthin.maven.llamacpp.aiindex.support.AiPathSupport +- net.ladenthin.maven.llamacpp.aiindex.support.AiSourceExcludeFilter +- net.ladenthin.maven.llamacpp.aiindex.support.AiTimeSupport +- net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper +- org.apache.maven.plugin.logging.Log +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- Throws IOException when reading or writing files +- Throws IllegalArgumentException when no field generation is configured or matches a file name +- Handles null inputs gracefully where annotations indicate @Nullable + +#### Concurrency +No explicit concurrency mechanisms; assumes single-threaded use during Maven plugin execution. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/package-info.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/package-info.java.ai.md new file mode 100644 index 0000000..ba78192 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/package-info.java.ai.md @@ -0,0 +1,44 @@ +### package-info.java +- H: 1.0 +- C: 9027E72C +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:13:10Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Orchestrates traversal of source trees to drive AI field generation for indexing. + +#### Purpose +- Drives automated field generation from source code +- Coordinates package tree traversal for indexing + +#### Type +package `net.ladenthin.maven.llamacpp.aiindex.indexer` + +#### Input +- Source package trees +- File system resources +- Configuration parameters (not shown) + +#### Output +- Generated field metadata +- Indexable artifacts +- Processed package structures + +#### Core logic +- Traverses source/package hierarchies +- Identifies candidates for field generation +- Coordinates generation workflow + +#### Public API +- No public members in package-info.java + +#### Dependencies +- No external imports or references + +#### Exceptions / Errors +- No explicit error handling shown + +#### Concurrency +- No concurrency concerns indicated diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/package.ai.md new file mode 100644 index 0000000..84a1af5 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/package.ai.md @@ -0,0 +1,49 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/indexer +- H: 1.0 +- C: 368B3C1F +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:16:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationSupport.java](AiFieldGenerationSupport.java.ai.md) +- F: [PackageIndexer.java](PackageIndexer.java.ai.md) +- F: [ProjectIndexer.java](ProjectIndexer.java.ai.md) +- F: [SourceFileIndexer.java](SourceFileIndexer.java.ai.md) +- F: [package-info.java](package-info.java.ai.md) +--- +> Automates AI-powered documentation and indexing of Java source code packages, files, and projects by generating structured markdown summaries with field-level metadata. + +#### Purpose +- Generates AI-driven documentation for Java source files, packages, and projects. +- Consolidates AI outputs into navigable, hierarchical index structures. + +#### Responsibilities +- Source file indexing: processes individual Java files to create AI-powered metadata documents. +- Package aggregation: builds package-level AI indexes from child entries and field generations. +- Project consolidation: aggregates package indexes into a project-wide navigable markdown file. +- Field generation: applies AI prompts to extract structured information from source code. + +#### Key units +- **AiFieldGenerationSupport**: Processes AI field generation requests, prepares prompts, handles retries. +- **PackageIndexer**: Builds package-level AI documentation by collecting child summaries and generating consolidated content. +- **ProjectIndexer**: Aggregates package-level indexes into a project-level index with optional AI overview. +- **SourceFileIndexer**: Creates structured markdown index files for Java source files with AI-generated summaries. + +#### Data flow +- Source code files are walked and filtered, then processed by `SourceFileIndexer` to generate `.ai.md` documents. +- Package directories are scanned by `PackageIndexer` to collect child content and build consolidated package indexes. +- `ProjectIndexer` aggregates all package-level `.ai.md` files into a project-level index file. +- AI field generation workflows use `AiFieldGenerationSupport` to process configurations, prepare prompts, and retry failed generations. + +#### Dependencies +- Internal modules: AiMdDocument, AiMdHeader, AiGenerationProvider, AiPromptPreparationSupport, AiModelDefinitionSupport. +- External libraries: Lombok, Maven plugin logging, Java 8 compatibility helpers. +- Configuration types: AiFieldGenerationConfig, AiGenerationConfig, AiPromptSupport. + +#### Cross-cutting +- Shared interfaces and patterns for AI generation and prompt preparation across components. +- Common exception handling with IOException, IllegalArgumentException, and retry logic for blank outputs. +- Thread-safe caching for max input character calculations in `AiFieldGenerationSupport`. +- Immutable data structures used in `ProjectIndexer` to ensure deterministic output. +- Use of `@ToString` and Lombok annotations for code clarity. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AbstractAiIndexMojo.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AbstractAiIndexMojo.java.ai.md new file mode 100644 index 0000000..cd1f373 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AbstractAiIndexMojo.java.ai.md @@ -0,0 +1,96 @@ +### AbstractAiIndexMojo.java +- H: 1.0 +- C: B294B09C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:44:39Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides shared configuration and utility methods for Maven Mojo plugins that generate AI-powered documentation and summaries from source code. + +#### Purpose +- Centralizes common AI index parameters and logic across multiple Maven goals. +- Supplies helper methods for resolving paths, building configurations, and logging execution details. + +#### Type +- Abstract class extending `org.apache.maven.plugin.AbstractMojo` +- Implements no interfaces +- Uses Lombok `@ToString` annotation + +#### Input +- Constructor: none +- Fields: + - `baseDirectory`: injected by Maven (`${project.basedir}`) + - `outputDirectory`: configurable property with default `${project.basedir}/src/site/ai` + - `skip`: global toggle flag + - `force`: regeneration control flag + - `subtrees`: list of relative paths to restrict processing + - `generationProvider`: string identifier for AI provider (e.g., "mock", "llamacpp-jni") + - `promptDefinitions`: list of prompt templates used by field generation + - `aiDefinitions`: list of model configurations referenced by field generations + - `fieldGenerations`: list of per-field AI configuration entries + - `llamaLibraryPath`, `llamaModelPath`, `llamaMaxOutputTokens`, `llamaTemperature`: llama.cpp specific parameters +- Methods: + - `resolveSubtrees(Path basePath)` consumes `subtrees` and `baseDirectory` + - `buildLlamaCppJniConfig()` uses `fieldGenerations`, `aiDefinitions`, and individual llama parameters + - `buildPromptSupport()` uses `promptDefinitions` + - `buildAiModelDefinitionSupport()` uses `aiDefinitions` + - `logExecutionParameters(...)` consumes various execution parameters + +#### Output +- Return types: + - `List` from `resolveSubtrees()` + - `int` from `sizeOf()` + - `LlamaCppJniConfig` from `buildLlamaCppJniConfig()` + - `AiPromptSupport` from `buildPromptSupport()` + - `AiModelDefinitionSupport` from `buildAiModelDefinitionSupport()` +- Side effects: + - Logs execution parameters using `getLog().info()` + - Warns about missing subtrees via `getLog().warn()` + +#### Core logic +- Determines whether to skip execution based on global or phase-specific skip flags. +- Resolves configured subtree paths against the project base directory, filtering out non-existent paths. +- Builds a LlamaCppJniConfig using either field-generation-driven definitions or fallback parameters. +- Constructs prompt and AI model definition support instances, handling missing required fields via exceptions. +- Logs standardized execution parameter set for debugging. + +#### Public API +- `getLlamaContextSize() -> int` declares context size for llama.cpp +- `getLlamaThreads() -> int` declares thread count for llama.cpp inference +- `isPhaseSkipped() -> boolean` returns phase-specific skip flag +- `shouldSkip() -> boolean` evaluates overall skip condition +- `resolveSubtrees(Path basePath) -> List` resolves configured subtrees +- `sizeOf(Collection collection) -> int` counts elements safely +- `buildLlamaCppJniConfig() -> LlamaCppJniConfig` constructs llama config +- `buildPromptSupport() -> AiPromptSupport` builds prompt support instance +- `buildAiModelDefinitionSupport() -> AiModelDefinitionSupport` builds model definition support +- `logExecutionParameters(...) -> void` logs execution parameters + +#### Dependencies +- `java.io.File` +- `java.nio.file.Path` +- `java.util.ArrayList` +- `java.util.Collection` +- `java.util.Collections` +- `java.util.List` +- `lombok.ToString` +- `net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig` +- `net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig` +- `net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinition` +- `net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniConfig` +- `org.apache.maven.plugin.AbstractMojo` +- `org.apache.maven.plugin.MojoExecutionException` +- `org.apache.maven.plugins.annotations.Parameter` + +#### Exceptions / Errors +- Throws `MojoExecutionException` when prompt or AI definition lists contain missing required fields +- Throws `IllegalArgumentException` in `buildLlamaCppJniConfig()` if referenced model definition key is invalid + +#### Concurrency +- No explicit concurrency handling; relies on Maven's per-execution instantiation model +- Thread-safe methods assume immutable inputs and do not mutate shared state diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AggregatePackagesMojo.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AggregatePackagesMojo.java.ai.md new file mode 100644 index 0000000..0d9974d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AggregatePackagesMojo.java.ai.md @@ -0,0 +1,71 @@ +### AggregatePackagesMojo.java +- H: 1.0 +- C: 6A34E4E4 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:49:44Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Aggregates per-package AI-generated index files into a unified summary and keyword structure. + +#### Purpose +- Builds aggregated package index files from individual .ai.md files. +- Configures AI model parameters for fast inference during package processing. + +#### Type +Class, final. Extends AbstractAiIndexMojo. Implements no interfaces. + +#### Input +- Constructor: no parameters. +- Parameters: + - skipPackage: boolean flag to conditionally skip phase. + - pluginVersion: Maven project version string. + - aiVersion: AI model version string. + - llamaContextSize: integer for context window size. + - llamaThreads: integer for CPU threads used during inference. +- Fields read: + - baseDirectory, outputDirectory, force, generationProvider, fieldGenerations. + +#### Output +- Side effects: logs informational messages. +- Return type: void (execute method). +- Mutated fields: none directly; indirectly affects package index file content. + +#### Core logic +- Checks if execution should be skipped based on global or phase-specific flags. +- Resolves subtree paths from base directory. +- Builds prompt and model definition support objects. +- Instantiates AI generation provider with configured llama.cpp JNI settings. +- Creates PackageIndexer with all necessary parameters including provider. +- Executes aggregation of package index files into output directory. +- Logs results and execution summary. + +#### Public API +- execute() -> void: runs the main aggregation logic. +- getLlamaContextSize() -> int: returns configured context window size. +- getLlamaThreads() -> int: returns configured thread count for inference. +- isPhaseSkipped() -> boolean: checks if current phase is skipped. + +#### Dependencies +- java.io.IOException +- java.nio.file.Path +- java.util.Collections +- java.util.List +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport +- net.ladenthin.maven.llamacpp.aiindex.indexer.PackageIndexer +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProviderFactory +- org.apache.maven.plugin.MojoExecutionException +- org.apache.maven.plugins.annotations.Mojo +- org.apache.maven.plugins.annotations.Parameter + +#### Exceptions / Errors +- IOException: thrown when output directory does not exist or cannot be accessed. +- MojoExecutionException: wraps IOExceptions during execution. + +#### Concurrency +- Thread-safe due to @Mojo annotation with threadSafe = true. +- Uses try-with-resources for AiGenerationProvider to ensure proper cleanup. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AggregateProjectMojo.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AggregateProjectMojo.java.ai.md new file mode 100644 index 0000000..d9ff6ce --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AggregateProjectMojo.java.ai.md @@ -0,0 +1,50 @@ +### AggregateProjectMojo.java +- H: 1.0 +- C: CB445C6F +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:51:13Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Aggregates per-package AI index files into a single project-level index, optionally including an AI-generated overview paragraph. + +#### Purpose +- Generates a consolidated AI index for a Maven project. +- Optionally produces an AI summary of package-level indexes. + +#### Type +Class `AggregateProjectMojo` extends `AbstractAiIndexMojo`, final. Implements no interfaces. Uses Lombok `@ToString`. + +#### Input +- Constructor: none. +- Parameters from Maven: `outputDirectory`, `force`, `skip`, `projectName`, `pluginVersion`, `aiVersion`, `llamaContextSize`, `llamaThreads`, `fieldGenerations`. +- Dependencies injected by Maven: `getLog()`, `generationProvider`, `buildLlamaCppJniConfig()`, `buildPromptSupport()`, `buildAiModelDefinitionSupport()`. + +#### Output +- Writes one or more `.ai.md` files to `outputDirectory`. +- Logs informational and error messages via `getLog()`. + +#### Core logic +- Skips execution if global or phase-specific skip flag is set. +- Determines project title from `projectName` or defaults to "project". +- Chooses deterministic aggregation path if no `fieldGenerations` configured; otherwise, creates AI provider and executes AI-driven summary. +- Calls `ProjectIndexer.aggregate()` for either path. + +#### Public API +- `execute() -> void` : Runs the index aggregation process. +- `getLlamaContextSize() -> int` : Returns context size for llama.cpp. +- `getLlamaThreads() -> int` : Returns thread count for llama.cpp. +- `isPhaseSkipped() -> boolean` : Checks if project phase is skipped. + +#### Dependencies +Imports: `java.io.IOException`, `java.nio.file.Path`, `lombok.ToString`, `net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig`, `net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport`, `net.ladenthin.maven.llamacpp.aiindex.indexer.ProjectIndexer`, `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport`, `net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider`, `net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProviderFactory`, `net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper`, `org.apache.maven.plugin.MojoExecutionException`, `org.apache.maven.plugins.annotations.Mojo`, `org.apache.maven.plugins.annotations.Parameter`. + +#### Exceptions / Errors +- Throws `MojoExecutionException` when provider/model setup fails or I/O error occurs. +- Handles null or blank `projectName` with default title. +- Catches and rethrows `IOException` during index writing. + +#### Concurrency +- Marked `@Mojo(threadSafe = true)`. +- Uses immutable fields; no shared mutable state. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/GenerateMojo.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/GenerateMojo.java.ai.md new file mode 100644 index 0000000..e630182 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/GenerateMojo.java.ai.md @@ -0,0 +1,80 @@ +### GenerateMojo.java +- H: 1.0 +- C: 64782257 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T16:53:23Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates AI-powered summaries and keywords for Java source files within a Maven project. + +#### Purpose +- Indexes Java source files. +- Populates AI-generated metadata into indexed files. + +#### Type +Class, final. Extends AbstractAiIndexMojo. Implements no interfaces. + +#### Input +- Constructor: none. +- Parameters: + - `skipFile`: boolean, controls skipping file phase. + - `pluginVersion`: String, Maven plugin version. + - `aiVersion`: String, AI model version. + - `fileExtensions`: List, file extensions to index. + - `excludes`: List, glob patterns for excluded files. + - `llamaContextSize`: int, context window size for llama.cpp. + - `llamaThreads`: int, CPU threads for inference. +- Fields: + - `baseDirectory`: File, project base directory. + - `outputDirectory`: File, output directory for AI index files. + - `generationProvider`: String, AI provider identifier. + - `force`: boolean, whether to overwrite existing files. + - `fieldGenerations`: List, fields to generate. +- Resources: + - File system paths resolved from base and output directories. + +#### Output +- Side effects: + - Writes AI-generated index files to output directory. + - Logs execution status and warnings. +- Return types: + - None directly, but mutates state via file writes and logging. + +#### Core logic +- Skips execution if global or phase skip flag is set. +- Resolves base path, output path, and file extensions. +- Builds prompt support and AI model definition support. +- Instantiates an AI generation provider using JNI config. +- Creates a source file indexer with resolved parameters. +- Iterates over subtrees to index Java files. +- Logs count of generated AI files upon completion. + +#### Public API +- `execute() -> void`: Runs the AI indexing process. +- `getLlamaContextSize() -> int`: Returns configured llama context size. +- `getLlamaThreads() -> int`: Returns configured llama thread count. +- `isPhaseSkipped() -> boolean`: Indicates if file phase is skipped. + +#### Dependencies +- java.io.IOException +- java.nio.file.Path +- java.util.List +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport +- net.ladenthin.maven.llamacpp.aiindex.indexer.SourceFileIndexer +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProviderFactory +- net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper +- org.apache.maven.plugin.MojoExecutionException +- org.apache.maven.plugins.annotations.Mojo +- org.apache.maven.plugins.annotations.Parameter + +#### Exceptions / Errors +- Throws MojoExecutionException on IOException during file operations. +- Logs warnings for missing subtrees. + +#### Concurrency +- Thread-safe due to `@Mojo(threadSafe = true)`. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/package-info.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/package-info.java.ai.md new file mode 100644 index 0000000..10b54e0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/package-info.java.ai.md @@ -0,0 +1,39 @@ +### package-info.java +- H: 1.0 +- C: A3C622F1 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:55:18Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides Maven plugin entry points for AI indexing tasks. + +#### Purpose +- Defines the root package for Maven Mojo implementations. +- Organizes the ai-index plugin goals under a cohesive namespace. + +#### Type +- Package `net.ladenthin.maven.llamacpp.aiindex.mojo` with no class, interface, or type declarations. + +#### Input +- No parameters, dependencies, or resources consumed directly by this file. + +#### Output +- No return values or side effects; serves only as a package declaration. + +#### Core logic +- Establishes the namespace for Maven plugin Mojo classes. +- Supports organization of ai-index functionality within the Maven build lifecycle. + +#### Public API +- None; no methods or members exposed. + +#### Dependencies +- None directly imported or referenced. + +#### Exceptions / Errors +- No exceptions or error handling present. + +#### Concurrency +- Not applicable; this is a package-info file with no runtime behavior. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/package.ai.md new file mode 100644 index 0000000..129e0c0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/package.ai.md @@ -0,0 +1,51 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/mojo +- H: 1.0 +- C: A7DF4B16 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:19:42Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AbstractAiIndexMojo.java](AbstractAiIndexMojo.java.ai.md) +- F: [AggregatePackagesMojo.java](AggregatePackagesMojo.java.ai.md) +- F: [AggregateProjectMojo.java](AggregateProjectMojo.java.ai.md) +- F: [GenerateMojo.java](GenerateMojo.java.ai.md) +- F: [package-info.java](package-info.java.ai.md) +--- +> Automates the generation of AI-powered documentation and code summaries from Java source files within Maven projects, supporting per-file, per-package, and project-level indexing. + +#### Purpose +- Generates AI-enhanced metadata and summaries for Java source code. +- Integrates with Maven build lifecycle to produce structured documentation artifacts. + +#### Responsibilities +- **File-level indexing**: Processes individual Java files to extract and augment code information using AI. +- **Package-level aggregation**: Combines per-file AI indexes into consolidated package summaries. +- **Project-level synthesis**: Creates a unified project overview from aggregated package indexes, optionally including an AI-generated summary paragraph. +- **Configuration management**: Centralizes AI model parameters and prompt definitions for consistent usage across indexing phases. + +#### Key units +- `AbstractAiIndexMojo`: Base class providing shared configuration and utility methods for all AI index Mojos. +- `GenerateMojo`: Indexes individual Java files using AI to produce per-file `.ai.md` outputs. +- `AggregatePackagesMojo`: Aggregates package-level AI indexes into a structured summary. +- `AggregateProjectMojo`: Consolidates project-wide AI indexes into a single, optionally summarized index file. +- `LlamaCppJniConfig`: Configuration object for llama.cpp inference settings. +- `AiPromptSupport`: Manages prompt templates used in AI generation. +- `AiModelDefinitionSupport`: Encapsulates model configurations for AI providers. + +#### Data flow +- Input source files are resolved from project base directory and filtered by extensions and exclusions. +- AI models are instantiated with configured parameters (e.g., context size, threads) via `LlamaCppJniConfig`. +- Prompt and model definitions are built from lists of configurations, used during generation steps. +- Generated content is written to output directories as `.ai.md` files, organized per file, package, or project scope. + +#### Dependencies +- Internal: `net.ladenthin.maven.llamacpp.aiindex.config`, `net.ladenthin.maven.llamacpp.aiindex.indexer`, `net.ladenthin.maven.llamacpp.aiindex.prompt`, `net.ladenthin.maven.llamacpp.aiindex.provider` +- External: Maven plugin API (`org.apache.maven.plugin`), Lombok annotations, Java NIO and collections + +#### Cross-cutting +- All Mojos extend `AbstractAiIndexMojo` for shared behavior. +- Uses consistent logging via `getLog()`. +- Configurable skip flags control execution at both global and phase levels. +- Thread safety ensured by `@Mojo(threadSafe = true)` on final classes. +- Exception handling wraps low-level I/O and configuration errors in `MojoExecutionException`. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/package-info.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/package-info.java.ai.md new file mode 100644 index 0000000..5260445 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/package-info.java.ai.md @@ -0,0 +1,43 @@ +### package-info.java +- H: 1.0 +- C: A05AE952 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:55:37Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates .ai.md index files for Java source trees using llama.cpp within a Maven plugin context. + +#### Purpose +- Produces AI-powered documentation index files for Java projects +- Integrates with Maven build lifecycle for automated documentation generation + +#### Type +Package-level documentation only; no class, interface, or type declaration present + +#### Input +- No direct inputs; package is purely for organizing Maven plugin modules + +#### Output +- No direct outputs; serves as module organization container for plugin artifacts + +#### Core logic +- Declares module-level null safety contract via JSpecify @NullMarked annotation +- Configures compile-time nullness checking using Error Prone and Checker Framework +- Excludes Maven plugin parameters from null initialization checks due to reflection-based population + +#### Public API +- No public API exposed; package is for internal organizational purposes only + +#### Dependencies +- References module-info.java for JSpecify @NullMarked declaration +- Depends on Maven plugin framework for parameter injection +- Integrates with Error Prone compiler plugin for null checking enforcement + +#### Exceptions / Errors +- No explicit exception handling or error conditions in this file +- Relies on transitive null safety enforcement from module-level annotations + +#### Concurrency +- No concurrency concerns; package is static organizational unit diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..4817bc1 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,52 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: E5A0A8E1 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:28:10Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [document/](document/package.ai.md) +- F: [indexer/](indexer/package.ai.md) +- F: [mojo/](mojo/package.ai.md) +- F: [package-info.java](package-info.java.ai.md) +- F: [prompt/](prompt/package.ai.md) +- F: [provider/](provider/package.ai.md) +- F: [support/](support/package.ai.md) +--- +> This package automates AI-powered documentation and indexing of Java source code, generating structured markdown summaries with field-level metadata for Maven projects. + +#### Purpose +- Generates AI-driven documentation for Java source files, packages, and projects. +- Produces structured markdown index files with deterministic metadata and content. + +#### Responsibilities +- AI configuration and prompt management: defines model parameters, prompt templates, and generation settings. +- Document processing: reads, writes, and validates .ai.md file formats with metadata headers. +- Source indexing: creates AI-powered summaries for individual Java files and aggregates them into package and project indexes. +- AI inference and generation: supports local GGUF models and mock backends for code analysis and field extraction. +- Maven integration: automates documentation generation within the Maven build lifecycle. + +#### Key units +- AiFieldGenerationConfig: maps prompt templates to model definitions for file-specific AI processing. +- AiMdDocument: stores structured metadata and content for AI indexing in .ai.md format. +- AiGenerationProvider: interface for AI text generation with retry logic, implemented by native and mock providers. +- SourceFileIndexer: generates per-file .ai.md documentation using AI prompts and summaries. +- GenerateMojo: Maven plugin goal that indexes Java files and produces AI-enhanced markdown outputs. +- AiPromptSupport: manages prompt templates and renders them into structured inputs for AI models. + +#### Data flow +Source code is filtered by extension, then processed by `SourceFileIndexer` to generate `.ai.md` documents. These are aggregated by `PackageIndexer` into package-level indexes, which are consolidated by `ProjectIndexer` into a project-wide summary. AI prompts are prepared using `AiPromptPreparationSupport`, rendered via `AiPromptSupport`, and fed into either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. Results are parsed by `AiCompletionParser` to remove internal reasoning before being written back to `.ai.md` files. + +#### Dependencies +- Internal modules: config, document, indexer, prompt, provider, support. +- External libraries: Maven plugin API, Lombok annotations, Java 8 compatibility helpers. +- AI inference backend: llama.cpp via JNI bindings for native model execution. + +#### Cross-cutting +- Immutable design across core classes ensures thread safety without synchronization. +- Shared use of Lombok annotations reduces boilerplate code. +- Null safety enforced via `@Nullable` and `Objects.requireNonNull`. +- Consistent field ordering and formatting support deterministic behavior in manifests and headers. +- Exception handling wraps low-level I/O, configuration, and AI backend errors in standard Java exceptions. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPreparedPrompt.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPreparedPrompt.java.ai.md new file mode 100644 index 0000000..6771797 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPreparedPrompt.java.ai.md @@ -0,0 +1,45 @@ +### AiPreparedPrompt.java +- H: 1.0 +- C: EBEFC327 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:56:07Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Represents the outcome of prompt preparation, including substituted text and trimming metrics. + +#### Purpose +- Encapsulates results from prompt processing +- Tracks source text trimming and character usage + +#### Type +Final class implementing value semantics via Lombok annotations; marked for future record migration + +#### Input +Constructor accepts: prompt String, sourceText String, trimmed boolean, originalSourceLength int, trimmedSourceLength int, availableSourceChars int; validates non-null prompt and sourceText + +#### Output +Public accessors return: prompt String, sourceText String, trimmed boolean, originalSourceLength int, trimmedSourceLength int, availableSourceChars int + +#### Core logic +- Stores immutable prompt preparation results +- Tracks whether source text was truncated +- Preserves character count metrics for source trimming analysis + +#### Public API +prompt() -> String returns prepared prompt text +sourceText() -> String returns substituted source text +trimmed() -> boolean indicates if source was trimmed +originalSourceLength() -> int returns original source length +trimmedSourceLength() -> int returns trimmed source length +availableSourceChars() -> int returns character budget + +#### Dependencies +lombok.EqualsAndHashCode, lombok.ToString, net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord + +#### Exceptions / Errors +Throws NullPointerException for null prompt or sourceText parameters + +#### Concurrency +Immutable design ensures thread-safe usage without synchronization diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptDefinition.java.ai.md new file mode 100644 index 0000000..1a36252 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptDefinition.java.ai.md @@ -0,0 +1,50 @@ +### AiPromptDefinition.java +- H: 1.0 +- C: 149C1FBD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:56:54Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines a configuration object for AI prompt templates used in a Maven plugin, associating lookup keys with template strings. + +#### Purpose +- Stores and manages prompt template configurations for AI processing. +- Supports Maven plugin integration via JavaBean property mapping. + +#### Type +class public final +Implements: none +Generics: none +Annotations: @ToString + +#### Input +- Constructor: no parameters. +- Methods: setKey(String), setTemplate(String). +- Fields read: key, template (via getters). + +#### Output +- Methods: getKey(), getTemplate() return field values. +- Side effects: field mutation via setters. + +#### Core logic +- Encapsulates a key-template pair for AI prompt configuration. +- Provides standard JavaBean accessors for configuration properties. +- Uses Lombok-generated toString for diagnostics without value-based equality. + +#### Public API +getKey() -> String returns lookup key +setKey(String) -> void sets lookup key +getTemplate() -> String returns template string +setTemplate(String) -> void sets template string + +#### Dependencies +lombok.ToString + +#### Exceptions / Errors +Null handling: fields may be null due to reflection initialization. +No explicit exception throwing. + +#### Concurrency +Not thread-safe. Instances are managed by identity in plugin context; mutable state implies no concurrency guarantees. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupport.java.ai.md new file mode 100644 index 0000000..308e1df --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupport.java.ai.md @@ -0,0 +1,54 @@ +### AiPromptPreparationSupport.java +- H: 1.0 +- C: BC50BFE5 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:57:28Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Prepares AI prompts by trimming source code to fit within character limits while preserving syntax integrity. + +#### Purpose +- Trims source text for AI prompts at line boundaries. +- Ensures prompt length fits within configured maximum character limits. + +#### Type +Class, final. Implements no interfaces. Uses Lombok @ToString annotation. + +#### Input +- Constructor: AiPromptSupport dependency. +- Method preparePrompt: AiGenerationRequest, int maxInputChars. +- Method getBasePromptLength: String promptKey, Path contextFile. +- Method trimSourceAtLineBreak: String sourceText, int targetIndex. + +#### Output +- Method preparePrompt returns AiPreparedPrompt with trimmed content and metrics. +- Method getBasePromptLength returns int character count of template with empty source. +- Method trimSourceAtLineBreak returns String trimmed at line boundary. + +#### Core logic +- Renders full prompt using template and source text. +- Compares rendered length to max input characters. +- If within limit, returns full prompt and source. +- Else, calculates available space after removing source from template. +- Trims source at last newline before available space. +- Appends EOF marker to indicate truncation. +- Re-renders prompt with trimmed source and marker. + +#### Public API +- preparePrompt(request, maxInputChars) → AiPreparedPrompt: Trims and renders prompt. +- getBasePromptLength(promptKey, contextFile) → int: Calculates fixed template overhead. +- trimSourceAtLineBreak(sourceText, targetIndex) → String: Trims source at line boundary. + +#### Dependencies +net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest +net.ladenthin.maven.llamacpp.aiindex.prompt.AiPreparedPrompt +net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport + +#### Exceptions / Errors +- IllegalArgumentException thrown by promptSupport.buildPrompt if no template found. +- Null handling: depends on AiPromptSupport and AiGenerationRequest implementations. + +#### Concurrency +No explicit concurrency control. Assumes AiPromptSupport and AiGenerationRequest are immutable or thread-safe. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupport.java.ai.md new file mode 100644 index 0000000..0b0ef13 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupport.java.ai.md @@ -0,0 +1,42 @@ +### AiPromptSupport.java +- H: 1.0 +- C: 5839F364 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:58:45Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Renders AI prompt templates for generation requests using registered key-value definitions. + +#### Purpose +- Provides prompt string rendering for AI generation tasks. +- Validates and enforces required template definitions at construction time. + +#### Type +Final class implementing no interfaces. Extends no type. Uses generics: Map. Notable annotations: @ToString. + +#### Input +Constructor accepts List which must contain non-null key and template fields. buildPrompt methods consume AiGenerationRequest or individual promptKey, sourceFile, sourceText parameters. + +#### Output +Returns rendered prompt strings from templates using provided file name and source text substitutions. Throws IllegalArgumentException for missing prompt keys. + +#### Core logic +- Initializes internal HashMap with capacity based on input list size. +- Validates each AiPromptDefinition entry for required key and template fields. +- Substitutes filename and source text into registered template strings. +- Throws exception when no matching template is found for a given prompt key. + +#### Public API +buildPrompt(request) -> String: Renders prompt from request data. +buildPrompt(promptKey, sourceFile, sourceText) -> String: Renders prompt from components. + +#### Dependencies +Imports: java.util.HashMap, java.util.List, java.util.Map, java.util.Objects, lombok.ToString, net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest, net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper. References: AiPromptDefinition, AiGenerationRequest. + +#### Exceptions / Errors +Throws NullPointerException during construction if any definition has null key or template. Throws IllegalArgumentException in buildPrompt if no template exists for given promptKey. + +#### Concurrency +No explicit concurrency control; class is immutable after construction. Assumes thread-safe usage of injected dependencies. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/package-info.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/package-info.java.ai.md new file mode 100644 index 0000000..1889f19 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/package-info.java.ai.md @@ -0,0 +1,39 @@ +### package-info.java +- H: 1.0 +- C: 97D8EFB2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T16:59:53Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Manages prompt templates, preparation, and lookup for AI indexing workflows. + +#### Purpose +- Defines a package for organizing prompt-related utilities. +- Supports AI indexing by providing structured prompt handling. + +#### Type +Package `net.ladenthin.maven.llamacpp.aiindex.prompt` + +#### Input +- No direct inputs; package-level organization. + +#### Output +- No direct outputs; serves as a logical grouping for related classes. + +#### Core logic +- Provides a namespace for prompt template management. +- Enables lookup and preparation of prompts in AI indexing contexts. + +#### Public API +- Package exports prompt-related utilities for use in AI workflows. + +#### Dependencies +- None directly referenced; part of larger module structure. + +#### Exceptions / Errors +- No exceptions or error handling in package declaration. + +#### Concurrency +- No concurrency concerns; package-level grouping only. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/package.ai.md new file mode 100644 index 0000000..05b9433 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/package.ai.md @@ -0,0 +1,46 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/prompt +- H: 1.0 +- C: DF3A2A2D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:22:42Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiPreparedPrompt.java](AiPreparedPrompt.java.ai.md) +- F: [AiPromptDefinition.java](AiPromptDefinition.java.ai.md) +- F: [AiPromptPreparationSupport.java](AiPromptPreparationSupport.java.ai.md) +- F: [AiPromptSupport.java](AiPromptSupport.java.ai.md) +- F: [package-info.java](package-info.java.ai.md) +--- +> Enables structured AI prompt generation and source text trimming for Maven-based code indexing workflows. + +#### Purpose +- Manages AI prompt templates and their configurations +- Prepares source code inputs for AI processing by trimming to character limits + +#### Responsibilities +- Prompt definition and configuration management +- Source text preparation and trimming logic +- Prompt rendering and template substitution +- Character limit enforcement and validation + +#### Key units +AiPreparedPrompt represents the result of prompt preparation with trimming metrics +AiPromptDefinition encapsulates key-template pairs for AI prompt configurations +AiPromptPreparationSupport handles source text trimming and prompt construction +AiPromptSupport renders prompts using registered templates and substitutions + +#### Data flow +Source code text is trimmed by AiPromptPreparationSupport to fit within character limits, then rendered into a final prompt string by AiPromptSupport using configured templates and substitutions + +#### Dependencies +net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest +net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord +lombok.EqualsAndHashCode +lombok.ToString + +#### Cross-cutting +Immutable design across AiPreparedPrompt ensures thread-safe usage +Lombok annotations reduce boilerplate for value objects and diagnostics +Null validation occurs at construction time in AiPromptSupport and AiPreparedPrompt constructors +Prompt preparation logic consistently handles template rendering and character budgeting diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..48caeab --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,45 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:00:09Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract and clean model answers by removing internal reasoning blocks. + +#### Purpose +- Strips Gemma-4 thinking blocks from model responses. +- Provides cleaned output for AI index storage. + +#### Type +Class, non-final. Implements no interfaces. Uses @ToString annotation. + +#### Input +- Constructor: no parameters. +- Method parseCompletion: String response (raw LLM text, may be null). + +#### Output +- Method parseCompletion returns String (cleaned answer text). +- Throws IOException if thinking block is incomplete. + +#### Core logic +- Checks for presence of THINKING_BLOCK_END_MARKER in response. +- If found, extracts text after the end marker and trims it. +- If THINKING_BLOCK_START_MARKER exists without END_MARKER, throws IOException. +- Returns trimmed input if no markers are present. + +#### Public API +parseCompletion(response) -> String removes thinking blocks and returns clean answer +THINKING_BLOCK_START_MARKER -> String identifies start of reasoning block +THINKING_BLOCK_END_MARKER -> String identifies end of reasoning block + +#### Dependencies +java.io.IOException, lombok.ToString + +#### Exceptions / Errors +Throws IOException when THINKING_BLOCK_START_MARKER is found but END_MARKER is missing. + +#### Concurrency +No concurrency considerations; class is stateless. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..aad89f9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,45 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:00:57Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides pluggable text generation for AI-powered code indexing tasks using local or mock backends. + +#### Purpose +- Defines a contract for generating AI-derived text from structured input requests. +- Supports both standard and overridden sampling parameters for retry logic. + +#### Type +Interface, no modifiers. Implements AutoCloseable. + +#### Input +- `AiGenerationRequest` object containing prompt key, source file, source text, and current header. +- Optional `float temperatureOverride` parameter in the extended method. + +#### Output +- Generated text as `String`; never null but may be empty. +- Throws `IOException` on failure. + +#### Core logic +- Delegates generation to underlying AI backend based on request input. +- Supports retry mechanism via temperature override to improve response quality. +- Provides default no-op close behavior for resource management. + +#### Public API +- `generate(AiGenerationRequest) -> String` produces text from a request. +- `generate(AiGenerationRequest, float) -> String` overrides sampling temperature for retries. + +#### Dependencies +- `AiGenerationRequest` +- `IOException` + +#### Exceptions / Errors +- Throws `IOException` if backend fails during generation. +- Handles null return by contract; returns blank string instead. + +#### Concurrency +- No explicit concurrency control. Behavior depends on implementation. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..b96e25e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,53 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:01:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an AI model provider implementation based on a configuration key. + +#### Purpose +- Instantiates AI generation providers dynamically. +- Maps provider names to concrete implementations. + +#### Type +class public final +Implements: none +Generics: none +Annotations: @ToString + +#### Input +- Constructor: none +- Method create: providerName (String), llamaConfig (LlamaCppJniConfig), promptSupport (AiPromptSupport) + +#### Output +- Return type: AiGenerationProvider +- Side effects: none +- Mutated fields: none + +#### Core logic +- Checks if providerName is null or blank, defaults to MockAiGenerationProvider. +- Matches providerName against known keys ("mock", "llamacpp-jni"). +- Throws IllegalArgumentException for unrecognized provider names. + +#### Public API +create(providerName, llamaConfig, promptSupport) -> AiGenerationProvider +Instantiates AI provider by name + +#### Dependencies +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport +- net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper +- net.ladenthin.maven.llamacpp.aiindex.provider.MockAiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniAiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider +- net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniConfig + +#### Exceptions / Errors +Throws IllegalArgumentException for unsupported provider names. +Handles null or blank providerName by defaulting to MockAiGenerationProvider. + +#### Concurrency +None noted. Class is stateless and immutable. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..369ac48 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,58 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:02:18Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Generates AI responses using a local GGUF model via JNI bindings, supporting configurable inference parameters and prompt templating. + +#### Purpose +- Provides AI text generation using a native llama.cpp model. +- Supports dynamic prompt building and inference configuration. + +#### Type +Final class implementing `AiGenerationProvider` and `AutoCloseable`. Extends no types. Implements interfaces: `AiGenerationProvider`, `AutoCloseable`. + +#### Input +- Constructor accepts `LlamaCppJniConfig` and `AiPromptSupport`. +- `generate()` methods take `AiGenerationRequest` and optional `temperatureOverride`. +- Reads model path, context size, thread count, and inference settings from `config`. +- Consumes `promptSupport` to render prompts from requests. + +#### Output +- Returns generated text as `String`. +- Mutates internal `model` field on first use. +- Produces side effect of loading native GGUF model on first call. + +#### Core logic +- Lazily initializes native `LlamaModel` on first `generate()` call. +- Builds user prompt using `AiPromptSupport`. +- Constructs `InferenceParameters` with request and config values. +- Invokes `chatCompleteText` on the model with parameters. +- Parses output using `AiCompletionParser`. + +#### Public API +- `generate(AiGenerationRequest) -> String` generates response with default temperature. +- `generate(AiGenerationRequest, float) -> String` generates response with custom temperature. +- `close() -> void` releases native model resources. + +#### Dependencies +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniConfig` +- `net.ladenthin.maven.llamacpp.aiindex.provider.AiCompletionParser` + +#### Exceptions / Errors +- Throws `IOException` during model inference or prompt building. +- Null checks on constructor parameters. + +#### Concurrency +- Not thread-safe; assumes single-threaded use per instance. +- Model loading is synchronized via null check and assignment. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..2f09daa --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,51 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:03:39Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures native llama.cpp inference parameters for AI model execution. + +#### Purpose +- Encapsulates immutable settings for JNI-based llama.cpp model invocation. +- Provides accessors for all configuration fields with defensive copying. + +#### Type +final class implements no interfaces; extends no type; generics: none; annotations: @ConvertToRecord, @ToString, @EqualsAndHashCode + +#### Input +Constructor accepts 11 parameters including String libraryPath, modelPath, int contextSize, int maxOutputTokens, float temperature, int threads, float topP, int topK, float repeatPenalty, boolean chatTemplateEnableThinking, List stopStrings; requires non-null modelPath + +#### Output +Public accessors return field values; stopStrings() returns unmodifiable view of list; all fields are defensively copied or wrapped + +#### Core logic +- Validates non-null modelPath during construction +- Assigns constructor parameters to private final fields +- Converts null stopStrings to empty immutable list +- Provides record-style accessor methods for each field + +#### Public API +libraryPath() -> String returns native library path +modelPath() -> String returns GGUF model file path +contextSize() -> int returns context window size +maxOutputTokens() -> int returns maximum output tokens +temperature() -> float returns sampling temperature +threads() -> int returns CPU threads count +topP() -> float returns nucleus-sampling threshold +topK() -> int returns top-k sampling limit +repeatPenalty() -> float returns repetition penalty +chatTemplateEnableThinking() -> boolean returns thinking mode flag +stopStrings() -> List returns unmodifiable stop strings + +#### Dependencies +java.util.Collections, java.util.List, java.util.Objects, lombok.EqualsAndHashCode, lombok.ToString, net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord + +#### Exceptions / Errors +Throws NullPointerException if modelPath is null; handles null stopStrings by converting to empty list + +#### Concurrency +Immutable field design ensures thread-safe access; no synchronization required; defensive copying prevents external mutation diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..4604d86 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,43 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:04:57Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides deterministic mock AI summaries for testing purposes. + +#### Purpose +- Supplies fake AI-generated content for unit testing. +- Enables isolated testing of components dependent on AI generation. + +#### Type +Class, final. Implements AiGenerationProvider. Uses Lombok @ToString annotation. + +#### Input +- Constructor takes no parameters. +- Method generate consumes AiGenerationRequest with sourceFile field. +- Reads file path from request for summary construction. + +#### Output +- Returns fixed string "Mock summary for {filename}". +- Produces no side effects or state changes. + +#### Core logic +- Extracts filename from input file path. +- Constructs deterministic mock response based on filename. +- Handles null filename case by falling back to full path. + +#### Public API +generate(request) -> String: Creates mock AI summary from file. + +#### Dependencies +AiGenerationProvider, AiGenerationRequest, Path, IOException, lombok.ToString + +#### Exceptions / Errors +Throws IOException when reading file path fails (though not actually doing I/O). + +#### Concurrency +No concurrency concerns; stateless and immutable. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package-info.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package-info.java.ai.md new file mode 100644 index 0000000..5f156ae --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package-info.java.ai.md @@ -0,0 +1,39 @@ +### package-info.java +- H: 1.0 +- C: 54E2A9C5 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:05:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides AI backend implementations and data carriers for text generation requests and results. + +#### Purpose +- Encapsulates AI generation capabilities using mock and llama.cpp JNI backends. +- Defines data structures for AI generation requests and results. + +#### Type +package `net.ladenthin.maven.llamacpp.aiindex.provider` + +#### Input +- No direct inputs; package-level documentation only. + +#### Output +- No direct outputs; package-level documentation only. + +#### Core logic +- Exposes AI generation backend modules. +- Defines request/response data models for AI text generation. + +#### Public API +- No public API; package-private scope. + +#### Dependencies +- None explicitly imported; relies on package structure. + +#### Exceptions / Errors +- No exception handling or error conditions in this file. + +#### Concurrency +- No concurrency concerns; package-level documentation only. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..3a57736 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,50 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: CC70AD52 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:23:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +- F: [package-info.java](package-info.java.ai.md) +--- +> Provides pluggable AI text generation for code indexing, supporting local GGUF models and mock backends for testing. + +#### Purpose +- Generates AI-derived text from structured input requests for code indexing tasks. +- Offers flexible backend selection (local or mock) with configurable inference parameters. + +#### Responsibilities +- AI model inference using native llama.cpp via JNI bindings. +- Mock AI generation for unit testing and development. +- Parsing and cleaning of raw LLM responses to remove internal reasoning blocks. +- Dynamic instantiation and configuration of AI generation providers based on runtime settings. + +#### Key units +AiCompletionParser extracts clean text from LLM outputs by removing thinking blocks +AiGenerationProvider defines contract for AI text generation with retry support +AiGenerationProviderFactory selects and instantiates AI backend implementations +LlamaCppJniAiGenerationProvider uses native GGUF models via JNI for inference +LlamaCppJniConfig encapsulates llama.cpp model configuration parameters +MockAiGenerationProvider delivers deterministic mock responses for testing + +#### Data flow +Input requests are processed through AiGenerationRequest objects, which are transformed into prompts by AiPromptSupport. These are fed into either LlamaCppJniAiGenerationProvider (for native inference) or MockAiGenerationProvider (for testing), with outputs parsed by AiCompletionParser to remove internal reasoning before being returned. + +#### Dependencies +- net.ladenthin.llama.LlamaModel for native model invocation +- net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport for prompt construction +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest for input data structure +- java.io.IOException for error handling in text generation + +#### Cross-cutting +Shared interface AiGenerationProvider defines common API across implementations +Stateless, immutable configuration via LlamaCppJniConfig ensures safe concurrent access +Exception handling standardizes on IOException for backend failures +MockAiGenerationProvider enables deterministic test behavior without external dependencies diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiChecksumSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiChecksumSupport.java.ai.md new file mode 100644 index 0000000..6c62a2b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiChecksumSupport.java.ai.md @@ -0,0 +1,56 @@ +### AiChecksumSupport.java +- H: 1.0 +- C: 2A51047F +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:05:38Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Computes CRC32 checksums for files and strings used in AI metadata headers. + +#### Purpose +- Generates hexadecimal CRC32 checksums for content validation. +- Supports AI index file integrity checks. + +#### Type +class public final +Implements: none +Extends: none +Generics: none +Annotations: @ToString + +#### Input +- Constructor: no parameters +- Method `calculateCrc32Hex(Path)`: Path file +- Method `calculateCrc32Hex(String)`: String value +- Method `calculateCrc32Hex(byte[])`: byte[] bytes + +#### Output +- Return type `String` for all methods +- Side effect: file read (in `calculateCrc32Hex(Path)`) + +#### Core logic +- Read file contents into byte array +- Compute CRC32 checksum on byte array +- Format checksum as 8-character uppercase hexadecimal string + +#### Public API +- `calculateCrc32Hex(Path) -> String` computes file checksum +- `calculateCrc32Hex(String) -> String` computes string checksum +- `calculateCrc32Hex(byte[]) -> String` computes byte array checksum + +#### Dependencies +java.io.IOException +java.nio.charset.StandardCharsets +java.nio.file.Files +java.nio.file.Path +java.util.zip.CRC32 +lombok.ToString + +#### Exceptions / Errors +- Throws IOException when file cannot be read +- Null handling: no explicit null checks, assumes valid inputs + +#### Concurrency +None noted. Class is stateless and immutable. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiPathSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiPathSupport.java.ai.md new file mode 100644 index 0000000..ccd224e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiPathSupport.java.ai.md @@ -0,0 +1,48 @@ +### AiPathSupport.java +- H: 1.0 +- C: 09DC92FB +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:06:19Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves and cleans source file paths for indexing by removing leading "src" segments. + +#### Purpose +- Normalizes file paths for consistent indexing. +- Strips redundant directory prefixes from source paths. + +#### Type +class AiPathSupport modifiers: public +extends: none +implements: none +generics: none +annotations: @ToString + +#### Input +- Constructor: no parameters +- Method `relativizeFromSrc`: baseDirectory (Path), path (Path) + +#### Output +- Return type: Path +- Side effect: none +- Mutated state: none + +#### Core logic +- Relativizes input path against base directory. +- Checks if the relativized path starts with "src" segment. +- Removes the leading "src" segment if present. + +#### Public API +relativizeFromSrc(baseDirectory, path) -> Path strips leading src from relativized path + +#### Dependencies +java.nio.file.Path +lombok.ToString + +#### Exceptions / Errors +None explicitly handled; relies on standard Path operations. + +#### Concurrency +No concurrency concerns; class is stateless and immutable. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiSourceExcludeFilter.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiSourceExcludeFilter.java.ai.md new file mode 100644 index 0000000..917c540 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiSourceExcludeFilter.java.ai.md @@ -0,0 +1,46 @@ +### AiSourceExcludeFilter.java +- H: 1.0 +- C: C06E0C2D +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:06:47Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Filters source file paths using glob patterns to exclude generated or trivial code from indexing. + +#### Purpose +- Excludes specific source files from being indexed based on path matching. +- Supports glob-style pattern syntax for flexible exclusion rules. + +#### Type +Class, final. Implements no interfaces. Uses @ToString annotation. Generics: List, Collection. + +#### Input +- Constructor accepts nullable Collection of glob patterns. +- Method isExcluded takes String relativePath. +- Internal method globToRegex converts String glob to regex pattern. + +#### Output +- Returns boolean from isExcluded indicating whether a path should be excluded. +- Compiled List stored in instance field. + +#### Core logic +- Compiles glob patterns into regex patterns during initialization. +- Matches input paths against compiled patterns using anchored regex matching. +- Converts glob wildcards (*, **, ?) into equivalent regex expressions. +- Handles special cases like **/ for zero-directory matching. + +#### Public API +- AiSourceExcludeFilter(Collection) -> void Initializes filter with glob patterns. +- isExcluded(String) -> boolean Determines if a path should be excluded. + +#### Dependencies +java.util.ArrayList, java.util.Collection, java.util.List, java.util.regex.Pattern, lombok.ToString, org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- Null or empty glob patterns are safely ignored during initialization. +- No explicit exception throwing beyond standard Java behavior. + +#### Concurrency +- Immutable state after construction; no synchronization required. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiTimeSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiTimeSupport.java.ai.md new file mode 100644 index 0000000..aeed4d4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiTimeSupport.java.ai.md @@ -0,0 +1,47 @@ +### AiTimeSupport.java +- H: 1.0 +- C: 27F1E50B +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:07:49Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Formats timestamps for AI index metadata files with second-level precision. + +#### Purpose +- Provides timestamp formatting for AI metadata headers. +- Supports consistent datetime representation in .ai.md files. + +#### Type +class AiTimeSupport final + +#### Input +- Constructor: no parameters +- Method `formatInstant`: Instant instant + +#### Output +- Return type: String +- Side effect: none +- State mutation: none + +#### Core logic +- Truncates an Instant to second precision using ChronoUnit.SECONDS +- Formats the truncated Instant into an ISO-8601 string + +#### Public API +- `formatInstant(final Instant instant) -> String` format timestamp + +#### Dependencies +- java.time.Instant +- java.time.format.DateTimeFormatter +- java.time.temporal.ChronoUnit +- lombok.ToString + +#### Exceptions / Errors +- None explicitly handled or thrown +- Null input may cause NullPointerException + +#### Concurrency +- No concurrency concerns; stateless utility class +- Immutable formatter constant used safely across threads diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/ConvertToRecord.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/ConvertToRecord.java.ai.md new file mode 100644 index 0000000..391798d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/ConvertToRecord.java.ai.md @@ -0,0 +1,41 @@ +### ConvertToRecord.java +- H: 1.0 +- C: BF72A15E +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:08:14Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Marks classes for migration to Java records upon target bytecode upgrade. + +#### Purpose +- Identifies classes suitable for refactoring into Java records. +- Serves as a migration marker for future bytecode upgrades. + +#### Type +- Annotation type: `@interface ConvertToRecord` +- Modifiers: none +- Notable annotations: none + +#### Input +- None + +#### Output +- None + +#### Core logic +- Acts as a compile-time marker for future code transformation. +- Provides no runtime behavior; used exclusively during development. + +#### Public API +- `ConvertToRecord()` -> void: Marks a class for record migration. + +#### Dependencies +- None + +#### Exceptions / Errors +- None + +#### Concurrency +- None diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/Java8CompatibilityHelper.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/Java8CompatibilityHelper.java.ai.md new file mode 100644 index 0000000..63504dd --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/Java8CompatibilityHelper.java.ai.md @@ -0,0 +1,65 @@ +### Java8CompatibilityHelper.java +- H: 1.0 +- C: B9EE5FC2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:08:30Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides Java 8 compatibility for Java 9+ APIs through wrapper methods for string, file, and collection operations. + +#### Purpose +- Wraps Java 9+ APIs to maintain compatibility with Java 1.8. +- Centralizes compatibility logic for testing and reuse. + +#### Type +Class, final. Implements no interfaces. Uses Lombok @ToString annotation. + +#### Input +- Constructor: no parameters. +- isBlank: String value. +- formatted: Format string and varargs of objects. +- readString: Path to file. +- writeString: Path, content string, charset. +- toList: Stream of elements. +- listOf: Varargs of elements. +- hashMapCapacityFor: Integer number of mappings. + +#### Output +- isBlank: Boolean indicating blank or empty string. +- formatted: Formatted string result. +- readString: File content as String. +- writeString: No return; writes content to file. +- toList: List of stream elements. +- listOf: Immutable list of input elements. +- hashMapCapacityFor: Integer initial capacity for HashMap. + +#### Core logic +- Checks if a string is empty or contains only whitespace. +- Formats strings using String.format as substitute for String.formatted. +- Reads file content using Files.readAllBytes with UTF-8 decoding. +- Writes string to file with specified charset, defaulting to UTF-8. +- Collects stream elements into a list using Collectors.toList. +- Creates immutable list from varargs using Arrays.asList. +- Calculates HashMap initial capacity based on load factor and expected entries. + +#### Public API +- isBlank(str) -> boolean: Checks if string is blank or empty. +- formatted(format, args) -> String: Formats string like Java 15+. +- readString(path) -> String: Reads file content as string. +- writeString(path, content, charset) -> void: Writes string to file. +- toList(stream) -> List: Collects stream into list. +- listOf(elements) -> List: Creates immutable list from elements. +- hashMapCapacityFor(numMappings) -> int: Computes HashMap capacity. + +#### Dependencies +java.io.IOException, java.nio.charset.Charset, java.nio.charset.StandardCharsets, java.nio.file.Files, java.nio.file.Path, java.util.Arrays, java.util.List, java.util.stream.Collectors, java.util.stream.Stream, lombok.ToString + +#### Exceptions / Errors +- readString throws IOException on file read errors. +- writeString throws IOException on file write errors. +- isBlank throws NullPointerException if input string is null. + +#### Concurrency +No concurrency handling; class is stateless and thread-safe for immutable inputs. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/package-info.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/package-info.java.ai.md new file mode 100644 index 0000000..f882812 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/package-info.java.ai.md @@ -0,0 +1,39 @@ +### package-info.java +- H: 1.0 +- C: 6A9CD842 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T17:10:11Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides stateless utility functions for checksums, time, paths, and Java 8 helpers. + +#### Purpose +- Offers reusable, stateless helper methods for common operations. +- Supports foundational tasks in file processing and system utilities. + +#### Type +Package `net.ladenthin.maven.llamacpp.aiindex.support` with no explicit type modifiers. + +#### Input +No parameters or dependencies; package-level documentation only. + +#### Output +No return values or side effects; purely documentation and organizational. + +#### Core logic +- Defines a package for utility classes that do not maintain state. +- Centralizes helper functions for checksums, time handling, path manipulation, and Java 8 functional utilities. + +#### Public API +None; this is a package-info.java file with no public members. + +#### Dependencies +None directly imported; relies on standard Java libraries and package structure. + +#### Exceptions / Errors +No exceptions or error conditions; package documentation only. + +#### Concurrency +No concurrency concerns; utilities are stateless and side-effect free. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/package.ai.md new file mode 100644 index 0000000..0daa6fe --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/aiindex/support/package.ai.md @@ -0,0 +1,51 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/support +- H: 1.0 +- C: 4A74F585 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:26:00Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiChecksumSupport.java](AiChecksumSupport.java.ai.md) +- F: [AiPathSupport.java](AiPathSupport.java.ai.md) +- F: [AiSourceExcludeFilter.java](AiSourceExcludeFilter.java.ai.md) +- F: [AiTimeSupport.java](AiTimeSupport.java.ai.md) +- F: [ConvertToRecord.java](ConvertToRecord.java.ai.md) +- F: [Java8CompatibilityHelper.java](Java8CompatibilityHelper.java.ai.md) +- F: [package-info.java](package-info.java.ai.md) +--- +> Provides foundational utility functions for AI metadata indexing, including checksums, path normalization, time formatting, and Java 8 compatibility. + +#### Purpose +- Generates and validates file integrity checksums for AI index metadata. +- Normalizes source paths and formats timestamps for consistent indexing. + +#### Responsibilities +- File integrity and validation: CRC32 checksum computation for files and strings. +- Path manipulation: Normalizing source file paths by stripping redundant segments. +- Time formatting: Formatting timestamps with second-level precision for metadata. +- Java compatibility: Wrapping modern Java APIs for use in older JDKs. +- Exclusion filtering: Applying glob patterns to exclude specific source files from indexing. + +#### Key units +- `AiChecksumSupport` computes hexadecimal CRC32 checksums for file and string content. +- `AiPathSupport` normalizes source paths by removing leading "src" segments. +- `AiTimeSupport` formats timestamps into ISO-8601 strings with second precision. +- `AiSourceExcludeFilter` filters source paths using glob patterns to exclude files from indexing. +- `Java8CompatibilityHelper` wraps Java 9+ APIs for compatibility with Java 8. +- `ConvertToRecord` serves as a compile-time marker for future refactoring to Java records. + +#### Data flow +Input file paths and content are processed through checksum and path normalization utilities before being formatted into AI metadata. Timestamps are generated at indexing time, and exclusion filters determine which files contribute to the index. All operations are stateless and side-effect free. + +#### Dependencies +- `java.io.IOException`, `java.nio.charset.StandardCharsets`, `java.nio.file.Files`, `java.nio.file.Path`, `java.util.zip.CRC32` +- `java.time.Instant`, `java.time.format.DateTimeFormatter`, `java.time.temporal.ChronoUnit` +- `java.util.ArrayList`, `java.util.Collection`, `java.util.List`, `java.util.regex.Pattern` +- `lombok.ToString`, `org.jspecify.annotations.Nullable` + +#### Cross-cutting +- Statelessness: All utility classes are immutable and stateless, ensuring thread safety. +- Exception handling: Standard Java exceptions like `IOException` and `NullPointerException` are used where applicable. +- Java 8 compatibility: The `Java8CompatibilityHelper` centralizes workarounds for Java 9+ APIs to maintain JDK 8 support. +- Glob pattern matching: `AiSourceExcludeFilter` uses regex compilation for efficient path exclusion based on glob syntax. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..c7db920 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 17576EA0 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:31:30Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> This package automates AI-powered documentation and indexing of Java source code, generating structured markdown summaries with field-level metadata for Maven projects. + +#### Purpose +- Generates AI-driven documentation for Java source files, packages, and projects. +- Produces structured markdown index files with deterministic metadata and content. + +#### Responsibilities +- AI configuration and prompt management: defines model parameters, prompt templates, and generation settings. +- Document processing: reads, writes, and validates .ai.md file formats with metadata headers. +- Source indexing: creates AI-powered summaries for individual Java files and aggregates them into package and project indexes. +- AI inference and generation: supports local GGUF models and mock backends for code analysis and field extraction. +- Maven integration: automates documentation generation within the Maven build lifecycle. + +#### Key units +- AiFieldGenerationConfig: maps prompt templates to model definitions for file-specific AI processing. +- AiMdDocument: stores structured metadata and content for AI indexing in .ai.md format. +- AiGenerationProvider: interface for AI text generation with retry logic, implemented by native and mock providers. +- SourceFileIndexer: generates per-file .ai.md documentation using AI prompts and summaries. +- GenerateMojo: Maven plugin goal that indexes Java files and produces AI-enhanced markdown outputs. +- AiPromptSupport: manages prompt templates and renders them into structured inputs for AI models. + +#### Data flow +Source code is filtered by extension, then processed by `SourceFileIndexer` to generate `.ai.md` documents. These are aggregated by `PackageIndexer` into package-level indexes, which are consolidated by `ProjectIndexer` into a project-wide summary. AI prompts are prepared using `AiPromptPreparationSupport`, rendered via `AiPromptSupport`, and fed into either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. Results are parsed by `AiCompletionParser` to remove internal reasoning before being written back to `.ai.md` files. + +#### Dependencies +- Internal modules: config, document, indexer, prompt, provider, support. +- External libraries: Maven plugin API, Lombok annotations, Java 8 compatibility helpers. +- AI inference backend: llama.cpp via JNI bindings for native model execution. + +#### Cross-cutting +- Immutable design across core classes ensures thread safety without synchronization. +- Shared use of Lombok annotations reduces boilerplate code. +- Null safety enforced via `@Nullable` and `Objects.requireNonNull`. +- Consistent field ordering and formatting support deterministic behavior in manifests and headers. +- Exception handling wraps low-level I/O, configuration, and AI backend errors in standard Java exceptions. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..b58805d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 11C81082 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:32:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> This package automates the generation of AI-powered documentation and structured markdown indexes for Maven-based Java projects, enabling intelligent source code analysis and metadata extraction. + +#### Purpose +- Generates AI-driven documentation for Java source files, packages, and projects. +- Produces structured markdown index files with deterministic metadata and content. + +#### Responsibilities +- AI configuration and prompt management: defines model parameters, prompt templates, and generation settings. +- Document processing: reads, writes, and validates .ai.md file formats with metadata headers. +- Source indexing: creates AI-powered summaries for individual Java files and aggregates them into package and project indexes. +- AI inference and generation: supports local GGUF models and mock backends for code analysis and field extraction. +- Maven integration: automates documentation generation within the Maven build lifecycle. + +#### Key units +- AiFieldGenerationConfig: maps prompt templates to model definitions for file-specific AI processing. +- AiMdDocument: stores structured metadata and content for AI indexing in .ai.md format. +- AiGenerationProvider: interface for AI text generation with retry logic, implemented by native and mock providers. +- SourceFileIndexer: generates per-file .ai.md documentation using AI prompts and summaries. +- GenerateMojo: Maven plugin goal that indexes Java files and produces AI-enhanced markdown outputs. +- AiPromptSupport: manages prompt templates and renders them into structured inputs for AI models. + +#### Data flow +Source code is filtered by extension, then processed by `SourceFileIndexer` to generate `.ai.md` documents. These are aggregated by `PackageIndexer` into package-level indexes, which are consolidated by `ProjectIndexer` into a project-wide summary. AI prompts are prepared using `AiPromptPreparationSupport`, rendered via `AiPromptSupport`, and fed into either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. Results are parsed by `AiCompletionParser` to remove internal reasoning before being written back to `.ai.md` files. + +#### Dependencies +- Internal modules: config, document, indexer, prompt, provider, support. +- External libraries: Maven plugin API, Lombok annotations, Java 8 compatibility helpers. +- AI inference backend: llama.cpp via JNI bindings for native model execution. + +#### Cross-cutting +- Immutable design across core classes ensures thread safety without synchronization. +- Shared use of Lombok annotations reduces boilerplate code. +- Null safety enforced via `@Nullable` and `Objects.requireNonNull`. +- Consistent field ordering and formatting support deterministic behavior in manifests and headers. +- Exception handling wraps low-level I/O, configuration, and AI backend errors in standard Java exceptions. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..f66e9c7 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: CCF0DD0C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:33:52Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> This package automates the generation of AI-powered documentation and structured markdown indexes for Maven-based Java projects, enabling intelligent source code analysis and metadata extraction. + +#### Purpose +- Generates AI-driven documentation for Java source files, packages, and projects. +- Produces structured markdown index files with deterministic metadata and content. + +#### Responsibilities +- AI configuration and prompt management: defines model parameters, prompt templates, and generation settings. +- Document processing: reads, writes, and validates .ai.md file formats with metadata headers. +- Source indexing: creates AI-powered summaries for individual Java files and aggregates them into package and project indexes. +- AI inference and generation: supports local GGUF models and mock backends for code analysis and field extraction. +- Maven integration: automates documentation generation within the Maven build lifecycle. + +#### Key units +- AiFieldGenerationConfig: maps prompt templates to model definitions for file-specific AI processing. +- AiMdDocument: stores structured metadata and content for AI indexing in .ai.md format. +- AiGenerationProvider: interface for AI text generation with retry logic, implemented by native and mock providers. +- SourceFileIndexer: generates per-file .ai.md documentation using AI prompts and summaries. +- GenerateMojo: Maven plugin goal that indexes Java files and produces AI-enhanced markdown outputs. +- AiPromptSupport: manages prompt templates and renders them into structured inputs for AI models. + +#### Data flow +Source code is filtered by extension, then processed by `SourceFileIndexer` to generate `.ai.md` documents. These are aggregated by `PackageIndexer` into package-level indexes, which are consolidated by `ProjectIndexer` into a project-wide summary. AI prompts are prepared using `AiPromptPreparationSupport`, rendered via `AiPromptSupport`, and fed into either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. Results are parsed by `AiCompletionParser` to remove internal reasoning before being written back to `.ai.md` files. + +#### Dependencies +- Internal modules: config, document, indexer, prompt, provider, support. +- External libraries: Maven plugin API, Lombok annotations, Java 8 compatibility helpers. +- AI inference backend: llama.cpp via JNI bindings for native model execution. + +#### Cross-cutting +- Immutable design across core classes ensures thread safety without synchronization. +- Shared use of Lombok annotations reduces boilerplate code. +- Null safety enforced via `@Nullable` and `Objects.requireNonNull`. +- Consistent field ordering and formatting support deterministic behavior in manifests and headers. +- Exception handling wraps low-level I/O, configuration, and AI backend errors in standard Java exceptions. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/package.ai.md new file mode 100644 index 0000000..a5dc458 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/net/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net +- H: 1.0 +- C: 897019F3 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:35:03Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> This package automates the generation of AI-powered documentation and structured markdown indexes for Maven-based Java projects, enabling intelligent source code analysis and metadata extraction. + +#### Purpose +- Generates AI-driven documentation for Java source files, packages, and projects. +- Produces structured markdown index files with deterministic metadata and content. + +#### Responsibilities +- AI configuration and prompt management: defines model parameters, prompt templates, and generation settings. +- Document processing: reads, writes, and validates .ai.md file formats with metadata headers. +- Source indexing: creates AI-powered summaries for individual Java files and aggregates them into package and project indexes. +- AI inference and generation: supports local GGUF models and mock backends for code analysis and field extraction. +- Maven integration: automates documentation generation within the Maven build lifecycle. + +#### Key units +- AiFieldGenerationConfig: maps prompt templates to model definitions for file-specific AI processing. +- AiMdDocument: stores structured metadata and content for AI indexing in .ai.md format. +- AiGenerationProvider: interface for AI text generation with retry logic, implemented by native and mock providers. +- SourceFileIndexer: generates per-file .ai.md documentation using AI prompts and summaries. +- GenerateMojo: Maven plugin goal that indexes Java files and produces AI-enhanced markdown outputs. +- AiPromptSupport: manages prompt templates and renders them into structured inputs for AI models. + +#### Data flow +Source code is filtered by extension, then processed by `SourceFileIndexer` to generate `.ai.md` documents. These are aggregated by `PackageIndexer` into package-level indexes, which are consolidated by `ProjectIndexer` into a project-wide summary. AI prompts are prepared using `AiPromptPreparationSupport`, rendered via `AiPromptSupport`, and fed into either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. Results are parsed by `AiCompletionParser` to remove internal reasoning before being written back to `.ai.md` files. + +#### Dependencies +- Internal modules: config, document, indexer, prompt, provider, support. +- External libraries: Maven plugin API, Lombok annotations, Java 8 compatibility helpers. +- AI inference backend: llama.cpp via JNI bindings for native model execution. + +#### Cross-cutting +- Immutable design across core classes ensures thread safety without synchronization. +- Shared use of Lombok annotations reduces boilerplate code. +- Null safety enforced via `@Nullable` and `Objects.requireNonNull`. +- Consistent field ordering and formatting support deterministic behavior in manifests and headers. +- Exception handling wraps low-level I/O, configuration, and AI backend errors in standard Java exceptions. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/package.ai.md new file mode 100644 index 0000000..761c162 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/java/package.ai.md @@ -0,0 +1,45 @@ +### main/java +- H: 1.0 +- C: 03BE10C3 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:36:14Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> This package automates intelligent documentation generation and structured indexing of Maven-based Java projects using AI-powered analysis. + +#### Purpose +- Generates AI-driven documentation for Java source files and projects. +- Produces deterministic markdown indexes with metadata for code analysis. + +#### Responsibilities +- AI configuration and prompt management: defines model parameters, prompt templates, and generation settings. +- Document processing: reads, writes, and validates .ai.md file formats. +- Source indexing: creates per-file and aggregated package/project AI summaries. +- AI inference: supports local GGUF models and mock backends for code analysis. +- Maven integration: automates documentation within the Maven build lifecycle. + +#### Key units +- AiFieldGenerationConfig: maps prompt templates to model definitions for file-specific AI processing. +- AiMdDocument: stores structured metadata and content for AI indexing in .ai.md format. +- AiGenerationProvider: interface for AI text generation with retry logic, implemented by native and mock providers. +- SourceFileIndexer: generates per-file .ai.md documentation using AI prompts and summaries. +- GenerateMojo: Maven plugin goal that indexes Java files and produces AI-enhanced markdown outputs. +- AiPromptSupport: manages prompt templates and renders them into structured inputs for AI models. + +#### Data flow +Source code is filtered by extension, then processed by `SourceFileIndexer` to generate `.ai.md` documents. These are aggregated by `PackageIndexer` into package-level indexes, which are consolidated by `ProjectIndexer` into a project-wide summary. AI prompts are prepared using `AiPromptPreparationSupport`, rendered via `AiPromptSupport`, and fed into either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. Results are parsed by `AiCompletionParser` to remove internal reasoning before being written back to `.ai.md` files. + +#### Dependencies +- Internal modules: config, document, indexer, prompt, provider, support. +- External libraries: Maven plugin API, Lombok annotations, Java 8 compatibility helpers. +- AI inference backend: llama.cpp via JNI bindings for native model execution. + +#### Cross-cutting +- Immutable design across core classes ensures thread safety without synchronization. +- Shared use of Lombok annotations reduces boilerplate code. +- Null safety enforced via `@Nullable` and `Objects.requireNonNull`. +- Consistent field ordering and formatting support deterministic behavior in manifests and headers. +- Exception handling wraps low-level I/O, configuration, and AI backend errors in standard Java exceptions. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/package.ai.md new file mode 100644 index 0000000..2c13fd6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/main/package.ai.md @@ -0,0 +1,45 @@ +### main +- H: 1.0 +- C: 1A7F6F03 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:37:22Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Automates intelligent documentation generation and structured indexing of Maven-based Java projects using AI-powered analysis. + +#### Purpose +- Generates AI-driven documentation for Java source files and projects. +- Produces deterministic markdown indexes with metadata for code analysis. + +#### Responsibilities +- AI configuration and prompt management: defines model parameters, prompt templates, and generation settings. +- Document processing: reads, writes, and validates .ai.md file formats. +- Source indexing: creates per-file and aggregated package/project AI summaries. +- AI inference: supports local GGUF models and mock backends for code analysis. +- Maven integration: automates documentation within the Maven build lifecycle. + +#### Key units +- AiFieldGenerationConfig: maps prompt templates to model definitions for file-specific AI processing. +- AiMdDocument: stores structured metadata and content for AI indexing in .ai.md format. +- AiGenerationProvider: interface for AI text generation with retry logic, implemented by native and mock providers. +- SourceFileIndexer: generates per-file .ai.md documentation using AI prompts and summaries. +- GenerateMojo: Maven plugin goal that indexes Java files and produces AI-enhanced markdown outputs. +- AiPromptSupport: manages prompt templates and renders them into structured inputs for AI models. + +#### Data flow +Source code is filtered by extension, then processed by `SourceFileIndexer` to generate `.ai.md` documents. These are aggregated by `PackageIndexer` into package-level indexes, which are consolidated by `ProjectIndexer` into a project-wide summary. AI prompts are prepared using `AiPromptPreparationSupport`, rendered via `AiPromptSupport`, and fed into either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. Results are parsed by `AiCompletionParser` to remove internal reasoning before being written back to `.ai.md` files. + +#### Dependencies +- Internal modules: config, document, indexer, prompt, provider, support. +- External libraries: Maven plugin API, Lombok annotations, Java 8 compatibility helpers. +- AI inference backend: llama.cpp via JNI bindings for native model execution. + +#### Cross-cutting +- Immutable design across core classes ensures thread safety without synchronization. +- Shared use of Lombok annotations reduces boilerplate code. +- Null safety enforced via `@Nullable` and `Objects.requireNonNull`. +- Consistent field ordering and formatting support deterministic behavior in manifests and headers. +- Exception handling wraps low-level I/O, configuration, and AI backend errors in standard Java exceptions. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/package.ai.md new file mode 100644 index 0000000..343506d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/package.ai.md @@ -0,0 +1,45 @@ +### ai +- H: 1.0 +- C: EBEF804D +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:38:28Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Automates intelligent documentation generation and structured indexing of Maven-based Java projects using AI-powered analysis. + +#### Purpose +- Generates AI-driven documentation for Java source files and projects. +- Produces deterministic markdown indexes with metadata for code analysis. + +#### Responsibilities +- AI configuration and prompt management: defines model parameters, prompt templates, and generation settings. +- Document processing: reads, writes, and validates .ai.md file formats. +- Source indexing: creates per-file and aggregated package/project AI summaries. +- AI inference: supports local GGUF models and mock backends for code analysis. +- Maven integration: automates documentation within the Maven build lifecycle. + +#### Key units +- AiFieldGenerationConfig: maps prompt templates to model definitions for file-specific AI processing. +- AiMdDocument: stores structured metadata and content for AI indexing in .ai.md format. +- AiGenerationProvider: interface for AI text generation with retry logic, implemented by native and mock providers. +- SourceFileIndexer: generates per-file .ai.md documentation using AI prompts and summaries. +- GenerateMojo: Maven plugin goal that indexes Java files and produces AI-enhanced markdown outputs. +- AiPromptSupport: manages prompt templates and renders them into structured inputs for AI models. + +#### Data flow +Source code is filtered by extension, then processed by `SourceFileIndexer` to generate `.ai.md` documents. These are aggregated by `PackageIndexer` into package-level indexes, which are consolidated by `ProjectIndexer` into a project-wide summary. AI prompts are prepared using `AiPromptPreparationSupport`, rendered via `AiPromptSupport`, and fed into either `LlamaCppJniAiGenerationProvider` or `MockAiGenerationProvider`. Results are parsed by `AiCompletionParser` to remove internal reasoning before being written back to `.ai.md` files. + +#### Dependencies +- Internal modules: config, document, indexer, prompt, provider, support. +- External libraries: Maven plugin API, Lombok annotations, Java 8 compatibility helpers. +- AI inference backend: llama.cpp via JNI bindings for native model execution. + +#### Cross-cutting +- Immutable design across core classes ensures thread safety without synchronization. +- Shared use of Lombok annotations reduces boilerplate code. +- Null safety enforced via `@Nullable` and `Objects.requireNonNull`. +- Consistent field ordering and formatting support deterministic behavior in manifests and headers. +- Exception handling wraps low-level I/O, configuration, and AI backend errors in standard Java exceptions. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/project.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/project.ai.md new file mode 100644 index 0000000..a557183 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v1__fullproject-c64k/project.ai.md @@ -0,0 +1,45 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: 41E9A112 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T17:39:40Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/document](main/java/net/ladenthin/maven/llamacpp/aiindex/document/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/indexer](main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/mojo](main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/prompt](main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/support](main/java/net/ladenthin/maven/llamacpp/aiindex/support/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +This Maven plugin automates AI-powered documentation and indexing of Java source code, generating structured markdown summaries with field-level metadata for packages, files, and entire projects. The system integrates configurable AI models and prompt templates to produce deterministic outputs, managing document representation and serialization through dedicated packages for Markdown handling and source text trimming. It supports both local GGUF models and mock backends for testing, providing pluggable AI generation capabilities alongside utility functions for metadata extraction, checksums, and path normalization. The plugin enables intelligent source code analysis by automating per-file, per-package, and project-level indexing workflows through Maven MOJOs and configuration management. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Configures and manages AI-driven code indexing and generation for Maven projects using model definitions, prompt templates, and generation parameters. +- main/java/net/ladenthin/maven/llamacpp/aiindex/document — This package manages the structured representation, parsing, and serialization of AI-generated Markdown (.ai.md) documents, enabling deterministic indexing and content processing. +- main/java/net/ladenthin/maven/llamacpp/aiindex/indexer — Automates AI-powered documentation and indexing of Java source code packages, files, and projects by generating structured markdown summaries with field-level metadata. +- main/java/net/ladenthin/maven/llamacpp/aiindex/mojo — Automates the generation of AI-powered documentation and code summaries from Java source files within Maven projects, supporting per-file, per-package, and project-level indexing. +- main/java/net/ladenthin/maven/llamacpp/aiindex — This package automates AI-powered documentation and indexing of Java source code, generating structured markdown summaries with field-level metadata for Maven projects. +- main/java/net/ladenthin/maven/llamacpp/aiindex/prompt — Enables structured AI prompt generation and source text trimming for Maven-based code indexing workflows. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Provides pluggable AI text generation for code indexing, supporting local GGUF models and mock backends for testing. +- main/java/net/ladenthin/maven/llamacpp/aiindex/support — Provides foundational utility functions for AI metadata indexing, including checksums, path normalization, time formatting, and Java 8 compatibility. +- main/java/net/ladenthin/maven/llamacpp — This package automates AI-powered documentation and indexing of Java source code, generating structured markdown summaries with field-level metadata for Maven projects. +- main/java/net/ladenthin/maven — This package automates the generation of AI-powered documentation and structured markdown indexes for Maven-based Java projects, enabling intelligent source code analysis and metadata extraction. +- main/java/net/ladenthin — This package automates the generation of AI-powered documentation and structured markdown indexes for Maven-based Java projects, enabling intelligent source code analysis and metadata extraction. +- main/java/net — This package automates the generation of AI-powered documentation and structured markdown indexes for Maven-based Java projects, enabling intelligent source code analysis and metadata extraction. +- main/java — This package automates intelligent documentation generation and structured indexing of Maven-based Java projects using AI-powered analysis. +- main — Automates intelligent documentation generation and structured indexing of Maven-based Java projects using AI-powered analysis. +- . — Automates intelligent documentation generation and structured indexing of Maven-based Java projects using AI-powered analysis. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..085efde --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,50 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:07:40Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI-driven field generation by linking prompt templates and AI model definitions for Maven plugin execution. + +#### Purpose +- Associates AI prompt templates with model definitions for field generation +- Supports file extension filtering for targeted generation + +#### Type +class public final AiFieldGenerationConfig extends java.lang.Object implements none; key generics: none; notable annotations: @ToString, @Nullable + +#### Input +- Constructor: no parameters +- Methods: setPromptKey(String), setAiDefinitionKey(String), setFileExtensions(Collection) +- Fields read: promptKey, aiDefinitionKey, fileExtensions + +#### Output +- Methods: getPromptKey() → String, getAiDefinitionKey() → String, getFileExtensions() → List +- Fields mutated: promptKey, aiDefinitionKey, fileExtensions + +#### Core logic +- Links AI model definition key to prompt template key for field generation +- Filters files by extension when specified +- Provides immutable view of file extensions list + +#### Public API +- getPromptKey() → String +- setPromptKey(String) +- getAiDefinitionKey() → String +- setAiDefinitionKey(String) +- getFileExtensions() → List +- setFileExtensions(Collection) + +#### Dependencies +net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinition +net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition + +#### Exceptions / Errors +- Null handling for fileExtensions field +- Defensive copying of input collection in setFileExtensions + +#### Concurrency +- No explicit concurrency concerns; class is intended for Maven plugin configuration use only diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..18aa6f9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,44 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:09:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects AI field generation configurations based on file extensions to apply language-specific prompts. + +#### Purpose +- Matches source files to AI configuration rules by file extension +- Provides fallback behavior when no extension matches + +#### Type +Final class; implements no interfaces; key generics: `AiFieldGenerationConfig`; notable annotations: `@ToString` + +#### Input +- Constructor takes no parameters +- Method `selectForFileName` consumes: `Iterable configs`, `String fileName` + +#### Output +- Method returns: `@Nullable AiFieldGenerationConfig` +- Side effects: none + +#### Core logic +- Iterates through configured entries in order +- Skips null configurations +- For each config, checks if file name ends with any extension in its list +- Returns first matching config or fallback config if no match found +- Returns null if no matches and no fallback + +#### Public API +`selectForFileName(configs, fileName) -> AiFieldGenerationConfig` Picks configuration by file extension + +#### Dependencies +`AiFieldGenerationConfig`, `Iterable`, `List`, `String` + +#### Exceptions / Errors +Handles null configs gracefully; returns null when no match found + +#### Concurrency +No concurrency concerns; stateless operation diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..2415ea0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,73 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:09:53Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures parameters for AI model inference steps including context size, sampling settings, and retry logic. + +#### Purpose +- Carries mutable configuration for AI generation steps between Maven plugin and AI providers. +- Holds defaults and calculation constants for input trimming and retry policies. + +#### Type +Public class with Lombok @ToString; no implements or extends. + +#### Input +- Constructor takes no parameters. +- Setters accept primitive types, strings, lists, and nullables. + +#### Output +- Getters return primitives, strings, and unmodifiable lists. +- Mutates internal state via setters. + +#### Core logic +- Holds configuration for GGUF model path, context size, output tokens, sampling parameters (temperature, top-p, top-k, repeat penalty). +- Manages retry behavior on empty responses with incremental temperature. +- Calculates max input characters based on context and token estimates. +- Controls prompt trimming warnings and stop strings. + +#### Public API +- getModelPath() -> String +- setModelPath(String) +- getContextSize() -> int +- setContextSize(int) +- getMaxOutputTokens() -> int +- setMaxOutputTokens(int) +- getTemperature() -> float +- setTemperature(float) +- getThreads() -> int +- setThreads(int) +- getCharsPerToken() -> int +- setCharsPerToken(int) +- getMaxInputChars() -> int +- setMaxInputChars(int) +- isWarnOnTrim() -> boolean +- setWarnOnTrim(boolean) +- getMaxRetries() -> int +- setMaxRetries(int) +- getRetryTemperatureIncrement() -> float +- setRetryTemperatureIncrement(float) +- getTopP() -> float +- setTopP(float) +- getTopK() -> int +- setTopK(int) +- getRepeatPenalty() -> float +- setRepeatPenalty(float) +- isChatTemplateEnableThinking() -> boolean +- setChatTemplateEnableThinking(boolean) +- getStopStrings() -> List +- setStopStrings(List) + +#### Dependencies +None beyond java.util.ArrayList, java.util.Collections, org.jspecify.annotations.Nullable. + +#### Exceptions / Errors +- Uses @Nullable annotation on stopStrings list. +- No explicit throws; relies on Java null handling. + +#### Concurrency +Not thread-safe due to mutable fields and lack of synchronization. Managed by identity in Maven plugin framework. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..f3a3760 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,33 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:12:31Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Enumerates the scope of AI generation tasks, distinguishing between individual file and package-level processing. + +#### Purpose +- Defines discrete AI generation scopes for code analysis. +- Supports configuration of AI behavior per source unit. + +#### Type +Enum public AiGenerationKind implements none; key generics none; notable annotations none + +#### Core logic +- Provides two distinct values: FILE_SUMMARY and PACKAGE_SUMMARY. +- Each value represents a unique processing context for AI tools. + +#### Public API +JavaBean getters/setters for: FILE_SUMMARY, PACKAGE_SUMMARY + +#### Dependencies +none + +#### Exceptions / Errors +none + +#### Concurrency +none diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..83d5669 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,69 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:12:44Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines reusable AI model configurations for Maven plugin field generation. + +#### Purpose +- Encapsulates AI model parameters for reuse across multiple generation tasks. +- Serves as a configuration POJO for Maven plugin settings. + +#### Type +Public class with Lombok @ToString; implements no interfaces; key generics: List; notable annotations: @Nullable, @ToString. + +#### Input +Constructor takes no parameters; setters accept all fields including String, int, float, boolean, and Collection. + +#### Output +Getters return field values; setters mutate internal state; stopStrings returns unmodifiable list view. + +#### Core logic +- Holds immutable model configuration data. +- Provides mutable JavaBean accessors for Maven plugin instantiation via reflection. +- Defaults numeric fields to values from AiGenerationConfig class. + +#### Public API +- getKey() -> String: retrieves lookup key +- setKey(String): sets lookup key +- getModelPath() -> String: retrieves model file path +- setModelPath(String): sets model file path +- getContextSize() -> int: retrieves context window size +- setContextSize(int): sets context window size +- getMaxOutputTokens() -> int: retrieves max output tokens +- setMaxOutputTokens(int): sets max output tokens +- getTemperature() -> float: retrieves sampling temperature +- setTemperature(float): sets sampling temperature +- getThreads() -> int: retrieves thread count +- setThreads(int): sets thread count +- getCharsPerToken() -> int: retrieves chars-per-token ratio +- setCharsPerToken(int): sets chars-per-token ratio +- isWarnOnTrim() -> boolean: retrieves trim warning flag +- setWarnOnTrim(boolean): sets trim warning flag +- getMaxRetries() -> int: retrieves max retry attempts +- setMaxRetries(int): sets max retry attempts +- getRetryTemperatureIncrement() -> float: retrieves retry temperature increment +- setRetryTemperatureIncrement(float): sets retry temperature increment +- getTopP() -> float: retrieves top-p sampling threshold +- setTopP(float): sets top-p sampling threshold +- getTopK() -> int: retrieves top-k sampling limit +- setTopK(int): sets top-k sampling limit +- getRepeatPenalty() -> float: retrieves repetition penalty +- setRepeatPenalty(float): sets repetition penalty +- isChatTemplateEnableThinking() -> boolean: retrieves chat template thinking flag +- setChatTemplateEnableThinking(boolean): sets chat template thinking flag +- getStopStrings() -> List: retrieves stop strings list +- setStopStrings(Collection): sets stop strings collection + +#### Dependencies +AiGenerationConfig, Collection, List, ArrayList, Collections, org.jspecify.annotations.Nullable + +#### Exceptions / Errors +Null handling for stopStrings; no explicit exception throwing. + +#### Concurrency +No concurrency considerations noted; class is designed for Maven plugin use with reflection-based instantiation. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..373480e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,44 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:15:15Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by key to provide configured generation settings for AI field generation tasks. + +#### Purpose +- Maps AI model definition keys to ready-to-use generation configurations. +- Enforces required keys in configuration lists at build time. + +#### Type +Final class implementing no interfaces; key generics: `Map`; notable annotations: `@ToString`. + +#### Input +- Constructor takes `List`; null or empty list treated as no definitions. +- `getConfig(key)` method consumes a `String` key. + +#### Output +- `getConfig(key)` returns `AiGenerationConfig`. +- Constructor builds internal `Map` from input list. + +#### Core logic +- Validates each `AiModelDefinition` has a non-null key; throws `NullPointerException` if not. +- Populates internal map with key → `AiGenerationConfig` mapping via `toConfig()` helper. +- Looks up config by key; throws `IllegalArgumentException` if not found. + +#### Public API +- `getConfig(key) -> AiGenerationConfig`: retrieves generation config for a given definition key. + +#### Dependencies +- `AiModelDefinition`, `AiGenerationConfig`, `Java8CompatibilityHelper` + +#### Exceptions / Errors +- Throws `NullPointerException` on null keys in input list. +- Throws `IllegalArgumentException` when `getConfig()` is called with unknown key. +- Uses `Objects.requireNonNull` for null key validation. + +#### Concurrency +- Immutable internal state; thread-safe read access to `configs` map. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..05e46a1 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:20:25Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. + +#### Purpose +- Defines reusable AI model configurations and generation parameters for Maven plugin execution +- Links prompt templates with AI model settings for field-level code analysis + +#### Responsibilities +- AI model configuration management: AiModelDefinition, AiGenerationConfig +- Field generation setup: AiFieldGenerationConfig, AiFieldGenerationSelector +- Generation scope control: AiGenerationKind +- Model resolution and parameter mapping: AiModelDefinitionSupport + +#### Key units +AiFieldGenerationConfig manages prompt-template-to-model mappings with file extension filtering +AiFieldGenerationSelector matches source files to appropriate AI configurations by extension +AiGenerationConfig holds mutable inference parameters for GGUF models including context, sampling, and retry logic +AiModelDefinitionSupport resolves model definitions by key to provide configured generation settings +AiGenerationKind enumerates processing scopes for AI tools: FILE_SUMMARY and PACKAGE_SUMMARY + +#### Data flow +Configuration objects are constructed from Maven plugin inputs, validated for required keys, then mapped to generation tasks; file names are matched against extension rules to select appropriate field generation configurations; these configs are used to instantiate AiGenerationConfig objects with model-specific parameters + +#### Dependencies +AiModelDefinition collaborates with AiGenerationConfig to provide reusable model settings +AiFieldGenerationConfig depends on AiModelDefinition and AiPromptDefinition for linking templates to models +AiModelDefinitionSupport relies on AiModelDefinition and AiGenerationConfig for resolution and mapping +AiFieldGenerationSelector uses AiFieldGenerationConfig for matching file extensions to configurations + +#### Cross-cutting +Shared null handling via @Nullable annotations and defensive copying of mutable collections +Immutable view patterns for file extension lists and stop strings +Configuration validation through required key checks in AiModelDefinitionSupport +Default value management from AiGenerationConfig constants in AiModelDefinition diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..88beb05 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,62 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:23:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. + +#### Purpose +- Defines reusable AI model configurations and generation parameters for Maven plugin execution +- Links prompt templates with AI model settings for field-level code analysis + +#### Responsibilities +- AI model configuration management: AiModelDefinition, AiGenerationConfig +- Field generation setup: AiFieldGenerationConfig, AiFieldGenerationSelector +- Generation scope control: AiGenerationKind +- Model resolution and parameter mapping: AiModelDefinitionSupport +- AI generation provider selection and instantiation +- Local llama.cpp JNI integration with configuration management +- Prompt building, completion parsing, and response cleaning +- Mock implementation for testing and development + +#### Key units +AiFieldGenerationConfig manages prompt-template-to-model mappings with file extension filtering +AiFieldGenerationSelector matches source files to appropriate AI configurations by extension +AiGenerationConfig holds mutable inference parameters for GGUF models including context, sampling, and retry logic +AiModelDefinitionSupport resolves model definitions by key to provide configured generation settings +AiGenerationKind enumerates processing scopes for AI tools: FILE_SUMMARY and PACKAGE_SUMMARY +AiGenerationProvider interface defines text generation contract +LlamaCppJniAiGenerationProvider wraps llama.cpp JNI for local inference +AiCompletionParser strips internal reasoning from LLM responses +LlamaCppJniConfig holds immutable inference parameters +AiGenerationProviderFactory selects and creates provider instances + +#### Data flow +Configuration objects are constructed from Maven plugin inputs, validated for required keys, then mapped to generation tasks; file names are matched against extension rules to select appropriate field generation configurations; these configs are used to instantiate AiGenerationConfig objects with model-specific parameters +Input request flows through AiGenerationProviderFactory to instantiate LlamaCppJniAiGenerationProvider or MockAiGenerationProvider, which builds prompt using AiPromptSupport, generates completion via llama.cpp or mock logic, and returns parsed response via AiCompletionParser + +#### Dependencies +AiModelDefinition collaborates with AiGenerationConfig to provide reusable model settings +AiFieldGenerationConfig depends on AiModelDefinition and AiPromptDefinition for linking templates to models +AiModelDefinitionSupport relies on AiModelDefinition and AiGenerationConfig for resolution and mapping +AiFieldGenerationSelector uses AiFieldGenerationConfig for matching file extensions to configurations +AiPromptSupport for prompt building +LlamaModel and InferenceParameters for JNI integration +AiGenerationRequest for structured input data +Java8CompatibilityHelper for runtime compatibility + +#### Cross-cutting +Shared null handling via @Nullable annotations and defensive copying of mutable collections +Immutable view patterns for file extension lists and stop strings +Configuration validation through required key checks in AiModelDefinitionSupport +Default value management from AiGenerationConfig constants in AiModelDefinition +Shared AiGenerationRequest type across provider implementations +Exception handling with IOException for generation failures +Immutable configuration via Lombok value semantics +Deterministic mock behavior for testing consistency diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..a2bd549 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,43 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:16:16Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses LLM completion text to extract model answers by stripping Gemma-4 thinking blocks. + +#### Purpose +- Strips internal reasoning blocks from LLM responses +- Extracts clean model answers for AI index storage + +#### Type +class public final + +#### Input +- `response` String parameter in `parseCompletion` method + +#### Output +- Cleaned response String from `parseCompletion` method +- IOException thrown when thinking block is incomplete + +#### Core logic +- Check if response contains thinking block end marker +- If found, return text after end marker trimmed +- If start marker present but no end marker, throw IOException +- Otherwise return trimmed response + +#### Public API +- `parseCompletion(response) -> String` extract clean answer from LLM response +- `AiCompletionParser()` create new parser instance + +#### Dependencies +none + +#### Exceptions / Errors +- IOException thrown when thinking block starts but doesn't end + +#### Concurrency +none diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..b9572bc --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,44 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:16:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Defines a contract for pluggable AI text generation backends that produce responses based on structured requests. + +#### Purpose +- Provides a standardized interface for AI text generation. +- Supports both local and mock implementations for testing. + +#### Type +Interface public; extends AutoCloseable + +#### Input +- `AiGenerationRequest` object containing prompt key, source file, source text, and current header +- Optional `float temperatureOverride` parameter in overloaded method + +#### Output +- Generated text as `String`; never null but may be blank +- Throws `IOException` on failure + +#### Core logic +- Delegate generation to underlying AI backend using request data +- Override default temperature for retry attempts when needed +- Close resource via inherited AutoCloseable behavior + +#### Public API +- `generate(AiGenerationRequest) -> String` produce text from request +- `generate(AiGenerationRequest, float) -> String` produce text with custom temperature + +#### Dependencies +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest + +#### Exceptions / Errors +- Throws `IOException` on underlying provider failure +- Handles null return values gracefully by contract + +#### Concurrency +- No explicit concurrency handling; relies on implementation thread safety diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..315d35d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,43 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:17:29Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an AI generation provider implementation by name for use in a Maven plugin. + +#### Purpose +- Instantiates AI generation providers based on configuration +- Provides mock fallback for testing and development + +#### Type +class public final AiGenerationProviderFactory extends java.lang.Object + +#### Input +- `providerName` String: identifies desired provider type +- `llamaConfig` LlamaCppJniConfig: configuration for llama.cpp JNI provider +- `promptSupport` AiPromptSupport: prompt lookup support for providers that need it + +#### Output +- `AiGenerationProvider`: newly created instance based on provider name +- throws `IllegalArgumentException` for unrecognized provider names + +#### Core logic +- Checks if provider name is null or blank, returns mock provider +- Uses switch statement to map provider names to concrete implementations +- Throws exception for unsupported provider names + +#### Public API +create(providerName, llamaConfig, promptSupport) -> AiGenerationProvider: creates AI provider by name + +#### Dependencies +Java8CompatibilityHelper, LlamaCppJniAiGenerationProvider, MockAiGenerationProvider, LlamaCppJniConfig, AiPromptSupport + +#### Exceptions / Errors +IllegalArgumentException: thrown when providerName is not recognized + +#### Concurrency +Not applicable diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..7ee16f7 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,46 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:18:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides local AI text generation using GGUF models via JNI bindings. + +#### Purpose +- Wraps JNI llama.cpp integration for local inference. +- Supports prompt building, completion parsing, and resource management. + +#### Type +Final class implementing `AiGenerationProvider` and `AutoCloseable`; extends no types; key generics: `LlamaCppJniConfig`, `AiPromptSupport`. + +#### Input +- Constructor: `LlamaCppJniConfig`, `AiPromptSupport` +- `generate(AiGenerationRequest, float)`: `AiGenerationRequest`, `temperatureOverride` +- Internal use: `config` fields (`modelPath`, `contextSize`, etc.), `promptSupport.buildPrompt()` + +#### Output +- `generate(...)`: `String` completion +- Side effects: lazy model loading, native resource cleanup via `close()` + +#### Core logic +- Lazily initializes `LlamaModel` on first use to defer native load. +- Builds prompt using `AiPromptSupport`. +- Constructs `InferenceParameters` with config and request data. +- Calls `model.chatCompleteText()` and parses result with `AiCompletionParser`. + +#### Public API +- `generate(AiGenerationRequest) -> String`: Generates text from request. +- `generate(AiGenerationRequest, float) -> String`: Generates with override temperature. +- `close() -> void`: Releases native model resources. + +#### Dependencies +`LlamaModel`, `InferenceParameters`, `ModelParameters`, `Pair`, `AiGenerationRequest`, `AiPromptSupport`, `AiCompletionParser` + +#### Exceptions / Errors +Throws `IOException` during generation; null-checked inputs via `Objects.requireNonNull`. + +#### Concurrency +Not explicitly thread-safe; model access synchronized via lazy initialization. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..329ff60 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,51 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:19:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures native llama.cpp inference via JNI with immutable settings for model, context, sampling, and threading. + +#### Purpose +- Encapsulates configuration for llama.cpp JNI provider. +- Provides immutable access to inference parameters. + +#### Type +Final class implementing value semantics via Lombok annotations; marked for future record conversion. + +#### Input +Constructor accepts: libraryPath, modelPath, contextSize, maxOutputTokens, temperature, threads, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings; modelPath is required. + +#### Output +Accessors return: libraryPath, modelPath, contextSize, maxOutputTokens, temperature, threads, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings; stopStrings returned as unmodifiable list. + +#### Core logic +- Validates non-null modelPath. +- Stores all parameters as final fields. +- Normalizes stopStrings to empty list if null. +- Generates equals/hashCode/toString via Lombok. + +#### Public API +libraryPath() -> String +modelPath() -> String +contextSize() -> int +maxOutputTokens() -> int +temperature() -> float +threads() -> int +topP() -> float +topK() -> int +repeatPenalty() -> float +chatTemplateEnableThinking() -> boolean +stopStrings() -> List + +#### Dependencies +ConvertToRecord, Collections, Objects + +#### Exceptions / Errors +Throws NullPointerException if modelPath is null. + +#### Concurrency +Immutable; thread-safe. diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..5799f94 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,40 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:20:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides deterministic mock AI generation results for testing purposes. + +#### Purpose +- Supplies fake AI summaries to enable testing of downstream logic without actual AI inference. +- Facilitates unit testing of components that depend on AI-generated content. + +#### Type +- Class public implements AiGenerationProvider; @ToString + +#### Input +- `AiGenerationRequest` consumed via `request.sourceFile()` + +#### Output +- Returns deterministic string summary based on input file name + +#### Core logic +- Extracts file name from input request +- Constructs mock summary string using extracted file name + +#### Public API +- `generate(request) -> String` produces mock AI summary for testing + +#### Dependencies +- AiGenerationRequest +- Path + +#### Exceptions / Errors +- Throws IOException (though implementation does not) + +#### Concurrency +- Not applicable; stateless and immutable behavior diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..56c78f5 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-26T23:22:42Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> Enables pluggable local and mock AI text generation for Maven-based code indexing with structured prompt handling and response parsing. + +#### Purpose +- Provides standardized interface for AI text generation in Maven plugins +- Supports local llama.cpp inference and deterministic mocking for testing + +#### Responsibilities +- AI generation provider selection and instantiation +- Local llama.cpp JNI integration with configuration management +- Prompt building, completion parsing, and response cleaning +- Mock implementation for testing and development + +#### Key units +- AiGenerationProvider interface defines text generation contract +- LlamaCppJniAiGenerationProvider wraps llama.cpp JNI for local inference +- AiCompletionParser strips internal reasoning from LLM responses +- LlamaCppJniConfig holds immutable inference parameters +- AiGenerationProviderFactory selects and creates provider instances + +#### Data flow +Input request flows through AiGenerationProviderFactory to instantiate LlamaCppJniAiGenerationProvider or MockAiGenerationProvider, which builds prompt using AiPromptSupport, generates completion via llama.cpp or mock logic, and returns parsed response via AiCompletionParser + +#### Dependencies +- AiPromptSupport for prompt building +- LlamaModel and InferenceParameters for JNI integration +- AiGenerationRequest for structured input data +- Java8CompatibilityHelper for runtime compatibility + +#### Cross-cutting +- Shared AiGenerationRequest type across provider implementations +- Exception handling with IOException for generation failures +- Immutable configuration via Lombok value semantics +- Deterministic mock behavior for testing consistency diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..8f97461 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,61 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:25:18Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. + +#### Purpose +- Defines reusable AI model configurations and generation parameters for Maven plugin execution +- Links prompt templates with AI model settings for field-level code analysis + +#### Responsibilities +- AI model configuration management: AiModelDefinition, AiGenerationConfig +- Field generation setup: AiFieldGenerationConfig, AiFieldGenerationSelector +- Generation scope control: AiGenerationKind +- Model resolution and parameter mapping: AiModelDefinitionSupport +- AI generation provider selection and instantiation +- Local llama.cpp JNI integration with configuration management +- Prompt building, completion parsing, and response cleaning +- Mock implementation for testing and development + +#### Key units +AiFieldGenerationConfig manages prompt-template-to-model mappings with file extension filtering +AiFieldGenerationSelector matches source files to appropriate AI configurations by extension +AiGenerationConfig holds mutable inference parameters for GGUF models including context, sampling, and retry logic +AiModelDefinitionSupport resolves model definitions by key to provide configured generation settings +AiGenerationKind enumerates processing scopes for AI tools: FILE_SUMMARY and PACKAGE_SUMMARY +AiGenerationProvider interface defines text generation contract +LlamaCppJniAiGenerationProvider wraps llama.cpp JNI for local inference +AiCompletionParser strips internal reasoning from LLM responses +LlamaCppJniConfig holds immutable inference parameters +AiGenerationProviderFactory selects and creates provider instances + +#### Data flow +Configuration objects are constructed from Maven plugin inputs, validated for required keys, then mapped to generation tasks; file names are matched against extension rules to select appropriate field generation configurations; these configs are used to instantiate AiGenerationConfig objects with model-specific parameters +Input request flows through AiGenerationProviderFactory to instantiate LlamaCppJniAiGenerationProvider or MockAiGenerationProvider, which builds prompt using AiPromptSupport, generates completion via llama.cpp or mock logic, and returns parsed response via AiCompletionParser + +#### Dependencies +AiModelDefinition collaborates with AiGenerationConfig to provide reusable model settings +AiFieldGenerationConfig depends on AiModelDefinition and AiPromptDefinition for linking templates to models +AiModelDefinitionSupport relies on AiModelDefinition and AiGenerationConfig for resolution and mapping +AiFieldGenerationSelector uses AiFieldGenerationConfig for matching file extensions to configurations +AiPromptSupport for prompt building +LlamaModel and InferenceParameters for JNI integration +AiGenerationRequest for structured input data +Java8CompatibilityHelper for runtime compatibility + +#### Cross-cutting +Shared null handling via @Nullable annotations and defensive copying of mutable collections +Immutable view patterns for file extension lists and stop strings +Configuration validation through required key checks in AiModelDefinitionSupport +Default value management from AiGenerationConfig constants in AiModelDefinition +Shared AiGenerationRequest type across provider implementations +Exception handling with IOException for generation failures +Immutable configuration via Lombok value semantics +Deterministic mock behavior for testing consistency diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..51f3657 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,61 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:26:34Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. + +#### Purpose +- Defines reusable AI model configurations and generation parameters for Maven plugin execution +- Links prompt templates with AI model settings for field-level code analysis + +#### Responsibilities +- AI model configuration management: AiModelDefinition, AiGenerationConfig +- Field generation setup: AiFieldGenerationConfig, AiFieldGenerationSelector +- Generation scope control: AiGenerationKind +- Model resolution and parameter mapping: AiModelDefinitionSupport +- AI generation provider selection and instantiation +- Local llama.cpp JNI integration with configuration management +- Prompt building, completion parsing, and response cleaning +- Mock implementation for testing and development + +#### Key units +AiFieldGenerationConfig manages prompt-template-to-model mappings with file extension filtering +AiFieldGenerationSelector matches source files to appropriate AI configurations by extension +AiGenerationConfig holds mutable inference parameters for GGUF models including context, sampling, and retry logic +AiModelDefinitionSupport resolves model definitions by key to provide configured generation settings +AiGenerationKind enumerates processing scopes for AI tools: FILE_SUMMARY and PACKAGE_SUMMARY +AiGenerationProvider interface defines text generation contract +LlamaCppJniAiGenerationProvider wraps llama.cpp JNI for local inference +AiCompletionParser strips internal reasoning from LLM responses +LlamaCppJniConfig holds immutable inference parameters +AiGenerationProviderFactory selects and creates provider instances + +#### Data flow +Configuration objects are constructed from Maven plugin inputs, validated for required keys, then mapped to generation tasks; file names are matched against extension rules to select appropriate field generation configurations; these configs are used to instantiate AiGenerationConfig objects with model-specific parameters +Input request flows through AiGenerationProviderFactory to instantiate LlamaCppJniAiGenerationProvider or MockAiGenerationProvider, which builds prompt using AiPromptSupport, generates completion via llama.cpp or mock logic, and returns parsed response via AiCompletionParser + +#### Dependencies +AiModelDefinition collaborates with AiGenerationConfig to provide reusable model settings +AiFieldGenerationConfig depends on AiModelDefinition and AiPromptDefinition for linking templates to models +AiModelDefinitionSupport relies on AiModelDefinition and AiGenerationConfig for resolution and mapping +AiFieldGenerationSelector uses AiFieldGenerationConfig for matching file extensions to configurations +AiPromptSupport for prompt building +LlamaModel and InferenceParameters for JNI integration +AiGenerationRequest for structured input data +Java8CompatibilityHelper for runtime compatibility + +#### Cross-cutting +Shared null handling via @Nullable annotations and defensive copying of mutable collections +Immutable view patterns for file extension lists and stop strings +Configuration validation through required key checks in AiModelDefinitionSupport +Default value management from AiGenerationConfig constants in AiModelDefinition +Shared AiGenerationRequest type across provider implementations +Exception handling with IOException for generation failures +Immutable configuration via Lombok value semantics +Deterministic mock behavior for testing consistency diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..2e8ddb6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,61 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:27:49Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. + +#### Purpose +- Defines reusable AI model configurations and generation parameters for Maven plugin execution +- Links prompt templates with AI model settings for field-level code analysis + +#### Responsibilities +- AI model configuration management: AiModelDefinition, AiGenerationConfig +- Field generation setup: AiFieldGenerationConfig, AiFieldGenerationSelector +- Generation scope control: AiGenerationKind +- Model resolution and parameter mapping: AiModelDefinitionSupport +- AI generation provider selection and instantiation +- Local llama.cpp JNI integration with configuration management +- Prompt building, completion parsing, and response cleaning +- Mock implementation for testing and development + +#### Key units +AiFieldGenerationConfig manages prompt-template-to-model mappings with file extension filtering +AiFieldGenerationSelector matches source files to appropriate AI configurations by extension +AiGenerationConfig holds mutable inference parameters for GGUF models including context, sampling, and retry logic +AiModelDefinitionSupport resolves model definitions by key to provide configured generation settings +AiGenerationKind enumerates processing scopes for AI tools: FILE_SUMMARY and PACKAGE_SUMMARY +AiGenerationProvider interface defines text generation contract +LlamaCppJniAiGenerationProvider wraps llama.cpp JNI for local inference +AiCompletionParser strips internal reasoning from LLM responses +LlamaCppJniConfig holds immutable inference parameters +AiGenerationProviderFactory selects and creates provider instances + +#### Data flow +Configuration objects are constructed from Maven plugin inputs, validated for required keys, then mapped to generation tasks; file names are matched against extension rules to select appropriate field generation configurations; these configs are used to instantiate AiGenerationConfig objects with model-specific parameters +Input request flows through AiGenerationProviderFactory to instantiate LlamaCppJniAiGenerationProvider or MockAiGenerationProvider, which builds prompt using AiPromptSupport, generates completion via llama.cpp or mock logic, and returns parsed response via AiCompletionParser + +#### Dependencies +AiModelDefinition collaborates with AiGenerationConfig to provide reusable model settings +AiFieldGenerationConfig depends on AiModelDefinition and AiPromptDefinition for linking templates to models +AiModelDefinitionSupport relies on AiModelDefinition and AiGenerationConfig for resolution and mapping +AiFieldGenerationSelector uses AiFieldGenerationConfig for matching file extensions to configurations +AiPromptSupport for prompt building +LlamaModel and InferenceParameters for JNI integration +AiGenerationRequest for structured input data +Java8CompatibilityHelper for runtime compatibility + +#### Cross-cutting +Shared null handling via @Nullable annotations and defensive copying of mutable collections +Immutable view patterns for file extension lists and stop strings +Configuration validation through required key checks in AiModelDefinitionSupport +Default value management from AiGenerationConfig constants in AiModelDefinition +Shared AiGenerationRequest type across provider implementations +Exception handling with IOException for generation failures +Immutable configuration via Lombok value semantics +Deterministic mock behavior for testing consistency diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/package.ai.md new file mode 100644 index 0000000..2bdc904 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/net/package.ai.md @@ -0,0 +1,61 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:29:05Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. + +#### Purpose +- Defines reusable AI model configurations and generation parameters for Maven plugin execution +- Links prompt templates with AI model settings for field-level code analysis + +#### Responsibilities +- AI model configuration management: AiModelDefinition, AiGenerationConfig +- Field generation setup: AiFieldGenerationConfig, AiFieldGenerationSelector +- Generation scope control: AiGenerationKind +- Model resolution and parameter mapping: AiModelDefinitionSupport +- AI generation provider selection and instantiation +- Local llama.cpp JNI integration with configuration management +- Prompt building, completion parsing, and response cleaning +- Mock implementation for testing and development + +#### Key units +AiFieldGenerationConfig manages prompt-template-to-model mappings with file extension filtering +AiFieldGenerationSelector matches source files to appropriate AI configurations by extension +AiGenerationConfig holds mutable inference parameters for GGUF models including context, sampling, and retry logic +AiModelDefinitionSupport resolves model definitions by key to provide configured generation settings +AiGenerationKind enumerates processing scopes for AI tools: FILE_SUMMARY and PACKAGE_SUMMARY +AiGenerationProvider interface defines text generation contract +LlamaCppJniAiGenerationProvider wraps llama.cpp JNI for local inference +AiCompletionParser strips internal reasoning from LLM responses +LlamaCppJniConfig holds immutable inference parameters +AiGenerationProviderFactory selects and creates provider instances + +#### Data flow +Configuration objects are constructed from Maven plugin inputs, validated for required keys, then mapped to generation tasks; file names are matched against extension rules to select appropriate field generation configurations; these configs are used to instantiate AiGenerationConfig objects with model-specific parameters +Input request flows through AiGenerationProviderFactory to instantiate LlamaCppJniAiGenerationProvider or MockAiGenerationProvider, which builds prompt using AiPromptSupport, generates completion via llama.cpp or mock logic, and returns parsed response via AiCompletionParser + +#### Dependencies +AiModelDefinition collaborates with AiGenerationConfig to provide reusable model settings +AiFieldGenerationConfig depends on AiModelDefinition and AiPromptDefinition for linking templates to models +AiModelDefinitionSupport relies on AiModelDefinition and AiGenerationConfig for resolution and mapping +AiFieldGenerationSelector uses AiFieldGenerationConfig for matching file extensions to configurations +AiPromptSupport for prompt building +LlamaModel and InferenceParameters for JNI integration +AiGenerationRequest for structured input data +Java8CompatibilityHelper for runtime compatibility + +#### Cross-cutting +Shared null handling via @Nullable annotations and defensive copying of mutable collections +Immutable view patterns for file extension lists and stop strings +Configuration validation through required key checks in AiModelDefinitionSupport +Default value management from AiGenerationConfig constants in AiModelDefinition +Shared AiGenerationRequest type across provider implementations +Exception handling with IOException for generation failures +Immutable configuration via Lombok value semantics +Deterministic mock behavior for testing consistency diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/package.ai.md new file mode 100644 index 0000000..c9b800e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/java/package.ai.md @@ -0,0 +1,61 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:30:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. + +#### Purpose +- Defines reusable AI model configurations and generation parameters for Maven plugin execution +- Links prompt templates with AI model settings for field-level code analysis + +#### Responsibilities +- AI model configuration management: AiModelDefinition, AiGenerationConfig +- Field generation setup: AiFieldGenerationConfig, AiFieldGenerationSelector +- Generation scope control: AiGenerationKind +- Model resolution and parameter mapping: AiModelDefinitionSupport +- AI generation provider selection and instantiation +- Local llama.cpp JNI integration with configuration management +- Prompt building, completion parsing, and response cleaning +- Mock implementation for testing and development + +#### Key units +AiFieldGenerationConfig manages prompt-template-to-model mappings with file extension filtering +AiFieldGenerationSelector matches source files to appropriate AI configurations by extension +AiGenerationConfig holds mutable inference parameters for GGUF models including context, sampling, and retry logic +AiModelDefinitionSupport resolves model definitions by key to provide configured generation settings +AiGenerationKind enumerates processing scopes for AI tools: FILE_SUMMARY and PACKAGE_SUMMARY +AiGenerationProvider interface defines text generation contract +LlamaCppJniAiGenerationProvider wraps llama.cpp JNI for local inference +AiCompletionParser strips internal reasoning from LLM responses +LlamaCppJniConfig holds immutable inference parameters +AiGenerationProviderFactory selects and creates provider instances + +#### Data flow +Configuration objects are constructed from Maven plugin inputs, validated for required keys, then mapped to generation tasks; file names are matched against extension rules to select appropriate field generation configurations; these configs are used to instantiate AiGenerationConfig objects with model-specific parameters +Input request flows through AiGenerationProviderFactory to instantiate LlamaCppJniAiGenerationProvider or MockAiGenerationProvider, which builds prompt using AiPromptSupport, generates completion via llama.cpp or mock logic, and returns parsed response via AiCompletionParser + +#### Dependencies +AiModelDefinition collaborates with AiGenerationConfig to provide reusable model settings +AiFieldGenerationConfig depends on AiModelDefinition and AiPromptDefinition for linking templates to models +AiModelDefinitionSupport relies on AiModelDefinition and AiGenerationConfig for resolution and mapping +AiFieldGenerationSelector uses AiFieldGenerationConfig for matching file extensions to configurations +AiPromptSupport for prompt building +LlamaModel and InferenceParameters for JNI integration +AiGenerationRequest for structured input data +Java8CompatibilityHelper for runtime compatibility + +#### Cross-cutting +Shared null handling via @Nullable annotations and defensive copying of mutable collections +Immutable view patterns for file extension lists and stop strings +Configuration validation through required key checks in AiModelDefinitionSupport +Default value management from AiGenerationConfig constants in AiModelDefinition +Shared AiGenerationRequest type across provider implementations +Exception handling with IOException for generation failures +Immutable configuration via Lombok value semantics +Deterministic mock behavior for testing consistency diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/package.ai.md new file mode 100644 index 0000000..10d3aff --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/main/package.ai.md @@ -0,0 +1,61 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:31:37Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. + +#### Purpose +- Defines reusable AI model configurations and generation parameters for Maven plugin execution +- Links prompt templates with AI model settings for field-level code analysis + +#### Responsibilities +- AI model configuration management: AiModelDefinition, AiGenerationConfig +- Field generation setup: AiFieldGenerationConfig, AiFieldGenerationSelector +- Generation scope control: AiGenerationKind +- Model resolution and parameter mapping: AiModelDefinitionSupport +- AI generation provider selection and instantiation +- Local llama.cpp JNI integration with configuration management +- Prompt building, completion parsing, and response cleaning +- Mock implementation for testing and development + +#### Key units +AiFieldGenerationConfig manages prompt-template-to-model mappings with file extension filtering +AiFieldGenerationSelector matches source files to appropriate AI configurations by extension +AiGenerationConfig holds mutable inference parameters for GGUF models including context, sampling, and retry logic +AiModelDefinitionSupport resolves model definitions by key to provide configured generation settings +AiGenerationKind enumerates processing scopes for AI tools: FILE_SUMMARY and PACKAGE_SUMMARY +AiGenerationProvider interface defines text generation contract +LlamaCppJniAiGenerationProvider wraps llama.cpp JNI for local inference +AiCompletionParser strips internal reasoning from LLM responses +LlamaCppJniConfig holds immutable inference parameters +AiGenerationProviderFactory selects and creates provider instances + +#### Data flow +Configuration objects are constructed from Maven plugin inputs, validated for required keys, then mapped to generation tasks; file names are matched against extension rules to select appropriate field generation configurations; these configs are used to instantiate AiGenerationConfig objects with model-specific parameters +Input request flows through AiGenerationProviderFactory to instantiate LlamaCppJniAiGenerationProvider or MockAiGenerationProvider, which builds prompt using AiPromptSupport, generates completion via llama.cpp or mock logic, and returns parsed response via AiCompletionParser + +#### Dependencies +AiModelDefinition collaborates with AiGenerationConfig to provide reusable model settings +AiFieldGenerationConfig depends on AiModelDefinition and AiPromptDefinition for linking templates to models +AiModelDefinitionSupport relies on AiModelDefinition and AiGenerationConfig for resolution and mapping +AiFieldGenerationSelector uses AiFieldGenerationConfig for matching file extensions to configurations +AiPromptSupport for prompt building +LlamaModel and InferenceParameters for JNI integration +AiGenerationRequest for structured input data +Java8CompatibilityHelper for runtime compatibility + +#### Cross-cutting +Shared null handling via @Nullable annotations and defensive copying of mutable collections +Immutable view patterns for file extension lists and stop strings +Configuration validation through required key checks in AiModelDefinitionSupport +Default value management from AiGenerationConfig constants in AiModelDefinition +Shared AiGenerationRequest type across provider implementations +Exception handling with IOException for generation failures +Immutable configuration via Lombok value semantics +Deterministic mock behavior for testing consistency diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/package.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/package.ai.md new file mode 100644 index 0000000..21ac224 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/package.ai.md @@ -0,0 +1,61 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:32:52Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. + +#### Purpose +- Defines reusable AI model configurations and generation parameters for Maven plugin execution +- Links prompt templates with AI model settings for field-level code analysis + +#### Responsibilities +- AI model configuration management: AiModelDefinition, AiGenerationConfig +- Field generation setup: AiFieldGenerationConfig, AiFieldGenerationSelector +- Generation scope control: AiGenerationKind +- Model resolution and parameter mapping: AiModelDefinitionSupport +- AI generation provider selection and instantiation +- Local llama.cpp JNI integration with configuration management +- Prompt building, completion parsing, and response cleaning +- Mock implementation for testing and development + +#### Key units +AiFieldGenerationConfig manages prompt-template-to-model mappings with file extension filtering +AiFieldGenerationSelector matches source files to appropriate AI configurations by extension +AiGenerationConfig holds mutable inference parameters for GGUF models including context, sampling, and retry logic +AiModelDefinitionSupport resolves model definitions by key to provide configured generation settings +AiGenerationKind enumerates processing scopes for AI tools: FILE_SUMMARY and PACKAGE_SUMMARY +AiGenerationProvider interface defines text generation contract +LlamaCppJniAiGenerationProvider wraps llama.cpp JNI for local inference +AiCompletionParser strips internal reasoning from LLM responses +LlamaCppJniConfig holds immutable inference parameters +AiGenerationProviderFactory selects and creates provider instances + +#### Data flow +Configuration objects are constructed from Maven plugin inputs, validated for required keys, then mapped to generation tasks; file names are matched against extension rules to select appropriate field generation configurations; these configs are used to instantiate AiGenerationConfig objects with model-specific parameters +Input request flows through AiGenerationProviderFactory to instantiate LlamaCppJniAiGenerationProvider or MockAiGenerationProvider, which builds prompt using AiPromptSupport, generates completion via llama.cpp or mock logic, and returns parsed response via AiCompletionParser + +#### Dependencies +AiModelDefinition collaborates with AiGenerationConfig to provide reusable model settings +AiFieldGenerationConfig depends on AiModelDefinition and AiPromptDefinition for linking templates to models +AiModelDefinitionSupport relies on AiModelDefinition and AiGenerationConfig for resolution and mapping +AiFieldGenerationSelector uses AiFieldGenerationConfig for matching file extensions to configurations +AiPromptSupport for prompt building +LlamaModel and InferenceParameters for JNI integration +AiGenerationRequest for structured input data +Java8CompatibilityHelper for runtime compatibility + +#### Cross-cutting +Shared null handling via @Nullable annotations and defensive copying of mutable collections +Immutable view patterns for file extension lists and stop strings +Configuration validation through required key checks in AiModelDefinitionSupport +Default value management from AiGenerationConfig constants in AiModelDefinition +Shared AiGenerationRequest type across provider implementations +Exception handling with IOException for generation failures +Immutable configuration via Lombok value semantics +Deterministic mock behavior for testing consistency diff --git a/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/project.ai.md b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/project.ai.md new file mode 100644 index 0000000..de1e1d6 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__qwen3coder-30b__v2/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: E56B7358 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-26T23:34:12Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +This Maven plugin orchestrates AI-powered code generation by defining model configurations, prompt templates, and generation parameters to produce targeted file outputs. It supports pluggable AI providers, including local and mock implementations, that handle structured prompts and parse responses for integration into the build process. The system is designed to work seamlessly within Maven workflows, enabling automated and customizable AI-assisted development tasks. The core functionality centers around managing AI-driven indexing and code generation tasks through configurable parameters and provider interfaces. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. +- main/java/net/ladenthin/maven/llamacpp/aiindex — Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — Enables pluggable local and mock AI text generation for Maven-based code indexing with structured prompt handling and response parsing. +- main/java/net/ladenthin/maven/llamacpp — Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. +- main/java/net/ladenthin/maven — Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. +- main/java/net/ladenthin — Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. +- main/java/net — Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. +- main/java — Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. +- main — Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. +- . — Configures and orchestrates AI-driven code generation tasks within Maven plugins, managing model definitions, prompt templates, and generation parameters for targeted file processing. diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..3da327a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,56 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:03:19Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI field generation for Maven plugin using prompt templates and model definitions + +#### Purpose +- Associates prompt templates with AI models for single field-generation steps +- Used in Maven plugin configuration + +#### Type +- Class +- Public +- Uses Lombok's @ToString annotation + +#### Input +- Constructor: No parameters +- Setters: promptKey, aiDefinitionKey, fileExtensions + +#### Output +- Getters: promptKey, aiDefinitionKey, fileExtensions +- Mutated fields: promptKey, aiDefinitionKey, fileExtensions + +#### Core logic +- Stores configuration for AI field generation +- Manages associations between prompts and AI models +- Handles file extension selection for field generation + +#### Public API +- `getPromptKey() -> String`: Returns prompt template key +- `setPromptKey(String) -> void`: Sets prompt template key +- `getAiDefinitionKey() -> String`: Returns AI model definition key +- `setAiDefinitionKey(String) -> void`: Sets AI model definition key +- `getFileExtensions() -> List`: Returns file extensions or null +- `setFileExtensions(Collection) -> void`: Sets file extensions + +#### Dependencies +- java.util.ArrayList +- java.util.Collection +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- No explicit exceptions thrown +- Null handling for fileExtensions in getFileExtensions() + +#### Concurrency +- Not explicitly thread-safe +- Mutable state, may require external synchronization diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..c1cd03d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,49 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:05:08Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects AI field generation configuration based on source file extensions + +#### Purpose +- Matches AI field generation config to source files by extension +- Implements selection logic for AI prompts + +#### Type +- `final class` +- Uses Lombok's `@ToString` annotation + +#### Input +- Iterable of `AiFieldGenerationConfig` objects +- Source file name as String + +#### Output +- Matching `AiFieldGenerationConfig` or null + +#### Core logic +- Iterates through configs in declaration order +- Checks for matching extensions +- Handles fallback configs +- Returns first match or fallback + +#### Public API +- `AiFieldGenerationSelector() -> void` + Constructs a new selector instance +- `selectForFileName(Iterable, String) -> @Nullable AiFieldGenerationConfig` + Selects appropriate config for given file name + +#### Dependencies +- `java.util.List` +- `lombok.ToString` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- Handles null inputs gracefully +- Returns null when no match and no fallback + +#### Concurrency +- Immutable class, thread-safe diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..bb60d38 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,78 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:06:01Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI generation parameters for Maven build integration + +#### Purpose +- Stores configuration for AI generation steps +- Facilitates communication between Maven config and AI providers + +#### Type +- Class +- Public fields +- Lombok-generated toString() + +#### Input +- Constructor: no input +- Setter methods for all configurable parameters + +#### Output +- Getter methods for all parameters +- Mutable state through setter methods + +#### Core logic +- Manages default values for AI generation settings +- Provides getter/setter pairs for each configuration option +- Handles stop strings list with null safety + +#### Public API +- getModelPath() -> String: Retrieves model file path +- setModelPath(String) -> void: Sets model file path +- getContextSize() -> int: Gets context window size +- setContextSize(int) -> void: Sets context window size +- getMaxOutputTokens() -> int: Retrieves max output tokens +- setMaxOutputTokens(int) -> void: Sets max output tokens +- getTemperature() -> float: Gets sampling temperature +- setTemperature(float) -> void: Sets sampling temperature +- getThreads() -> int: Gets CPU threads count +- setThreads(int) -> void: Sets CPU threads count +- getCharsPerToken() -> int: Gets chars per token ratio +- setCharsPerToken(int) -> void: Sets chars per token ratio +- getMaxInputChars() -> int: Gets max input characters +- setMaxInputChars(int) -> void: Sets max input characters +- isWarnOnTrim() -> boolean: Checks trim warning setting +- setWarnOnTrim(boolean) -> void: Sets trim warning setting +- getMaxRetries() -> int: Gets max retry attempts +- setMaxRetries(int) -> void: Sets max retry attempts +- getRetryTemperatureIncrement() -> float: Gets retry temp increment +- setRetryTemperatureIncrement(float) -> void: Sets retry temp increment +- getTopP() -> float: Gets nucleus sampling threshold +- setTopP(float) -> void: Sets nucleus sampling threshold +- getTopK() -> int: Gets top-k sampling limit +- setTopK(int) -> void: Sets top-k sampling limit +- getRepeatPenalty() -> float: Gets repeat penalty +- setRepeatPenalty(float) -> void: Sets repeat penalty +- isChatTemplateEnableThinking() -> boolean: Checks chat template thinking mode +- setChatTemplateEnableThinking(boolean) -> void: Sets chat template thinking mode +- getStopStrings() -> List: Retrieves stop strings list +- setStopStrings(List) -> void: Sets stop strings list + +#### Dependencies +- java.util.ArrayList +- java.util.Collections +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- Null safety for stop strings list +- No explicit exception handling in methods + +#### Concurrency +- Mutable state allows for concurrent modifications +- Thread-safety depends on external usage diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..027f209 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,38 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:09:47Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Identifies AI generation scope: single files or packages + +#### Purpose +- Enumerates AI generation targets (per-file or aggregate) + +#### Type +enum public sealed + +#### Input +- None (pure enum) + +#### Output +- None (no methods, only constants) + +#### Core logic +- Defines two constants for file-level and package-level AI generation + +#### Public API +- FILE_SUMMARY -> Represents per-file AI generation +- PACKAGE_SUMMARY -> Represents aggregate package AI generation + +#### Dependencies +- net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationKind + +#### Exceptions / Errors +- None (enum constants) + +#### Concurrency +- Immutable, thread-safe diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..ee5977e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,81 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:10:13Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configures AI model parameters for Maven plugin integration + +#### Purpose +- Defines AI model configurations for Maven plugin use +- Allows reuse of model definitions across multiple field generations + +#### Type +- Class +- Public +- Lombok @ToString annotation + +#### Input +- Constructor: No input +- Setters: Various AI parameter values and paths + +#### Output +- Getters: Return configured AI parameters and paths +- Mutable state: Field values can be modified after construction + +#### Core logic +- Stores AI model configuration settings +- Provides getter/setter methods for each configurable parameter +- Manages default values from AiGenerationConfig +- Handles nullable stop strings collection + +#### Public API +- getKey() -> String: Retrieves unique identifier +- setKey(String) -> void: Sets unique identifier +- getModelPath() -> String: Gets model file path +- setModelPath(String) -> void: Sets model file path +- getContextSize() -> int: Retrieves context window size +- setContextSize(int) -> void: Sets context window size +- getMaxOutputTokens() -> int: Gets max output tokens +- setMaxOutputTokens(int) -> void: Sets max output tokens +- getTemperature() -> float: Retrieves temperature setting +- setTemperature(float) -> void: Sets temperature +- getThreads() -> int: Gets thread count +- setThreads(int) -> void: Sets thread count +- getCharsPerToken() -> int: Retrieves chars-per-token ratio +- setCharsPerToken(int) -> void: Sets chars-per-token ratio +- isWarnOnTrim() -> boolean: Checks trim warning setting +- setWarnOnTrim(boolean) -> void: Sets trim warning +- getMaxRetries() -> int: Gets max retry attempts +- setMaxRetries(int) -> void: Sets max retry attempts +- getRetryTemperatureIncrement() -> float: Retrieves retry temp increment +- setRetryTemperatureIncrement(float) -> void: Sets retry temp increment +- getTopP() -> float: Gets nucleus sampling threshold +- setTopP(float) -> void: Sets nucleus sampling threshold +- getTopK() -> int: Gets top-k sampling limit +- setTopK(int) -> void: Sets top-k sampling limit +- getRepeatPenalty() -> float: Retrieves repeat penalty +- setRepeatPenalty(float) -> void: Sets repeat penalty +- isChatTemplateEnableThinking() -> boolean: Checks chat template thinking mode +- setChatTemplateEnableThinking(boolean) -> void: Sets chat template thinking mode +- getStopStrings() -> List: Gets stop strings +- setStopStrings(Collection) -> void: Sets stop strings + +#### Dependencies +- java.util.ArrayList +- java.util.Collection +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- No explicit exception handling +- Null values allowed for optional fields (stopStrings) + +#### Concurrency +- Mutable class, not thread-safe +- Caller must ensure thread-safety when accessing shared instances diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..cc6d907 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,53 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:13:40Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Resolves AI model definitions by converting them to generation configurations + +#### Purpose +- Maps AI model definitions to generation configurations +- Provides lookup for AI models based on keys + +#### Type +- Class +- Final +- Notable annotations: @ToString + +#### Input +- List of AiModelDefinition objects in constructor +- String key in getConfig method + +#### Output +- Map of String keys to AiGenerationConfig objects +- AiGenerationConfig object from getConfig method + +#### Core logic +- Builds map of definitions during construction +- Converts definitions to configs using toConfig method +- Performs null checks on definition keys +- Throws exceptions for missing or null keys + +#### Public API +- `AiModelDefinitionSupport(List)` -> Constructor +- `AiGenerationConfig getConfig(String)` -> Retrieves config by key + +#### Dependencies +- java.util.HashMap +- java.util.List +- java.util.Map +- java.util.Objects +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper + +#### Exceptions / Errors +- NullPointerException for null keys during construction +- IllegalArgumentException for missing keys in getConfig +- NullPointerExceptions in toConfig if definition is null + +#### Concurrency +- Thread-safe due to final class and immutable state diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..a9da0ab --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,46 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:21:47Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> This package provides AI configuration and field generation capabilities for Maven builds, facilitating integration with various AI models and generation settings. + +#### Purpose +- Facilitates AI model configuration and field generation in Maven projects +- Supports integration with different AI models and generation parameters + +#### Responsibilities +- Configuration management for AI models and generation settings +- Field generation based on AI prompts and model definitions +- Selection of appropriate configurations for source files + +#### Key units +- `AiFieldGenerationConfig`: Configures AI field generation for Maven plugin +- `AiFieldGenerationSelector`: Selects AI field generation configuration based on file extensions +- `AiGenerationConfig`: Manages AI generation parameters for Maven build integration +- `AiGenerationKind`: Enumerates AI generation targets (per-file or aggregate) +- `AiModelDefinition`: Defines AI model configurations for Maven plugin use +- `AiModelDefinitionSupport`: Resolves AI model definitions to generation configurations + +#### Data flow +AI field generation configurations are applied to source files based on their extensions. The `AiFieldGenerationSelector` matches these configurations to input files, which are then processed using the associated `AiGenerationConfig` and `AiModelDefinition`. + +#### Dependencies +- Java collections framework (List, Map) +- Lombok for annotations (ToString) +- JSpecify for nullability annotations + +#### Cross-cutting +- Configuration management across multiple classes +- Error handling for null inputs and missing configurations +- Thread-safety considerations for mutable state diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..23bdae2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,42 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:26:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. + +#### Purpose +- Facilitates AI model integration in Maven projects +- Supports configuration and field generation for different AI models + +#### Responsibilities +- AI model configuration management +- Field generation based on AI prompts +- Integration with Maven build processes +- Support for multiple AI provider implementations + +#### Key units +- `AiFieldGenerationConfig`: Configures AI field generation for Maven plugin +- `AiGenerationConfig`: Manages AI generation parameters for Maven build integration +- `AiModelDefinition`: Defines AI model configurations for Maven plugin use +- `LlamaCppJniAiGenerationProvider`: Local GGUF model provider for AI text generation + +#### Data flow +AI configurations are applied to source files, with the `AiFieldGenerationConfig` and `AiModelDefinition` driving the process. The `LlamaCppJniAiGenerationProvider` handles the actual text generation using local models. + +#### Dependencies +- Java collections framework (List, Map) +- Lombok for annotations (ToString) +- JSpecify for nullability annotations +- llama.cpp JNI bindings for local model support + +#### Cross-cutting +- Configuration management across multiple classes +- Error handling for null inputs and missing configurations +- Thread-safety considerations for mutable state in generation providers diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..f1828eb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,44 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:15:02Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses LLM completion text to extract model answer, stripping internal reasoning + +#### Purpose +- Extracts and cleans model answers from LLM completions +- Handles Gemma-4 specific thinking block formatting + +#### Type +- Class +- Non-final for subclassing and testing + +#### Input +- Raw completion text (String) + +#### Output +- Cleaned answer text (String) +- IOException for incomplete reasoning blocks + +#### Core logic +- Identifies start and end markers of thinking blocks +- Removes internal reasoning while preserving the actual answer +- Handles edge cases (null input, exhausted token budget) + +#### Public API +- `AiCompletionParser()` -> Constructor +- `parseCompletion(String response) -> String` -> Strips thinking block from response + +#### Dependencies +- java.io.IOException +- lombok.ToString + +#### Exceptions / Errors +- IOException when token budget is exhausted inside a thinking block + +#### Concurrency +- Thread-safe due to immutable static final markers diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..61cbd18 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,50 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:15:59Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides AI text generation for documents based on prompts and parameters. + +#### Purpose +- Defines an interface for pluggable AI backends +- Handles text generation requests for AI models + +#### Type +- Interface +- Implements AutoCloseable +- Extends net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest + +#### Input +- AiGenerationRequest object containing prompt details + +#### Output +- Generated text as String +- May throw IOException + +#### Core logic +- Generates text based on AI model and request parameters +- Supports temperature override for retry attempts +- Provides default close method + +#### Public API +- generate(AiGenerationRequest) -> String + Generates text using provider's default settings +- generate(AiGenerationRequest, float) -> String + Generates text with specified temperature override +- close() -> void + Closes the AI generation provider + +#### Dependencies +- java.io.IOException +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest + +#### Exceptions / Errors +- Throws IOException for underlying provider failures +- Returns null or blank string for empty model responses + +#### Concurrency +- Thread-safe due to interface nature and AutoCloseable implementation diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..fbee0b2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,53 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:16:52Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an AiGenerationProvider implementation by name. + +#### Purpose +- Creates instances of AiGenerationProvider based on a given name +- Handles provider selection logic + +#### Type +- Class +- Public +- Annotated with @ToString + +#### Input +- String providerName +- LlamaCppJniConfig llamaConfig +- AiPromptSupport promptSupport + +#### Output +- AiGenerationProvider instance +- Throws IllegalArgumentException for unsupported providers + +#### Core logic +- Checks if providerName is null or blank +- Uses switch statement to select appropriate provider implementation +- Returns new MockAiGenerationProvider for "mock" or null/blank input +- Returns new LlamaCppJniAiGenerationProvider for "llamacpp-jni" +- Throws exception for unsupported providers + +#### Public API +- create(String, LlamaCppJniConfig, AiPromptSupport) -> AiGenerationProvider + Selects and instantiates an AI generation provider based on the given name. + +#### Dependencies +- lombok.ToString +- Java8CompatibilityHelper +- MockAiGenerationProvider +- LlamaCppJniAiGenerationProvider +- AiPromptSupport + +#### Exceptions / Errors +- Throws IllegalArgumentException for unsupported providers +- Handles null or blank providerName by defaulting to mock provider + +#### Concurrency +- Thread-safe due to immutable state and stateless factory methods diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..bc8503a --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,64 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:17:47Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides AI text generation using locally-run GGUF models via llama.cpp JNI binding + +#### Purpose +- Implements `AiGenerationProvider` for AI text generation +- Uses llama.cpp JNI binding to run GGUF models locally + +#### Type +- Class +- Final +- Implements `AiGenerationProvider`, `AutoCloseable` +- Uses Lombok's `@ToString` annotation + +#### Input +- `LlamaCppJniConfig` and `AiPromptSupport` in constructor +- `AiGenerationRequest` and optional temperature in `generate` methods + +#### Output +- Generated text as `String` from `generate` methods +- Closes native resources with `close` method + +#### Core logic +- Lazy initialization of llama.cpp model +- Builds AI prompts using `AiPromptSupport` +- Configures inference parameters for text generation +- Parses completion results using `AiCompletionParser` + +#### Public API +- `LlamaCppJniAiGenerationProvider(LlamaCppJniConfig, AiPromptSupport) -> void` +- `generate(AiGenerationRequest) -> String` +- `generate(AiGenerationRequest, float) -> String` +- `close() -> void` + +#### Dependencies +- `java.io.IOException` +- `java.util.ArrayList` +- `java.util.Collections` +- `java.util.List` +- `java.util.Objects` +- `lombok.ToString` +- `net.ladenthin.llama.LlamaModel` +- `net.ladenthin.llama.parameters.InferenceParameters` +- `net.ladenthin.llama.parameters.ModelParameters` +- `net.ladenthin.llama.value.Pair` +- `net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest` +- `net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport` +- `org.jspecify.annotations.Nullable` + +#### Exceptions / Errors +- Throws `IOException` for I/O errors during generation +- Handles null model state in `generate` methods +- Propagates exceptions from native llama.cpp calls + +#### Concurrency +- Thread-safe due to immutable configuration and local model execution +- Model initialization is synchronized via double-checked locking pattern diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..32801d2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,58 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:19:37Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides configuration for llama.cpp JNI provider with immutable fields and accessor methods. + +#### Purpose +- Configures llama.cpp JNI settings +- Immutable value type for safe concurrent use + +#### Type +- `final class` +- Annotated with Lombok annotations +- Implements `ConvertToRecord` interface + +#### Input +- Constructor parameters: library path, model path, context size, etc. +- List of stop strings (may be null) + +#### Output +- Accessor methods returning configuration values +- Immutable list of stop strings + +#### Core logic +- Validates non-null model path in constructor +- Initializes all fields, setting stopStrings to empty list if null +- Provides read-only access to all configuration properties + +#### Public API +- `libraryPath() -> String` - Returns native library path or null +- `modelPath() -> String` - Returns model file path +- `contextSize() -> int` - Returns context window size +- `maxOutputTokens() -> int` - Returns max output tokens +- `temperature() -> float` - Returns sampling temperature +- `threads() -> int` - Returns number of CPU threads +- `topP() -> float` - Returns nucleus-sampling threshold +- `topK() -> int` - Returns top-k sampling limit +- `repeatPenalty() -> float` - Returns repetition penalty +- `chatTemplateEnableThinking() -> boolean` - Returns chat-template mode status +- `stopStrings() -> List` - Returns unmodifiable list of stop strings + +#### Dependencies +- `java.util.Collections` +- `java.util.List` +- `java.util.Objects` +- Lombok annotations +- `ConvertToRecord` interface + +#### Exceptions / Errors +- Throws `NullPointerException` if modelPath is null in constructor + +#### Concurrency +- Immutable, thread-safe class diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..c4a3c41 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,40 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:21:16Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides mock AI generation summaries for testing purposes + +#### Purpose +- Implements a deterministic AI generation provider +- Returns mock summaries for testing + +#### Type +class public implements AiGenerationProvider @ToString + +#### Input +- AiGenerationRequest object with source file information + +#### Output +- String containing mock summary + +#### Core logic +1. Extracts filename from source file path +2. Generates mock summary string + +#### Public API +- MockAiGenerationProvider() -> constructor +- generate(AiGenerationRequest) -> String throws IOException + +#### Dependencies +- java.io.IOException +- java.nio.file.Path +- lombok.ToString +- net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest + +#### Exceptions +- Throws IOException if file operations fail diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..ebdedb9 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,46 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:24:19Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> This package provides AI text generation capabilities using various backends, including local GGUF models via llama.cpp JNI binding and mock implementations for testing. + +#### Purpose +- Offers pluggable AI text generation services +- Supports multiple AI provider implementations + +#### Responsibilities +- AI generation request handling +- Provider selection and instantiation +- Text parsing and cleaning +- Mock provider for testing + +#### Key units +- `AiCompletionParser`: Parses LLM completion text +- `AiGenerationProvider`: Defines AI generation interface +- `AiGenerationProviderFactory`: Creates AI generation providers +- `LlamaCppJniAiGenerationProvider`: Local GGUF model provider +- `LlamaCppJniConfig`: Configuration for llama.cpp JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +AI generation requests flow through the factory to select an appropriate provider, which then uses the completion parser to process model outputs. + +#### Dependencies +- Internal collaboration between providers and parsers +- External dependencies include llama.cpp JNI bindings and AI model files + +#### Cross-cutting +- Shared configuration handling across providers +- Common exception handling for I/O operations +- Thread-safe implementations for concurrent use diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..5773b76 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,41 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:27:03Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. + +#### Purpose +- Facilitates AI model integration in Maven projects +- Supports configuration and field generation for different AI models + +#### Responsibilities +- AI model configuration management +- Field generation based on AI prompts +- Integration with Maven build processes +- Support for multiple AI provider implementations + +#### Key units +- `AiFieldGenerationConfig`: Configures AI field generation for Maven plugin +- `AiGenerationConfig`: Manages AI generation parameters for Maven build integration +- `AiModelDefinition`: Defines AI model configurations for Maven plugin use +- `LlamaCppJniAiGenerationProvider`: Local GGUF model provider for AI text generation + +#### Data flow +AI configurations are applied to source files, with the `AiFieldGenerationConfig` and `AiModelDefinition` driving the process. The `LlamaCppJniAiGenerationProvider` handles the actual text generation using local models. + +#### Dependencies +- Java collections framework (List, Map) +- Lombok for annotations (ToString) +- JSpecify for nullability annotations +- llama.cpp JNI bindings for local model support + +#### Cross-cutting +- Configuration management across multiple classes +- Error handling for null inputs and missing configurations +- Thread-safety considerations for mutable state in generation providers diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..ab4e5cb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,41 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:27:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. + +#### Purpose +- Facilitates AI model integration in Maven projects +- Supports configuration and field generation for different AI models + +#### Responsibilities +- AI model configuration management +- Field generation based on AI prompts +- Integration with Maven build processes +- Support for multiple AI provider implementations + +#### Key units +- `AiFieldGenerationConfig`: Configures AI field generation for Maven plugin +- `AiGenerationConfig`: Manages AI generation parameters for Maven build integration +- `AiModelDefinition`: Defines AI model configurations for Maven plugin use +- `LlamaCppJniAiGenerationProvider`: Local GGUF model provider for AI text generation + +#### Data flow +AI configurations are applied to source files, with the `AiFieldGenerationConfig` and `AiModelDefinition` driving the process. The `LlamaCppJniAiGenerationProvider` handles the actual text generation using local models. + +#### Dependencies +- Java collections framework (List, Map) +- Lombok for annotations (ToString) +- JSpecify for nullability annotations +- llama.cpp JNI bindings for local model support + +#### Cross-cutting +- Configuration management across multiple classes +- Error handling for null inputs and missing configurations +- Thread-safety considerations for mutable state in generation providers diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..f9069a5 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,41 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:28:46Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. + +#### Purpose +- Facilitates AI model integration in Maven projects +- Supports configuration and field generation for different AI models + +#### Responsibilities +- AI model configuration management +- Field generation based on AI prompts +- Integration with Maven build processes +- Support for multiple AI provider implementations + +#### Key units +- `AiFieldGenerationConfig`: Configures AI field generation for Maven plugin +- `AiGenerationConfig`: Manages AI generation parameters for Maven build integration +- `AiModelDefinition`: Defines AI model configurations for Maven plugin use +- `LlamaCppJniAiGenerationProvider`: Local GGUF model provider for AI text generation + +#### Data flow +AI configurations are applied to source files, with the `AiFieldGenerationConfig` and `AiModelDefinition` driving the process. The `LlamaCppJniAiGenerationProvider` handles the actual text generation using local models. + +#### Dependencies +- Java collections framework (List, Map) +- Lombok for annotations (ToString) +- JSpecify for nullability annotations +- llama.cpp JNI bindings for local model support + +#### Cross-cutting +- Configuration management across multiple classes +- Error handling for null inputs and missing configurations +- Thread-safety considerations for mutable state in generation providers diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/package.ai.md new file mode 100644 index 0000000..07c3c1f --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/net/package.ai.md @@ -0,0 +1,41 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:29:38Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. + +#### Purpose +- Facilitates AI model integration in Maven projects +- Supports configuration and field generation for different AI models + +#### Responsibilities +- AI model configuration management +- Field generation based on AI prompts +- Integration with Maven build processes +- Support for multiple AI provider implementations + +#### Key units +- `AiFieldGenerationConfig`: Configures AI field generation for Maven plugin +- `AiGenerationConfig`: Manages AI generation parameters for Maven build integration +- `AiModelDefinition`: Defines AI model configurations for Maven plugin use +- `LlamaCppJniAiGenerationProvider`: Local GGUF model provider for AI text generation + +#### Data flow +AI configurations are applied to source files, with the `AiFieldGenerationConfig` and `AiModelDefinition` driving the process. The `LlamaCppJniAiGenerationProvider` handles the actual text generation using local models. + +#### Dependencies +- Java collections framework (List, Map) +- Lombok for annotations (ToString) +- JSpecify for nullability annotations +- llama.cpp JNI bindings for local model support + +#### Cross-cutting +- Configuration management across multiple classes +- Error handling for null inputs and missing configurations +- Thread-safety considerations for mutable state in generation providers diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/package.ai.md new file mode 100644 index 0000000..6494863 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/java/package.ai.md @@ -0,0 +1,41 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:30:30Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> This package streamlines AI integration within Maven projects, enabling seamless configuration and field generation for various AI models. + +#### Purpose +- Simplifies AI model integration in Maven builds +- Automates configuration and field generation for different AI models + +#### Responsibilities +- Manages AI model configurations +- Generates fields based on AI prompts +- Integrates with Maven build processes +- Supports multiple AI provider implementations + +#### Key units +- `AiFieldGenerationConfig`: Configures AI field generation for Maven plugin +- `AiGenerationConfig`: Manages AI generation parameters for Maven build integration +- `AiModelDefinition`: Defines AI model configurations for Maven plugin use +- `LlamaCppJniAiGenerationProvider`: Local GGUF model provider for AI text generation + +#### Data flow +AI configurations are applied to source files, with `AiFieldGenerationConfig` and `AiModelDefinition` driving the process. The `LlamaCppJniAiGenerationProvider` handles the actual text generation using local models. + +#### Dependencies +- Java collections framework (List, Map) +- Lombok for annotations (ToString) +- JSpecify for nullability annotations +- llama.cpp JNI bindings for local model support + +#### Cross-cutting +- Configuration management across multiple classes +- Error handling for null inputs and missing configurations +- Thread-safety considerations for mutable state in generation providers diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/package.ai.md new file mode 100644 index 0000000..a090e30 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/main/package.ai.md @@ -0,0 +1,41 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:31:22Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> This package streamlines AI integration within Maven projects, enabling seamless configuration and field generation for various AI models. + +#### Purpose +- Simplifies AI model integration in Maven builds +- Automates configuration and field generation for different AI models + +#### Responsibilities +- Manages AI model configurations +- Generates fields based on AI prompts +- Integrates with Maven build processes +- Supports multiple AI provider implementations + +#### Key units +- `AiFieldGenerationConfig`: Configures AI field generation for Maven plugin +- `AiGenerationConfig`: Manages AI generation parameters for Maven build integration +- `AiModelDefinition`: Defines AI model configurations for Maven plugin use +- `LlamaCppJniAiGenerationProvider`: Local GGUF model provider for AI text generation + +#### Data flow +AI configurations are applied to source files, with `AiFieldGenerationConfig` and `AiModelDefinition` driving the process. The `LlamaCppJniAiGenerationProvider` handles the actual text generation using local models. + +#### Dependencies +- Java collections framework (List, Map) +- Lombok for annotations (ToString) +- JSpecify for nullability annotations +- llama.cpp JNI bindings for local model support + +#### Cross-cutting +- Configuration management across multiple classes +- Error handling for null inputs and missing configurations +- Thread-safety considerations for mutable state in generation providers diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/package.ai.md new file mode 100644 index 0000000..322ece3 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/package.ai.md @@ -0,0 +1,41 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:32:13Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> This package streamlines AI integration within Maven projects, enabling seamless configuration and field generation for various AI models. + +#### Purpose +- Simplifies AI model integration in Maven builds +- Automates configuration and field generation for different AI models + +#### Responsibilities +- Manages AI model configurations +- Generates fields based on AI prompts +- Integrates with Maven build processes +- Supports multiple AI provider implementations + +#### Key units +- `AiFieldGenerationConfig`: Configures AI field generation for Maven plugin +- `AiGenerationConfig`: Manages AI generation parameters for Maven build integration +- `AiModelDefinition`: Defines AI model configurations for Maven plugin use +- `LlamaCppJniAiGenerationProvider`: Local GGUF model provider for AI text generation + +#### Data flow +AI configurations are applied to source files, with `AiFieldGenerationConfig` and `AiModelDefinition` driving the process. The `LlamaCppJniAiGenerationProvider` handles the actual text generation using local models. + +#### Dependencies +- Java collections framework (List, Map) +- Lombok for annotations (ToString) +- JSpecify for nullability annotations +- llama.cpp JNI bindings for local model support + +#### Cross-cutting +- Configuration management across multiple classes +- Error handling for null inputs and missing configurations +- Thread-safety considerations for mutable state in generation providers diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/project.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/project.ai.md new file mode 100644 index 0000000..5cffd95 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v1/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: 10473F99 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:33:08Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +This project provides a comprehensive AI integration solution for Maven builds, offering configuration and field generation capabilities across multiple AI models. It includes subsystems for managing AI configurations, supporting various backends for text generation, and facilitating seamless integration into Maven projects. The core functionality is centered around the llamacpp-ai-index-maven-plugin, which leverages llama.cpp JNI bindings for local GGUF model support and mock implementations for testing purposes. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — This package provides AI configuration and field generation capabilities for Maven builds, facilitating integration with various AI models and generation settings. +- main/java/net/ladenthin/maven/llamacpp/aiindex — This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — This package provides AI text generation capabilities using various backends, including local GGUF models via llama.cpp JNI binding and mock implementations for testing. +- main/java/net/ladenthin/maven/llamacpp — This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. +- main/java/net/ladenthin/maven — This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. +- main/java/net/ladenthin — This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. +- main/java/net — This package provides AI integration capabilities for Maven builds, supporting configuration and field generation for various AI models. +- main/java — This package streamlines AI integration within Maven projects, enabling seamless configuration and field generation for various AI models. +- main — This package streamlines AI integration within Maven projects, enabling seamless configuration and field generation for various AI models. +- . — This package streamlines AI integration within Maven projects, enabling seamless configuration and field generation for various AI models. diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md new file mode 100644 index 0000000..11cfe17 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java.ai.md @@ -0,0 +1,50 @@ +### AiFieldGenerationConfig.java +- H: 1.0 +- C: D35DA51C +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:33:47Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Maven plugin configuration for associating prompt templates with AI model definitions for field generation. + +#### Purpose +- Configure AI field generation via prompt templates and AI models. +- Associate configurations with specific file extensions or use as a fallback. + +#### Type +class public @ToString + +#### Input +- String promptKey, aiDefinitionKey +- Collection fileExtensions + +#### Output +- String promptKey, aiDefinitionKey +- List fileExtensions (unmodifiable copy) + +#### Core logic +- Store and retrieve configuration for AI field generation. +- Handle file extension-based selection or fallback. +- Provide defensive copying for file extensions. + +#### Public API +- getPromptKey() -> String: Get prompt template key +- setPromptKey(String) -> void: Set prompt template key +- getAiDefinitionKey() -> String: Get AI model definition key +- setAiDefinitionKey(String) -> void: Set AI model definition key +- getFileExtensions() -> List: Get file extensions (unmodifiable) +- setFileExtensions(Collection) -> void: Set file extensions + +#### Dependencies +- AiModelDefinition +- AiModelDefinitionSupport +- AiPromptDefinition +- List, ArrayList, Collections + +#### Exceptions / Errors +No explicit exceptions. Null handling for fileExtensions is documented. + +#### Concurrency +Not explicitly thread-safe. Mutable state with potential race conditions in multi-threaded environments. diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md new file mode 100644 index 0000000..819ffa7 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java.ai.md @@ -0,0 +1,44 @@ +### AiFieldGenerationSelector.java +- H: 1.0 +- C: ACD28FC9 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:35:32Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects the appropriate AI field generation configuration based on source file extensions. + +#### Purpose +- Selects `AiFieldGenerationConfig` for a given source file. +- Determines applicable config using file extensions. + +#### Type +class final, Lombok @ToString annotation + +#### Input +- Iterable of `AiFieldGenerationConfig` objects +- Source file name as String + +#### Output +- Matching `AiFieldGenerationConfig` or null + +#### Core logic +1. Iterate through configs +2. Check for matching extensions +3. Return first match or fallback +4. Return null if no match and no fallback + +#### Public API +```java +selectForFileName(Iterable, String) -> @Nullable AiFieldGenerationConfig +``` + +#### Dependencies +- `AiFieldGenerationConfig` +- `List` +- `Nullable` annotation + +#### Exceptions / Errors +- Throws exceptions from `AiFieldGenerationConfig.getFileExtensions()` +- Handles null configs and extensions gracefully diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md new file mode 100644 index 0000000..da83387 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java.ai.md @@ -0,0 +1,67 @@ +### AiGenerationConfig.java +- H: 1.0 +- C: 59512635 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:36:21Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configuration object for AI generation parameters between Maven and provider implementations + +#### Purpose +- Mutable configuration for AI generation steps +- Carries all parameters for a single AI generation step + +#### Type +class public @ToString + +#### Input +- Constructor: no input +- Setters: various primitive and String parameters + +#### Output +- Getters: return various primitive types, Strings, or Lists +- Produced state: mutable fields + +#### Core logic +- Stores AI generation parameters +- Provides getter/setter methods for each parameter +- Manages a list of stop strings + +#### Public API +- `getModelPath() -> String`: Returns model file path +- `setModelPath(String) -> void`: Sets model file path +- `getContextSize() -> int`: Returns context size +- `setMaxOutputTokens(int) -> void`: Sets max output tokens +- `getTemperature() -> float`: Returns temperature +- `setTemperature(float) -> void`: Sets temperature +- `getThreads() -> int`: Returns thread count +- `setThreads(int) -> void`: Sets thread count +- `getCharsPerToken() -> int`: Returns chars per token +- `setCharsPerToken(int) -> void`: Sets chars per token +- `getMaxInputChars() -> int`: Returns max input chars +- `setMaxInputChars(int) -> void`: Sets max input chars +- `isWarnOnTrim() -> boolean`: Checks trim warning setting +- `setWarnOnTrim(boolean) -> void`: Sets trim warning setting +- `getMaxRetries() -> int`: Returns max retries +- `setMaxRetries(int) -> void`: Sets max retries +- `getRetryTemperatureIncrement() -> float`: Returns retry temp increment +- `setRetryTemperatureIncrement(float) -> void`: Sets retry temp increment +- `getTopP() -> float`: Returns top-p value +- `setTopP(float) -> void`: Sets top-p value +- `getTopK() -> int`: Returns top-k value +- `setTopK(int) -> void`: Sets top-k value +- `getRepeatPenalty() -> float`: Returns repeat penalty +- `setRepeatPenalty(float) -> void`: Sets repeat penalty +- `isChatTemplateEnableThinking() -> boolean`: Checks chat template thinking mode +- `setChatTemplateEnableThinking(boolean) -> void`: Sets chat template thinking mode +- `getStopStrings() -> List`: Returns stop strings list +- `setStopStrings(List) -> void`: Sets stop strings list + +#### Dependencies +- java.util.ArrayList +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md new file mode 100644 index 0000000..59cb6f8 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationKind.java.ai.md @@ -0,0 +1,35 @@ +### AiGenerationKind.java +- H: 1.0 +- C: 502093E2 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:39:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Enum defining AI generation scope: single file or entire package + +#### Purpose +- Defines AI generation targets (file vs. package) +- Enumerates possible generation modes + +#### Type +enum public + final + +#### Core logic +- Lists two generation modes: FILE_SUMMARY and PACKAGE_SUMMARY +- Each mode represents a distinct purpose for AI processing + +#### Public API +AiGenerationKind() -> void +values() -> AiGenerationKind[] +valueOf(String) -> AiGenerationKind +FILE_SUMMARY -> enum constant representing file-level summary +PACKAGE_SUMMARY -> enum constant representing package-level summary + +#### Dependencies +java.lang.Enum +java.lang.String + +#### Exceptions / Errors +No explicit exceptions diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md new file mode 100644 index 0000000..a5fb381 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java.ai.md @@ -0,0 +1,80 @@ +### AiModelDefinition.java +- H: 1.0 +- C: F0FA9D43 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:40:19Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configuration POJO for AI model parameters, supporting Maven plugin integration and reusable configurations. + +#### Purpose +- Define AI model parameters +- Support Maven plugin configuration +- Enable reuse of model configurations + +#### Type +class public final @ToString + +#### Input +- Constructor: none +- Setters: all fields (key, modelPath, contextSize, etc.) + +#### Output +- Getters: all fields (key, modelPath, contextSize, etc.) +- Returns: various types (String, int, float, boolean, List) + +#### Core logic +- Store and retrieve AI model parameters +- Handle default values from AiGenerationConfig +- Manage collection of stop strings +- Provide immutable access to stop strings list + +#### Public API +- getKey() -> String: Retrieve unique identifier +- setKey(String) -> void: Set unique identifier +- getModelPath() -> String: Get model file path +- setModelPath(String) -> void: Set model file path +- getContextSize() -> int: Get context window size +- setContextSize(int) -> void: Set context window size +- getMaxOutputTokens() -> int: Get max output tokens +- setMaxOutputTokens(int) -> void: Set max output tokens +- getTemperature() -> float: Get sampling temperature +- setTemperature(float) -> void: Set sampling temperature +- getThreads() -> int: Get thread count +- setThreads(int) -> void: Set thread count +- getCharsPerToken() -> int: Get chars per token ratio +- setCharsPerToken(int) -> void: Set chars per token ratio +- isWarnOnTrim() -> boolean: Check trim warning setting +- setWarnOnTrim(boolean) -> void: Set trim warning setting +- getMaxRetries() -> int: Get max retry attempts +- setMaxRetries(int) -> void: Set max retry attempts +- getRetryTemperatureIncrement() -> float: Get retry temperature increment +- setRetryTemperatureIncrement(float) -> void: Set retry temperature increment +- getTopP() -> float: Get nucleus sampling threshold +- setTopP(float) -> void: Set nucleus sampling threshold +- getTopK() -> int: Get top-k sampling limit +- setTopK(int) -> void: Set top-k sampling limit +- getRepeatPenalty() -> float: Get repetition penalty +- setRepeatPenalty(float) -> void: Set repetition penalty +- isChatTemplateEnableThinking() -> boolean: Check chat template thinking mode +- setChatTemplateEnableThinking(boolean) -> void: Set chat template thinking mode +- getStopStrings() -> List: Get stop strings +- setStopStrings(Collection) -> void: Set stop strings + +#### Dependencies +- java.util.ArrayList +- java.util.Collection +- java.util.Collections +- java.util.List +- lombok.ToString +- org.jspecify.annotations.Nullable + +#### Exceptions / Errors +- NullPointerException: Possible from getStopStrings() if not initialized +- UnsupportedOperationException: From unmodifiableList in getStopStrings() + +#### Concurrency +- Not thread-safe due to mutable fields +- Collections.unmodifiableList provides some level of protection for stop strings diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md new file mode 100644 index 0000000..e9797cb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java.ai.md @@ -0,0 +1,51 @@ +### AiModelDefinitionSupport.java +- H: 1.0 +- C: 0A078A71 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:43:47Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Manages AI model definitions, converting them to generation configurations for use in Maven plugin configurations. + +#### Purpose +- Resolves `AiModelDefinition` entries into `AiGenerationConfig` objects +- Enforces non-null keys in configuration +- Provides eager error detection for missing definitions + +#### Type +class final + @ToString + +#### Input +- List of `AiModelDefinition` objects (may be null or empty) +- Individual `AiModelDefinition` entries must have non-null keys + +#### Output +- Map of `String` to `AiGenerationConfig` +- `AiGenerationConfig` objects populated from `AiModelDefinition` fields + +#### Core logic +1. Initialize config map with optimized capacity +2. Iterate through definitions, validate keys, and populate config map +3. Convert `AiModelDefinition` to `AiGenerationConfig` using field values +4. Provide lookup method for generation configs by key + +#### Public API +- `AiModelDefinitionSupport(List)` -> Constructs the support object +- `getConfig(String)` -> Returns the corresponding `AiGenerationConfig` for a given key + +#### Dependencies +- `HashMap` +- `List` +- `Objects` +- `Java8CompatibilityHelper` +- `AiModelDefinition` +- `AiGenerationConfig` + +#### Exceptions / Errors +- `NullPointerException` for null keys in definitions +- `IllegalArgumentException` for missing definition lookups + +#### Concurrency +- Thread-safe due to immutable state after construction diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md new file mode 100644 index 0000000..9aafd78 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/config +- H: 1.0 +- C: 7C13CB6A +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:51:39Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiFieldGenerationConfig.java](AiFieldGenerationConfig.java.ai.md) +- F: [AiFieldGenerationSelector.java](AiFieldGenerationSelector.java.ai.md) +- F: [AiGenerationConfig.java](AiGenerationConfig.java.ai.md) +- F: [AiGenerationKind.java](AiGenerationKind.java.ai.md) +- F: [AiModelDefinition.java](AiModelDefinition.java.ai.md) +- F: [AiModelDefinitionSupport.java](AiModelDefinitionSupport.java.ai.md) +--- +> Maven plugin configuration for AI field generation, associating prompt templates with AI model definitions for field generation across various file extensions. + +#### Purpose +- Configure AI field generation via prompt templates and AI models +- Associate configurations with specific file extensions or use as a fallback + +#### Responsibilities +- Manage AI field generation configurations +- Handle file extension-based selection of configurations +- Provide public API for configuration management + +#### Key units +- `AiFieldGenerationConfig`: Manages individual configuration settings +- `AiFieldGenerationSelector`: Selects appropriate configuration based on file extensions +- `AiModelDefinition`: Defines AI model parameters and supports Maven plugin integration + +#### Data flow +- Input: Source file name, prompt template key, AI model definition key, file extensions +- Process: Configuration selection based on file extensions +- Output: Matching `AiFieldGenerationConfig` or null + +#### Dependencies +- `AiModelDefinition` +- `AiPromptDefinition` (implied) +- `List`, `ArrayList`, `Collections` (for data structures) + +#### Cross-cutting +- Error handling for null configurations and extensions +- Mutable state management in `AiFieldGenerationConfig` +- Immutable access to stop strings list in `AiModelDefinition` diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md new file mode 100644 index 0000000..10be087 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md @@ -0,0 +1,49 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex +- H: 1.0 +- C: 83E61DEB +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:55:38Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [config/](config/package.ai.md) +- F: [provider/](provider/package.ai.md) +--- +> This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. + +#### Purpose +- Manage AI field generation configurations +- Offer pluggable AI text generation providers + +#### Responsibilities +- Configure AI field generation via prompt templates and AI models +- Associate configurations with specific file extensions or use as a fallback +- Provide public API for configuration management +- Offer pluggable AI text generation providers +- Enable integration of various AI backends +- Facilitate testing through mock implementations + +#### Key units +- `AiFieldGenerationConfig`: Manages individual configuration settings +- `AiFieldGenerationSelector`: Selects appropriate configuration based on file extensions +- `AiModelDefinition`: Defines AI model parameters and supports Maven plugin integration +- `AiGenerationProvider`: Core interface for text generation providers +- `AiGenerationProviderFactory`: Factory for creating provider instances +- `LlamaCppJniAiGenerationProvider`: Local LLM implementation via JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +- AI field generation: Inputs move through `AiFieldGenerationSelector` to produce `AiFieldGenerationConfig`. +- Text generation: Requests flow through `AiGenerationProviderFactory` to instantiate appropriate providers, which generate text. + +#### Dependencies +- `AiModelDefinition`, `AiPromptDefinition` (implied), `List`, `ArrayList`, `Collections` for data structures +- Cross-unit collaborations between provider implementations and shared interfaces/utility classes +- JNI bindings for local LLM integration + +#### Cross-cutting +- Error handling for null configurations, extensions, and provider failures +- Mutable state management in `AiFieldGenerationConfig` +- Immutable access to stop strings list in `AiModelDefinition` +- Configuration management: Immutable configuration objects for provider settings +- Concurrency considerations for shared resources in multi-threaded environments diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md new file mode 100644 index 0000000..27ef5a0 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiCompletionParser.java.ai.md @@ -0,0 +1,42 @@ +### AiCompletionParser.java +- H: 1.0 +- C: 78BEBEB3 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:45:17Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Parses raw LLM completion text to extract the model answer by stripping any model-internal thinking block before storing in an AI index file. + +#### Purpose +- Extracts and cleans model answers from LLM completion texts +- Handles Gemma-4 specific thinking block markers + +#### Type +class public final @ToString + +#### Input +- String response: raw completion text from the model, may be null + +#### Output +- String: cleaned answer text, never null +- IOException: if token budget exhausted inside a thinking block + +#### Core logic +1. Check for null input +2. Look for end marker to extract answer +3. Handle case where start marker present but end marker absent +4. Return trimmed response if no markers found + +#### Public API +``` +parseCompletion(String response) -> String throws IOException +``` + +#### Dependencies +- java.io.IOException +- lombok.ToString + +#### Exceptions / Errors +- IOException: when token budget exhausted inside a thinking block diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md new file mode 100644 index 0000000..2062af4 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java.ai.md @@ -0,0 +1,40 @@ +### AiGenerationProvider.java +- H: 1.0 +- C: 450236CF +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:46:14Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Interface for pluggable AI backend that produces text for generation requests + +#### Purpose +- Defines an interface for AI text generation providers +- Allows for local or mock implementations + +#### Type +interface + public; implements AutoCloseable + +#### Input +AiGenerationRequest object with prompt key, source file, source text, and current header + +#### Output +String containing generated text; may be empty but never null; throws IOException on failure + +#### Core logic +- Generate text based on AiGenerationRequest +- Allow temperature override for retry attempts +- Provide close method for resource management + +#### Public API +generate(AiGenerationRequest) -> String +generate(AiGenerationRequest, float) -> String +close() -> void + +#### Dependencies +AiGenerationRequest +IOException + +#### Exceptions / Errors +Throws IOException if underlying provider fails diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md new file mode 100644 index 0000000..1a9ef20 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactory.java.ai.md @@ -0,0 +1,50 @@ +### AiGenerationProviderFactory.java +- H: 1.0 +- C: 0ADDB961 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:46:54Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Selects and instantiates an `AiGenerationProvider` implementation by name. + +#### Purpose +- Instantiates `AiGenerationProvider` based on a given name. +- Handles default and specific provider cases. + +#### Type +class public; implements none; extends none; key generics none; notable annotations: @ToString + +#### Input +- `String providerName`: Provider key (mock/llamacpp-jni). +- `LlamaCppJniConfig llamaConfig`: Configuration for llama.cpp JNI provider. +- `AiPromptSupport promptSupport`: Prompt lookup support for providers needing it. + +#### Output +- `AiGenerationProvider`: Newly-created provider instance. +- `IllegalArgumentException`: If `providerName` is unrecognized. + +#### Core logic +1. Check if `providerName` is null or blank. +2. Switch on `providerName`: + - Return `MockAiGenerationProvider` for "mock". + - Return `LlamaCppJniAiGenerationProvider` for "llamacpp-jni". + - Throw exception for unsupported providers. + +#### Public API +- `create(String, LlamaCppJniConfig, AiPromptSupport) -> AiGenerationProvider`: Creates and returns an AI generation provider based on the given name and configurations. + +#### Dependencies +- `AiGenerationProvider` +- `MockAiGenerationProvider` +- `LlamaCppJniAiGenerationProvider` +- `Java8CompatibilityHelper` +- `LlamaCppJniConfig` +- `AiPromptSupport` + +#### Exceptions / Errors +- `IllegalArgumentException`: Thrown for unsupported provider names. + +#### Concurrency +No explicit concurrency considerations in the source. diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..b70f9c5 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java.ai.md @@ -0,0 +1,58 @@ +### LlamaCppJniAiGenerationProvider.java +- H: 1.0 +- C: 7DBF06B9 +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:48:00Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Provides AI text generation using locally-run GGUF models via llama.cpp JNI binding. + +#### Purpose +- Implements `AiGenerationProvider` interface +- Manages lifecycle of native LLama model +- Handles AI prompt generation and completion parsing + +#### Type +class final implements AiGenerationProvider, AutoCloseable + +#### Input +- `LlamaCppJniConfig`, `AiPromptSupport` in constructor +- `AiGenerationRequest` in generate methods +- Model parameters from config + +#### Output +- Generated text as `String` +- May mutate internal `LlamaModel` state +- Closes native resources on `close()` + +#### Core logic +1. Lazy-loads GGUF model on first generation +2. Builds AI prompts using `AiPromptSupport` +3. Configures inference parameters from config +4. Calls native model for text completion +5. Parses and returns generated text + +#### Public API +- `LlamaCppJniAiGenerationProvider(LlamaCppJniConfig, AiPromptSupport) -> void` + Initializes provider with configuration and prompt support +- `generate(AiGenerationRequest) -> String` + Generates text using default temperature +- `generate(AiGenerationRequest, float) -> String` + Generates text with specified temperature override +- `close() -> void` + Releases native resources + +#### Dependencies +- `LlamaCppJniConfig` +- `AiPromptSupport` +- `AiGenerationRequest` +- `LlamaModel` +- `InferenceParameters` +- `Pair` +- `AiCompletionParser` + +#### Exceptions / Errors +- Throws `IOException` for native model loading or generation errors +- Handles null values in input parameters diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md new file mode 100644 index 0000000..759338e --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java.ai.md @@ -0,0 +1,53 @@ +### LlamaCppJniConfig.java +- H: 1.0 +- C: 0B74C5FA +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:49:31Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Configuration for llama.cpp JNI provider, managing native library paths and AI model parameters. + +#### Purpose +- Immutable configuration for llama.cpp JNI provider +- Manages native library paths and AI model parameters + +#### Type +class final; implements ConvertToRecord; Lombok annotations: @ToString, @EqualsAndHashCode + +#### Input +- Constructor parameters: libraryPath, modelPath, contextSize, maxOutputTokens, temperature, threads, topP, topK, repeatPenalty, chatTemplateEnableThinking, stopStrings +- List for stopStrings (may be null) + +#### Output +- Getter methods returning primitive types or String +- List for stopStrings (unmodifiable) + +#### Core logic +- Validates modelPath in constructor +- Initializes immutable fields with provided values +- Provides access to configuration parameters via getter methods + +#### Public API +- libraryPath() -> String: Returns native library path or null +- modelPath() -> String: Returns model file path +- contextSize() -> int: Returns context window size +- maxOutputTokens() -> int: Returns maximum output tokens +- temperature() -> float: Returns sampling temperature +- threads() -> int: Returns number of CPU threads +- topP() -> float: Returns nucleus-sampling probability threshold +- topK() -> int: Returns top-k sampling limit +- repeatPenalty() -> float: Returns repetition penalty +- chatTemplateEnableThinking() -> boolean: Returns whether chat-template thinking mode is enabled +- stopStrings() -> List: Returns unmodifiable list of stop strings + +#### Dependencies +- ConvertToRecord +- Collections +- Objects +- List +- String + +#### Exceptions / Errors +- NullPointerException if modelPath is null in constructor diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md new file mode 100644 index 0000000..0a0c2fb --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProvider.java.ai.md @@ -0,0 +1,39 @@ +### MockAiGenerationProvider.java +- H: 1.0 +- C: C1880BAD +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:51:06Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: file +--- +> Mock AI generation provider for testing purposes, returning deterministic mock summaries. + +#### Purpose +- Mock implementation of `AiGenerationProvider` for testing +- Returns a fixed mock summary based on the input file name + +#### Type +class public implements AiGenerationProvider @ToString + +#### Input +- `AiGenerationRequest` object containing source file information + +#### Output +- String containing mock summary + +#### Core logic +1. Extract file name from request +2. Generate mock summary string with file name + +#### Public API +- `MockAiGenerationProvider() -> void` Constructs the provider +- `generate(AiGenerationRequest) -> String` Generates mock summary + +#### Dependencies +- `AiGenerationRequest` +- `Path` +- `IOException` + +#### Exceptions / Errors +- May throw `IOException` if file operations fail diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md new file mode 100644 index 0000000..4b38175 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md @@ -0,0 +1,45 @@ +### main/java/net/ladenthin/maven/llamacpp/aiindex/provider +- H: 1.0 +- C: BA4DB05D +- D: 2026-06-25T05:31:58Z +- T: 2026-06-27T04:53:58Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [AiCompletionParser.java](AiCompletionParser.java.ai.md) +- F: [AiGenerationProvider.java](AiGenerationProvider.java.ai.md) +- F: [AiGenerationProviderFactory.java](AiGenerationProviderFactory.java.ai.md) +- F: [LlamaCppJniAiGenerationProvider.java](LlamaCppJniAiGenerationProvider.java.ai.md) +- F: [LlamaCppJniConfig.java](LlamaCppJniConfig.java.ai.md) +- F: [MockAiGenerationProvider.java](MockAiGenerationProvider.java.ai.md) +--- +> This package provides a flexible AI generation provider framework, supporting multiple backends including local LLMs via JNI and mock implementations for testing. + +#### Purpose +- Offers pluggable AI text generation providers +- Enables integration of various AI backends +- Facilitates testing through mock implementations + +#### Responsibilities +- Provider selection and instantiation +- Interface definition for AI generation +- Handling of different provider types (mock, local LLMs) +- Resource management and lifecycle control + +#### Key units +- `AiGenerationProvider`: Core interface for text generation providers +- `AiGenerationProviderFactory`: Factory for creating provider instances +- `LlamaCppJniAiGenerationProvider`: Local LLM implementation via JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +AI generation requests flow through the factory to create appropriate providers, which then generate text based on the provided configuration and input parameters. + +#### Dependencies +- Cross-unit collaborations: Provider implementations depend on shared interfaces and utility classes +- External modules: JNI bindings for local LLM integration + +#### Cross-cutting +- Error handling: IOException thrown for various failure scenarios +- Configuration management: Immutable configuration objects for provider settings +- Concurrency: Potential for concurrent access to shared resources in multi-threaded environments diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md new file mode 100644 index 0000000..ba87d91 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/llamacpp/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin/maven/llamacpp +- H: 1.0 +- C: 52B8025B +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:56:57Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [aiindex/](aiindex/package.ai.md) +--- +> This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. + +#### Purpose +- Manage AI field generation configurations +- Offer pluggable AI text generation providers + +#### Responsibilities +- Configure AI field generation via prompt templates and AI models +- Associate configurations with specific file extensions or use as a fallback +- Provide public API for configuration management +- Offer pluggable AI text generation providers +- Enable integration of various AI backends +- Facilitate testing through mock implementations + +#### Key units +- `AiFieldGenerationConfig`: Manages individual configuration settings +- `AiFieldGenerationSelector`: Selects appropriate configuration based on file extensions +- `AiModelDefinition`: Defines AI model parameters and supports Maven plugin integration +- `AiGenerationProvider`: Core interface for text generation providers +- `AiGenerationProviderFactory`: Factory for creating provider instances +- `LlamaCppJniAiGenerationProvider`: Local LLM implementation via JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +- AI field generation: Inputs move through `AiFieldGenerationSelector` to produce `AiFieldGenerationConfig`. +- Text generation: Requests flow through `AiGenerationProviderFactory` to instantiate appropriate providers, which generate text. + +#### Dependencies +- `AiModelDefinition`, `AiPromptDefinition` (implied), `List`, `ArrayList`, `Collections` for data structures +- Cross-unit collaborations between provider implementations and shared interfaces/utility classes +- JNI bindings for local LLM integration + +#### Cross-cutting +- Error handling for null configurations, extensions, and provider failures +- Mutable state management in `AiFieldGenerationConfig` +- Immutable access to stop strings list in `AiModelDefinition` +- Configuration management: Immutable configuration objects for provider settings +- Concurrency considerations for shared resources in multi-threaded environments diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/package.ai.md new file mode 100644 index 0000000..2895979 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/maven/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin/maven +- H: 1.0 +- C: 192118FD +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:58:12Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [llamacpp/](llamacpp/package.ai.md) +--- +> This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. + +#### Purpose +- Manage AI field generation configurations +- Offer pluggable AI text generation providers + +#### Responsibilities +- Configure AI field generation via prompt templates and AI models +- Associate configurations with specific file extensions or use as a fallback +- Provide public API for configuration management +- Offer pluggable AI text generation providers +- Enable integration of various AI backends +- Facilitate testing through mock implementations + +#### Key units +- `AiFieldGenerationConfig`: Manages individual configuration settings +- `AiFieldGenerationSelector`: Selects appropriate configuration based on file extensions +- `AiModelDefinition`: Defines AI model parameters and supports Maven plugin integration +- `AiGenerationProvider`: Core interface for text generation providers +- `AiGenerationProviderFactory`: Factory for creating provider instances +- `LlamaCppJniAiGenerationProvider`: Local LLM implementation via JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +- AI field generation: Inputs move through `AiFieldGenerationSelector` to produce `AiFieldGenerationConfig`. +- Text generation: Requests flow through `AiGenerationProviderFactory` to instantiate appropriate providers, which generate text. + +#### Dependencies +- `AiModelDefinition`, `AiPromptDefinition` (implied), `List`, `ArrayList`, `Collections` for data structures +- Cross-unit collaborations between provider implementations and shared interfaces/utility classes +- JNI bindings for local LLM integration + +#### Cross-cutting +- Error handling for null configurations, extensions, and provider failures +- Mutable state management in `AiFieldGenerationConfig` +- Immutable access to stop strings list in `AiModelDefinition` +- Configuration management: Immutable configuration objects for provider settings +- Concurrency considerations for shared resources in multi-threaded environments diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/package.ai.md new file mode 100644 index 0000000..94fcd3b --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/ladenthin/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net/ladenthin +- H: 1.0 +- C: 1F224605 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T04:59:27Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [maven/](maven/package.ai.md) +--- +> This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. + +#### Purpose +- Manage AI field generation configurations +- Offer pluggable AI text generation providers + +#### Responsibilities +- Configure AI field generation via prompt templates and AI models +- Associate configurations with specific file extensions or use as a fallback +- Provide public API for configuration management +- Offer pluggable AI text generation providers +- Enable integration of various AI backends +- Facilitate testing through mock implementations + +#### Key units +- `AiFieldGenerationConfig`: Manages individual configuration settings +- `AiFieldGenerationSelector`: Selects appropriate configuration based on file extensions +- `AiModelDefinition`: Defines AI model parameters and supports Maven plugin integration +- `AiGenerationProvider`: Core interface for text generation providers +- `AiGenerationProviderFactory`: Factory for creating provider instances +- `LlamaCppJniAiGenerationProvider`: Local LLM implementation via JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +- AI field generation: Inputs move through `AiFieldGenerationSelector` to produce `AiFieldGenerationConfig`. +- Text generation: Requests flow through `AiGenerationProviderFactory` to instantiate appropriate providers, which generate text. + +#### Dependencies +- `AiModelDefinition`, `AiPromptDefinition` (implied), `List`, `ArrayList`, `Collections` for data structures +- Cross-unit collaborations between provider implementations and shared interfaces/utility classes +- JNI bindings for local LLM integration + +#### Cross-cutting +- Error handling for null configurations, extensions, and provider failures +- Mutable state management in `AiFieldGenerationConfig` +- Immutable access to stop strings list in `AiModelDefinition` +- Configuration management: Immutable configuration objects for provider settings +- Concurrency considerations for shared resources in multi-threaded environments diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/package.ai.md new file mode 100644 index 0000000..67e0c8d --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/net/package.ai.md @@ -0,0 +1,48 @@ +### main/java/net +- H: 1.0 +- C: 9BBA9341 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:00:41Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [ladenthin/](ladenthin/package.ai.md) +--- +> This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. + +#### Purpose +- Manage AI field generation configurations +- Offer pluggable AI text generation providers + +#### Responsibilities +- Configure AI field generation via prompt templates and AI models +- Associate configurations with specific file extensions or use as a fallback +- Provide public API for configuration management +- Offer pluggable AI text generation providers +- Enable integration of various AI backends +- Facilitate testing through mock implementations + +#### Key units +- `AiFieldGenerationConfig`: Manages individual configuration settings +- `AiFieldGenerationSelector`: Selects appropriate configuration based on file extensions +- `AiModelDefinition`: Defines AI model parameters and supports Maven plugin integration +- `AiGenerationProvider`: Core interface for text generation providers +- `AiGenerationProviderFactory`: Factory for creating provider instances +- `LlamaCppJniAiGenerationProvider`: Local LLM implementation via JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +- AI field generation: Inputs move through `AiFieldGenerationSelector` to produce `AiFieldGenerationConfig`. +- Text generation: Requests flow through `AiGenerationProviderFactory` to instantiate appropriate providers, which generate text. + +#### Dependencies +- `AiModelDefinition`, `AiPromptDefinition` (implied), `List`, `ArrayList`, `Collections` for data structures +- Cross-unit collaborations between provider implementations and shared interfaces/utility classes +- JNI bindings for local LLM integration + +#### Cross-cutting +- Error handling for null configurations, extensions, and provider failures +- Mutable state management in `AiFieldGenerationConfig` +- Immutable access to stop strings list in `AiModelDefinition` +- Configuration management: Immutable configuration objects for provider settings +- Concurrency considerations for shared resources in multi-threaded environments diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/package.ai.md new file mode 100644 index 0000000..a48ddfd --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/java/package.ai.md @@ -0,0 +1,48 @@ +### main/java +- H: 1.0 +- C: E9AF7086 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:01:55Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [net/](net/package.ai.md) +--- +> This package provides AI field generation and text generation capabilities, supporting configuration through templates and models, and enabling multiple backend integrations including local LLMs and mock implementations. + +#### Purpose +- Manage AI field generation configurations +- Offer pluggable AI text generation providers + +#### Responsibilities +- Configure AI field generation via prompt templates and AI models +- Associate configurations with specific file extensions or use as a fallback +- Provide public API for configuration management +- Offer pluggable AI text generation providers +- Enable integration of various AI backends +- Facilitate testing through mock implementations + +#### Key units +- `AiFieldGenerationConfig`: Manages individual configuration settings +- `AiFieldGenerationSelector`: Selects appropriate configuration based on file extensions +- `AiModelDefinition`: Defines AI model parameters and supports Maven plugin integration +- `AiGenerationProvider`: Core interface for text generation providers +- `AiGenerationProviderFactory`: Factory for creating provider instances +- `LlamaCppJniAiGenerationProvider`: Local LLM implementation via JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +- AI field generation: Inputs move through `AiFieldGenerationSelector` to produce `AiFieldGenerationConfig`. +- Text generation: Requests flow through `AiGenerationProviderFactory` to instantiate appropriate providers, which generate text. + +#### Dependencies +- `AiModelDefinition`, `AiPromptDefinition` (implied), `List`, `ArrayList`, `Collections` for data structures +- Cross-unit collaborations between provider implementations and shared interfaces/utility classes +- JNI bindings for local LLM integration + +#### Cross-cutting +- Error handling for null configurations, extensions, and provider failures +- Mutable state management in `AiFieldGenerationConfig` +- Immutable access to stop strings list in `AiModelDefinition` +- Configuration management: Immutable configuration objects for provider settings +- Concurrency considerations for shared resources in multi-threaded environments diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/package.ai.md new file mode 100644 index 0000000..1b397f2 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/main/package.ai.md @@ -0,0 +1,48 @@ +### main +- H: 1.0 +- C: 0D4DE298 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:03:09Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [java/](java/package.ai.md) +--- +> This package provides AI field generation and text generation capabilities, supporting configuration through templates and models, and enabling multiple backend integrations including local LLMs and mock implementations. + +#### Purpose +- Manage AI field generation configurations +- Offer pluggable AI text generation providers + +#### Responsibilities +- Configure AI field generation via prompt templates and AI models +- Associate configurations with specific file extensions or use as a fallback +- Provide public API for configuration management +- Offer pluggable AI text generation providers +- Enable integration of various AI backends +- Facilitate testing through mock implementations + +#### Key units +- `AiFieldGenerationConfig`: Manages individual configuration settings +- `AiFieldGenerationSelector`: Selects appropriate configuration based on file extensions +- `AiModelDefinition`: Defines AI model parameters and supports Maven plugin integration +- `AiGenerationProvider`: Core interface for text generation providers +- `AiGenerationProviderFactory`: Factory for creating provider instances +- `LlamaCppJniAiGenerationProvider`: Local LLM implementation via JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +- AI field generation: Inputs move through `AiFieldGenerationSelector` to produce `AiFieldGenerationConfig`. +- Text generation: Requests flow through `AiGenerationProviderFactory` to instantiate appropriate providers, which generate text. + +#### Dependencies +- `AiModelDefinition`, `AiPromptDefinition` (implied), `List`, `ArrayList`, `Collections` for data structures +- Cross-unit collaborations between provider implementations and shared interfaces/utility classes +- JNI bindings for local LLM integration + +#### Cross-cutting +- Error handling for null configurations, extensions, and provider failures +- Mutable state management in `AiFieldGenerationConfig` +- Immutable access to stop strings list in `AiModelDefinition` +- Configuration management: Immutable configuration objects for provider settings +- Concurrency considerations for shared resources in multi-threaded environments diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/package.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/package.ai.md new file mode 100644 index 0000000..c0236fe --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/package.ai.md @@ -0,0 +1,48 @@ +### ai +- H: 1.0 +- C: F01CDC07 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:04:23Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: package +- F: [main/](main/package.ai.md) +--- +> This package provides AI field generation and text generation capabilities, supporting configuration through templates and models, and enabling multiple backend integrations including local LLMs and mock implementations. + +#### Purpose +- Manage AI field generation configurations +- Offer pluggable AI text generation providers + +#### Responsibilities +- Configure AI field generation via prompt templates and AI models +- Associate configurations with specific file extensions or use as a fallback +- Provide public API for configuration management +- Offer pluggable AI text generation providers +- Enable integration of various AI backends +- Facilitate testing through mock implementations + +#### Key units +- `AiFieldGenerationConfig`: Manages individual configuration settings +- `AiFieldGenerationSelector`: Selects appropriate configuration based on file extensions +- `AiModelDefinition`: Defines AI model parameters and supports Maven plugin integration +- `AiGenerationProvider`: Core interface for text generation providers +- `AiGenerationProviderFactory`: Factory for creating provider instances +- `LlamaCppJniAiGenerationProvider`: Local LLM implementation via JNI +- `MockAiGenerationProvider`: Mock implementation for testing + +#### Data flow +- AI field generation: Inputs move through `AiFieldGenerationSelector` to produce `AiFieldGenerationConfig`. +- Text generation: Requests flow through `AiGenerationProviderFactory` to instantiate appropriate providers, which generate text. + +#### Dependencies +- `AiModelDefinition`, `AiPromptDefinition` (implied), `List`, `ArrayList`, `Collections` for data structures +- Cross-unit collaborations between provider implementations and shared interfaces/utility classes +- JNI bindings for local LLM integration + +#### Cross-cutting +- Error handling for null configurations, extensions, and provider failures +- Mutable state management in `AiFieldGenerationConfig` +- Immutable access to stop strings list in `AiModelDefinition` +- Configuration management: Immutable configuration objects for provider settings +- Concurrency considerations for shared resources in multi-threaded environments diff --git a/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/project.ai.md b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/project.ai.md new file mode 100644 index 0000000..cbde692 --- /dev/null +++ b/docs/ai-index-benchmark/outputs/ai__seed-coder-8b__v2/project.ai.md @@ -0,0 +1,35 @@ +### llamacpp-ai-index-maven-plugin +- H: 1.0 +- C: 2CF9ADD2 +- D: 2026-06-26T14:41:56Z +- T: 2026-06-27T05:05:40Z +- G: 1.0.1-SNAPSHOT +- A: 0.0.0 +- X: project +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/config](main/java/net/ladenthin/maven/llamacpp/aiindex/config/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex](main/java/net/ladenthin/maven/llamacpp/aiindex/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp/aiindex/provider](main/java/net/ladenthin/maven/llamacpp/aiindex/provider/package.ai.md) +- F: [main/java/net/ladenthin/maven/llamacpp](main/java/net/ladenthin/maven/llamacpp/package.ai.md) +- F: [main/java/net/ladenthin/maven](main/java/net/ladenthin/maven/package.ai.md) +- F: [main/java/net/ladenthin](main/java/net/ladenthin/package.ai.md) +- F: [main/java/net](main/java/net/package.ai.md) +- F: [main/java](main/java/package.ai.md) +- F: [main](main/package.ai.md) +- F: [.](package.ai.md) +--- +> Project index of llamacpp-ai-index-maven-plugin: one line per package; leads here, clickable links in the header F list. + +#### Overview +The llamacpp-ai-index-maven-plugin project offers a comprehensive solution for AI-driven code generation within Maven projects. It primarily focuses on facilitating AI field generation and text generation providers, with a strong emphasis on configuration through prompt templates and AI models. The plugin supports multiple backend integrations, including local LLMs (Large Language Models) via JNI (Java Native Interface) and mock implementations for testing purposes. This versatile framework allows developers to easily incorporate advanced AI capabilities into their Maven builds, enhancing code generation processes across various file extensions. + +#### Packages +- main/java/net/ladenthin/maven/llamacpp/aiindex/config — Maven plugin configuration for AI field generation, associating prompt templates with AI model definitions for field generation across various file extensions. +- main/java/net/ladenthin/maven/llamacpp/aiindex — This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. +- main/java/net/ladenthin/maven/llamacpp/aiindex/provider — This package provides a flexible AI generation provider framework, supporting multiple backends including local LLMs via JNI and mock implementations for testing. +- main/java/net/ladenthin/maven/llamacpp — This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. +- main/java/net/ladenthin/maven — This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. +- main/java/net/ladenthin — This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. +- main/java/net — This package facilitates AI field generation and text generation providers, supporting configuration via prompt templates and AI models, and offering multiple backend integrations including local LLMs and mock implementations. +- main/java — This package provides AI field generation and text generation capabilities, supporting configuration through templates and models, and enabling multiple backend integrations including local LLMs and mock implementations. +- main — This package provides AI field generation and text generation capabilities, supporting configuration through templates and models, and enabling multiple backend integrations including local LLMs and mock implementations. +- . — This package provides AI field generation and text generation capabilities, supporting configuration through templates and models, and enabling multiple backend integrations including local LLMs and mock implementations. diff --git a/docs/ai-index-benchmark/tools/generate-fixture.sh b/docs/ai-index-benchmark/tools/generate-fixture.sh new file mode 100644 index 0000000..4554e37 --- /dev/null +++ b/docs/ai-index-benchmark/tools/generate-fixture.sh @@ -0,0 +1,201 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: 2026 Bernard Ladenthin +# +# SPDX-License-Identifier: Apache-2.0 +# +# Generates a large, *valid* synthetic Java class for benchmarking how the AI +# index plugin handles big source files (context sizing, trim/no-trim, output +# truncation, prefill/decode time on CPU). +# +# It models a fictional in-memory ledger (accounts, balances, transfers, +# weighted "bucket" scoring) so the file has genuine, varied content to +# summarize rather than dead filler. +# +# Usage: +# docs/ai-index-benchmark/tools/generate-fixture.sh [class_name] +# +# Examples: +# generate-fixture.sh 100 build/fixture/BigFixture.java BigFixture +# generate-fixture.sh 250 build/fixture/HugeFixture.java HugeFixture +# +# Notes: +# - The package is fixed to net.ladenthin.maven.llamacpp.aiindex.bigfixture; put +# the output under .../bigfixture/ if you want javac to accept it (the plugin +# itself only reads .java as text, so it does not require compilation). +# - Size is approximate: the script grows the method count until the file +# reaches the requested size, then appends fixed tail methods. +set -euo pipefail + +TARGET_KB="${1:?usage: generate-fixture.sh [class_name]}" +OUT="${2:?usage: generate-fixture.sh [class_name]}" +CLASS="${3:-BigFixture}" +TARGET_BYTES=$(( TARGET_KB * 1024 )) + +mkdir -p "$(dirname "$OUT")" + +header() { +cat < +// +// SPDX-License-Identifier: Apache-2.0 +// @formatter:on +package net.ladenthin.maven.llamacpp.aiindex.bigfixture; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Large synthetic fixture (target ~${TARGET_KB} KB) used ONLY to benchmark how the + * AI index plugin handles big source files. It models a fictional in-memory + * ledger of accounts and transactions: it stores balances, applies + * deposits/withdrawals/transfers, computes aggregates, and exposes many small + * accessors so the file is genuinely large and varied. + * + *

This is not production code; it exists to exercise context sizing.

+ */ +public final class ${CLASS} { + + /** Maximum number of accounts this ledger tracks. */ + public static final int MAX_ACCOUNTS = 4096; + + /** Default starting balance applied to a freshly opened account. */ + public static final long DEFAULT_BALANCE = 1000L; + + private final Map balances = new HashMap<>(); + private final Map owners = new HashMap<>(); + private final List auditLog = new ArrayList<>(); + private long totalVolume; + private int transactionCount; +HDR +} + +# A single bucket method (bug-free: every identifier is a real local/field). +method() { + local i="$1" + local w=$(( (i % 40) + 1 )) + cat < weight$w) { + auditLog.add("bucket$i exceeded base weight: " + weighted); + } + return weighted + (double) ($i % 7); + } +M +} + +tail_methods() { +cat <<'TAIL' + + /** + * Opens a new account with the default balance, recording its owner and an + * audit entry. Rejects ids outside the valid range or already in use. + * + * @param id unique account id in [0, MAX_ACCOUNTS) + * @param owner human-readable owner name + * @return true if the account was created, false if rejected + */ + public boolean openAccount(final int id, final String owner) { + if (id < 0 || id >= MAX_ACCOUNTS) { + return false; + } + if (balances.containsKey(id)) { + return false; + } + balances.put(id, DEFAULT_BALANCE); + owners.put(id, owner == null ? "unknown" : owner); + auditLog.add("opened " + id + " for " + owners.get(id)); + return true; + } + + /** + * Transfers an amount between two existing accounts when the source holds + * sufficient funds. Updates the running totals and appends an audit entry. + * + * @param from source account id + * @param to destination account id + * @param amount strictly positive amount to move + * @return true on success, false on any validation failure + */ + public boolean transfer(final int from, final int to, final long amount) { + if (amount <= 0L) { + return false; + } + final Long src = balances.get(from); + final Long dst = balances.get(to); + if (src == null || dst == null || src < amount) { + return false; + } + balances.put(from, src - amount); + balances.put(to, dst + amount); + this.totalVolume += amount; + this.transactionCount++; + auditLog.add("transfer " + amount + " from " + from + " to " + to); + return true; + } + + /** + * Computes the sum of all account balances currently tracked. + * + * @return total balance across every open account + */ + public long totalBalance() { + long sum = 0L; + for (final Long b : balances.values()) { + sum += b == null ? 0L : b; + } + return sum; + } + + /** @return the number of transactions applied so far */ + public int getTransactionCount() { + return transactionCount; + } + + /** @return the cumulative monetary volume processed */ + public long getTotalVolume() { + return totalVolume; + } + + /** @return an immutable snapshot count of audit entries */ + public int auditSize() { + return auditLog.size(); + } +} +TAIL +} + +# Build the file: header + 40 weight fields + as many bucket methods as needed. +{ + header + for i in $(seq 1 40); do + echo " /** Tunable weight number $i used by the scoring helpers below. */" + echo " private double weight$i = ${i}.0d;" + done +} > "$OUT" + +i=1 +# Grow until the body (without the ~90-line tail) reaches the target size. +while [ "$(wc -c < "$OUT")" -lt "$TARGET_BYTES" ]; do + method "$i" >> "$OUT" + i=$(( i + 1 )) +done +tail_methods >> "$OUT" + +echo "wrote $OUT" +echo "class=$CLASS methods=$(( i - 1 )) lines=$(wc -l < "$OUT") bytes=$(wc -c < "$OUT") (~$(( $(wc -c < "$OUT") / 1024 )) KB)" diff --git a/docs/ai-index-benchmark/tools/score.sh b/docs/ai-index-benchmark/tools/score.sh new file mode 100644 index 0000000..decd3ae --- /dev/null +++ b/docs/ai-index-benchmark/tools/score.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Objective scorer for one AI-index benchmark cell. +# Usage: score.sh +# Prints a single TSV row: sections\treachesConc\bytes\claimedMaxBucket\parenCount\countErr\truncated\promptTok\prefillMs\decodeTok\decodeMs +set -uo pipefail +ai="$1"; log="$2"; exp="$3" + +if [ ! -f "$ai" ]; then + echo -e "FAIL\tFAIL\t0\tNA\tNA\tNA\tNA\tNA\tNA\tNA\tNA" + exit 0 +fi + +# --- section completeness (9 expected) --- +secs=0 +for h in "Purpose" "Type" "Input" "Output" "Core logic" "Public API" "Dependencies" "Exceptions" "Concurrency"; do + if grep -qiE "^#+ +.*${h}" "$ai"; then secs=$((secs+1)); fi +done +reaches=0; grep -qiE "^#+ +.*Concurrency" "$ai" && reaches=1 +bytes=$(wc -c < "$ai" | tr -d ' ') + +# --- claimed counts (best effort) --- +claimed=$(grep -oE "adjustBucket[0-9]+" "$ai" | grep -oE "[0-9]+" | sort -n | tail -1) +[ -z "$claimed" ] && claimed=NA +paren=$(grep -oiE "[0-9]+[^0-9]{0,12}methods" "$ai" | grep -oE "^[0-9]+" | sort -n | tail -1) +[ -z "$paren" ] && paren=NA +cerr=NA +ref=$claimed; [ "$ref" = "NA" ] && ref=$paren +if [ "$ref" != "NA" ] && [ "$exp" != "NA" ]; then cerr=$(( ref > exp ? ref - exp : exp - ref )); fi + +# --- log metrics (UTF-16 -> UTF-8) --- +txt=$(iconv -f UTF-16LE -t UTF-8 "$log" 2>/dev/null || cat "$log") +trunc=$(printf '%s' "$txt" | grep -oE "truncated = [0-9]+" | grep -oE "[0-9]+$" | sort -rn | head -1); [ -z "$trunc" ] && trunc=NA +pe=$(printf '%s' "$txt" | grep -oE "prompt eval time =[^/]*/ +[0-9]+ tokens" | tail -1) +ptok=$(printf '%s' "$pe" | grep -oE "/ +[0-9]+ tokens" | grep -oE "[0-9]+" | head -1); [ -z "$ptok" ] && ptok=NA +pms=$(printf '%s' "$pe" | grep -oE "= +[0-9.]+ ms" | grep -oE "[0-9.]+" | head -1); [ -z "$pms" ] && pms=NA +ev=$(printf '%s' "$txt" | grep -oE "[^t]eval time =[^/]*/ +[0-9]+ tokens" | tail -1) +dtok=$(printf '%s' "$ev" | grep -oE "/ +[0-9]+ tokens" | grep -oE "[0-9]+" | head -1); [ -z "$dtok" ] && dtok=NA +dms=$(printf '%s' "$ev" | grep -oE "= +[0-9.]+ ms" | grep -oE "[0-9.]+" | head -1); [ -z "$dms" ] && dms=NA + +echo -e "${secs}\t${reaches}\t${bytes}\t${claimed}\t${paren}\t${cerr}\t${trunc}\t${ptok}\t${pms}\t${dtok}\t${dms}" diff --git a/pom.xml b/pom.xml index 58dd748..3e3d7d0 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,34 @@ SPDX-License-Identifier: Apache-2.0 UTF-8 3.15.2 3.9.16 - 5.0.2 + + 5.0.3 + + + + gpt-oss-20B-mxfp4 + + -1 + + -1 + + 6.1.0 3.0 1.37 @@ -88,6 +115,20 @@ SPDX-License-Identifier: Apache-2.0 ${project.basedir}/src/site/ai + + true + + + ${git.commit.time} @@ -128,6 +169,7 @@ SPDX-License-Identifier: Apache-2.0 net.ladenthin llama ${llama.version} + ${llama.classifier} @@ -672,11 +714,16 @@ SPDX-License-Identifier: Apache-2.0 + net.ladenthin.maven.llamacpp.aiindex.config.AiCondition + net.ladenthin.maven.llamacpp.aiindex.config.AiConditionEvaluator net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationSelector + net.ladenthin.maven.llamacpp.aiindex.config.AiFileContext net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig + net.ladenthin.maven.llamacpp.aiindex.config.AiRangeCondition net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinition net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport + net.ladenthin.maven.llamacpp.aiindex.indexer.AiInputWindowCalculator net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationResult net.ladenthin.maven.llamacpp.aiindex.document.AiMdChildEntryLineFormatter @@ -686,13 +733,16 @@ SPDX-License-Identifier: Apache-2.0 net.ladenthin.maven.llamacpp.aiindex.document.AiMdLeadExtractor net.ladenthin.maven.llamacpp.aiindex.prompt.AiPreparedPrompt net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition + net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport net.ladenthin.maven.llamacpp.aiindex.provider.AiCompletionParser net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProviderFactory net.ladenthin.maven.llamacpp.aiindex.provider.MockAiGenerationProvider net.ladenthin.maven.llamacpp.aiindex.support.AiChecksumSupport + net.ladenthin.maven.llamacpp.aiindex.support.AiGenerationTimeEstimator net.ladenthin.maven.llamacpp.aiindex.support.AiPathSupport + net.ladenthin.maven.llamacpp.aiindex.support.AiProgressBar net.ladenthin.maven.llamacpp.aiindex.support.AiSourceExcludeFilter net.ladenthin.maven.llamacpp.aiindex.support.AiTimeSupport net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper @@ -708,6 +758,28 @@ SPDX-License-Identifier: Apache-2.0 + + + gpu-cuda + + cuda13-windows-x86-64 + + + + gpu-vulkan + + vulkan-windows-x86-64 + + + release @@ -756,10 +828,21 @@ SPDX-License-Identifier: Apache-2.0 ${ai.index.output.directory} + - src/main/java/net/ladenthin/maven/llamacpp/aiindex + src/main/java/net/ladenthin/maven/llamacpp/aiindex/config + src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider + + + **/package-info.java + **/module-info.java + + llamacpp-jni + 16384 1536 0.7 8 4 true - 0.0 0.8 20 1.05 + ${ai.cachePrompt}
+ + EXP-Qwen3.5-4B + X:/Modelle/Qwen3.5-4B-Q4_K_M.gguf + 16384 + 1536 + 0.7 + 8 + 4 + true + 0.8 + 20 + 1.05 + false + + + EXP-Qwen2.5-Coder-7B + X:/Modelle/qwen2.5-coder-7b-instruct-q5_k_m.gguf + 16384 + 1536 + 0.7 + 8 + 4 + true + 0.8 + 20 + 1.05 + + + + gpt-oss-20B-c16k + X:/Modelle/gpt-oss-20b-UD-Q4_K_XL.gguf + 16384 + ${ai.gpuLayers} + ${ai.mainGpu} + ${ai.devices} + 2048 + 0.7 + 8 + 3 + true + 1.0 + 0 + 0.05 + 1.0 + low + + + gpt-oss-20B-c48k + X:/Modelle/gpt-oss-20b-UD-Q4_K_XL.gguf + 49152 + ${ai.gpuLayers} + ${ai.mainGpu} + ${ai.devices} + 4096 + 0.7 + 8 + 3 + true + 1.0 + 0 + 0.05 + 1.0 + low + + + gpt-oss-20B-c96k + X:/Modelle/gpt-oss-20b-UD-Q4_K_XL.gguf + 98304 + ${ai.gpuLayers} + ${ai.mainGpu} + ${ai.devices} + 6144 + 0.7 + 8 + 3 + true + 1.0 + 0 + 0.05 + 1.0 + low + + + + + gpt-oss-20B-mxfp4 + X:/Modelle/gpt-oss-20b-mxfp4.gguf + 98304 + ${ai.gpuLayers} + ${ai.mainGpu} + ${ai.devices} + 6144 + 0.7 + 8 + 3 + true + 1.0 + 0 + 0.05 + 1.0 + low + + + gpt-oss-20B-Q4_K_M + X:/Modelle/gpt-oss-20b-Q4_K_M.gguf + 98304 + ${ai.gpuLayers} + ${ai.mainGpu} + ${ai.devices} + 6144 + 0.7 + 8 + 3 + true + 1.0 + 0 + 0.05 + 1.0 + low + + + gpt-oss-20B-Q5_K_M + X:/Modelle/gpt-oss-20b-Q5_K_M.gguf + 98304 + ${ai.gpuLayers} + ${ai.mainGpu} + ${ai.devices} + 6144 + 0.7 + 8 + 3 + true + 1.0 + 0 + 0.05 + 1.0 + low + + + gpt-oss-20B-Q8_0 + X:/Modelle/gpt-oss-20b-Q8_0.gguf + 98304 + ${ai.gpuLayers} + ${ai.mainGpu} + ${ai.devices} + 6144 + 0.7 + 8 + 3 + true + 1.0 + 0 + 0.05 + 1.0 + low + + + gpt-oss-20B-F16 + X:/Modelle/gpt-oss-20b-F16.gguf + 98304 + ${ai.gpuLayers} + ${ai.mainGpu} + ${ai.devices} + 6144 + 0.7 + 8 + 3 + true + 1.0 + 0 + 0.05 + 1.0 + low + + + + + granite-4.0-h-tiny-bigwindow + X:/Modelle/granite-4.0-h-tiny-Q4_K_M.gguf + 393216 + ${ai.gpuLayers} + ${ai.mainGpu} + ${ai.devices} + 4096 + 0.2 + 8 + 3 + true + 1.0 + 0 + 0.05 + 1.0 + + + + + EXP-Qwen3-Coder-30B + X:/Modelle/Qwen3-Coder-30B-A3B-Instruct-UD-Q4_K_XL.gguf + 16384 + 1536 + 0.7 + 8 + 4 + true + 0.8 + 20 + 1.05 + + + + EXP-DeepSeek-Coder-V2-Lite + X:/Modelle/DeepSeek-Coder-V2-Lite-Instruct-Q4_K_M.gguf + 16384 + 1536 + 0.3 + 8 + 4 + true + 0.9 + 40 + 1.05 + + + EXP-Seed-Coder-8B + X:/Modelle/Seed-Coder-8B-Instruct-Q4_K_M.gguf + 16384 + 1536 + 0.3 + 8 + 4 + true + 0.9 + 40 + 1.05 + + + EXP-Granite-4.0-H-Tiny + X:/Modelle/granite-4.0-h-tiny-Q4_K_M.gguf + 16384 + 1536 + 0.0 + 8 + 4 + true + 1.0 + 0 + 1.0 + + + EXP-Qwen3-4B-Instruct-2507 + X:/Modelle/Qwen3-4B-Instruct-2507-Q4_K_M.gguf + 16384 + 1536 + 0.7 + 8 + 4 + true + 0.8 + 20 + 1.05 + + + file-body-java-v2 + + + + package-body-v2 +
+ ai-generate @@ -1453,23 +2024,60 @@ Index file: %s .sql
+ + + big-window + file-body-java + granite-4.0-h-tiny-bigwindow + 100 + + + + + .java + + + 275000 + + + + + + java file-body-java - Qwen3-Coder-30B-A3B-Instruct-UD-Q4_K_XL-C64k - - .java - + ${ai.model} + + .java + + sql file-body-sql - Qwen3-Coder-30B-A3B-Instruct-UD-Q4_K_XL-C64k - - .sql - + ${ai.model} + + .sql + + + fallback file-body-fallback - Qwen3-Coder-30B-A3B-Instruct-UD-Q4_K_XL-C64k + ${ai.model} + true @@ -1485,7 +2093,7 @@ Index file: %s package-body - Qwen3-Coder-30B-A3B-Instruct-UD-Q4_K_XL-C64k + ${ai.model} @@ -1511,7 +2119,7 @@ Index file: %s project-body - Qwen3-Coder-30B-A3B-Instruct-UD-Q4_K_XL-C64k + ${ai.model} diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index baedd30..1961980 100644 --- a/spotbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -302,4 +302,130 @@ SPDX-License-Identifier: Apache-2.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiCondition.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiCondition.java new file mode 100644 index 0000000..7addf3b --- /dev/null +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiCondition.java @@ -0,0 +1,211 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import lombok.ToString; +import org.jspecify.annotations.Nullable; + +/** + * A composable file-matching condition for a routing rule — a recursive boolean tree. + * + *

Each node sets exactly one of the following (validated by + * {@link AiConditionEvaluator#validate}):

+ *
    + *
  • combinators: {@code and} (all children true), {@code or} (any child true), + * {@code not} (single child negated);
  • + *
  • leaves: {@code extension} (file name ends with any of the listed extensions), + * {@code size} ({@link AiRangeCondition} over file bytes), {@code lines} + * ({@link AiRangeCondition} over line count), {@code modifiedAfter} / {@code modifiedBefore} + * (ISO-8601 instant compared to the file's last-modified time), {@code pathGlob} (glob over the + * base-relative path, same syntax as {@code excludes}).
  • + *
+ * + *

Because every variant is a distinctly named field, the Maven plugin framework binds the tree + * natively (no {@code implementation=} attributes); nesting is expressed by repeating {@code + * } inside {@code }/{@code }/{@code }. New leaf kinds are added by adding a + * field here and a branch in the evaluator. Mutable JavaBean for the Maven configurator.

+ */ +@ToString +public class AiCondition { + + private @Nullable AiConditionGroup and; + private @Nullable AiConditionGroup or; + private @Nullable AiCondition not; + private @Nullable List extensions; + private @Nullable AiRangeCondition size; + private @Nullable AiRangeCondition lines; + private @Nullable String modifiedAfter; + private @Nullable String modifiedBefore; + private @Nullable String pathGlob; + + /** Creates a new {@link AiCondition}. */ + public AiCondition() { + // no-op + } + + /** + * Returns the AND group, or {@code null} when this is not an AND node. + * + * @return the AND group, or {@code null} + */ + public @Nullable AiConditionGroup getAnd() { + return and; + } + + /** + * Sets the AND group (all children must match). + * + * @param and the AND group + */ + public void setAnd(final @Nullable AiConditionGroup and) { + this.and = and; + } + + /** + * Returns the OR group, or {@code null} when this is not an OR node. + * + * @return the OR group, or {@code null} + */ + public @Nullable AiConditionGroup getOr() { + return or; + } + + /** + * Sets the OR group (any child may match). + * + * @param or the OR group + */ + public void setOr(final @Nullable AiConditionGroup or) { + this.or = or; + } + + /** + * Returns the negated child, or {@code null} when this is not a NOT node. + * + * @return the negated child, or {@code null} + */ + public @Nullable AiCondition getNot() { + return not; + } + + /** + * Sets the negated child. + * + * @param not the negated child + */ + public void setNot(final @Nullable AiCondition not) { + this.not = not; + } + + /** + * Returns the matching extensions, or {@code null} when this is not an extensions node. + * + * @return the extensions, or {@code null} + */ + public @Nullable List getExtensions() { + return extensions; + } + + /** + * Sets the matching extensions. + * + * @param extensions the extensions (e.g. {@code .java}) + */ + public void setExtensions(final @Nullable Collection extensions) { + this.extensions = extensions != null ? new ArrayList<>(extensions) : null; + } + + /** + * Returns the size range, or {@code null} when this is not a size node. + * + * @return the size range, or {@code null} + */ + public @Nullable AiRangeCondition getSize() { + return size; + } + + /** + * Sets the size range (bytes). + * + * @param size the size range + */ + public void setSize(final @Nullable AiRangeCondition size) { + this.size = size; + } + + /** + * Returns the line-count range, or {@code null} when this is not a lines node. + * + * @return the line range, or {@code null} + */ + public @Nullable AiRangeCondition getLines() { + return lines; + } + + /** + * Sets the line-count range. + * + * @param lines the line range + */ + public void setLines(final @Nullable AiRangeCondition lines) { + this.lines = lines; + } + + /** + * Returns the ISO-8601 instant the file must be modified after, or {@code null}. + * + * @return the lower modified bound, or {@code null} + */ + public @Nullable String getModifiedAfter() { + return modifiedAfter; + } + + /** + * Sets the ISO-8601 instant the file must be modified after. + * + * @param modifiedAfter the ISO-8601 instant (e.g. {@code 2026-01-01T00:00:00Z}) + */ + public void setModifiedAfter(final @Nullable String modifiedAfter) { + this.modifiedAfter = modifiedAfter; + } + + /** + * Returns the ISO-8601 instant the file must be modified before, or {@code null}. + * + * @return the upper modified bound, or {@code null} + */ + public @Nullable String getModifiedBefore() { + return modifiedBefore; + } + + /** + * Sets the ISO-8601 instant the file must be modified before. + * + * @param modifiedBefore the ISO-8601 instant + */ + public void setModifiedBefore(final @Nullable String modifiedBefore) { + this.modifiedBefore = modifiedBefore; + } + + /** + * Returns the base-relative path glob, or {@code null} when this is not a pathGlob node. + * + * @return the path glob, or {@code null} + */ + public @Nullable String getPathGlob() { + return pathGlob; + } + + /** + * Sets the base-relative path glob. + * + * @param pathGlob the glob (e.g. {@code **}{@code /generated/**}) + */ + public void setPathGlob(final @Nullable String pathGlob) { + this.pathGlob = pathGlob; + } +} diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionEvaluator.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionEvaluator.java new file mode 100644 index 0000000..c9ba67d --- /dev/null +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionEvaluator.java @@ -0,0 +1,264 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import java.time.Instant; +import java.time.format.DateTimeParseException; +import java.util.Collections; +import java.util.List; +import net.ladenthin.maven.llamacpp.aiindex.support.AiSourceExcludeFilter; +import org.jspecify.annotations.Nullable; + +/** + * Evaluates and validates {@link AiCondition} trees against an {@link AiFileContext}. + * + *

{@link #matches} walks the tree (and/or/not + leaves); {@link #validate} fails fast on a + * misconfigured node (not exactly one branch set, empty combinator, unbounded range, unparseable + * date, blank glob); {@link #usesLines} reports whether any node needs the line count, so the indexer + * only reads file contents when a {@code lines} condition is actually used.

+ */ +public final class AiConditionEvaluator { + + /** Message when a node does not set exactly one branch/leaf. */ + private static final String ERROR_ONE_BRANCH = + "a condition node must set exactly one of and/or/not/extensions/size/lines/" + + "modifiedAfter/modifiedBefore/pathGlob: "; + + /** Creates a new {@link AiConditionEvaluator}. */ + public AiConditionEvaluator() { + // no-op + } + + /** + * Returns whether {@code context} satisfies {@code condition}. Assumes the condition was validated + * via {@link #validate}. + * + * @param condition the condition tree + * @param context the file facts + * @return {@code true} if the file matches + */ + public boolean matches(final AiCondition condition, final AiFileContext context) { + final AiConditionGroup and = condition.getAnd(); + if (and != null) { + final List children = and.getConditions(); + if (children != null) { + for (final AiCondition child : children) { + if (!matches(child, context)) { + return false; + } + } + } + return true; + } + final AiConditionGroup or = condition.getOr(); + if (or != null) { + final List children = or.getConditions(); + if (children != null) { + for (final AiCondition child : children) { + if (matches(child, context)) { + return true; + } + } + } + return false; + } + final AiCondition not = condition.getNot(); + if (not != null) { + return !matches(not, context); + } + final List extensions = condition.getExtensions(); + if (extensions != null) { + return matchesExtension(extensions, context.fileName()); + } + final AiRangeCondition size = condition.getSize(); + if (size != null) { + return size.contains(context.sizeBytes()); + } + final AiRangeCondition lines = condition.getLines(); + if (lines != null) { + return lines.contains(context.lineCount()); + } + final String modifiedAfter = condition.getModifiedAfter(); + if (modifiedAfter != null) { + return context.lastModifiedEpochMilli() > parseEpochMilli(modifiedAfter); + } + final String modifiedBefore = condition.getModifiedBefore(); + if (modifiedBefore != null) { + return context.lastModifiedEpochMilli() < parseEpochMilli(modifiedBefore); + } + final String pathGlob = condition.getPathGlob(); + if (pathGlob != null) { + return globMatches(pathGlob, context.relativePath()); + } + throw new IllegalStateException(ERROR_ONE_BRANCH + condition); + } + + /** + * Validates a condition tree, throwing {@link IllegalArgumentException} on a misconfiguration. + * + * @param condition the condition tree + * @throws IllegalArgumentException if any node is invalid + */ + public void validate(final AiCondition condition) { + if (branchCount(condition) != 1) { + throw new IllegalArgumentException(ERROR_ONE_BRANCH + condition); + } + final AiConditionGroup and = condition.getAnd(); + final AiConditionGroup or = condition.getOr(); + final AiCondition not = condition.getNot(); + final List extensions = condition.getExtensions(); + final AiRangeCondition size = condition.getSize(); + final AiRangeCondition lines = condition.getLines(); + final String modifiedAfter = condition.getModifiedAfter(); + final String modifiedBefore = condition.getModifiedBefore(); + final String pathGlob = condition.getPathGlob(); + if (and != null) { + validateGroup(and, ""); + } else if (or != null) { + validateGroup(or, ""); + } else if (not != null) { + validate(not); + } else if (extensions != null) { + if (extensions.isEmpty()) { + throw new IllegalArgumentException("an condition must list at least one extension"); + } + } else if (size != null) { + if (!size.hasBound()) { + throw new IllegalArgumentException("a condition must set or "); + } + } else if (lines != null) { + if (!lines.hasBound()) { + throw new IllegalArgumentException("a condition must set or "); + } + } else if (modifiedAfter != null) { + parseEpochMilli(modifiedAfter); + } else if (modifiedBefore != null) { + parseEpochMilli(modifiedBefore); + } else if (pathGlob != null && pathGlob.trim().isEmpty()) { + throw new IllegalArgumentException("a condition must not be blank"); + } + } + + /** + * Returns whether any node in the tree is a {@code lines} condition, so the indexer knows whether it + * must read file contents to count lines. + * + * @param condition the condition tree + * @return {@code true} if a {@code lines} condition is present anywhere + */ + public boolean usesLines(final AiCondition condition) { + if (condition.getLines() != null) { + return true; + } + final AiConditionGroup and = condition.getAnd(); + if (and != null) { + return anyUsesLines(and.getConditions()); + } + final AiConditionGroup or = condition.getOr(); + if (or != null) { + return anyUsesLines(or.getConditions()); + } + final AiCondition not = condition.getNot(); + if (not != null) { + return usesLines(not); + } + return false; + } + + private boolean anyUsesLines(final @Nullable List children) { + if (children == null) { + return false; + } + for (final AiCondition child : children) { + if (usesLines(child)) { + return true; + } + } + return false; + } + + /** + * Validates an {@code }/{@code } group: it must hold at least one child, and each child is + * validated recursively. + * + * @param group the combinator group + * @param label the element label for error messages + */ + private void validateGroup(final AiConditionGroup group, final String label) { + final List children = group.getConditions(); + if (children == null || children.isEmpty()) { + throw new IllegalArgumentException("an " + label + " condition must have at least one child"); + } + for (final AiCondition child : children) { + validate(child); + } + } + + /** + * Returns how many branch/leaf fields the node sets (must be exactly one). + * + * @param c the condition node + * @return the number of non-null branch/leaf fields + */ + private int branchCount(final AiCondition c) { + int count = 0; + if (c.getAnd() != null) { + count++; + } + if (c.getOr() != null) { + count++; + } + if (c.getNot() != null) { + count++; + } + if (c.getExtensions() != null) { + count++; + } + if (c.getSize() != null) { + count++; + } + if (c.getLines() != null) { + count++; + } + if (c.getModifiedAfter() != null) { + count++; + } + if (c.getModifiedBefore() != null) { + count++; + } + if (c.getPathGlob() != null) { + count++; + } + return count; + } + + private boolean matchesExtension(final List extensions, final String fileName) { + for (final @Nullable String extension : extensions) { + if (extension != null && fileName.endsWith(extension)) { + return true; + } + } + return false; + } + + private boolean globMatches(final String glob, final String relativePath) { + return new AiSourceExcludeFilter(Collections.singletonList(glob)).isExcluded(relativePath); + } + + /** + * Parses an ISO-8601 instant (e.g. {@code 2026-01-01T00:00:00Z}) to epoch milliseconds. + * + * @param isoInstant the ISO-8601 instant + * @return epoch milliseconds + * @throws IllegalArgumentException if the value is not a valid ISO-8601 instant + */ + private long parseEpochMilli(final String isoInstant) { + try { + return Instant.parse(isoInstant).toEpochMilli(); + } catch (final DateTimeParseException e) { + throw new IllegalArgumentException( + "invalid ISO-8601 instant (expected e.g. 2026-01-01T00:00:00Z): " + isoInstant, e); + } + } +} diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionGroup.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionGroup.java new file mode 100644 index 0000000..2bf337b --- /dev/null +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionGroup.java @@ -0,0 +1,50 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import lombok.ToString; +import org.jspecify.annotations.Nullable; + +/** + * A list of child {@link AiCondition}s, used as the body of an {@code } / {@code } combinator + * in {@link AiCondition}. + * + *

The list field is named {@code conditions} so the Maven plugin framework binds the items as + * {@code } — Maven derives a collection's item element + * name from the field name's singular, which is why the combinators wrap their children in this group + * rather than holding a {@code List} directly (a field named {@code and}/{@code or} would + * require the items to be {@code }/{@code }).

+ */ +@ToString +@SuppressWarnings({"NullAway.Init", "initialization.fields.uninitialized"}) +public class AiConditionGroup { + + private @Nullable List conditions; + + /** Creates a new {@link AiConditionGroup}. */ + public AiConditionGroup() { + // no-op + } + + /** + * Returns the child conditions, or {@code null} when none were configured. + * + * @return the child conditions, or {@code null} + */ + public @Nullable List getConditions() { + return conditions; + } + + /** + * Sets the child conditions (defensively copied). + * + * @param conditions the child conditions + */ + public void setConditions(final @Nullable Collection conditions) { + this.conditions = conditions != null ? new ArrayList<>(conditions) : null; + } +} diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java index dc15e78..6f9929f 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfig.java @@ -3,40 +3,23 @@ // SPDX-License-Identifier: Apache-2.0 package net.ladenthin.maven.llamacpp.aiindex.config; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; import lombok.ToString; import org.jspecify.annotations.Nullable; /** - * Maven plugin configuration POJO that associates a prompt template (by key) with an - * AI model definition (also by key) for a single field-generation step. + * One routing rule for the {@code generate} goal: a {@link #condition} that selects files, a + * {@link #priority} to break ties when several rules match, and an action — route the matched files to + * a {@code (promptKey, aiDefinitionKey)}, mark them {@link #skip skipped}, or act as the single explicit + * {@link #fallback}. * - *

Instances are declared inside the {@code } list in the plugin - * configuration. Each entry causes one AI generation call per indexed file or package: - * the prompt identified by {@link #promptKey} is prepared and sent to the AI provider - * configured by the {@link AiModelDefinition} identified by {@link #aiDefinitionKey}.

+ *

Note: this class must remain a mutable JavaBean with setters because the Maven + * plugin framework populates it via reflection.

* - *

Example POM fragment:

- *
{@code
- * 
- *     file-body
- *     codestral-32k
- * 
- * }
- * - *

Note: This class must remain a mutable JavaBean with setters because - * Maven's plugin framework instantiates configuration objects via reflection and injects - * values through setters.

- * - * @see AiModelDefinition - * @see AiModelDefinitionSupport - * @see net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition + * @see AiFieldGenerationSelector + * @see AiCondition */ -@SuppressWarnings({"NullAway.Init", "initialization.fields.uninitialized"}) @ToString +@SuppressWarnings({"NullAway.Init", "initialization.fields.uninitialized"}) public class AiFieldGenerationConfig { /** Creates a new {@link AiFieldGenerationConfig}. */ @@ -44,32 +27,76 @@ public AiFieldGenerationConfig() { // no-op } + /** + * Optional human-readable id for this routing rule (e.g. {@code java-small}, {@code skip-generated}). + * Purely a label: it is shown in the plan tree so you can see which rule routed each file, + * and it appears in validation error messages. {@code null} when not set. + */ + private @Nullable String id; + private String promptKey; /** - * Key that references an {@link AiModelDefinition} registered in the - * {@code } list. - * - *

The referenced definition supplies all AI generation parameters (model path, - * context size, temperature, retry policy, input trimming limits, etc.) for this - * field-generation step.

+ * Key that references an {@link AiModelDefinition} registered in the {@code } list; + * that definition supplies all AI generation parameters (model path, context size, sampling, …). */ private String aiDefinitionKey; /** - * Optional source file extensions (e.g. {@code .java}, {@code .sql}) that select this field - * generation for a file. When non-empty, this entry applies only to files whose name ends with - * one of the listed extensions. When {@code null} or empty, this entry is the fallback applied to - * any file that no extension-specific entry matched. + * The file-matching condition (a composable and/or/not tree of leaves — extension, size, lines, + * modified-after/before, path glob). Required for route and skip rules; the {@link #fallback} has + * none (it catches everything else). * - * @see AiFieldGenerationSelector + * @see AiCondition + * @see AiConditionEvaluator */ - private @Nullable List fileExtensions; + private @Nullable AiCondition condition; + + /** + * Selection priority. When several rules match the same file, the highest priority wins; ties are + * broken by declaration order (the earlier rule wins). Default {@code 0}. Lets a specific rule + * (e.g. a high-priority {@link #skip}) override a more general one regardless of XML order. + */ + private int priority; + + /** + * Marks this rule as the explicit fallback: it applies to any file no other rule matched. At most + * one fallback may be configured. A fallback routes (needs {@link #promptKey} and + * {@link #aiDefinitionKey}), has no {@link #condition}, and cannot be a {@link #skip}. When no rule + * matches a file and no fallback is configured, indexing fails rather than silently skipping it. + */ + private boolean fallback; + + /** + * Marks this rule as a skip (ignore) rule: matching files are excluded from indexing entirely. A + * skip competes by {@link #priority} like any matching rule, so a high-priority skip excludes files + * a route rule or the fallback would otherwise pick up. Skip rules need a {@link #condition} but no + * prompt/model. + */ + private boolean skip; + + /** + * Returns the optional rule id (label), or {@code null} when not set. + * + * @return the rule id, or {@code null} + */ + public @Nullable String getId() { + return id; + } + + /** + * Sets the optional rule id (label). + * + * @param id the rule id + */ + public void setId(final @Nullable String id) { + this.id = id; + } /** * Returns the prompt template key. * - * @return the key that identifies the prompt template to use for this field + * @return the key that identifies the prompt template ({@code null} only on an unconfigured skip rule) */ public String getPromptKey() { return promptKey; @@ -87,7 +114,7 @@ public void setPromptKey(final String promptKey) { /** * Returns the AI model definition key. * - * @return the key that references the {@link AiModelDefinition} to use + * @return the key that references the {@link AiModelDefinition} ({@code null} only on a skip rule) */ public String getAiDefinitionKey() { return aiDefinitionKey; @@ -103,22 +130,74 @@ public void setAiDefinitionKey(final String aiDefinitionKey) { } /** - * Returns the source file extensions that select this entry, or {@code null} when this entry is - * the extension-agnostic fallback. + * Returns the file-matching condition, or {@code null} (the fallback has none). + * + * @return the condition, or {@code null} + */ + public @Nullable AiCondition getCondition() { + return condition; + } + + /** + * Sets the file-matching condition. + * + * @param condition the condition tree + */ + public void setCondition(final @Nullable AiCondition condition) { + this.condition = condition; + } + + /** + * Returns the selection priority ({@code 0} = default). + * + * @return the selection priority + */ + public int getPriority() { + return priority; + } + + /** + * Sets the selection priority (higher wins when several rules match). + * + * @param priority the selection priority + */ + public void setPriority(final int priority) { + this.priority = priority; + } + + /** + * Returns whether this rule is the explicit fallback. + * + * @return {@code true} if this rule is the fallback + */ + public boolean isFallback() { + return fallback; + } + + /** + * Sets whether this rule is the explicit fallback. + * + * @param fallback {@code true} to mark this rule as the fallback + */ + public void setFallback(final boolean fallback) { + this.fallback = fallback; + } + + /** + * Returns whether this rule is a skip (ignore) rule. * - * @return the selecting file extensions, or {@code null} + * @return {@code true} if matching files should be skipped */ - public @Nullable List getFileExtensions() { - return fileExtensions != null ? Collections.unmodifiableList(fileExtensions) : null; + public boolean isSkip() { + return skip; } /** - * Sets the source file extensions that select this entry. The list is defensively copied. + * Sets whether this rule is a skip (ignore) rule. * - * @param fileExtensions selecting file extensions (e.g. {@code .java}); {@code null} or empty - * makes this entry the fallback + * @param skip {@code true} to skip files this rule matches */ - public void setFileExtensions(final @Nullable Collection fileExtensions) { - this.fileExtensions = fileExtensions != null ? new ArrayList<>(fileExtensions) : null; + public void setSkip(final boolean skip) { + this.skip = skip; } } diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java index 58ce351..d2cf2a7 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelector.java @@ -3,59 +3,117 @@ // SPDX-License-Identifier: Apache-2.0 package net.ladenthin.maven.llamacpp.aiindex.config; -import java.util.List; import lombok.ToString; import org.jspecify.annotations.Nullable; /** - * Selects the {@link AiFieldGenerationConfig} that applies to a given source file, based on the - * entries' {@link AiFieldGenerationConfig#getFileExtensions() file extensions}. + * Selects the routing rule ({@link AiFieldGenerationConfig}) that applies to a file. * - *

Selection rule, in list order: the first entry whose non-empty extension list matches the file - * name wins; otherwise the first extension-agnostic entry (empty or absent extension list) is the - * fallback. Returns {@code null} when no entry matches and no fallback is configured.

+ *

Each rule carries an {@link AiCondition} (a composable and/or/not tree of leaf matchers) plus a + * {@link AiFieldGenerationConfig#getPriority() priority}, and is a normal route rule + * (prompt + model), the explicit {@link AiFieldGenerationConfig#isFallback() fallback}, or a + * {@link AiFieldGenerationConfig#isSkip() skip} rule.

* - *

This lets the prompt vary by language while a single AI model stays loaded for the whole run — - * e.g. a Java-specific prompt for {@code .java}, a SQL-schema prompt for {@code .sql}, and a generic - * fallback for everything else. A configuration with one extension-agnostic entry (the historical - * shape) keeps working unchanged: that entry is the fallback and applies to every file.

+ *

Selection: among all non-fallback rules whose condition matches, the highest priority wins (ties + * by declaration order); if the winner is a skip the file is excluded; if no non-fallback rule matches, + * the explicit fallback applies; if nothing matches and there is no fallback, {@link #select} returns + * {@code null} so the caller fails loudly.

*/ @ToString public final class AiFieldGenerationSelector { + private final AiConditionEvaluator conditionEvaluator = new AiConditionEvaluator(); + /** Creates a new {@link AiFieldGenerationSelector}. */ public AiFieldGenerationSelector() { // no-op } /** - * Returns the field generation that applies to {@code fileName}. + * Returns the rule that applies to {@code context}, resolving ties by priority then declaration + * order. * - * @param configs the configured field generations, in declaration order; {@code null} entries - * are skipped - * @param fileName the source file name (e.g. {@code Foo.java}) - * @return the first extension-matching entry, else the first fallback entry, else {@code null} + * @param configs the configured rules, in declaration order; {@code null} entries are skipped + * @param context the file facts the conditions are evaluated against + * @return the winning rule (which may be a skip or the fallback), or {@code null} when nothing + * matches and no fallback is configured */ - public @Nullable AiFieldGenerationConfig selectForFileName( - final Iterable configs, final String fileName) { + public @Nullable AiFieldGenerationConfig select( + final Iterable configs, final AiFileContext context) { AiFieldGenerationConfig fallback = null; + AiFieldGenerationConfig best = null; for (final AiFieldGenerationConfig config : configs) { if (config == null) { continue; } - final List extensions = config.getFileExtensions(); - if (extensions == null || extensions.isEmpty()) { + if (config.isFallback()) { if (fallback == null) { fallback = config; } continue; } - for (final String extension : extensions) { - if (fileName.endsWith(extension)) { - return config; + final AiCondition condition = config.getCondition(); + if (condition != null + && conditionEvaluator.matches(condition, context) + && (best == null || config.getPriority() > best.getPriority())) { + best = config; + } + } + return best != null ? best : fallback; + } + + /** + * Validates a rule set, throwing {@link IllegalArgumentException} on a misconfiguration so the build + * fails fast. + * + *

Checks: at most one fallback; the fallback must have no condition, must not be a skip, and must + * have a prompt + model; every non-fallback rule must have a (valid) condition; route rules must + * have a prompt + model (skip rules need neither).

+ * + * @param configs the configured rules + * @throws IllegalArgumentException if the rule set is invalid + */ + public void validate(final Iterable configs) { + int fallbackCount = 0; + for (final AiFieldGenerationConfig config : configs) { + if (config == null) { + continue; + } + if (config.isFallback()) { + fallbackCount++; + if (config.isSkip()) { + throw new IllegalArgumentException("A fallback rule cannot also be a skip rule: " + config); + } + if (config.getCondition() != null) { + throw new IllegalArgumentException( + "A fallback rule must not have a (it catches everything else): " + config); + } + requireRouteKeys(config); + } else { + final AiCondition condition = config.getCondition(); + if (condition == null) { + throw new IllegalArgumentException("A non-fallback rule must have a : " + config); + } + conditionEvaluator.validate(condition); + if (!config.isSkip()) { + requireRouteKeys(config); } } } - return fallback; + if (fallbackCount > 1) { + throw new IllegalArgumentException("At most one fallback rule may be configured, found " + fallbackCount); + } + } + + /** + * Throws when a route/fallback rule is missing the prompt key or AI definition key. + * + * @param config the rule + */ + private void requireRouteKeys(final AiFieldGenerationConfig config) { + if (config.getPromptKey() == null || config.getAiDefinitionKey() == null) { + throw new IllegalArgumentException( + "A route/fallback rule must have a promptKey and an aiDefinitionKey: " + config); + } } } diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFileContext.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFileContext.java new file mode 100644 index 0000000..b0177c3 --- /dev/null +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFileContext.java @@ -0,0 +1,88 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import lombok.ToString; + +/** + * Immutable snapshot of the file facts a {@link AiCondition} is evaluated against: name, base-relative + * path ({@code /} separators), size in bytes, line count, and last-modified time. Built by the indexer + * (the I/O side) and consumed by {@link AiConditionEvaluator} (the pure side). + */ +@ToString +public final class AiFileContext { + + private final String fileName; + private final String relativePath; + private final long sizeBytes; + private final int lineCount; + private final long lastModifiedEpochMilli; + + /** + * Creates a file context. + * + * @param fileName the file name (e.g. {@code Foo.java}) + * @param relativePath the base-relative path with {@code /} separators + * @param sizeBytes the file size in bytes + * @param lineCount the line count ({@code 0} when not computed) + * @param lastModifiedEpochMilli the last-modified time in epoch milliseconds + */ + public AiFileContext( + final String fileName, + final String relativePath, + final long sizeBytes, + final int lineCount, + final long lastModifiedEpochMilli) { + this.fileName = fileName; + this.relativePath = relativePath; + this.sizeBytes = sizeBytes; + this.lineCount = lineCount; + this.lastModifiedEpochMilli = lastModifiedEpochMilli; + } + + /** + * Returns the file name. + * + * @return the file name + */ + public String fileName() { + return fileName; + } + + /** + * Returns the base-relative path with {@code /} separators. + * + * @return the relative path + */ + public String relativePath() { + return relativePath; + } + + /** + * Returns the file size in bytes. + * + * @return the size in bytes + */ + public long sizeBytes() { + return sizeBytes; + } + + /** + * Returns the line count. + * + * @return the line count + */ + public int lineCount() { + return lineCount; + } + + /** + * Returns the last-modified time in epoch milliseconds. + * + * @return the last-modified epoch milliseconds + */ + public long lastModifiedEpochMilli() { + return lastModifiedEpochMilli; + } +} diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java index 9ddea62..0ed14a7 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfig.java @@ -74,23 +74,6 @@ public AiGenerationConfig() { */ public static final boolean DEFAULT_WARN_ON_TRIM = true; - /** - * Default maximum number of retry attempts when the AI provider returns an empty body. - * A value of {@code 0} disables retries entirely. - * Each retry uses a temperature incremented by {@link #DEFAULT_RETRY_TEMPERATURE_INCREMENT}. - */ - public static final int DEFAULT_MAX_RETRIES = 3; - - /** - * Default temperature increment applied on each successive retry attempt. - * Added to {@link #temperature} per attempt: attempt 1 uses - * {@code temperature + retryTemperatureIncrement}, attempt 2 uses - * {@code temperature + 2 * retryTemperatureIncrement}, and so on. - * Higher temperatures make the model less deterministic and can break out of - * EOS-early failure modes. - */ - public static final float DEFAULT_RETRY_TEMPERATURE_INCREMENT = 0.1f; - /** * Default nucleus-sampling probability threshold. * Matches the {@code net.ladenthin:llama} {@code InferenceParameters} library default so @@ -107,6 +90,23 @@ public AiGenerationConfig() { */ public static final int DEFAULT_TOP_K = 40; + /** + * Default min-p sampling threshold. A value of {@code 0.0} disables min-p truncation and + * preserves existing behaviour for models that do not specify it. min-p keeps only tokens whose + * probability is at least this fraction of the top token's probability; it is the recommended + * primary truncation for gpt-oss at a non-greedy temperature (scales the cut-off to the model's + * confidence — see {@code docs/ai-index-benchmark/gpt-oss-tuning.md} D1). + */ + public static final float DEFAULT_MIN_P = 0.0f; + + /** + * Default top-n-sigma sampling threshold. A value of {@code -1.0} disables it and preserves + * existing behaviour. top-n-sigma keeps tokens within n standard deviations of the max logit; + * unlike top-p/min-p its candidate set is temperature-invariant, which can make structured + * extraction more reproducible (see {@code docs/ai-index-benchmark/gpt-oss-tuning.md} E6). + */ + public static final float DEFAULT_TOP_N_SIGMA = -1.0f; + /** * Default repetition penalty. A value of {@code 1.0} means no penalty and preserves * existing behaviour for models that do not specify it. @@ -124,6 +124,107 @@ public AiGenerationConfig() { */ public static final boolean DEFAULT_CHAT_TEMPLATE_ENABLE_THINKING = true; + /** + * Default for whether llama.cpp prompt caching ({@code cache_prompt}) is enabled. + * + *

When {@code true}, the provider keeps the shared prompt-template prefix in the KV cache and + * reuses it across files — only the differing source text is re-prefilled per file. This is a + * pure speed optimisation: prefix reuse is exact, so the generated output is unchanged.

+ */ + public static final boolean DEFAULT_CACHE_PROMPT = true; + + /** + * Default gpt-oss reasoning-effort level ({@code "low"} / {@code "medium"} / {@code "high"}). + * + *

{@code "low"} keeps the discarded chain-of-thought minimal for the short, structured + * summaries this plugin produces (the gpt-oss model default would be {@code "medium"}). It is + * passed as the {@code reasoning_effort} chat-template kwarg; non-gpt-oss chat templates ignore + * it. An empty value omits the kwarg entirely so the model's own template default applies.

+ */ + public static final String DEFAULT_REASONING_EFFORT = "low"; + + /** + * Default reasoning/think-token budget ({@code thinking_budget_tokens} / {@code --reasoning-budget}). + * {@code -1} = unrestricted (llama.cpp default). A value {@code >= 0} caps the harmony analysis + * (reasoning) tokens so a runaway chain-of-thought cannot starve the final answer of output budget; + * see {@code docs/ai-index-benchmark/gpt-oss-tuning.md} E2. + */ + public static final int DEFAULT_REASONING_BUDGET_TOKENS = -1; + + /** + * Default for whether the full-size sliding-window-attention (SWA) KV cache is kept + * ({@code --swa-full}). {@code true} = keep the full SWA KV so the shared prompt prefix is reusable + * across files (the llama.cpp default of window-sized SWA KV uses ~half the RAM but is not reusable + * across requests). Adopted as the shipped default (pairs with {@link #DEFAULT_CACHE_REUSE}) because + * project indexing is a multi-file batch sharing one prompt prefix, where E4 measured ~21% less + * prefill / ~12% less wall time; cost is ~2× SWA-layer KV RAM (acceptable for the typical overnight + * full-project run). Set {@code false} for RAM-constrained single-file use. + */ + public static final boolean DEFAULT_SWA_FULL = true; + + /** + * Default minimum chunk size (tokens) for cross-request KV prefix reuse ({@code --cache-reuse}). + * {@code 256} = the value E4 measured; lets the server reuse a matching prompt prefix from a previous + * request instead of re-prefilling it (exact-prefix match, so output is unchanged). Pairs with + * {@link #DEFAULT_SWA_FULL}; set {@code 0} to disable (the llama.cpp default). + */ + public static final int DEFAULT_CACHE_REUSE = 256; + + /** + * Default number of model layers to offload to the GPU ({@code --gpu-layers}). {@code -1} (default) + * means "do not set it" — the binding/native build decides (a CPU build stays on CPU; a GPU build + * uses its own default). {@code 0} forces CPU even on a GPU build; a positive value offloads that + * many layers (use partial offload when the model does not fit in VRAM). Only effective with a GPU + * native (e.g. the {@code cuda13-windows-x86-64} / {@code vulkan-windows-x86-64} classifier). + */ + public static final int DEFAULT_GPU_LAYERS = -1; + + /** + * Default primary GPU index ({@code --main-gpu}). {@code -1} (default) means "do not set it" — the + * binding/native build decides (llama.cpp's own default is device {@code 0}). Set a non-negative + * index to pick a specific device. This matters on machines with more than one GPU visible to the + * backend: a Vulkan build enumerates all GPUs (e.g. an integrated GPU as device {@code 0} + * and a discrete GPU as device {@code 1}), so the default may select the slower one; a CUDA build + * only enumerates NVIDIA devices. Only effective with a GPU native. See also {@link #DEFAULT_DEVICES}. + */ + public static final int DEFAULT_MAIN_GPU = -1; + + /** + * Default device selection ({@code --device}). Empty (default) means "do not set it" — the + * binding/native build decides. A non-empty value is a comma-separated list of backend device + * names to use (e.g. {@code Vulkan1} or {@code CUDA0}); it takes precedence over a single + * {@link #DEFAULT_MAIN_GPU} index when finer control across multiple devices is needed. Only + * effective with a GPU native. + */ + public static final String DEFAULT_DEVICES = ""; + + /** + * Default DRY (Don't Repeat Yourself) sampling multiplier ({@code --dry-multiplier}). + * {@code 0.0} = disabled (llama.cpp default). A positive value penalises verbatim n-gram + * repetition, which can break runaway repetition loops; the other {@code dry*} knobs only take + * effect when this is non-zero. Opt-in safety knob for repetition-prone models/configs. + */ + public static final float DEFAULT_DRY_MULTIPLIER = 0.0f; + + /** + * Default DRY base ({@code --dry-base}); the exponential growth base of the repetition penalty. + * {@code 1.75} = llama.cpp default. Only takes effect when {@link #DEFAULT_DRY_MULTIPLIER} is non-zero. + */ + public static final float DEFAULT_DRY_BASE = 1.75f; + + /** + * Default DRY allowed length ({@code --dry-allowed-length}); the longest n-gram that may repeat + * without penalty. {@code 2} = llama.cpp default. Only takes effect when DRY is enabled. + */ + public static final int DEFAULT_DRY_ALLOWED_LENGTH = 2; + + /** + * Default DRY penalty look-back window in tokens ({@code --dry-penalty-last-n}). + * {@code -1} = whole context (llama.cpp default), {@code 0} = disabled. Only takes effect when DRY + * is enabled. + */ + public static final int DEFAULT_DRY_PENALTY_LAST_N = -1; + private String modelPath; private int contextSize = DEFAULT_CONTEXT_SIZE; private int maxOutputTokens = DEFAULT_MAX_OUTPUT_TOKENS; @@ -132,12 +233,25 @@ public AiGenerationConfig() { private int charsPerToken = DEFAULT_CHARS_PER_TOKEN; private int maxInputChars = DEFAULT_MAX_INPUT_CHARS; private boolean warnOnTrim = DEFAULT_WARN_ON_TRIM; - private int maxRetries = DEFAULT_MAX_RETRIES; - private float retryTemperatureIncrement = DEFAULT_RETRY_TEMPERATURE_INCREMENT; private float topP = DEFAULT_TOP_P; private int topK = DEFAULT_TOP_K; + private float minP = DEFAULT_MIN_P; + private float topNSigma = DEFAULT_TOP_N_SIGMA; private float repeatPenalty = DEFAULT_REPEAT_PENALTY; private boolean chatTemplateEnableThinking = DEFAULT_CHAT_TEMPLATE_ENABLE_THINKING; + private boolean cachePrompt = DEFAULT_CACHE_PROMPT; + private boolean swaFull = DEFAULT_SWA_FULL; + private int cacheReuse = DEFAULT_CACHE_REUSE; + private int gpuLayers = DEFAULT_GPU_LAYERS; + private int mainGpu = DEFAULT_MAIN_GPU; + private String devices = DEFAULT_DEVICES; + private String reasoningEffort = DEFAULT_REASONING_EFFORT; + private int reasoningBudgetTokens = DEFAULT_REASONING_BUDGET_TOKENS; + private float dryMultiplier = DEFAULT_DRY_MULTIPLIER; + private float dryBase = DEFAULT_DRY_BASE; + private int dryAllowedLength = DEFAULT_DRY_ALLOWED_LENGTH; + private int dryPenaltyLastN = DEFAULT_DRY_PENALTY_LAST_N; + private List drySequenceBreakers = new ArrayList<>(); private List stopStrings = new ArrayList<>(); /** @@ -286,42 +400,6 @@ public void setWarnOnTrim(final boolean warnOnTrim) { this.warnOnTrim = warnOnTrim; } - /** - * Returns the maximum number of retry attempts on empty-body responses. - * - * @return maximum retry attempts - */ - public int getMaxRetries() { - return maxRetries; - } - - /** - * Sets the maximum number of retry attempts on empty-body responses. - * - * @param maxRetries maximum retry attempts - */ - public void setMaxRetries(final int maxRetries) { - this.maxRetries = maxRetries; - } - - /** - * Returns the temperature increment added on each retry attempt. - * - * @return temperature increment per retry - */ - public float getRetryTemperatureIncrement() { - return retryTemperatureIncrement; - } - - /** - * Sets the temperature increment added on each retry attempt. - * - * @param retryTemperatureIncrement temperature increment per retry - */ - public void setRetryTemperatureIncrement(final float retryTemperatureIncrement) { - this.retryTemperatureIncrement = retryTemperatureIncrement; - } - /** * Returns the nucleus-sampling probability threshold. * @@ -376,6 +454,42 @@ public void setRepeatPenalty(final float repeatPenalty) { this.repeatPenalty = repeatPenalty; } + /** + * Returns the min-p sampling threshold. + * + * @return min-p threshold ({@code 0.0} = disabled) + */ + public float getMinP() { + return minP; + } + + /** + * Sets the min-p sampling threshold. + * + * @param minP min-p threshold ({@code 0.0} = disabled) + */ + public void setMinP(final float minP) { + this.minP = minP; + } + + /** + * Returns the top-n-sigma sampling threshold. + * + * @return top-n-sigma threshold ({@code -1.0} = disabled) + */ + public float getTopNSigma() { + return topNSigma; + } + + /** + * Sets the top-n-sigma sampling threshold. + * + * @param topNSigma top-n-sigma threshold ({@code -1.0} = disabled) + */ + public void setTopNSigma(final float topNSigma) { + this.topNSigma = topNSigma; + } + /** * Returns whether the model's chat-template thinking mode is enabled. * @@ -394,6 +508,241 @@ public void setChatTemplateEnableThinking(final boolean chatTemplateEnableThinki this.chatTemplateEnableThinking = chatTemplateEnableThinking; } + /** + * Returns whether llama.cpp prompt caching ({@code cache_prompt}) is enabled. + * + * @return {@code true} when prompt-prefix KV reuse across files is enabled + */ + public boolean isCachePrompt() { + return cachePrompt; + } + + /** + * Returns whether the full-size SWA KV cache is kept ({@code --swa-full}). + * + * @return {@code true} when full SWA KV is kept + */ + public boolean isSwaFull() { + return swaFull; + } + + /** + * Sets whether the full-size SWA KV cache is kept ({@code --swa-full}). + * + * @param swaFull {@code true} to keep full SWA KV (enables cross-request prefix reuse, more RAM) + */ + public void setSwaFull(final boolean swaFull) { + this.swaFull = swaFull; + } + + /** + * Returns the KV prefix-reuse minimum chunk size ({@code --cache-reuse}). + * + * @return cache-reuse chunk size ({@code 0} = disabled) + */ + public int getCacheReuse() { + return cacheReuse; + } + + /** + * Sets the KV prefix-reuse minimum chunk size ({@code --cache-reuse}). + * + * @param cacheReuse chunk size in tokens ({@code 0} = disabled) + */ + public void setCacheReuse(final int cacheReuse) { + this.cacheReuse = cacheReuse; + } + + /** + * Returns the number of model layers to offload to the GPU ({@code --gpu-layers}). + * + * @return GPU layers ({@code -1} = leave the binding/build default) + */ + public int getGpuLayers() { + return gpuLayers; + } + + /** + * Sets the number of model layers to offload to the GPU ({@code --gpu-layers}). + * + * @param gpuLayers GPU layers ({@code -1} = leave default, {@code 0} = force CPU, {@code >0} = offload) + */ + public void setGpuLayers(final int gpuLayers) { + this.gpuLayers = gpuLayers; + } + + /** + * Returns the primary GPU index ({@code --main-gpu}). + * + * @return the GPU index, or {@code -1} to leave the binding/build default + */ + public int getMainGpu() { + return mainGpu; + } + + /** + * Sets the primary GPU index ({@code --main-gpu}). + * + * @param mainGpu the GPU index ({@code -1} = leave default; a non-negative value selects that device) + */ + public void setMainGpu(final int mainGpu) { + this.mainGpu = mainGpu; + } + + /** + * Returns the device selection ({@code --device}). + * + * @return the comma-separated device list, or an empty string to leave the binding/build default + */ + public String getDevices() { + return devices; + } + + /** + * Sets the device selection ({@code --device}). A {@code null} argument resets to the empty default. + * + * @param devices the comma-separated backend device names (e.g. {@code Vulkan1}), or {@code null}/empty to leave default + */ + public void setDevices(final String devices) { + this.devices = devices == null ? DEFAULT_DEVICES : devices; + } + + /** + * Sets whether llama.cpp prompt caching ({@code cache_prompt}) is enabled. + * + * @param cachePrompt {@code true} to reuse the shared prompt-prefix KV across calls + */ + public void setCachePrompt(final boolean cachePrompt) { + this.cachePrompt = cachePrompt; + } + + /** + * Returns the gpt-oss reasoning-effort level passed as the {@code reasoning_effort} kwarg. + * + * @return reasoning effort ({@code "low"}/{@code "medium"}/{@code "high"}), or empty to omit it + */ + public String getReasoningEffort() { + return reasoningEffort; + } + + /** + * Sets the gpt-oss reasoning-effort level. + * + * @param reasoningEffort {@code "low"}/{@code "medium"}/{@code "high"}, or empty/blank to omit + * the kwarg (the model's own chat-template default then applies) + */ + public void setReasoningEffort(final String reasoningEffort) { + this.reasoningEffort = reasoningEffort; + } + + /** + * Returns the reasoning/think-token budget. + * + * @return reasoning budget tokens ({@code -1} = unrestricted) + */ + public int getReasoningBudgetTokens() { + return reasoningBudgetTokens; + } + + /** + * Sets the reasoning/think-token budget (caps harmony analysis tokens). + * + * @param reasoningBudgetTokens budget in tokens ({@code -1} = unrestricted, {@code 0} = no thinking) + */ + public void setReasoningBudgetTokens(final int reasoningBudgetTokens) { + this.reasoningBudgetTokens = reasoningBudgetTokens; + } + + /** + * Returns the DRY sampling multiplier. + * + * @return DRY multiplier ({@code 0.0} = disabled) + */ + public float getDryMultiplier() { + return dryMultiplier; + } + + /** + * Sets the DRY sampling multiplier. + * + * @param dryMultiplier DRY multiplier ({@code 0.0} = disabled) + */ + public void setDryMultiplier(final float dryMultiplier) { + this.dryMultiplier = dryMultiplier; + } + + /** + * Returns the DRY base. + * + * @return DRY base + */ + public float getDryBase() { + return dryBase; + } + + /** + * Sets the DRY base. + * + * @param dryBase DRY base + */ + public void setDryBase(final float dryBase) { + this.dryBase = dryBase; + } + + /** + * Returns the DRY allowed length (longest unpenalised repeating n-gram). + * + * @return DRY allowed length + */ + public int getDryAllowedLength() { + return dryAllowedLength; + } + + /** + * Sets the DRY allowed length. + * + * @param dryAllowedLength DRY allowed length + */ + public void setDryAllowedLength(final int dryAllowedLength) { + this.dryAllowedLength = dryAllowedLength; + } + + /** + * Returns the DRY penalty look-back window in tokens. + * + * @return DRY penalty last-n ({@code -1} = whole context, {@code 0} = disabled) + */ + public int getDryPenaltyLastN() { + return dryPenaltyLastN; + } + + /** + * Sets the DRY penalty look-back window in tokens. + * + * @param dryPenaltyLastN DRY penalty last-n ({@code -1} = whole context, {@code 0} = disabled) + */ + public void setDryPenaltyLastN(final int dryPenaltyLastN) { + this.dryPenaltyLastN = dryPenaltyLastN; + } + + /** + * Returns an unmodifiable view of the configured DRY sequence breakers. + * + * @return unmodifiable list of DRY sequence breakers (empty = use the model/binding default) + */ + public List getDrySequenceBreakers() { + return Collections.unmodifiableList(drySequenceBreakers); + } + + /** + * Sets the DRY sequence breakers (tokens that reset n-gram matching). + * + * @param drySequenceBreakers sequence breakers, or {@code null} to reset to empty + */ + public void setDrySequenceBreakers(final @Nullable List drySequenceBreakers) { + this.drySequenceBreakers = drySequenceBreakers != null ? drySequenceBreakers : new ArrayList<>(); + } + /** * Returns an unmodifiable view of the configured stop strings. * diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java index 9913d6d..18090d3 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinition.java @@ -46,12 +46,25 @@ public AiModelDefinition() { private int threads = AiGenerationConfig.DEFAULT_THREADS; private int charsPerToken = AiGenerationConfig.DEFAULT_CHARS_PER_TOKEN; private boolean warnOnTrim = AiGenerationConfig.DEFAULT_WARN_ON_TRIM; - private int maxRetries = AiGenerationConfig.DEFAULT_MAX_RETRIES; - private float retryTemperatureIncrement = AiGenerationConfig.DEFAULT_RETRY_TEMPERATURE_INCREMENT; private float topP = AiGenerationConfig.DEFAULT_TOP_P; private int topK = AiGenerationConfig.DEFAULT_TOP_K; + private float minP = AiGenerationConfig.DEFAULT_MIN_P; + private float topNSigma = AiGenerationConfig.DEFAULT_TOP_N_SIGMA; private float repeatPenalty = AiGenerationConfig.DEFAULT_REPEAT_PENALTY; private boolean chatTemplateEnableThinking = AiGenerationConfig.DEFAULT_CHAT_TEMPLATE_ENABLE_THINKING; + private boolean cachePrompt = AiGenerationConfig.DEFAULT_CACHE_PROMPT; + private boolean swaFull = AiGenerationConfig.DEFAULT_SWA_FULL; + private int cacheReuse = AiGenerationConfig.DEFAULT_CACHE_REUSE; + private int gpuLayers = AiGenerationConfig.DEFAULT_GPU_LAYERS; + private int mainGpu = AiGenerationConfig.DEFAULT_MAIN_GPU; + private String devices = AiGenerationConfig.DEFAULT_DEVICES; + private String reasoningEffort = AiGenerationConfig.DEFAULT_REASONING_EFFORT; + private int reasoningBudgetTokens = AiGenerationConfig.DEFAULT_REASONING_BUDGET_TOKENS; + private float dryMultiplier = AiGenerationConfig.DEFAULT_DRY_MULTIPLIER; + private float dryBase = AiGenerationConfig.DEFAULT_DRY_BASE; + private int dryAllowedLength = AiGenerationConfig.DEFAULT_DRY_ALLOWED_LENGTH; + private int dryPenaltyLastN = AiGenerationConfig.DEFAULT_DRY_PENALTY_LAST_N; + private @Nullable List drySequenceBreakers; private @Nullable List stopStrings; /** @@ -205,42 +218,6 @@ public void setWarnOnTrim(final boolean warnOnTrim) { this.warnOnTrim = warnOnTrim; } - /** - * Returns the maximum number of retry attempts when the provider returns an empty body. - * - * @return max retries, defaults to {@link AiGenerationConfig#DEFAULT_MAX_RETRIES} - */ - public int getMaxRetries() { - return maxRetries; - } - - /** - * Sets the maximum number of retry attempts when the provider returns an empty body. - * - * @param maxRetries {@code 0} disables retries entirely - */ - public void setMaxRetries(final int maxRetries) { - this.maxRetries = maxRetries; - } - - /** - * Returns the temperature increment applied on each successive retry attempt. - * - * @return retry temperature increment, defaults to {@link AiGenerationConfig#DEFAULT_RETRY_TEMPERATURE_INCREMENT} - */ - public float getRetryTemperatureIncrement() { - return retryTemperatureIncrement; - } - - /** - * Sets the temperature increment applied on each successive retry attempt. - * - * @param retryTemperatureIncrement added to the base temperature on each retry - */ - public void setRetryTemperatureIncrement(final float retryTemperatureIncrement) { - this.retryTemperatureIncrement = retryTemperatureIncrement; - } - /** * Returns the nucleus-sampling probability threshold. * @@ -295,6 +272,42 @@ public void setRepeatPenalty(final float repeatPenalty) { this.repeatPenalty = repeatPenalty; } + /** + * Returns the min-p sampling threshold. + * + * @return min-p threshold; defaults to {@link AiGenerationConfig#DEFAULT_MIN_P} ({@code 0.0} = disabled) + */ + public float getMinP() { + return minP; + } + + /** + * Sets the min-p sampling threshold (keep tokens with probability ≥ minP × top-token probability). + * + * @param minP min-p threshold; {@code 0.0} disables min-p truncation + */ + public void setMinP(final float minP) { + this.minP = minP; + } + + /** + * Returns the top-n-sigma sampling threshold. + * + * @return top-n-sigma threshold; defaults to {@link AiGenerationConfig#DEFAULT_TOP_N_SIGMA} ({@code -1.0} = disabled) + */ + public float getTopNSigma() { + return topNSigma; + } + + /** + * Sets the top-n-sigma sampling threshold (temperature-invariant truncation; -1.0 disables it). + * + * @param topNSigma top-n-sigma threshold; {@code -1.0} disables it + */ + public void setTopNSigma(final float topNSigma) { + this.topNSigma = topNSigma; + } + /** * Returns whether the model's chat-template thinking mode is enabled. * @@ -317,6 +330,244 @@ public void setChatTemplateEnableThinking(final boolean chatTemplateEnableThinki this.chatTemplateEnableThinking = chatTemplateEnableThinking; } + /** + * Returns whether llama.cpp prompt caching is enabled for this model. + * + * @return {@code true} to reuse the shared prompt-prefix KV across files; + * defaults to {@link AiGenerationConfig#DEFAULT_CACHE_PROMPT} + */ + public boolean isCachePrompt() { + return cachePrompt; + } + + /** + * Sets whether llama.cpp prompt caching ({@code cache_prompt}) is enabled for this model. + * + * @param cachePrompt {@code true} keeps the prompt-template prefix warm in the KV cache and + * reuses it per file (only the differing source is re-prefilled); output is unchanged + */ + public void setCachePrompt(final boolean cachePrompt) { + this.cachePrompt = cachePrompt; + } + + /** + * Returns whether the full-size SWA KV cache is kept ({@code --swa-full}) for this model. + * + * @return {@code true} to keep full SWA KV; defaults to {@link AiGenerationConfig#DEFAULT_SWA_FULL} + */ + public boolean isSwaFull() { + return swaFull; + } + + /** + * Sets whether the full-size SWA KV cache is kept ({@code --swa-full}) for this model. + * + * @param swaFull {@code true} keeps full SWA KV (enables cross-request prefix reuse, more RAM) + */ + public void setSwaFull(final boolean swaFull) { + this.swaFull = swaFull; + } + + /** + * Returns the KV prefix-reuse minimum chunk size ({@code --cache-reuse}) for this model. + * + * @return cache-reuse chunk size; defaults to {@link AiGenerationConfig#DEFAULT_CACHE_REUSE} (0 = off) + */ + public int getCacheReuse() { + return cacheReuse; + } + + /** + * Sets the KV prefix-reuse minimum chunk size ({@code --cache-reuse}) for this model. + * + * @param cacheReuse chunk size in tokens ({@code 0} = disabled) + */ + public void setCacheReuse(final int cacheReuse) { + this.cacheReuse = cacheReuse; + } + + /** + * Returns the GPU layer offload count ({@code --gpu-layers}) for this model. + * + * @return GPU layers; defaults to {@link AiGenerationConfig#DEFAULT_GPU_LAYERS} (-1 = leave default) + */ + public int getGpuLayers() { + return gpuLayers; + } + + /** + * Sets the GPU layer offload count ({@code --gpu-layers}) for this model. + * + * @param gpuLayers GPU layers ({@code -1} = leave default, {@code 0} = force CPU, {@code >0} = offload) + */ + public void setGpuLayers(final int gpuLayers) { + this.gpuLayers = gpuLayers; + } + + /** + * Returns the primary GPU index ({@code --main-gpu}) for this model. + * + * @return the GPU index; defaults to {@link AiGenerationConfig#DEFAULT_MAIN_GPU} (-1 = leave default) + */ + public int getMainGpu() { + return mainGpu; + } + + /** + * Sets the primary GPU index ({@code --main-gpu}) for this model. + * + * @param mainGpu the GPU index ({@code -1} = leave default; a non-negative value selects that device) + */ + public void setMainGpu(final int mainGpu) { + this.mainGpu = mainGpu; + } + + /** + * Returns the device selection ({@code --device}) for this model. + * + * @return the comma-separated device list; defaults to {@link AiGenerationConfig#DEFAULT_DEVICES} (empty = leave default) + */ + public String getDevices() { + return devices; + } + + /** + * Sets the device selection ({@code --device}) for this model. A {@code null} argument resets to the empty default. + * + * @param devices the comma-separated backend device names (e.g. {@code Vulkan1}), or {@code null}/empty to leave default + */ + public void setDevices(final String devices) { + this.devices = devices == null ? AiGenerationConfig.DEFAULT_DEVICES : devices; + } + + /** + * Returns the gpt-oss reasoning-effort level for this model. + * + * @return reasoning effort ({@code "low"}/{@code "medium"}/{@code "high"}), or empty to omit it; + * defaults to {@link AiGenerationConfig#DEFAULT_REASONING_EFFORT} + */ + public String getReasoningEffort() { + return reasoningEffort; + } + + /** + * Sets the gpt-oss reasoning-effort level for this model. + * + * @param reasoningEffort {@code "low"}/{@code "medium"}/{@code "high"} (passed as the + * {@code reasoning_effort} chat-template kwarg), or empty/blank to omit it + */ + public void setReasoningEffort(final String reasoningEffort) { + this.reasoningEffort = reasoningEffort; + } + + /** + * Returns the reasoning/think-token budget for this model. + * + * @return budget tokens; defaults to {@link AiGenerationConfig#DEFAULT_REASONING_BUDGET_TOKENS} (-1 = off) + */ + public int getReasoningBudgetTokens() { + return reasoningBudgetTokens; + } + + /** + * Sets the reasoning/think-token budget for this model (caps harmony analysis tokens). + * + * @param reasoningBudgetTokens budget in tokens ({@code -1} = unrestricted, {@code 0} = no thinking) + */ + public void setReasoningBudgetTokens(final int reasoningBudgetTokens) { + this.reasoningBudgetTokens = reasoningBudgetTokens; + } + + /** + * Returns the DRY sampling multiplier for this model. + * + * @return DRY multiplier; defaults to {@link AiGenerationConfig#DEFAULT_DRY_MULTIPLIER} (0.0 = off) + */ + public float getDryMultiplier() { + return dryMultiplier; + } + + /** + * Sets the DRY sampling multiplier for this model. + * + * @param dryMultiplier DRY multiplier ({@code 0.0} = disabled) + */ + public void setDryMultiplier(final float dryMultiplier) { + this.dryMultiplier = dryMultiplier; + } + + /** + * Returns the DRY base for this model. + * + * @return DRY base; defaults to {@link AiGenerationConfig#DEFAULT_DRY_BASE} + */ + public float getDryBase() { + return dryBase; + } + + /** + * Sets the DRY base for this model. + * + * @param dryBase DRY base + */ + public void setDryBase(final float dryBase) { + this.dryBase = dryBase; + } + + /** + * Returns the DRY allowed length for this model. + * + * @return DRY allowed length; defaults to {@link AiGenerationConfig#DEFAULT_DRY_ALLOWED_LENGTH} + */ + public int getDryAllowedLength() { + return dryAllowedLength; + } + + /** + * Sets the DRY allowed length for this model. + * + * @param dryAllowedLength DRY allowed length + */ + public void setDryAllowedLength(final int dryAllowedLength) { + this.dryAllowedLength = dryAllowedLength; + } + + /** + * Returns the DRY penalty look-back window for this model. + * + * @return DRY penalty last-n; defaults to {@link AiGenerationConfig#DEFAULT_DRY_PENALTY_LAST_N} + */ + public int getDryPenaltyLastN() { + return dryPenaltyLastN; + } + + /** + * Sets the DRY penalty look-back window for this model. + * + * @param dryPenaltyLastN DRY penalty last-n ({@code -1} = whole context, {@code 0} = disabled) + */ + public void setDryPenaltyLastN(final int dryPenaltyLastN) { + this.dryPenaltyLastN = dryPenaltyLastN; + } + + /** + * Returns the DRY sequence breakers for this model. + * + * @return DRY sequence breakers, or {@code null} if not configured (use the model/binding default) + */ + public @Nullable List getDrySequenceBreakers() { + return drySequenceBreakers != null ? Collections.unmodifiableList(drySequenceBreakers) : null; + } + + /** + * Sets the DRY sequence breakers (tokens that reset n-gram matching) for this model. + * + * @param drySequenceBreakers collection of sequence breakers, or {@code null} to clear + */ + public void setDrySequenceBreakers(final @Nullable Collection drySequenceBreakers) { + this.drySequenceBreakers = drySequenceBreakers != null ? new ArrayList<>(drySequenceBreakers) : null; + } + /** * Returns the list of stop strings that terminate generation when encountered. * diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java index 2ce4e0e..a412dc5 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupport.java @@ -109,13 +109,26 @@ private static AiGenerationConfig toConfig(final AiModelDefinition definition) { config.setThreads(definition.getThreads()); config.setCharsPerToken(definition.getCharsPerToken()); config.setWarnOnTrim(definition.isWarnOnTrim()); - config.setMaxRetries(definition.getMaxRetries()); - config.setRetryTemperatureIncrement(definition.getRetryTemperatureIncrement()); config.setTopP(definition.getTopP()); config.setTopK(definition.getTopK()); + config.setMinP(definition.getMinP()); + config.setTopNSigma(definition.getTopNSigma()); config.setRepeatPenalty(definition.getRepeatPenalty()); config.setStopStrings(definition.getStopStrings()); config.setChatTemplateEnableThinking(definition.isChatTemplateEnableThinking()); + config.setCachePrompt(definition.isCachePrompt()); + config.setSwaFull(definition.isSwaFull()); + config.setCacheReuse(definition.getCacheReuse()); + config.setGpuLayers(definition.getGpuLayers()); + config.setMainGpu(definition.getMainGpu()); + config.setDevices(definition.getDevices()); + config.setReasoningEffort(definition.getReasoningEffort()); + config.setReasoningBudgetTokens(definition.getReasoningBudgetTokens()); + config.setDryMultiplier(definition.getDryMultiplier()); + config.setDryBase(definition.getDryBase()); + config.setDryAllowedLength(definition.getDryAllowedLength()); + config.setDryPenaltyLastN(definition.getDryPenaltyLastN()); + config.setDrySequenceBreakers(definition.getDrySequenceBreakers()); return config; } } diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiRangeCondition.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiRangeCondition.java new file mode 100644 index 0000000..6da350a --- /dev/null +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/config/AiRangeCondition.java @@ -0,0 +1,88 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import lombok.ToString; + +/** + * A numeric range leaf used by {@link AiCondition} for the {@code size} (bytes) and {@code lines} + * conditions. The lower bound {@link #min} is exclusive and the upper bound {@link #max} is + * inclusive; either is disabled when {@code <= 0}. Adjacent, non-overlapping ranges are + * therefore written as {@code range2.min == range1.max} (a value exactly on the boundary belongs to the + * lower range). + * + *

Mutable JavaBean so the Maven plugin framework can populate {@code }/{@code }.

+ */ +@ToString +public class AiRangeCondition { + + private long min; + private long max; + + /** Creates a new {@link AiRangeCondition}. */ + public AiRangeCondition() { + // no-op + } + + /** + * Returns the exclusive lower bound ({@code <= 0} disables it). + * + * @return the exclusive lower bound + */ + public long getMin() { + return min; + } + + /** + * Sets the exclusive lower bound. + * + * @param min the exclusive lower bound ({@code <= 0} disables it) + */ + public void setMin(final long min) { + this.min = min; + } + + /** + * Returns the inclusive upper bound ({@code <= 0} disables it). + * + * @return the inclusive upper bound + */ + public long getMax() { + return max; + } + + /** + * Sets the inclusive upper bound. + * + * @param max the inclusive upper bound ({@code <= 0} disables it) + */ + public void setMax(final long max) { + this.max = max; + } + + /** + * Returns {@code true} when {@code value} is within this range (exclusive lower, inclusive upper). + * + * @param value the value to test + * @return {@code true} if the value is in range + */ + public boolean contains(final long value) { + if (min > 0 && value <= min) { + return false; + } + if (max > 0 && value > max) { + return false; + } + return true; + } + + /** + * Returns {@code true} when at least one bound is set (a usable range). + * + * @return {@code true} if {@code min} or {@code max} is positive + */ + public boolean hasBound() { + return min > 0 || max > 0; + } +} diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupport.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupport.java index ef8db90..e92d328 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupport.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupport.java @@ -18,6 +18,7 @@ import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPreparedPrompt; import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport; import net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider; +import net.ladenthin.maven.llamacpp.aiindex.support.AiGenerationTimeEstimator; import net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper; import org.apache.maven.plugin.logging.Log; @@ -59,67 +60,56 @@ public class AiFieldGenerationSupport { private static final String EMPTY_OUTPUT_WARN_PREFIX = "AI provider returned empty body for "; /** - * Log message prefix for info messages emitted at the start of each retry attempt, - * showing the attempt number and the escalated sampling temperature. + * Separator used to construct the cache key for the computed {@code maxInputChars} + * per {@code (aiDefinitionKey, promptKey)} pair. * - * @see #processFieldGenerations + * @see #computeMaxInputCharsKey */ - private static final String RETRY_ATTEMPT_INFO_PREFIX = "Retrying AI generation (attempt "; + private static final String CACHE_KEY_SEPARATOR = ":"; - /** - * Log message fragment inserted between the attempt index and the maximum retry count - * in retry-attempt info messages. - * - * @see #processFieldGenerations - */ - private static final String RETRY_OF_INFIX = "/"; + /** Bytes per kibibyte, used to render the source size in the per-file processing log. */ + private static final int KIBIBYTES_DIVISOR = 1024; - /** - * Log message fragment inserted before the prompt key in retry-attempt info messages. - * - * @see #processFieldGenerations - */ - private static final String RETRY_FIELD_INFIX = ") for field '"; + /** Size label used in the processing log line for sources smaller than one kibibyte. */ + private static final String SIZE_BELOW_ONE_KIB_LABEL = "<1"; - /** - * Log message fragment inserted before the escalated temperature value in retry-attempt - * info messages. - * - * @see #processFieldGenerations - */ - private static final String RETRY_TEMPERATURE_INFIX = "' temperature="; + /** Prefix of the per-file processing/ETA log line. */ + private static final String PROCESSING_LOG_PREFIX = "Processing "; - /** - * Log message suffix appended after temperature data in retry-attempt info messages. - * - * @see #processFieldGenerations - */ - private static final String RETRY_CONTEXT_SUFFIX = " for "; + /** Infix introducing the estimated source size in the processing log line. */ + private static final String PROCESSING_LOG_SIZE_INFIX = " ("; - /** - * Log message fragment showing the temperature escalation calculation formula in - * retry-attempt info messages (e.g., " (baseTemp=0.15 + attempt 1 × 0.15)"). - * - * @see #processFieldGenerations - */ - private static final String RETRY_TEMPERATURE_CALCULATION_TEMPLATE = " (baseTemp={0} + attempt {1} × {2})"; + /** Unit/infix for the source size and token estimate in the processing log line. */ + private static final String PROCESSING_LOG_TOKENS_INFIX = " KB source, ~"; + + /** Infix introducing the estimated duration in the processing log line. ASCII-only for CI logs. */ + private static final String PROCESSING_LOG_ETA_INFIX = " tokens) - estimated "; /** - * Separator used to construct the cache key for the computed {@code maxInputChars} - * per {@code (aiDefinitionKey, promptKey)} pair. - * - * @see #computeMaxInputCharsKey + * Suffix on the processing log line stressing that the duration is a rough, + * hardware-specific estimate (see {@link AiGenerationTimeEstimator}). ASCII-only for CI logs. */ - private static final String CACHE_KEY_SEPARATOR = ":"; + private static final String PROCESSING_LOG_DISCLAIMER = + " (rough; calibrated on reference CPU + gpt-oss-20b - actual depends on your hardware)"; + + /** Prefix of the per-file actual-duration log line emitted after generation completes. */ + private static final String GENERATED_LOG_PREFIX = "Generated "; + + /** Infix between the file path and the measured wall-clock duration in the actual-duration line. */ + private static final String GENERATED_LOG_IN_INFIX = "' in "; /** - * Rounding granularity applied when computing the final {@code maxInputChars} value. - * The available character count is rounded DOWN to the nearest multiple of this value - * to produce a conservative, human-readable result. - * - * @see #calculateAndLogMaxInputChars + * Infix introducing the estimate for side-by-side comparison in the actual-duration line, so a real + * run shows measured-vs-estimated per file (lets you compare models/quants in live runs without a + * separate benchmark). ASCII-only for CI logs. */ - private static final int MAX_INPUT_CHARS_ROUNDING = 100; + private static final String GENERATED_LOG_ACTUAL_INFIX = " (actual; estimated "; + + /** Suffix closing the actual-duration log line. */ + private static final String GENERATED_LOG_SUFFIX = ")"; + + /** Nanoseconds per second, used to convert the measured generation duration to whole seconds. */ + private static final long NANOS_PER_SECOND = 1_000_000_000L; // Maven plugin Log — its default toString prints implementation details // (logger configuration, output stream state); excluded from the rendered output. @@ -130,6 +120,7 @@ public class AiFieldGenerationSupport { private final AiPromptPreparationSupport promptPreparationSupport; private final AiModelDefinitionSupport modelDefinitionSupport; private final Java8CompatibilityHelper compatibilityHelper = new Java8CompatibilityHelper(); + private final AiGenerationTimeEstimator timeEstimator = new AiGenerationTimeEstimator(); /** * Per-{@code (aiDefinitionKey, promptKey)} cache of the computed {@code maxInputChars} @@ -167,11 +158,11 @@ public AiFieldGenerationSupport( *
  • A trim warning is logged if the source was truncated and * {@link net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig#isWarnOnTrim()} is {@code true}.
  • *
  • The AI provider generates a value for the trimmed source.
  • - *
  • If the provider returns a blank body, up to {@link net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig#getMaxRetries()} - * retry attempts are made, each using a temperature of - * {@code temperature + attempt * retryTemperatureIncrement} to escape - * EOS-early failure modes. Each retry is logged at INFO level. - * A warning is only emitted after all retries are exhausted.
  • + *
  • If the provider returns a blank body, a single warning is emitted (fail-fast). + * Blank output no longer occurs in normal operation with a non-greedy temperature + * and an adequate output budget; the previous escalating-temperature retry loop was + * removed after it was shown to waste full generations re-inferring to the same empty + * result (see {@code docs/ai-index-benchmark/gpt-oss-tuning.md}, E2).
  • *
  • The generated value is stored as the document body.
  • * * @@ -225,45 +216,34 @@ public AiGenerationResult processFieldGenerations( final AiGenerationRequest generationRequest = new AiGenerationRequest( fieldGeneration.getPromptKey(), contextFile, preparedPrompt.sourceText(), baseHeader); + final int processedSourceChars = preparedPrompt.sourceText().length(); + final String sourceSizeKb = sourceText.length() < KIBIBYTES_DIVISOR + ? SIZE_BELOW_ONE_KIB_LABEL + : Integer.toString(sourceText.length() / KIBIBYTES_DIVISOR); + final long estimatedSeconds = timeEstimator.estimateSeconds(processedSourceChars); + log.info(PROCESSING_LOG_PREFIX + contextType + " '" + contextFile + "'" + + PROCESSING_LOG_SIZE_INFIX + sourceSizeKb + + PROCESSING_LOG_TOKENS_INFIX + timeEstimator.estimatePromptTokens(processedSourceChars) + + PROCESSING_LOG_ETA_INFIX + + timeEstimator.formatDuration(estimatedSeconds) + + PROCESSING_LOG_DISCLAIMER); + log.info("Generating field '" + fieldGeneration.getPromptKey() + "' with temperature=" - + generationConfig.getTemperature() + ", maxRetries=" - + generationConfig.getMaxRetries() + ", retryTemperatureIncrement=" - + generationConfig.getRetryTemperatureIncrement() + ", maxInputChars=" + + generationConfig.getTemperature() + ", maxInputChars=" + effectiveMaxInputChars); + final long generationStartNanos = System.nanoTime(); body = generationProvider.generate(generationRequest); + final long actualSeconds = (System.nanoTime() - generationStartNanos) / NANOS_PER_SECOND; + + // Log the MEASURED wall-clock duration next to the estimate so real runs are directly + // comparable across models/quants without a separate benchmark harness. + log.info(GENERATED_LOG_PREFIX + contextType + " '" + contextFile + GENERATED_LOG_IN_INFIX + + timeEstimator.formatDuration(actualSeconds) + GENERATED_LOG_ACTUAL_INFIX + + timeEstimator.formatDuration(estimatedSeconds) + GENERATED_LOG_SUFFIX); if (compatibilityHelper.isBlank(body)) { - final int maxRetries = generationConfig.getMaxRetries(); - for (int attempt = 1; attempt <= maxRetries && compatibilityHelper.isBlank(body); attempt++) { - // Escalate temperature with each retry to break out of EOS-early failure modes. - // Formula: baseTemp + (attempt * increment) - // Example with baseTemp=0.4, increment=0.2: - // - Attempt 1: 0.4 + (1 × 0.2) = 0.6 - // - Attempt 2: 0.4 + (2 × 0.2) = 0.8 - // - Attempt 3: 0.4 + (3 × 0.2) = 1.0 - final float retryTemperature = generationConfig.getTemperature() - + attempt * generationConfig.getRetryTemperatureIncrement(); - final String temperatureCalculation = RETRY_TEMPERATURE_CALCULATION_TEMPLATE - .replace("{0}", String.valueOf(generationConfig.getTemperature())) - .replace("{1}", String.valueOf(attempt)) - .replace("{2}", String.valueOf(generationConfig.getRetryTemperatureIncrement())); - log.info(RETRY_ATTEMPT_INFO_PREFIX - + attempt - + RETRY_OF_INFIX - + maxRetries - + RETRY_FIELD_INFIX - + fieldGeneration.getPromptKey() - + RETRY_TEMPERATURE_INFIX - + retryTemperature - + temperatureCalculation - + RETRY_CONTEXT_SUFFIX - + contextFile); - body = generationProvider.generate(generationRequest, retryTemperature); - } - if (compatibilityHelper.isBlank(body)) { - log.warn(EMPTY_OUTPUT_WARN_PREFIX + contextType + TRIM_WARN_FIELD_LABEL - + fieldGeneration.getPromptKey() + "': " + contextFile); - } + log.warn(EMPTY_OUTPUT_WARN_PREFIX + contextType + TRIM_WARN_FIELD_LABEL + fieldGeneration.getPromptKey() + + "': " + contextFile); } } @@ -338,7 +318,8 @@ private int calculateAndLogMaxInputChars(final AiGenerationConfig config, final final int safetyChars = AiGenerationConfig.DEFAULT_SAFETY_MARGIN_CHARS; final int overheadTotal = promptChars + eofChars + outputChars + safetyChars; final int availableChars = totalChars - overheadTotal; - final int finalChars = Math.max(0, (availableChars / MAX_INPUT_CHARS_ROUNDING) * MAX_INPUT_CHARS_ROUNDING); + // Single source of truth for the threshold shared with the planning path (SourceFileIndexer.classify). + final int finalChars = AiInputWindowCalculator.maxInputChars(config, basePromptLength); log.info("Maximum input characters for source code before trimming. Calculated as: (context_size x " + charsPerToken + ") - overhead"); diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiIndexPlan.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiIndexPlan.java new file mode 100644 index 0000000..c0f56b2 --- /dev/null +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiIndexPlan.java @@ -0,0 +1,423 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.indexer; + +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig; +import net.ladenthin.maven.llamacpp.aiindex.support.AiGenerationTimeEstimator; + +/** + * The routing plan for one {@code generate} run: which files each AI model will index (with which + * prompt), which files are skipped, and which matched no rule. + * + *

    Built in a planning pass before any inference so the user sees the full mapping up front + * (see {@link #renderMarkdown}) and a misconfiguration fails fast. Routed files are grouped by + * {@code aiDefinitionKey} (the model id, which carries the full parameter set) so the executor can load + * each model exactly once.

    + */ +public final class AiIndexPlan { + + /** A single planned file together with the rule that routed it and its rough time estimate. */ + public static final class Entry { + private final Path file; + private final AiFieldGenerationConfig rule; + private final long estimatedSeconds; + private final boolean windowChecked; + private final long sourceChars; + private final long availableSourceChars; + + /** + * Creates a plan entry. + * + * @param file the source file + * @param rule the rule that selected it + * @param estimatedSeconds the rough estimated generation time in seconds + * @param windowChecked whether the context-window fit was computed for this entry + * @param sourceChars the source length in characters fed to the model (when checked) + * @param availableSourceChars the source-character budget of the routed model+prompt (when checked) + */ + public Entry( + final Path file, + final AiFieldGenerationConfig rule, + final long estimatedSeconds, + final boolean windowChecked, + final long sourceChars, + final long availableSourceChars) { + this.file = file; + this.rule = rule; + this.estimatedSeconds = estimatedSeconds; + this.windowChecked = windowChecked; + this.sourceChars = sourceChars; + this.availableSourceChars = availableSourceChars; + } + + /** + * Returns the source file. + * + * @return the source file + */ + public Path file() { + return file; + } + + /** + * Returns the rule that routed the file. + * + * @return the routing rule + */ + public AiFieldGenerationConfig rule() { + return rule; + } + + /** + * Returns the rough estimated generation time in seconds. + * + * @return the estimated seconds + */ + public long estimatedSeconds() { + return estimatedSeconds; + } + + /** + * Returns whether the context-window fit was computed for this entry. + * + * @return {@code true} when window data is available + */ + public boolean windowChecked() { + return windowChecked; + } + + /** + * Returns the source length in characters fed to the model (meaningful only when + * {@link #windowChecked()} is {@code true}). + * + * @return the source character count + */ + public long sourceChars() { + return sourceChars; + } + + /** + * Returns the source-character budget of the routed model+prompt (meaningful only when + * {@link #windowChecked()} is {@code true}). + * + * @return the available source-character budget + */ + public long availableSourceChars() { + return availableSourceChars; + } + + /** + * Returns whether this file exceeds the routed model's context window and would be trimmed. + * + * @return {@code true} when checked and the source exceeds the window budget + */ + public boolean exceedsWindow() { + return windowChecked && sourceChars > availableSourceChars; + } + } + + private final Map> routesByModel = new LinkedHashMap<>(); + private final List skipped = new ArrayList<>(); + private final List unmatched = new ArrayList<>(); + + /** Creates an empty plan. */ + public AiIndexPlan() { + // no-op + } + + /** + * Records a routed file under its model id. + * + * @param aiDefinitionKey the model id (rule's {@code aiDefinitionKey}) + * @param file the source file + * @param rule the routing rule + * @param estimatedSeconds the rough estimated generation time in seconds + */ + public void addRoute( + final String aiDefinitionKey, + final Path file, + final AiFieldGenerationConfig rule, + final long estimatedSeconds) { + routesByModel + .computeIfAbsent(aiDefinitionKey, key -> new ArrayList<>()) + .add(new Entry(file, rule, estimatedSeconds, false, 0L, 0L)); + } + + /** + * Records a routed file under its model id together with its context-window fit. + * + * @param aiDefinitionKey the model id (rule's {@code aiDefinitionKey}) + * @param file the source file + * @param rule the routing rule + * @param estimatedSeconds the rough estimated generation time in seconds + * @param sourceChars the source length in characters fed to the model + * @param availableSourceChars the source-character budget of the routed model+prompt + */ + public void addRoute( + final String aiDefinitionKey, + final Path file, + final AiFieldGenerationConfig rule, + final long estimatedSeconds, + final long sourceChars, + final long availableSourceChars) { + routesByModel + .computeIfAbsent(aiDefinitionKey, key -> new ArrayList<>()) + .add(new Entry(file, rule, estimatedSeconds, true, sourceChars, availableSourceChars)); + } + + /** + * Records a skipped (ignored) file. + * + * @param file the source file + */ + public void addSkipped(final Path file) { + skipped.add(file); + } + + /** + * Records a file that matched no rule and no fallback (a fatal misconfiguration). + * + * @param file the source file + */ + public void addUnmatched(final Path file) { + unmatched.add(file); + } + + /** + * Returns the routed files grouped by model id, in first-seen order. + * + * @return an order-preserving map of model id to its planned entries + */ + public Map> routesByModel() { + return routesByModel; + } + + /** + * Returns the skipped files. + * + * @return the skipped files + */ + public List skipped() { + return skipped; + } + + /** + * Returns the files that matched no rule and no fallback. + * + * @return the unmatched files + */ + public List unmatched() { + return unmatched; + } + + /** + * Returns the total number of routed files across all models. + * + * @return the routed file count + */ + public int routedCount() { + int total = 0; + for (final List entries : routesByModel.values()) { + total += entries.size(); + } + return total; + } + + /** + * Returns the number of routed files whose source exceeds the routed model's context window + * (would be trimmed). Zero when no window check was performed. + * + * @return the count of over-window files + */ + public int windowExceededCount() { + int total = 0; + for (final List entries : routesByModel.values()) { + for (final Entry entry : entries) { + if (entry.exceedsWindow()) { + total++; + } + } + } + return total; + } + + /** + * Returns the summed estimated seconds for one model's entries. + * + * @param entries the model's planned entries + * @return the total estimated seconds + */ + private long modelSeconds(final List entries) { + long total = 0; + for (final Entry entry : entries) { + total += entry.estimatedSeconds(); + } + return total; + } + + /** + * Returns the grand total of estimated seconds across all routed files. + * + * @return the total estimated seconds + */ + public long totalEstimatedSeconds() { + long total = 0; + for (final List entries : routesByModel.values()) { + total += modelSeconds(entries); + } + return total; + } + + /** + * Renders the plan as a Markdown document for the build log: a summary, one section + table per + * model (file → prompt → rough time estimate) with a per-model subtotal, a grand total, and the + * skipped / unmatched lists. Markdown so it can be copied straight out of the console. Paths are + * relative to {@code baseDir}; the time column is a rough estimate (see {@code AiGenerationTimeEstimator}). + * + * @param baseDir directory to relativize file paths against for readability + * @return the Markdown document + */ + public String renderMarkdown(final Path baseDir) { + final AiGenerationTimeEstimator estimator = new AiGenerationTimeEstimator(); + final StringBuilder sb = new StringBuilder(); + sb.append("## AI index plan\n\n"); + sb.append("**Total:** ") + .append(routedCount()) + .append(" file(s) across ") + .append(routesByModel.size()) + .append(" model(s), est. ") + .append(estimator.formatDuration(totalEstimatedSeconds())) + .append(" - ") + .append(skipped.size()) + .append(" skipped, ") + .append(unmatched.size()) + .append(" unmatched, ") + .append(windowExceededCount()) + .append(" over window _(time is a rough estimate)_\n"); + for (final Map.Entry> group : routesByModel.entrySet()) { + final List entries = group.getValue(); + sb.append("\n### Model `") + .append(group.getKey()) + .append("` - ") + .append(entries.size()) + .append(" file(s), est. ") + .append(estimator.formatDuration(modelSeconds(entries))) + .append("\n\n| File | Rule | Prompt | Window | Est. |\n|---|---|---|---|---|\n"); + for (final Entry entry : entries) { + sb.append("| ") + .append(relativize(baseDir, entry.file())) + .append(" | ") + .append(ruleId(entry.rule())) + .append(" | ") + .append(entry.rule().getPromptKey()) + .append(" | ") + .append(windowCell(entry)) + .append(" | ") + .append(estimator.formatDuration(entry.estimatedSeconds())) + .append(" |\n"); + } + } + if (!skipped.isEmpty()) { + sb.append("\n### Skipped (").append(skipped.size()).append(")\n\n"); + for (final Path file : skipped) { + sb.append("- ").append(relativize(baseDir, file)).append("\n"); + } + } + if (!unmatched.isEmpty()) { + sb.append("\n### (!) Unmatched - no rule and no fallback (") + .append(unmatched.size()) + .append(")\n\n"); + for (final Path file : unmatched) { + sb.append("- ").append(relativize(baseDir, file)).append("\n"); + } + } + appendWindowExceededSection(sb, baseDir); + return sb.toString(); + } + + /** + * Appends the section listing files whose source exceeds the routed model's context window (would be + * trimmed): each file with its model, source chars and the window budget, so the user can route it to + * a larger-window model. + * + * @param sb the buffer to append to + * @param baseDir the base directory for relativizing paths + */ + private void appendWindowExceededSection(final StringBuilder sb, final Path baseDir) { + final int count = windowExceededCount(); + if (count == 0) { + return; + } + sb.append("\n### (!) Over window - source exceeds the model's context window, would be trimmed (") + .append(count) + .append(")\n\n"); + for (final Map.Entry> group : routesByModel.entrySet()) { + for (final Entry entry : group.getValue()) { + if (entry.exceedsWindow()) { + sb.append("- ") + .append(relativize(baseDir, entry.file())) + .append(" -> model `") + .append(group.getKey()) + .append("` (source ") + .append(entry.sourceChars()) + .append(" chars > window ") + .append(entry.availableSourceChars()) + .append(" chars)\n"); + } + } + } + sb.append("\nThis fails the build. Add a rule with a size that routes") + .append(" these files to a model with a large enough context window (config only; the build") + .append(" never picks a model for you).\n"); + } + + /** + * Returns the per-entry "Window" cell: {@code "-"} when not checked, {@code "ok"} when it fits, or a + * {@code "(!) X>Y"} marker (source chars vs budget) when the source exceeds the window. + * + * @param entry the plan entry + * @return the window cell text + */ + private String windowCell(final Entry entry) { + if (!entry.windowChecked()) { + return "-"; + } + if (entry.exceedsWindow()) { + return "(!) " + entry.sourceChars() + ">" + entry.availableSourceChars(); + } + return "ok"; + } + + /** + * Returns the rule's id for display, or {@code "-"} when the rule has no id set. + * + * @param rule the routing rule + * @return the rule id, or {@code "-"} + */ + private String ruleId(final AiFieldGenerationConfig rule) { + final String id = rule.getId(); + return id != null ? id : "-"; + } + + /** + * Relativizes {@code file} against {@code baseDir} with {@code /} separators, falling back to the + * absolute path when relativization is not possible. + * + * @param baseDir the base directory + * @param file the file + * @return a display path + */ + private String relativize(final Path baseDir, final Path file) { + try { + return baseDir.relativize(file).toString().replace('\\', '/'); + } catch (final IllegalArgumentException e) { + return file.toString().replace('\\', '/'); + } + } +} diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiInputWindowCalculator.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiInputWindowCalculator.java new file mode 100644 index 0000000..c5b082c --- /dev/null +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiInputWindowCalculator.java @@ -0,0 +1,90 @@ +// @formatter:off +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +// @formatter:on +package net.ladenthin.maven.llamacpp.aiindex.indexer; + +import net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig; +import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport; + +/** + * Pure calculator for the input window: how many source characters fit a model's context window + * before the source must be trimmed, and whether a given source would exceed it. + * + *

    This is the single source of truth for the trim threshold. Both the run path + * ({@link AiFieldGenerationSupport}, which trims and warns) and the planning path + * ({@link SourceFileIndexer#classify}, which flags over-window files up front) use it, so the plan's + * prediction matches what the run actually does.

    + * + *

    The budget mirrors the runtime trim check in + * {@link AiPromptPreparationSupport#preparePrompt}: the rendered prompt (template + source) must fit + * {@link #maxInputChars(AiGenerationConfig, int)}; since the template ({@code basePromptLength}) is + * fixed, the source budget is {@link #availableSourceChars(AiGenerationConfig, int)} and a source is + * trimmed when its length exceeds it.

    + */ +public final class AiInputWindowCalculator { + + /** + * Rounding granularity (in characters) applied to the computed maximum input size, kept + * conservative (rounds down) so the value is a safe, human-readable multiple. + */ + public static final int MAX_INPUT_CHARS_ROUNDING = 100; + + /** Utility class; not instantiable. */ + private AiInputWindowCalculator() { + // no-op + } + + /** + * Returns the maximum number of characters of the rendered prompt (template + source) that fit the + * model's context window before trimming. Mirrors the runtime computation: when + * {@link AiGenerationConfig#getCharsPerToken()} is {@code <= 0} the static + * {@link AiGenerationConfig#getMaxInputChars()} fallback is used (e.g. mock-based tests); otherwise + * it is {@code (contextSize x charsPerToken)} minus the prompt-template, EOF-marker, reserved-output + * and safety-margin overhead, rounded down to a {@link #MAX_INPUT_CHARS_ROUNDING} multiple. + * + * @param config the model generation config + * @param basePromptLength the length of the rendered prompt template with an empty source + * @return the maximum rendered-prompt length in characters (never negative) + */ + public static int maxInputChars(final AiGenerationConfig config, final int basePromptLength) { + if (config.getCharsPerToken() <= 0) { + return config.getMaxInputChars(); + } + final int totalChars = config.getContextSize() * config.getCharsPerToken(); + final int overhead = basePromptLength + + AiPromptPreparationSupport.EOF_MARKER_LENGTH + + config.getMaxOutputTokens() * config.getCharsPerToken() + + AiGenerationConfig.DEFAULT_SAFETY_MARGIN_CHARS; + final int available = totalChars - overhead; + return Math.max(0, (available / MAX_INPUT_CHARS_ROUNDING) * MAX_INPUT_CHARS_ROUNDING); + } + + /** + * Returns how many characters of source fit before trimming: the + * {@link #maxInputChars(AiGenerationConfig, int)} budget minus the fixed prompt template + * ({@code basePromptLength}). Never negative. + * + * @param config the model generation config + * @param basePromptLength the length of the rendered prompt template with an empty source + * @return the source-character budget (never negative) + */ + public static long availableSourceChars(final AiGenerationConfig config, final int basePromptLength) { + return Math.max(0L, (long) maxInputChars(config, basePromptLength) - basePromptLength); + } + + /** + * Returns whether a source of the given length would be trimmed because it does not fit the model's + * window. Equivalent to the runtime trim trigger: {@code sourceChars > availableSourceChars}. + * + * @param config the model generation config + * @param basePromptLength the length of the rendered prompt template with an empty source + * @param sourceChars the source length in characters + * @return {@code true} when the source would be trimmed (exceeds the window) + */ + public static boolean exceedsWindow( + final AiGenerationConfig config, final int basePromptLength, final long sourceChars) { + return sourceChars > availableSourceChars(config, basePromptLength); + } +} diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/ProjectIndexer.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/ProjectIndexer.java index c298933..2dce903 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/ProjectIndexer.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/ProjectIndexer.java @@ -208,7 +208,8 @@ public ProjectIndexer( final AiFieldGenerationConfig copy = new AiFieldGenerationConfig(); copy.setPromptKey(source.getPromptKey()); copy.setAiDefinitionKey(source.getAiDefinitionKey()); - copy.setFileExtensions(source.getFileExtensions()); + // The project-overview generation uses a single field generation; per-file routing fields + // (condition/priority/skip/fallback) do not apply, so only prompt + model are copied. return copy; } diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexer.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexer.java index 2bf44ae..8067f52 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexer.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexer.java @@ -12,8 +12,12 @@ import java.util.List; import java.util.stream.Stream; import lombok.ToString; +import net.ladenthin.maven.llamacpp.aiindex.config.AiCondition; +import net.ladenthin.maven.llamacpp.aiindex.config.AiConditionEvaluator; import net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig; import net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationSelector; +import net.ladenthin.maven.llamacpp.aiindex.config.AiFileContext; +import net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig; import net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport; import net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationResult; import net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocument; @@ -22,9 +26,8 @@ import net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderCodec; import net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderSupport; import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport; -import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport; -import net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider; import net.ladenthin.maven.llamacpp.aiindex.support.AiChecksumSupport; +import net.ladenthin.maven.llamacpp.aiindex.support.AiGenerationTimeEstimator; import net.ladenthin.maven.llamacpp.aiindex.support.AiPathSupport; import net.ladenthin.maven.llamacpp.aiindex.support.AiSourceExcludeFilter; import net.ladenthin.maven.llamacpp.aiindex.support.AiTimeSupport; @@ -33,13 +36,22 @@ import org.jspecify.annotations.Nullable; /** - * Walks the configured source subtrees, creates per-file {@code .ai.md} index files, - * and fills in their AI-generated summary and keyword fields. + * Walks the configured source subtrees and writes per-file {@code .ai.md} index files. * - *

    {@code toString} is generated by Lombok over the configuration and collaborator - * fields. The Maven {@link Log} is excluded because its default {@code toString} prints - * implementation details (logger configuration, output stream state) that are noisy - * and not useful for build-log diagnostics. + *

    Split into three steps so the {@code generate} goal can plan the whole run before any inference, + * show the model/prompt mapping up front, and load each model exactly once:

    + *
      + *
    1. {@link #collectCandidates(Path)} — walk a source root applying the extension, subtree, exclude + * and goal-level size-band filters.
    2. + *
    3. {@link #classify(Collection, List)} — route each candidate to a rule (prompt + model), a skip, + * or unmatched, producing an {@link AiIndexPlan}.
    4. + *
    5. {@link #indexFile(Path, AiFieldGenerationConfig, AiFieldGenerationSupport)} — write one file's + * {@code .ai.md} with a given rule, using a provider-bearing support (one per model group).
    6. + *
    + * + *

    {@code toString} is generated by Lombok over the configuration fields. The Maven {@link Log} is + * excluded because its default {@code toString} prints implementation details that are noisy in + * build-log diagnostics.

    */ @ToString public class SourceFileIndexer { @@ -62,10 +74,10 @@ public class SourceFileIndexer { private final String aiVersion; private final List subtrees; private final AiSourceExcludeFilter excludeFilter; + private final long minFileSizeBytes; + private final long maxFileSizeBytes; private final boolean force; - private final @Nullable List fieldGenerations; - private final AiPathSupport pathSupport = new AiPathSupport(); private final AiTimeSupport timeSupport = new AiTimeSupport(); private final AiChecksumSupport checksumSupport = new AiChecksumSupport(); @@ -73,26 +85,26 @@ public class SourceFileIndexer { private final AiMdDocumentCodec documentCodec = new AiMdDocumentCodec(); private final Java8CompatibilityHelper compatibilityHelper = new Java8CompatibilityHelper(); private final AiFieldGenerationSelector fieldGenerationSelector = new AiFieldGenerationSelector(); - - private final AiFieldGenerationSupport fieldGenerationSupport; + private final AiConditionEvaluator conditionEvaluator = new AiConditionEvaluator(); + private final AiGenerationTimeEstimator timeEstimator = new AiGenerationTimeEstimator(); /** - * Creates a new {@link SourceFileIndexer}. + * Creates a new {@link SourceFileIndexer}. The AI provider and rules are supplied later + * ({@link #classify(Collection, List)} / {@link #indexFile}) so a run can load a separate model per + * routing group. * - * @param log Maven plugin logger - * @param baseDirectory project base directory - * @param outputRoot root directory in which {@code .ai.md} files are written - * @param fileExtensions file extensions to index; may be empty (matches no files) - * @param pluginVersion plugin version recorded in headers - * @param aiVersion AI summarisation logic version recorded in headers - * @param subtrees source subtrees in scope; may be empty - * @param excludes glob patterns (relative to {@code baseDirectory}, {@code /} - * separators) for source files to skip; may be {@code null} or empty - * @param force when {@code true}, regenerate even when fields are populated - * @param generationProvider AI provider used to generate fields - * @param fieldGenerations field generation configurations; may be {@code null} - * @param promptSupport prompt lookup - * @param modelDefinitionSupport AI model definition lookup + * @param log Maven plugin logger + * @param baseDirectory project base directory + * @param outputRoot root directory in which {@code .ai.md} files are written + * @param fileExtensions file extensions to index; may be empty (matches no files) + * @param pluginVersion plugin version recorded in headers + * @param aiVersion AI summarisation logic version recorded in headers + * @param subtrees source subtrees in scope; may be empty + * @param excludes glob patterns (relative to {@code baseDirectory}, {@code /} separators) + * for source files to skip; may be {@code null} or empty + * @param minFileSizeBytes exclusive lower size bound in bytes ({@code <= 0} disables it) + * @param maxFileSizeBytes inclusive upper size bound in bytes ({@code <= 0} = unlimited) + * @param force when {@code true}, regenerate even when fields are populated */ public SourceFileIndexer( final Log log, @@ -103,11 +115,9 @@ public SourceFileIndexer( final String aiVersion, final Collection subtrees, final @Nullable Collection excludes, - final boolean force, - final AiGenerationProvider generationProvider, - final @Nullable Collection fieldGenerations, - final AiPromptSupport promptSupport, - final AiModelDefinitionSupport modelDefinitionSupport) { + final long minFileSizeBytes, + final long maxFileSizeBytes, + final boolean force) { this.log = log; this.baseDirectory = baseDirectory; this.outputRoot = outputRoot; @@ -116,78 +126,137 @@ public SourceFileIndexer( this.aiVersion = aiVersion; this.subtrees = new ArrayList<>(subtrees); this.excludeFilter = new AiSourceExcludeFilter(excludes); + this.minFileSizeBytes = minFileSizeBytes; + this.maxFileSizeBytes = maxFileSizeBytes; this.force = force; - this.fieldGenerations = fieldGenerations != null ? new ArrayList<>(fieldGenerations) : null; - this.fieldGenerationSupport = new AiFieldGenerationSupport( - log, generationProvider, new AiPromptPreparationSupport(promptSupport), modelDefinitionSupport); } /** - * Indexes every matching file beneath {@code sourceRoot}. + * Returns every file beneath {@code sourceRoot} that passes the extension, subtree, exclude and + * size-band filters — the candidate set for routing. * * @param sourceRoot source root directory to walk - * @return number of source-file index files written or refreshed - * @throws IOException if a file cannot be read or written + * @return the matching candidate files, in walk order + * @throws IOException if the tree cannot be walked or a file size cannot be read */ - public int indexSourceRoot(final Path sourceRoot) throws IOException { - int count = 0; - + public List collectCandidates(final Path sourceRoot) throws IOException { + final List candidates = new ArrayList<>(); try (Stream stream = Files.walk(sourceRoot)) { - for (Path path : compatibilityHelper.toList(stream.filter(Files::isRegularFile))) { + for (final Path path : compatibilityHelper.toList(stream.filter(Files::isRegularFile))) { if (!matchesExtension(path)) { continue; } - if (!matchesSubtree(path)) { continue; } - if (isExcluded(path)) { log.debug("Excluded from indexing: " + path); continue; } - - writeAiFile(path); - count++; + if (!matchesSize(path)) { + log.debug("Outside configured size band, skipped: " + path); + continue; + } + candidates.add(path); } } - - return count; + return candidates; } /** - * Returns {@code true} when {@code path} matches a configured exclude glob. The path is - * relativised against {@link #baseDirectory} and normalised to {@code /} separators before - * matching, so the same pattern behaves identically on Windows and POSIX. + * Routes each candidate file to a rule, producing the {@link AiIndexPlan}. * - * @param path absolute source file path encountered during the walk - * @return {@code true} if the file should be skipped + *

    For every file the selector picks the winning rule by extension/size/lines and priority; a + * skip rule sends the file to {@link AiIndexPlan#skipped()}, no match (and no fallback) to + * {@link AiIndexPlan#unmatched()}, otherwise the file is routed under the rule's + * {@code aiDefinitionKey}. Line counts are only computed when some rule actually uses a line filter, + * so the common size-only configuration does not read file contents during planning.

    + * + * @param candidates the candidate files (typically from {@link #collectCandidates(Path)}) + * @param rules the routing rules in declaration order + * @return the routing plan + * @throws IOException if a file size or content cannot be read */ - private boolean isExcluded(final Path path) { - final String relative = baseDirectory.relativize(path).toString().replace('\\', '/'); - return excludeFilter.isExcluded(relative); + public AiIndexPlan classify(final Collection candidates, final List rules) + throws IOException { + return classify(candidates, rules, null, null); } - private boolean matchesExtension(final Path path) { - final Path fileNamePath = path.getFileName(); - if (fileNamePath == null) { - return false; - } - final String fileName = fileNamePath.toString(); - for (String extension : fileExtensions) { - if (fileName.endsWith(extension)) { - return true; + /** + * Plans the run as {@link #classify(Collection, List)} and, when both supports are provided, also + * computes each routed file's context-window fit: it resolves the routed model's + * {@code contextSize}/sampling config and the prompt template length, derives the source-character + * budget via {@link AiInputWindowCalculator} (the same threshold the run uses to trim), and records + * whether the file would be trimmed. This lets the plan flag over-window files up front (and the + * goal fail fast) instead of silently trimming them at run time. Pass {@code null} supports to skip + * the window check. + * + * @param candidates the candidate files (typically from {@link #collectCandidates(Path)}) + * @param rules the routing rules in declaration order + * @param modelDefinitionSupport model-config lookup by key, or {@code null} to skip the window check + * @param promptPreparationSupport prompt-template helper, or {@code null} to skip the window check + * @return the routing plan + * @throws IOException if a file size or content cannot be read + */ + public AiIndexPlan classify( + final Collection candidates, + final List rules, + final @Nullable AiModelDefinitionSupport modelDefinitionSupport, + final @Nullable AiPromptPreparationSupport promptPreparationSupport) + throws IOException { + final boolean lineFiltersUsed = anyRuleUsesLines(rules); + final AiIndexPlan plan = new AiIndexPlan(); + for (final Path file : candidates) { + final Path fileNamePath = file.getFileName(); + final String fileName = fileNamePath != null ? fileNamePath.toString() : file.toString(); + final long fileSizeBytes = Files.size(file); + final int lineCount = lineFiltersUsed ? countLines(compatibilityHelper.readString(file)) : 0; + final String relativePath = + baseDirectory.relativize(file).toString().replace('\\', '/'); + final long lastModified = Files.getLastModifiedTime(file).toMillis(); + final AiFileContext context = + new AiFileContext(fileName, relativePath, fileSizeBytes, lineCount, lastModified); + + final AiFieldGenerationConfig rule = fieldGenerationSelector.select(rules, context); + if (rule == null) { + plan.addUnmatched(file); + } else if (rule.isSkip()) { + plan.addSkipped(file); + } else { + final long estimatedSeconds = + timeEstimator.estimateSeconds((int) Math.min(fileSizeBytes, Integer.MAX_VALUE)); + if (modelDefinitionSupport != null && promptPreparationSupport != null) { + final AiGenerationConfig modelConfig = modelDefinitionSupport.getConfig(rule.getAiDefinitionKey()); + final int basePromptLength = + promptPreparationSupport.getBasePromptLength(rule.getPromptKey(), file); + final long availableSourceChars = + AiInputWindowCalculator.availableSourceChars(modelConfig, basePromptLength); + final long sourceChars = + compatibilityHelper.readString(file).length(); + plan.addRoute( + rule.getAiDefinitionKey(), file, rule, estimatedSeconds, sourceChars, availableSourceChars); + } else { + plan.addRoute(rule.getAiDefinitionKey(), file, rule, estimatedSeconds); + } } } - return false; + return plan; } - private void writeAiFile(final Path sourceFile) throws IOException { - if (fieldGenerations == null || fieldGenerations.isEmpty()) { - throw new IllegalArgumentException( - "No field generations configured for source file indexing of " + sourceFile); - } - + /** + * Writes the {@code .ai.md} for one source file using the given rule and a provider-bearing + * support. Honours the incremental-skip rule: an up-to-date target (matching source checksum, no + * {@code force}) is left untouched. + * + * @param sourceFile the source file + * @param rule the routing rule selected for it (supplies the prompt key) + * @param support the field-generation support holding the model group's provider + * @return {@code true} if the file was (re)written, {@code false} if it was already up to date + * @throws IOException if the file cannot be read or written + */ + public boolean indexFile( + final Path sourceFile, final AiFieldGenerationConfig rule, final AiFieldGenerationSupport support) + throws IOException { final Path relativeToBase = pathSupport.relativizeFromSrc(baseDirectory, sourceFile); final Path targetFile = outputRoot .resolve(relativeToBase.toString() + AiMdHeaderCodec.AI_MD_EXTENSION) @@ -217,37 +286,117 @@ private void writeAiFile(final Path sourceFile) throws IOException { if (!headerSupport.shouldWrite(force, targetFile, baseHeader)) { log.info("Unchanged AI index file: " + targetFile); - return; + return false; } final String sourceText = compatibilityHelper.readString(sourceFile); - final AiFieldGenerationConfig selected = fieldGenerationSelector.selectForFileName(fieldGenerations, fileName); - if (selected == null) { - throw new IllegalArgumentException("No field generation matches file '" + fileName - + "' and no extension-agnostic fallback is configured: " + sourceFile); - } - - final AiGenerationResult result = fieldGenerationSupport.processFieldGenerations( - Collections.singletonList(selected), sourceFile, CONTEXT_TYPE_FILE, sourceText, baseHeader); + final AiGenerationResult result = support.processFieldGenerations( + Collections.singletonList(rule), sourceFile, CONTEXT_TYPE_FILE, sourceText, baseHeader); final AiMdDocument document = new AiMdDocument(baseHeader, result.body()); documentCodec.write(targetFile, document); log.info("Wrote AI index file: " + targetFile); + return true; + } + + /** + * Returns {@code true} when at least one rule's condition uses a {@code lines} leaf, so planning + * knows whether it must read file contents to count lines. + * + * @param rules the routing rules + * @return {@code true} if any rule's condition uses a line count + */ + private boolean anyRuleUsesLines(final List rules) { + for (final AiFieldGenerationConfig rule : rules) { + if (rule == null) { + continue; + } + final AiCondition condition = rule.getCondition(); + if (condition != null && conditionEvaluator.usesLines(condition)) { + return true; + } + } + return false; + } + + /** + * Returns {@code true} when {@code path} matches a configured exclude glob. The path is + * relativised against {@link #baseDirectory} and normalised to {@code /} separators before matching. + * + * @param path absolute source file path encountered during the walk + * @return {@code true} if the file should be skipped + */ + private boolean isExcluded(final Path path) { + final String relative = baseDirectory.relativize(path).toString().replace('\\', '/'); + return excludeFilter.isExcluded(relative); + } + + /** + * Returns {@code true} when {@code path}'s size on disk falls within the goal-level size band + * (exclusive lower {@link #minFileSizeBytes}, inclusive upper {@link #maxFileSizeBytes}; each + * disabled when {@code <= 0}). + * + * @param path absolute source file path encountered during the walk + * @return {@code true} if the file is within the band + * @throws IOException if the file size cannot be read + */ + private boolean matchesSize(final Path path) throws IOException { + final long size = Files.size(path); + if (minFileSizeBytes > 0 && size <= minFileSizeBytes) { + return false; + } + if (maxFileSizeBytes > 0 && size > maxFileSizeBytes) { + return false; + } + return true; + } + + /** + * Counts the lines in {@code text} for the line-based prompt selector: the number of newline + * characters, plus one when the text is non-empty and does not end with a newline (so a trailing + * newline does not add a phantom empty line). An empty file counts as zero lines. + * + * @param text the source text + * @return the line count + */ + private int countLines(final String text) { + if (text.isEmpty()) { + return 0; + } + int newlines = 0; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '\n') { + newlines++; + } + } + return text.charAt(text.length() - 1) == '\n' ? newlines : newlines + 1; + } + + private boolean matchesExtension(final Path path) { + final Path fileNamePath = path.getFileName(); + if (fileNamePath == null) { + return false; + } + final String fileName = fileNamePath.toString(); + for (final String extension : fileExtensions) { + if (fileName.endsWith(extension)) { + return true; + } + } + return false; } private boolean matchesSubtree(final Path path) { if (subtrees == null || subtrees.isEmpty()) { return true; } - - for (Path subtree : subtrees) { + for (final Path subtree : subtrees) { if (path.startsWith(subtree)) { return true; } } - return false; } } diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AbstractAiIndexMojo.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AbstractAiIndexMojo.java index cd3630a..0a1bcaf 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AbstractAiIndexMojo.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/AbstractAiIndexMojo.java @@ -233,21 +233,7 @@ protected int sizeOf(final Collection collection) { */ protected LlamaCppJniConfig buildLlamaCppJniConfig() throws MojoExecutionException { if (fieldGenerations != null && !fieldGenerations.isEmpty()) { - final AiFieldGenerationConfig first = fieldGenerations.get(0); - final AiGenerationConfig config = buildAiModelDefinitionSupport().getConfig(first.getAiDefinitionKey()); - final List stopStrings = config.getStopStrings(); - return new LlamaCppJniConfig( - llamaLibraryPath, - config.getModelPath(), - config.getContextSize(), - config.getMaxOutputTokens(), - config.getTemperature(), - config.getThreads(), - config.getTopP(), - config.getTopK(), - config.getRepeatPenalty(), - config.isChatTemplateEnableThinking(), - stopStrings != null ? stopStrings : Collections.emptyList()); + return buildLlamaCppJniConfig(fieldGenerations.get(0).getAiDefinitionKey()); } return new LlamaCppJniConfig( llamaLibraryPath, @@ -258,11 +244,69 @@ protected LlamaCppJniConfig buildLlamaCppJniConfig() throws MojoExecutionExcepti getLlamaThreads(), AiGenerationConfig.DEFAULT_TOP_P, AiGenerationConfig.DEFAULT_TOP_K, + AiGenerationConfig.DEFAULT_MIN_P, + AiGenerationConfig.DEFAULT_TOP_N_SIGMA, AiGenerationConfig.DEFAULT_REPEAT_PENALTY, AiGenerationConfig.DEFAULT_CHAT_TEMPLATE_ENABLE_THINKING, + AiGenerationConfig.DEFAULT_CACHE_PROMPT, + AiGenerationConfig.DEFAULT_SWA_FULL, + AiGenerationConfig.DEFAULT_CACHE_REUSE, + AiGenerationConfig.DEFAULT_GPU_LAYERS, + AiGenerationConfig.DEFAULT_MAIN_GPU, + AiGenerationConfig.DEFAULT_DEVICES, + AiGenerationConfig.DEFAULT_REASONING_EFFORT, + AiGenerationConfig.DEFAULT_REASONING_BUDGET_TOKENS, + AiGenerationConfig.DEFAULT_DRY_MULTIPLIER, + AiGenerationConfig.DEFAULT_DRY_BASE, + AiGenerationConfig.DEFAULT_DRY_ALLOWED_LENGTH, + AiGenerationConfig.DEFAULT_DRY_PENALTY_LAST_N, + Collections.emptyList(), Collections.emptyList()); } + /** + * Builds a {@link net.ladenthin.maven.llamacpp.aiindex.provider.LlamaCppJniConfig} from a specific + * AI model definition, identified by its key. Used by the {@code generate} goal to load a separate + * model per routing group (one provider per distinct {@code aiDefinitionKey}). + * + * @param aiDefinitionKey the {@link net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinition} key + * @return fully populated llama.cpp configuration for that definition + * @throws IllegalArgumentException if {@code aiDefinitionKey} matches no registered definition + * @throws MojoExecutionException propagated from {@link #buildAiModelDefinitionSupport()} + */ + protected LlamaCppJniConfig buildLlamaCppJniConfig(final String aiDefinitionKey) throws MojoExecutionException { + final AiGenerationConfig config = buildAiModelDefinitionSupport().getConfig(aiDefinitionKey); + final List stopStrings = config.getStopStrings(); + final List drySequenceBreakers = config.getDrySequenceBreakers(); + return new LlamaCppJniConfig( + llamaLibraryPath, + config.getModelPath(), + config.getContextSize(), + config.getMaxOutputTokens(), + config.getTemperature(), + config.getThreads(), + config.getTopP(), + config.getTopK(), + config.getMinP(), + config.getTopNSigma(), + config.getRepeatPenalty(), + config.isChatTemplateEnableThinking(), + config.isCachePrompt(), + config.isSwaFull(), + config.getCacheReuse(), + config.getGpuLayers(), + config.getMainGpu(), + config.getDevices(), + config.getReasoningEffort(), + config.getReasoningBudgetTokens(), + config.getDryMultiplier(), + config.getDryBase(), + config.getDryAllowedLength(), + config.getDryPenaltyLastN(), + drySequenceBreakers != null ? drySequenceBreakers : Collections.emptyList(), + stopStrings != null ? stopStrings : Collections.emptyList()); + } + /** * Builds an {@link net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport} from the configured {@link #promptDefinitions}. * diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/GenerateMojo.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/GenerateMojo.java index 148c36a..e00bbab 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/GenerateMojo.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/mojo/GenerateMojo.java @@ -5,13 +5,21 @@ import java.io.IOException; import java.nio.file.Path; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import lombok.ToString; +import net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationSelector; import net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport; +import net.ladenthin.maven.llamacpp.aiindex.indexer.AiFieldGenerationSupport; +import net.ladenthin.maven.llamacpp.aiindex.indexer.AiIndexPlan; import net.ladenthin.maven.llamacpp.aiindex.indexer.SourceFileIndexer; +import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport; import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport; import net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider; import net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProviderFactory; +import net.ladenthin.maven.llamacpp.aiindex.support.AiGenerationTimeEstimator; +import net.ladenthin.maven.llamacpp.aiindex.support.AiProgressBar; import net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -40,6 +48,9 @@ public GenerateMojo() { */ private static final String DEFAULT_FILE_EXTENSION = ".java"; + /** Nanoseconds per second, for converting the measured run elapsed time to whole seconds. */ + private static final long NANOS_PER_SECOND = 1_000_000_000L; + /** * Phase switch for the file phase (the {@code generate} goal): when {@code true}, * only this phase is skipped. The global {@link #skip} still skips every phase. @@ -67,6 +78,25 @@ public GenerateMojo() { @Parameter(property = "aiIndex.excludes") private List excludes; + /** + * Exclusive lower file-size bound in bytes: source files whose size is {@code <= this} are skipped. + * {@code 0} (default) disables the lower bound. Together with {@link #maxFileSizeBytes} this lets one + * {@code generate} execution target a size band, so several executions (each with its own model, + * context size and prompt) can tier a project by file size while the source-checksum skip indexes + * every file exactly once. Use non-overlapping bands ({@code band2.min == band1.max}); make the last + * band unbounded ({@code maxFileSizeBytes=0}) so files above all bands still get indexed. + */ + @Parameter(property = "aiIndex.file.minSizeBytes", defaultValue = "0") + private long minFileSizeBytes; + + /** + * Inclusive upper file-size bound in bytes: source files whose size is {@code > this} are skipped. + * {@code 0} (default) disables the upper bound (unlimited). See {@link #minFileSizeBytes} for the + * size-tiering pattern. + */ + @Parameter(property = "aiIndex.file.maxSizeBytes", defaultValue = "0") + private long maxFileSizeBytes; + /** llama.cpp context window size; smaller default suits the fast generate pass. */ @Parameter(property = "aiIndex.llama.contextSize", defaultValue = "2048") private int llamaContextSize; @@ -75,6 +105,14 @@ public GenerateMojo() { @Parameter(property = "aiIndex.llama.threads", defaultValue = "2") private int llamaThreads; + /** + * When {@code true}, only build and log the routing plan (which model indexes which files with which + * prompt) and then stop — no model is loaded and nothing is generated. Useful to verify routing + * before a long run. + */ + @Parameter(property = "aiIndex.planOnly", defaultValue = "false") + private boolean planOnly; + private final Java8CompatibilityHelper compatibilityHelper = new Java8CompatibilityHelper(); @Override @@ -107,46 +145,122 @@ public void execute() throws MojoExecutionException { logExecutionParameters( "Starting AI index generation", basePath, outputPath, resolvedSubtrees, resolvedExtensions); - try { - final AiPromptSupport promptSupport = buildPromptSupport(); - final AiModelDefinitionSupport modelDefinitionSupport = buildAiModelDefinitionSupport(); - final AiGenerationProviderFactory providerFactory = new AiGenerationProviderFactory(); + if (fieldGenerations == null || fieldGenerations.isEmpty()) { + throw new MojoExecutionException("No configured for the generate goal."); + } - try (AiGenerationProvider provider = - providerFactory.create(generationProvider, buildLlamaCppJniConfig(), promptSupport)) { - - final SourceFileIndexer fileIndexer = new SourceFileIndexer( - getLog(), - basePath, - outputPath, - resolvedExtensions, - pluginVersion, - aiVersion, - resolvedSubtrees, - excludes, - force, - provider, - fieldGenerations, - promptSupport, - modelDefinitionSupport); - - int count = 0; - - for (Path subtree : resolvedSubtrees.isEmpty() - ? compatibilityHelper.listOf(basePath.resolve("src/main/java")) - : resolvedSubtrees) { - - if (!subtree.toFile().exists()) { - getLog().warn("Skipping missing subtree: " + subtree); - continue; - } + final AiPromptSupport promptSupport = buildPromptSupport(); + final AiModelDefinitionSupport modelDefinitionSupport = buildAiModelDefinitionSupport(); + final AiPromptPreparationSupport promptPreparationSupport = new AiPromptPreparationSupport(promptSupport); + final AiFieldGenerationSelector selector = new AiFieldGenerationSelector(); + // Fail fast on a bad rule set (e.g. >1 fallback, a route rule missing prompt/model). + selector.validate(fieldGenerations); - count += fileIndexer.indexSourceRoot(subtree); + final SourceFileIndexer fileIndexer = new SourceFileIndexer( + getLog(), + basePath, + outputPath, + resolvedExtensions, + pluginVersion, + aiVersion, + resolvedSubtrees, + excludes, + minFileSizeBytes, + maxFileSizeBytes, + force); + + try { + // 1. Collect candidate files across the configured subtrees. + final List candidates = new ArrayList<>(); + for (final Path subtree : resolvedSubtrees.isEmpty() + ? compatibilityHelper.listOf(basePath.resolve("src/main/java")) + : resolvedSubtrees) { + if (!subtree.toFile().exists()) { + getLog().warn("Skipping missing subtree: " + subtree); + continue; } + candidates.addAll(fileIndexer.collectCandidates(subtree)); + } + + // 2. Plan the run: which model + prompt each file gets (or skip / unmatched), and whether + // each file fits its routed model's context window (computed up front, same threshold the + // run uses to trim — see AiInputWindowCalculator). + final AiIndexPlan plan = fileIndexer.classify( + candidates, fieldGenerations, modelDefinitionSupport, promptPreparationSupport); + getLog().info("AI index plan (Markdown):\n" + plan.renderMarkdown(basePath)); + + // 3. A file that matched no rule and no fallback is a fatal misconfiguration. + if (!plan.unmatched().isEmpty()) { + throw new MojoExecutionException(plan.unmatched().size() + + " source file(s) matched no rule and no fallback is configured; " + + "add a rule or a matching rule (see the plan above)."); + } + + // 3b. A file larger than its routed model's window would lose content if trimmed. This is + // ALWAYS a hard failure (planOnly and real run alike). The fix is user configuration, + // never an automatic model choice: the user must add a routing rule ( + // with a size ) that sends oversized files to a model with a large enough + // context window. The plugin deliberately does not pick a model for you. + final int overWindowCount = plan.windowExceededCount(); + if (overWindowCount > 0) { + throw new MojoExecutionException(overWindowCount + + " source file(s) exceed their routed model's context window (see the 'Over window' " + + "section in the plan above). Add a rule with a size " + + "that routes these files to a model with a large enough context window (see the " + + "big-window fallback example in the POM). The build does not pick a model for you; " + + "this is configuration only."); + } - getLog().info("Generated AI files: " + count); + if (planOnly) { + getLog().info("planOnly=true: stopping after the plan; no model loaded, nothing generated."); + return; } + // 4. Execute model group by model group: load each model once, index its files, close. + // Progress is the running sum of each finished file's PLAN estimate over the grand total + // (no re-estimation), logged as a bar + percent after every file, with the estimated time + // left and the actual wall-clock elapsed for comparison. + final AiGenerationProviderFactory providerFactory = new AiGenerationProviderFactory(); + final AiGenerationTimeEstimator estimator = new AiGenerationTimeEstimator(); + final long totalEstimatedSeconds = plan.totalEstimatedSeconds(); + final int totalFiles = plan.routedCount(); + final long runStartNanos = System.nanoTime(); + long doneEstimatedSeconds = 0; + int doneFiles = 0; + int wrote = 0; + int unchanged = 0; + for (final Map.Entry> group : + plan.routesByModel().entrySet()) { + final String aiDefinitionKey = group.getKey(); + getLog().info("Loading model '" + aiDefinitionKey + "' for " + + group.getValue().size() + " file(s)"); + try (AiGenerationProvider provider = providerFactory.create( + generationProvider, buildLlamaCppJniConfig(aiDefinitionKey), promptSupport)) { + final AiFieldGenerationSupport support = new AiFieldGenerationSupport( + getLog(), provider, promptPreparationSupport, modelDefinitionSupport); + for (final AiIndexPlan.Entry entry : group.getValue()) { + if (fileIndexer.indexFile(entry.file(), entry.rule(), support)) { + wrote++; + } else { + unchanged++; + } + doneEstimatedSeconds += entry.estimatedSeconds(); + doneFiles++; + final long elapsedSeconds = (System.nanoTime() - runStartNanos) / NANOS_PER_SECOND; + final long remainingSeconds = Math.max(0L, totalEstimatedSeconds - doneEstimatedSeconds); + getLog().info(AiProgressBar.render(doneEstimatedSeconds, totalEstimatedSeconds) + + " " + doneFiles + "/" + totalFiles + " files - est. " + + estimator.formatDuration(doneEstimatedSeconds) + "/" + + estimator.formatDuration(totalEstimatedSeconds) + " done, " + + estimator.formatDuration(remainingSeconds) + " left (estimate) | " + + estimator.formatDuration(elapsedSeconds) + " elapsed (actual)"); + } + } + } + + getLog().info("Generated AI files: " + wrote + " written, " + unchanged + " unchanged, " + + plan.skipped().size() + " skipped"); + } catch (IOException e) { throw new MojoExecutionException( "Failed to generate AI index files under " + outputPath + " from base " + basePath, e); diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupport.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupport.java index 6806515..6833061 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupport.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupport.java @@ -110,7 +110,9 @@ public int getBasePromptLength(final String promptKey, final java.nio.file.Path * @return the source trimmed at the last newline at or before {@code targetIndex}, * or the entire source if no newline is found before the index */ - private String trimSourceAtLineBreak(final String sourceText, final int targetIndex) { + // Package-private (not private) so the line-boundary trimming branches can be unit-tested + // directly; the method is not part of the public API. + String trimSourceAtLineBreak(final String sourceText, final int targetIndex) { if (targetIndex >= sourceText.length()) { return sourceText; } diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupport.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupport.java index 8dea753..b8234ed 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupport.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupport.java @@ -15,6 +15,16 @@ @ToString public final class AiPromptSupport { + /** Separator between the name line and the body within the user message. */ + private static final String USER_NAME_BODY_SEPARATOR = "\n\n"; + + /** + * Separator used only to concatenate the system instructions and the user message for length + * budgeting in {@link AiPromptPreparationSupport}; at inference time the provider sends the two + * parts as a separate system and user message. + */ + private static final String SYSTEM_USER_SEPARATOR = "\n\n"; + private final Map templates; private final Java8CompatibilityHelper compatibilityHelper = new Java8CompatibilityHelper(); @@ -73,24 +83,53 @@ public String buildPrompt(final AiGenerationRequest request) { } /** - * Builds the prompt string for the given key, file, and source text without - * requiring a full {@link net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest}. Useful when only template - * length measurement is needed and no {@link net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader} is available. + * Builds the combined system + user text for the given key, file, and source text. * - * @param promptKey the key identifying the prompt template - * @param sourceFile the file path substituted as the filename argument - * @param sourceText the source text substituted into the template - * @return the rendered prompt string + *

    This concatenation ({@code systemPrompt + separator + userMessage}) is used only for + * length budgeting / trimming by {@link AiPromptPreparationSupport} and for the + * {@code maxInputChars} calculation; at inference time the provider sends the two parts + * separately — see {@link #systemPrompt(String)} and {@link #userMessage(java.nio.file.Path, String)}.

    + * + * @param promptKey the key identifying the prompt template (system instructions) + * @param sourceFile the file path whose name heads the user message + * @param sourceText the source text delivered in the user message + * @return the combined system + user text * @throws IllegalArgumentException if no template is registered for {@code promptKey} */ public String buildPrompt(final String promptKey, final java.nio.file.Path sourceFile, final String sourceText) { + return systemPrompt(promptKey) + SYSTEM_USER_SEPARATOR + userMessage(sourceFile, sourceText); + } + + /** + * Returns the static system-instruction prompt (the registered template, verbatim) for the + * given key. The template carries no placeholders; the variable file name and content are + * delivered separately via {@link #userMessage(java.nio.file.Path, String)}. + * + * @param promptKey the key identifying the prompt template + * @return the system instructions registered for {@code promptKey} + * @throws IllegalArgumentException if no (non-blank) template is registered for {@code promptKey} + */ + public String systemPrompt(final String promptKey) { final String template = templates.get(promptKey); if (template == null || compatibilityHelper.isBlank(template)) { throw new IllegalArgumentException("Missing prompt template for key: " + promptKey); } + return template; + } + /** + * Builds the user message carrying the variable data: the file (or package/project) name on + * the first line, a blank line, then the body (file source, child summaries, or package leads, + * depending on the prompt). Falls back to the full path when the file name is {@code null} + * (e.g. a filesystem root). + * + * @param sourceFile the file path whose name heads the message + * @param sourceText the body delivered after the name + * @return the user message text + */ + public String userMessage(final java.nio.file.Path sourceFile, final String sourceText) { final java.nio.file.Path fileName = sourceFile.getFileName(); - final Object fileNameArg = fileName != null ? fileName : sourceFile; - return compatibilityHelper.formatted(template, fileNameArg, sourceText); + final Object nameArg = fileName != null ? fileName : sourceFile; + return nameArg + USER_NAME_BODY_SEPARATOR + sourceText; } } diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java index b0affcd..262de49 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProvider.java @@ -21,28 +21,6 @@ public interface AiGenerationProvider extends AutoCloseable { */ String generate(AiGenerationRequest request) throws IOException; - /** - * Generates text for the given request using the specified temperature, overriding any - * temperature configured in the provider itself. - * - *

    This method is called during retry attempts to use a higher temperature than the - * original request, which can break out of EOS-early failure modes that produce empty - * responses. Implementations that support per-call temperature overrides should override - * this method; the default implementation ignores {@code temperatureOverride} and - * delegates to {@link #generate(AiGenerationRequest)}.

    - * - * @param request the generation request containing prompt key, source file, - * source text, and current header - * @param temperatureOverride the sampling temperature to use for this call, replacing - * any temperature value held by the provider's own configuration - * @return the generated text; never {@code null}, but may be blank if the model - * produced no tokens - * @throws IOException if the underlying provider fails - */ - default String generate(final AiGenerationRequest request, final float temperatureOverride) throws IOException { - return generate(request); - } - @Override default void close() throws IOException {} } diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java index 81689d2..8df8580 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProvider.java @@ -5,16 +5,19 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import lombok.ToString; import net.ladenthin.llama.LlamaModel; +import net.ladenthin.llama.args.ReasoningFormat; import net.ladenthin.llama.parameters.InferenceParameters; import net.ladenthin.llama.parameters.ModelParameters; import net.ladenthin.llama.value.Pair; import net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest; import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport; +import net.ladenthin.maven.llamacpp.aiindex.support.Java8CompatibilityHelper; import org.jspecify.annotations.Nullable; /** @@ -42,6 +45,24 @@ public final class LlamaCppJniAiGenerationProvider implements AiGenerationProvid private final AiPromptSupport promptSupport; private final AiCompletionParser completionParser = new AiCompletionParser(); + private final Java8CompatibilityHelper compatibilityHelper = new Java8CompatibilityHelper(); + + /** + * Fixed llama.cpp server slot every request is pinned to. The model is loaded once and reused + * for all files; pinning each request to the same slot lets the prompt cache + * ({@code cache_prompt}) reuse the shared prompt-template prefix's KV across files instead of + * re-prefilling it for every file. Reuse is exact, so generated output is unchanged. + */ + private static final int REUSE_SLOT_ID = 0; + + /** Chat-template kwarg controlling Qwen-style thinking (ignored by non-Qwen templates). */ + private static final String ENABLE_THINKING_KWARG = "enable_thinking"; + + /** Chat-template kwarg for the gpt-oss reasoning-effort level (ignored by non-gpt-oss templates). */ + private static final String REASONING_EFFORT_KWARG = "reasoning_effort"; + + /** Number of chat-template kwargs put into the map (used for presizing). */ + private static final int CHAT_TEMPLATE_KWARG_COUNT = 2; /** * Creates a new {@link LlamaCppJniAiGenerationProvider}; the GGUF model is loaded lazily on the first generate(...) call. @@ -58,12 +79,47 @@ public LlamaCppJniAiGenerationProvider(final LlamaCppJniConfig config, final AiP private LlamaModel model() { LlamaModel current = model; if (current == null) { + final Map chatTemplateKwargs = + new HashMap<>(compatibilityHelper.hashMapCapacityFor(CHAT_TEMPLATE_KWARG_COUNT)); + chatTemplateKwargs.put(ENABLE_THINKING_KWARG, String.valueOf(config.chatTemplateEnableThinking())); + // gpt-oss honors reasoning_effort; non-gpt-oss chat templates ignore it. An empty + // configured value omits the kwarg so the model's own template default applies. + if (!compatibilityHelper.isBlank(config.reasoningEffort())) { + chatTemplateKwargs.put(REASONING_EFFORT_KWARG, config.reasoningEffort()); + } final ModelParameters modelParameters = new ModelParameters() .setModel(config.modelPath()) .setCtxSize(config.contextSize()) .setThreads(config.threads()) - .setChatTemplateKwargs(Collections.singletonMap( - "enable_thinking", String.valueOf(config.chatTemplateEnableThinking()))); + // Parse reasoning channels (Qwen , gpt-oss harmony analysis) into + // reasoning_content so message content stays clean (final channel only). + .setReasoningFormat(ReasoningFormat.AUTO) + .setChatTemplateKwargs(chatTemplateKwargs); + // Keep the full-size SWA KV cache so the sliding-window layers' KV is reusable across + // files (restores prompt-prefix reuse for gpt-oss), at the cost of more KV RAM. + if (config.swaFull()) { + modelParameters.enableSwaFull(); + } + // Enable cross-request KV prefix reuse (min chunk size in tokens) when configured. + if (config.cacheReuse() > 0) { + modelParameters.setCacheReuse(config.cacheReuse()); + } + // Offload model layers to the GPU when explicitly configured (>= 0). -1 leaves the + // binding/native-build default (CPU build stays CPU; GPU build uses its own default). + if (config.gpuLayers() >= 0) { + modelParameters.setGpuLayers(config.gpuLayers()); + } + // Pick a specific GPU when configured (>= 0). Matters on multi-GPU hosts: a Vulkan build + // enumerates every GPU (an integrated GPU may be device 0), so the default can select the + // slower one. -1 leaves the binding/native-build default. + if (config.mainGpu() >= 0) { + modelParameters.setMainGpu(config.mainGpu()); + } + // Explicit device selection (comma-separated backend device names, e.g. "Vulkan1") takes + // precedence over a single main-GPU index. Empty leaves the binding/native-build default. + if (!config.devices().isEmpty()) { + modelParameters.setDevices(config.devices()); + } current = new LlamaModel(modelParameters); model = current; } @@ -72,31 +128,49 @@ private LlamaModel model() { @Override public String generate(final AiGenerationRequest request) throws IOException { - return generate(request, config.temperature()); - } - - @Override - public String generate(final AiGenerationRequest request, final float temperatureOverride) throws IOException { - final String prompt = promptSupport.buildPrompt(request); + // Static instructions go in the SYSTEM message (byte-identical across files, so its KV + // prefix is reused by cache_prompt); the variable file name + source go in the USER message. + final String systemPrompt = promptSupport.systemPrompt(request.promptKey()); + final String userMessage = promptSupport.userMessage(request.sourceFile(), request.sourceText()); final List> messages = new ArrayList<>(); - messages.add(new Pair<>("user", prompt)); - - // withMessages(systemMessage, ...) accepts null upstream to omit the system message, - // but it is unannotated, so Checker Framework infers @NonNull. - // InferenceParameters uses immutable withers (jllama 5.0.2): each with* returns a new - // instance, so withStopStrings is folded into the single chain rather than a separate - // mutating call. - @SuppressWarnings("argument") - final InferenceParameters inferenceParameters = new InferenceParameters("") - .withMessages(null, messages) + messages.add(new Pair<>("user", userMessage)); + + // InferenceParameters uses immutable withers: each with* returns a new instance, so the + // whole request is built as a single chain. + final InferenceParameters baseParameters = new InferenceParameters("") + .withMessages(systemPrompt, messages) .withUseChatTemplate(true) - .withTemperature(temperatureOverride) + .withTemperature(config.temperature()) .withNPredict(config.maxOutputTokens()) .withTopP(config.topP()) .withTopK(config.topK()) + .withMinP(config.minP()) + .withTopNSigma(config.topNSigma()) .withRepeatPenalty(config.repeatPenalty()) - .withStopStrings(config.stopStrings().toArray(new String[0])); + // Cap harmony analysis (reasoning) tokens so a runaway chain-of-thought cannot + // starve the final answer; -1 (default) = unrestricted, so behaviour is unchanged. + .withReasoningBudgetTokens(config.reasoningBudgetTokens()) + // DRY (Don't Repeat Yourself) repetition suppression; multiplier 0.0 (default) = off, + // so the base/allowed-length/penalty-last-n knobs have no effect unless opted in. + .withDryMultiplier(config.dryMultiplier()) + .withDryBase(config.dryBase()) + .withDryAllowedLength(config.dryAllowedLength()) + .withDryPenaltyLastN(config.dryPenaltyLastN()) + .withStopStrings(config.stopStrings().toArray(new String[0])) + // Keep the shared prompt-template prefix warm in the KV cache and reuse it across + // files (pinned to one slot); only the differing source is re-prefilled. + // Reuse is exact -> output unchanged. + .withCachePrompt(config.cachePrompt()) + .withSlotId(REUSE_SLOT_ID); + + // Only override the DRY sequence breakers when explicitly configured; an empty list keeps + // the binding/model default set instead of clearing it. + final InferenceParameters inferenceParameters = + config.drySequenceBreakers().isEmpty() + ? baseParameters + : baseParameters.withDrySequenceBreakers( + config.drySequenceBreakers().toArray(new String[0])); return completionParser.parseCompletion(model().chatCompleteText(inferenceParameters)); } diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java index 1f95e3b..644a435 100644 --- a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniConfig.java @@ -15,7 +15,7 @@ * *

    Record-shaped value type marked {@link net.ladenthin.maven.llamacpp.aiindex.support.ConvertToRecord} for the future Java 17+ * migration. Accessors are record-style. {@code equals}, {@code hashCode} and - * {@code toString} are generated by Lombok over all eleven fields; full value semantics + * {@code toString} are generated by Lombok over all twenty-six fields; full value semantics * apply. Lombok emits the exact-bit float comparison * ({@code Float.floatToIntBits}) automatically.

    */ @@ -31,8 +31,23 @@ public final class LlamaCppJniConfig { private final int threads; private final float topP; private final int topK; + private final float minP; + private final float topNSigma; private final float repeatPenalty; private final boolean chatTemplateEnableThinking; + private final boolean cachePrompt; + private final boolean swaFull; + private final int cacheReuse; + private final int gpuLayers; + private final int mainGpu; + private final String devices; + private final String reasoningEffort; + private final int reasoningBudgetTokens; + private final float dryMultiplier; + private final float dryBase; + private final int dryAllowedLength; + private final int dryPenaltyLastN; + private final List drySequenceBreakers; private final List stopStrings; /** @@ -46,8 +61,23 @@ public final class LlamaCppJniConfig { * @param threads number of CPU threads * @param topP nucleus-sampling probability threshold * @param topK top-k sampling limit + * @param minP min-p sampling threshold ({@code 0.0} = disabled) + * @param topNSigma top-n-sigma sampling threshold ({@code -1.0} = disabled) * @param repeatPenalty repetition penalty * @param chatTemplateEnableThinking whether chat-template thinking mode is enabled + * @param cachePrompt whether llama.cpp prompt caching ({@code cache_prompt}) is enabled + * @param swaFull whether to keep the full-size SWA KV cache ({@code --swa-full}) + * @param cacheReuse KV prefix-reuse minimum chunk size ({@code --cache-reuse}); 0 = off + * @param gpuLayers GPU layers to offload ({@code --gpu-layers}); -1 = leave default + * @param mainGpu primary GPU index ({@code --main-gpu}); -1 = leave default + * @param devices device selection ({@code --device}); empty = leave default + * @param reasoningEffort gpt-oss reasoning-effort kwarg value ("low"/"medium"/"high"); empty omits it + * @param reasoningBudgetTokens reasoning/think-token budget ({@code -1} = unrestricted) + * @param dryMultiplier DRY sampling multiplier ({@code 0.0} = disabled) + * @param dryBase DRY base (effective only when {@code dryMultiplier > 0}) + * @param dryAllowedLength DRY allowed length (effective only when {@code dryMultiplier > 0}) + * @param dryPenaltyLastN DRY penalty look-back tokens ({@code -1} = whole context, {@code 0} = off) + * @param drySequenceBreakers DRY sequence breakers; may be {@code null} (treated as empty → binding default) * @param stopStrings stop strings; may be {@code null} (treated as empty) */ public LlamaCppJniConfig( @@ -59,8 +89,23 @@ public LlamaCppJniConfig( int threads, float topP, int topK, + float minP, + float topNSigma, float repeatPenalty, boolean chatTemplateEnableThinking, + boolean cachePrompt, + boolean swaFull, + int cacheReuse, + int gpuLayers, + int mainGpu, + String devices, + String reasoningEffort, + int reasoningBudgetTokens, + float dryMultiplier, + float dryBase, + int dryAllowedLength, + int dryPenaltyLastN, + List drySequenceBreakers, List stopStrings) { Objects.requireNonNull(modelPath, "modelPath"); this.libraryPath = libraryPath; @@ -71,8 +116,23 @@ public LlamaCppJniConfig( this.threads = threads; this.topP = topP; this.topK = topK; + this.minP = minP; + this.topNSigma = topNSigma; this.repeatPenalty = repeatPenalty; this.chatTemplateEnableThinking = chatTemplateEnableThinking; + this.cachePrompt = cachePrompt; + this.swaFull = swaFull; + this.cacheReuse = cacheReuse; + this.gpuLayers = gpuLayers; + this.mainGpu = mainGpu; + this.devices = devices; + this.reasoningEffort = reasoningEffort; + this.reasoningBudgetTokens = reasoningBudgetTokens; + this.dryMultiplier = dryMultiplier; + this.dryBase = dryBase; + this.dryAllowedLength = dryAllowedLength; + this.dryPenaltyLastN = dryPenaltyLastN; + this.drySequenceBreakers = drySequenceBreakers != null ? drySequenceBreakers : Collections.emptyList(); this.stopStrings = stopStrings != null ? stopStrings : Collections.emptyList(); } @@ -148,6 +208,24 @@ public int topK() { return topK; } + /** + * Returns the min-p sampling threshold. + * + * @return min-p threshold ({@code 0.0} = disabled) + */ + public float minP() { + return minP; + } + + /** + * Returns the top-n-sigma sampling threshold. + * + * @return top-n-sigma threshold ({@code -1.0} = disabled) + */ + public float topNSigma() { + return topNSigma; + } + /** * Returns the repetition penalty. * @@ -166,6 +244,123 @@ public boolean chatTemplateEnableThinking() { return chatTemplateEnableThinking; } + /** + * Returns whether llama.cpp prompt caching ({@code cache_prompt}) is enabled. + * + * @return {@code true} when prompt-prefix KV reuse across files is enabled + */ + public boolean cachePrompt() { + return cachePrompt; + } + + /** + * Returns whether the full-size SWA KV cache is kept ({@code --swa-full}). + * + * @return {@code true} when full SWA KV is kept + */ + public boolean swaFull() { + return swaFull; + } + + /** + * Returns the KV prefix-reuse minimum chunk size ({@code --cache-reuse}). + * + * @return cache-reuse chunk size ({@code 0} = disabled) + */ + public int cacheReuse() { + return cacheReuse; + } + + /** + * Returns the number of model layers to offload to the GPU ({@code --gpu-layers}). + * + * @return GPU layers ({@code -1} = leave the binding/build default) + */ + public int gpuLayers() { + return gpuLayers; + } + + /** + * Returns the primary GPU index ({@code --main-gpu}). + * + * @return GPU index ({@code -1} = leave the binding/build default) + */ + public int mainGpu() { + return mainGpu; + } + + /** + * Returns the device selection ({@code --device}). + * + * @return comma-separated device list, or empty to leave the binding/build default + */ + public String devices() { + return devices; + } + + /** + * Returns the gpt-oss reasoning-effort kwarg value. + * + * @return reasoning effort ("low"/"medium"/"high"), or empty to omit the kwarg + */ + public String reasoningEffort() { + return reasoningEffort; + } + + /** + * Returns the reasoning/think-token budget. + * + * @return budget tokens ({@code -1} = unrestricted) + */ + public int reasoningBudgetTokens() { + return reasoningBudgetTokens; + } + + /** + * Returns the DRY sampling multiplier. + * + * @return DRY multiplier ({@code 0.0} = disabled) + */ + public float dryMultiplier() { + return dryMultiplier; + } + + /** + * Returns the DRY base. + * + * @return DRY base + */ + public float dryBase() { + return dryBase; + } + + /** + * Returns the DRY allowed length. + * + * @return DRY allowed length + */ + public int dryAllowedLength() { + return dryAllowedLength; + } + + /** + * Returns the DRY penalty look-back window in tokens. + * + * @return DRY penalty last-n ({@code -1} = whole context, {@code 0} = disabled) + */ + public int dryPenaltyLastN() { + return dryPenaltyLastN; + } + + /** + * Returns an unmodifiable view of the configured DRY sequence breakers. + * + * @return unmodifiable list of DRY sequence breakers (empty = use the binding default) + */ + public List drySequenceBreakers() { + return Collections.unmodifiableList(drySequenceBreakers); + } + /** * Returns an unmodifiable view of the configured stop strings. * diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiGenerationTimeEstimator.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiGenerationTimeEstimator.java new file mode 100644 index 0000000..437bee0 --- /dev/null +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiGenerationTimeEstimator.java @@ -0,0 +1,182 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.support; + +import lombok.ToString; + +/** + * Rough, reference-CPU duration estimate for a single AI generation, used to warn the + * user before a large file blocks the build for minutes. + * + *

    Why this is non-trivial. On CPU, generation time is not a constant + * tokens/second: it is dominated by prefill (processing the prompt), whose + * per-token cost grows linearly with the prompt length {@code n} because attention is + * {@code O(n)} per token — so total prefill is {@code O(n^2)}. Decode (generating the + * answer) is comparatively small but also slows as the context grows. The model below + * was fitted to three end-to-end measurements and reproduces them to within ~0.5 % + * (see {@code AiGenerationTimeEstimatorTest}):

    + * + *
    + *   prompt tokens n   measured prefill   model prefill
    + *   3 309             88.3 s             88.1 s
    + *   24 081            978.0 s            978.5 s
    + *   61 484            4053 s             4049 s
    + * 
    + * + *

    Calibration. The constants are measured on an AMD Ryzen 7 5800H (CPU-only, + * 8 threads) running gpt-oss-20b UD-Q4_K_XL via llama.cpp. They are intentionally a + * rough estimate: a different CPU, thread count, model, or quantisation shifts + * the absolute numbers (a GPU would make them far smaller). Treat the output as an + * order-of-magnitude hint, not a guarantee. The shape (quadratic prefill) holds + * across hardware; only the coefficients scale.

    + */ +@ToString +public class AiGenerationTimeEstimator { + + /** + * Linear prefill coefficient in milliseconds per prompt token. Dominates for small + * prompts; fitted on the reference CPU (see class Javadoc). + */ + public static final double PREFILL_LINEAR_MS_PER_TOKEN = 24.4d; + + /** + * Quadratic prefill coefficient in milliseconds per prompt token squared. Dominates + * for large prompts and is the reason throughput "shrinks" as files grow. + */ + public static final double PREFILL_QUADRATIC_MS_PER_TOKEN_SQUARED = 0.000674d; + + /** + * Linear decode coefficient in milliseconds per generated token at (near) zero + * context length. + */ + public static final double DECODE_LINEAR_MS_PER_TOKEN = 56.8d; + + /** + * Additional decode milliseconds per generated token for each token already in the + * context — captures the decode slowdown on long prompts. + */ + public static final double DECODE_MS_PER_TOKEN_PER_CONTEXT_TOKEN = 0.01568d; + + /** + * Measured characters per token for real Java source (~4.8, from a linear regression over 7 real + * repo files; see {@code docs/ai-index-benchmark/gpt-oss-tuning.md} Phase 5). Used only to estimate + * the token count from a character count; this is deliberately distinct from the conservative + * {@code charsPerToken} used for input trimming. + */ + public static final double ESTIMATION_CHARS_PER_TOKEN = 4.8d; + + /** + * Approximate fixed prompt-template token overhead added on top of the source tokens (system + + * developer instructions plus chat-template scaffolding); ~700 from the same Phase 5 regression. + */ + public static final int PROMPT_TEMPLATE_TOKEN_OVERHEAD = 700; + + /** + * Display safety margin applied to the final estimate. The chars/token and template constants are + * accurate central values (not conservative), so a +15 % margin keeps the logged ETA from + * under-promising on the per-file variance observed in the benchmark. + */ + public static final double ETA_SAFETY_MARGIN = 1.15d; + + /** + * Typical number of generated output tokens assumed for the decode part of the + * estimate when the caller does not specify one. Observed summaries ranged ~450–1200 + * tokens; this is a representative middle value. + */ + public static final int DEFAULT_EXPECTED_OUTPUT_TOKENS = 800; + + /** Milliseconds per second, for converting the internal millisecond model to seconds. */ + public static final double MILLIS_PER_SECOND = 1000.0d; + + /** Seconds per minute, for the human-readable duration formatting. */ + public static final long SECONDS_PER_MINUTE = 60L; + + /** + * Threshold (seconds) at or above which {@link #formatDuration(long)} switches from a + * "{@code ~N s}" rendering to a "{@code ~N min}" rendering. + */ + public static final long MINUTE_FORMAT_THRESHOLD_SECONDS = 90L; + + /** Creates a new {@link AiGenerationTimeEstimator}. */ + public AiGenerationTimeEstimator() { + // no-op + } + + /** + * Estimates the prompt token count for a source of the given character length, + * including the fixed template overhead. + * + * @param sourceChars number of source characters that will be sent to the model + * @return estimated prompt token count (source tokens + template overhead) + */ + public int estimatePromptTokens(final int sourceChars) { + return (int) Math.round(sourceChars / ESTIMATION_CHARS_PER_TOKEN) + PROMPT_TEMPLATE_TOKEN_OVERHEAD; + } + + /** + * Estimates prefill (prompt-processing) time for a prompt of {@code promptTokens} + * tokens using the quadratic model. + * + * @param promptTokens prompt length in tokens + * @return estimated prefill time in milliseconds + */ + public double estimatePrefillMillis(final int promptTokens) { + final double n = promptTokens; + return PREFILL_LINEAR_MS_PER_TOKEN * n + PREFILL_QUADRATIC_MS_PER_TOKEN_SQUARED * n * n; + } + + /** + * Estimates decode (answer-generation) time for the given context length and expected + * output token count. + * + * @param promptTokens context length in tokens (the prompt already prefilled) + * @param expectedOutputTokens number of tokens the model is expected to generate + * @return estimated decode time in milliseconds + */ + public double estimateDecodeMillis(final int promptTokens, final int expectedOutputTokens) { + return expectedOutputTokens + * (DECODE_LINEAR_MS_PER_TOKEN + DECODE_MS_PER_TOKEN_PER_CONTEXT_TOKEN * promptTokens); + } + + /** + * Estimates total generation time (prefill + decode) in seconds for a source of the + * given character length, assuming {@link #DEFAULT_EXPECTED_OUTPUT_TOKENS} of output. + * + * @param sourceChars number of source characters that will be sent to the model + * @return estimated total time in seconds, rounded to the nearest second + */ + public long estimateSeconds(final int sourceChars) { + return estimateSeconds(sourceChars, DEFAULT_EXPECTED_OUTPUT_TOKENS); + } + + /** + * Estimates total generation time (prefill + decode) in seconds for a source of the + * given character length and expected output token count. + * + * @param sourceChars number of source characters that will be sent to the model + * @param expectedOutputTokens number of tokens the model is expected to generate + * @return estimated total time in seconds, rounded to the nearest second + */ + public long estimateSeconds(final int sourceChars, final int expectedOutputTokens) { + final int promptTokens = estimatePromptTokens(sourceChars); + final double millis = + estimatePrefillMillis(promptTokens) + estimateDecodeMillis(promptTokens, expectedOutputTokens); + return Math.round(millis / MILLIS_PER_SECOND * ETA_SAFETY_MARGIN); + } + + /** + * Formats a second count as a short human-readable string: "{@code ~N s}" below + * {@link #MINUTE_FORMAT_THRESHOLD_SECONDS}, otherwise "{@code ~N min}". + * + * @param seconds duration in seconds + * @return short, prefixed duration string + */ + public String formatDuration(final long seconds) { + if (seconds >= MINUTE_FORMAT_THRESHOLD_SECONDS) { + final long minutes = Math.round((double) seconds / (double) SECONDS_PER_MINUTE); + return "~" + minutes + " min"; + } + return "~" + seconds + " s"; + } +} diff --git a/src/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiProgressBar.java b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiProgressBar.java new file mode 100644 index 0000000..5db1815 --- /dev/null +++ b/src/main/java/net/ladenthin/maven/llamacpp/aiindex/support/AiProgressBar.java @@ -0,0 +1,77 @@ +// @formatter:off +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +// @formatter:on +package net.ladenthin.maven.llamacpp.aiindex.support; + +/** + * Renders a simple ASCII progress bar from a completed/total ratio, e.g. {@code [##### ] 42%}. + * + *

    Pure string formatting with no time model: the caller decides what {@code completed}/{@code total} + * mean (here, summed per-file estimated seconds, so progress advances by each file's estimate as + * it finishes — no re-estimation). ASCII-only for CI logs.

    + */ +public final class AiProgressBar { + + /** Default bar width in characters (the count of fill cells between the brackets). */ + public static final int DEFAULT_WIDTH = 20; + + /** Character for completed cells. */ + private static final char FILLED_CHAR = '#'; + + /** Character for remaining cells. */ + private static final char EMPTY_CHAR = ' '; + + /** Percent value representing a full bar. */ + private static final int FULL_PERCENT = 100; + + /** Utility class; not instantiable. */ + private AiProgressBar() { + // no-op + } + + /** + * Renders the bar at the {@link #DEFAULT_WIDTH default width}. + * + * @param completed the completed amount (e.g. summed estimated seconds of finished files) + * @param total the total amount (e.g. the grand-total estimated seconds) + * @return the rendered bar, e.g. {@code [##### ] 42%} + */ + public static String render(final long completed, final long total) { + return render(completed, total, DEFAULT_WIDTH); + } + + /** + * Renders the bar at the given width. A non-positive {@code total} renders a full bar ({@code 100%}); + * the ratio is clamped to {@code [0, 1]} so out-of-range inputs never overflow the bar. + * + * @param completed the completed amount + * @param total the total amount + * @param width the bar width in cells (values {@code < 0} are treated as {@code 0}) + * @return the rendered bar, e.g. {@code [##### ] 42%} + */ + public static String render(final long completed, final long total, final int width) { + final int cells = Math.max(0, width); + final double fraction = total <= 0L ? 1.0d : clampFraction((double) completed / (double) total); + final int percent = (int) Math.round(fraction * FULL_PERCENT); + final int filled = (int) Math.round(fraction * cells); + final StringBuilder sb = new StringBuilder(cells + 8); + sb.append('['); + for (int i = 0; i < cells; i++) { + sb.append(i < filled ? FILLED_CHAR : EMPTY_CHAR); + } + sb.append("] ").append(percent).append('%'); + return sb.toString(); + } + + /** + * Clamps a fraction to the closed interval {@code [0, 1]}. + * + * @param fraction the raw fraction + * @return the clamped fraction + */ + private static double clampFraction(final double fraction) { + return Math.max(0.0d, Math.min(1.0d, fraction)); + } +} diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/CommonTestFixtures.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/CommonTestFixtures.java index da70fe2..c7c6bd8 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/CommonTestFixtures.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/CommonTestFixtures.java @@ -103,7 +103,7 @@ public static List createPackageFieldGenerations() { * *

    Provides a single definition keyed {@link #AI_DEFINITION_KEY_DEFAULT} that uses * all {@link AiGenerationConfig} default values. Tests that need custom values - * (e.g. different {@code maxRetries}) should build their own list.

    + * (e.g. different {@code temperature}) should build their own list.

    * * @return list with one default model definition */ diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionEvaluatorTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionEvaluatorTest.java new file mode 100644 index 0000000..c94ab88 --- /dev/null +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionEvaluatorTest.java @@ -0,0 +1,276 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.Arrays; +import org.junit.jupiter.api.Test; + +public class AiConditionEvaluatorTest { + + private final AiConditionEvaluator evaluator = new AiConditionEvaluator(); + + private static AiFileContext ctx( + final String name, final String path, final long size, final int lines, final long mtime) { + return new AiFileContext(name, path, size, lines, mtime); + } + + private static AiFileContext javaCtx() { + return ctx("Foo.java", "src/Foo.java", 500L, 10, 1000L); + } + + private static AiCondition ext(final String... e) { + final AiCondition c = new AiCondition(); + c.setExtensions(Arrays.asList(e)); + return c; + } + + private static AiCondition size(final long min, final long max) { + final AiCondition c = new AiCondition(); + final AiRangeCondition r = new AiRangeCondition(); + r.setMin(min); + r.setMax(max); + c.setSize(r); + return c; + } + + private static AiCondition lines(final long min, final long max) { + final AiCondition c = new AiCondition(); + final AiRangeCondition r = new AiRangeCondition(); + r.setMin(min); + r.setMax(max); + c.setLines(r); + return c; + } + + private static AiConditionGroup group(final AiCondition... kids) { + final AiConditionGroup g = new AiConditionGroup(); + g.setConditions(Arrays.asList(kids)); + return g; + } + + private static AiCondition and(final AiCondition... kids) { + final AiCondition c = new AiCondition(); + c.setAnd(group(kids)); + return c; + } + + private static AiCondition or(final AiCondition... kids) { + final AiCondition c = new AiCondition(); + c.setOr(group(kids)); + return c; + } + + private static AiCondition not(final AiCondition kid) { + final AiCondition c = new AiCondition(); + c.setNot(kid); + return c; + } + + // + @Test + public void matches_extension() { + assertThat(evaluator.matches(ext(".java", ".kt"), javaCtx()), is(true)); + assertThat(evaluator.matches(ext(".sql"), javaCtx()), is(false)); + } + + @Test + public void matches_size() { + assertThat(evaluator.matches(size(0L, 1000L), javaCtx()), is(true)); // 500 <= 1000 + assertThat(evaluator.matches(size(1000L, 0L), javaCtx()), is(false)); // 500 not > 1000 + } + + @Test + public void matches_lines() { + assertThat(evaluator.matches(lines(0L, 10L), javaCtx()), is(true)); // 10 <= 10 + assertThat(evaluator.matches(lines(10L, 0L), javaCtx()), is(false)); // 10 not > 10 + } + + @Test + public void matches_modifiedAfter() { + // instant 1970-01-01T00:00:01Z = 1000ms + final AiCondition after = new AiCondition(); + after.setModifiedAfter("1970-01-01T00:00:01Z"); + assertThat(evaluator.matches(after, ctx("F.java", "F.java", 1L, 0, 2000L)), is(true)); + assertThat(evaluator.matches(after, ctx("F.java", "F.java", 1L, 0, 500L)), is(false)); + // exactly equal -> strictly-after is false (pins the '>' boundary) + assertThat(evaluator.matches(after, ctx("F.java", "F.java", 1L, 0, 1000L)), is(false)); + } + + @Test + public void matches_modifiedBefore() { + final AiCondition before = new AiCondition(); + before.setModifiedBefore("1970-01-01T00:00:01Z"); // 1000ms + assertThat(evaluator.matches(before, ctx("F.java", "F.java", 1L, 0, 500L)), is(true)); + assertThat(evaluator.matches(before, ctx("F.java", "F.java", 1L, 0, 2000L)), is(false)); + // exactly equal -> strictly-before is false (pins the '<' boundary) + assertThat(evaluator.matches(before, ctx("F.java", "F.java", 1L, 0, 1000L)), is(false)); + } + + @Test + public void matches_pathGlob() { + final AiCondition glob = new AiCondition(); + glob.setPathGlob("**/generated/**"); + assertThat(evaluator.matches(glob, ctx("X.java", "src/generated/X.java", 1L, 0, 0L)), is(true)); + assertThat(evaluator.matches(glob, ctx("X.java", "src/main/X.java", 1L, 0, 0L)), is(false)); + } + // + + // + @Test + public void matches_and_allTrue_oneFalse() { + assertThat(evaluator.matches(and(ext(".java"), size(0L, 1000L)), javaCtx()), is(true)); + assertThat(evaluator.matches(and(ext(".java"), size(1000L, 0L)), javaCtx()), is(false)); + } + + @Test + public void matches_or_oneTrue_allFalse() { + assertThat(evaluator.matches(or(ext(".sql"), size(0L, 1000L)), javaCtx()), is(true)); + assertThat(evaluator.matches(or(ext(".sql"), size(1000L, 0L)), javaCtx()), is(false)); + } + + @Test + public void matches_not() { + assertThat(evaluator.matches(not(ext(".sql")), javaCtx()), is(true)); + assertThat(evaluator.matches(not(ext(".java")), javaCtx()), is(false)); + } + + @Test + public void matches_nested() { + // .java AND (>=big OR <=small) AND NOT generated + final AiCondition glob = new AiCondition(); + glob.setPathGlob("**/generated/**"); + final AiCondition nested = and(ext(".java"), or(size(0L, 1000L), size(9999L, 0L)), not(glob)); + assertThat(evaluator.matches(nested, javaCtx()), is(true)); + assertThat(evaluator.matches(nested, ctx("X.java", "src/generated/X.java", 500L, 0, 0L)), is(false)); + } + + @Test + public void matches_groupWithNullConditions_isVacuous() { + // a group whose list is null: AND is vacuously true, OR vacuously false + final AiCondition andNull = new AiCondition(); + andNull.setAnd(new AiConditionGroup()); + assertThat(evaluator.matches(andNull, javaCtx()), is(true)); + final AiCondition orNull = new AiCondition(); + orNull.setOr(new AiConditionGroup()); + assertThat(evaluator.matches(orNull, javaCtx()), is(false)); + // and usesLines tolerates a null-conditions group + assertThat(evaluator.usesLines(andNull), is(false)); + assertThat(evaluator.usesLines(orNull), is(false)); + } + + @Test + public void matches_emptyNode_throws() { + assertThrows(IllegalStateException.class, () -> evaluator.matches(new AiCondition(), javaCtx())); + } + // + + // + @Test + public void validate_validLeavesAndTree() { + // every leaf/combinator must pass validation as the single branch of a node — this also pins the + // branchCount() count++ for each kind (or / lines / modifiedBefore included). + assertDoesNotThrow(() -> evaluator.validate(ext(".java"))); + assertDoesNotThrow(() -> evaluator.validate(size(0L, 1000L))); + assertDoesNotThrow(() -> evaluator.validate(lines(0L, 100L))); + assertDoesNotThrow(() -> evaluator.validate(and(ext(".java"), not(size(1000L, 0L))))); + assertDoesNotThrow(() -> evaluator.validate(or(ext(".java"), size(0L, 100L)))); + final AiCondition after = new AiCondition(); + after.setModifiedAfter("2026-01-01T00:00:00Z"); + assertDoesNotThrow(() -> evaluator.validate(after)); + final AiCondition before = new AiCondition(); + before.setModifiedBefore("2026-01-01T00:00:00Z"); + assertDoesNotThrow(() -> evaluator.validate(before)); + final AiCondition glob = new AiCondition(); + glob.setPathGlob("**/x/**"); + assertDoesNotThrow(() -> evaluator.validate(glob)); + } + + @Test + public void validate_zeroBranches_throws() { + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(new AiCondition())); + } + + @Test + public void validate_twoBranches_throws() { + final AiCondition c = ext(".java"); + c.setPathGlob("**/x/**"); // now two branches set + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(c)); + } + + @Test + public void validate_emptyAnd_throws() { + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(and())); + } + + @Test + public void validate_emptyOr_throws() { + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(or())); + } + + @Test + public void validate_recursesIntoChildren() { + final AiCondition badChild = ext(".java"); + badChild.setSize(new AiRangeCondition()); // two branches in the child + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(and(badChild))); + // recursion must reach OR children and NOT children too + final AiCondition badOrChild = ext(".java"); + badOrChild.setSize(new AiRangeCondition()); + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(or(badOrChild))); + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(not(new AiCondition()))); + } + + @Test + public void validate_emptyExtensions_throws() { + final AiCondition c = new AiCondition(); + c.setExtensions(Arrays.asList()); + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(c)); + } + + @Test + public void validate_unboundedRange_throws() { + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(size(0L, 0L))); + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(lines(0L, 0L))); + } + + @Test + public void validate_invalidDate_throws() { + final AiCondition after = new AiCondition(); + after.setModifiedAfter("not-a-date"); + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(after)); + final AiCondition before = new AiCondition(); + before.setModifiedBefore("2026/01/01"); + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(before)); + } + + @Test + public void validate_blankGlob_throws() { + final AiCondition c = new AiCondition(); + c.setPathGlob(" "); + assertThrows(IllegalArgumentException.class, () -> evaluator.validate(c)); + } + // + + // + @Test + public void usesLines_directAndNested() { + assertThat(evaluator.usesLines(lines(0L, 100L)), is(true)); + assertThat(evaluator.usesLines(and(ext(".java"), lines(0L, 100L))), is(true)); + assertThat(evaluator.usesLines(or(ext(".java"), lines(0L, 100L))), is(true)); + assertThat(evaluator.usesLines(not(lines(0L, 100L))), is(true)); + } + + @Test + public void usesLines_absent() { + assertThat(evaluator.usesLines(ext(".java")), is(false)); + assertThat(evaluator.usesLines(and(ext(".java"), size(0L, 100L))), is(false)); + assertThat(evaluator.usesLines(or(ext(".java"), size(0L, 100L))), is(false)); + assertThat(evaluator.usesLines(not(ext(".java"))), is(false)); + } + // +} diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionGroupTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionGroupTest.java new file mode 100644 index 0000000..3e1ff0f --- /dev/null +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionGroupTest.java @@ -0,0 +1,46 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Test; + +public class AiConditionGroupTest { + + @Test + public void conditionsDefaultNull() { + assertThat(new AiConditionGroup().getConditions(), is(nullValue())); + } + + @Test + public void setConditionsRoundTrip() { + final AiConditionGroup g = new AiConditionGroup(); + g.setConditions(java.util.Arrays.asList(new AiCondition(), new AiCondition())); + assertThat(g.getConditions().size(), is(equalTo(2))); + } + + @Test + public void setConditionsDefensivelyCopied() { + final AiConditionGroup g = new AiConditionGroup(); + final List source = new ArrayList<>(); + source.add(new AiCondition()); + g.setConditions(source); + source.add(new AiCondition()); // mutating the source must not affect the stored value + assertThat(g.getConditions().size(), is(equalTo(1))); + } + + @Test + public void setConditionsNullClears() { + final AiConditionGroup g = new AiConditionGroup(); + g.setConditions(java.util.Arrays.asList(new AiCondition())); + g.setConditions(null); + assertThat(g.getConditions(), is(nullValue())); + } +} diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionTest.java new file mode 100644 index 0000000..9ece2e4 --- /dev/null +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiConditionTest.java @@ -0,0 +1,90 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.Arrays; +import org.junit.jupiter.api.Test; + +public class AiConditionTest { + + @Test + public void allFieldsDefaultNull() { + final AiCondition c = new AiCondition(); + assertThat(c.getAnd(), is(nullValue())); + assertThat(c.getOr(), is(nullValue())); + assertThat(c.getNot(), is(nullValue())); + assertThat(c.getExtensions(), is(nullValue())); + assertThat(c.getSize(), is(nullValue())); + assertThat(c.getLines(), is(nullValue())); + assertThat(c.getModifiedAfter(), is(nullValue())); + assertThat(c.getModifiedBefore(), is(nullValue())); + assertThat(c.getPathGlob(), is(nullValue())); + } + + @Test + public void andOrNotRoundTrip() { + final AiCondition leaf = new AiCondition(); + final AiCondition c = new AiCondition(); + final AiConditionGroup g = new AiConditionGroup(); + g.setConditions(Arrays.asList(leaf)); + c.setAnd(g); + assertThat(c.getAnd().getConditions().size(), is(equalTo(1))); + c.setOr(g); + assertThat(c.getOr().getConditions().size(), is(equalTo(1))); + c.setNot(leaf); + assertThat(c.getNot(), is(leaf)); + c.setAnd(null); + assertThat(c.getAnd(), is(nullValue())); + } + + @Test + public void extensionsDefensivelyCopied() { + final AiCondition c = new AiCondition(); + c.setExtensions(Arrays.asList(".java", ".kt")); + assertThat(c.getExtensions(), hasItem(".java")); + assertThat(c.getExtensions(), hasItem(".kt")); + c.setExtensions(null); + assertThat(c.getExtensions(), is(nullValue())); + } + + @Test + public void sizeLinesRoundTrip() { + final AiCondition c = new AiCondition(); + final AiRangeCondition size = new AiRangeCondition(); + size.setMax(100L); + c.setSize(size); + assertThat(c.getSize().getMax(), is(equalTo(100L))); + final AiRangeCondition lines = new AiRangeCondition(); + lines.setMin(5L); + c.setLines(lines); + assertThat(c.getLines().getMin(), is(equalTo(5L))); + } + + @Test + public void stringLeavesRoundTrip() { + final AiCondition c = new AiCondition(); + c.setModifiedAfter("2026-01-01T00:00:00Z"); + c.setModifiedBefore("2027-01-01T00:00:00Z"); + c.setPathGlob("**/x/**"); + assertThat(c.getModifiedAfter(), is(equalTo("2026-01-01T00:00:00Z"))); + assertThat(c.getModifiedBefore(), is(equalTo("2027-01-01T00:00:00Z"))); + assertThat(c.getPathGlob(), is(equalTo("**/x/**"))); + } + + @Test + public void notRoundTripAndClear() { + final AiCondition c = new AiCondition(); + final AiCondition child = new AiCondition(); + c.setNot(child); + assertThat(c.getNot(), is(child)); + c.setNot(null); + assertThat(c.getNot(), is(nullValue())); + } +} diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfigTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfigTest.java index e0f1b2a..9282747 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfigTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationConfigTest.java @@ -5,57 +5,67 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import org.junit.jupiter.api.Test; public class AiFieldGenerationConfigTest { @Test - public void fileExtensions_defaultsToNull() { - assertThat(new AiFieldGenerationConfig().getFileExtensions(), is(nullValue())); + public void id_defaultsNullAndRoundTrips() { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + assertThat(c.getId(), is(nullValue())); + c.setId("java-small"); + assertThat(c.getId(), is(equalTo("java-small"))); } @Test - public void setFileExtensions_null_getterReturnsNull() { - final AiFieldGenerationConfig config = new AiFieldGenerationConfig(); - config.setFileExtensions(null); - assertThat(config.getFileExtensions(), is(nullValue())); + public void promptKeyRoundTrips() { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + c.setPromptKey("file-body-java"); + assertThat(c.getPromptKey(), is(equalTo("file-body-java"))); } @Test - public void setFileExtensions_storesValuesInOrder() { - final AiFieldGenerationConfig config = new AiFieldGenerationConfig(); - config.setFileExtensions(Arrays.asList(".java", ".sql")); - assertThat(config.getFileExtensions(), is(equalTo(Arrays.asList(".java", ".sql")))); + public void aiDefinitionKeyRoundTrips() { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + c.setAiDefinitionKey("gpt-oss-20B-c96k"); + assertThat(c.getAiDefinitionKey(), is(equalTo("gpt-oss-20B-c96k"))); } @Test - public void setFileExtensions_defensivelyCopiesSource() { - // arrange - final AiFieldGenerationConfig config = new AiFieldGenerationConfig(); - final List source = new ArrayList<>(); - source.add(".java"); - config.setFileExtensions(source); - - // act: mutating the source after the set must not affect the stored value - source.add(".sql"); - - // assert - assertThat(config.getFileExtensions(), is(equalTo(Arrays.asList(".java")))); + public void condition_defaultsNullAndRoundTrips() { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + assertThat(c.getCondition(), is(nullValue())); + final AiCondition condition = new AiCondition(); + c.setCondition(condition); + assertThat(c.getCondition(), is(notNullValue())); + assertThat(c.getCondition(), is(condition)); } @Test - public void getFileExtensions_returnedListIsUnmodifiable() { - final AiFieldGenerationConfig config = new AiFieldGenerationConfig(); - config.setFileExtensions(Arrays.asList(".java")); - assertThrows( - UnsupportedOperationException.class, - () -> config.getFileExtensions().add(".sql")); + public void priority_defaultsZeroAndRoundTrips() { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + assertThat(c.getPriority(), is(equalTo(0))); + c.setPriority(10); + assertThat(c.getPriority(), is(equalTo(10))); + } + + @Test + public void fallback_defaultsFalseAndTogglesTrue() { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + assertThat(c.isFallback(), is(false)); + c.setFallback(true); + assertThat(c.isFallback(), is(true)); + } + + @Test + public void skip_defaultsFalseAndTogglesTrue() { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + assertThat(c.isSkip(), is(false)); + c.setSkip(true); + assertThat(c.isSkip(), is(true)); } } diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelectorTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelectorTest.java index 8c935fe..fa3d415 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelectorTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFieldGenerationSelectorTest.java @@ -7,116 +7,193 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Arrays; import java.util.Collections; -import java.util.List; import org.junit.jupiter.api.Test; public class AiFieldGenerationSelectorTest { + private static final String MODEL = "model-x"; private final AiFieldGenerationSelector selector = new AiFieldGenerationSelector(); - private static AiFieldGenerationConfig config(final String promptKey, final List extensions) { - final AiFieldGenerationConfig config = new AiFieldGenerationConfig(); - config.setPromptKey(promptKey); - config.setFileExtensions(extensions); - return config; + private static AiCondition extCond(final String... ext) { + final AiCondition c = new AiCondition(); + c.setExtensions(Arrays.asList(ext)); + return c; } - // - @Test - public void selectForFileName_extensionMatch_returnsSpecificEntry() { - final AiFieldGenerationConfig java = config("java", Arrays.asList(".java")); - final AiFieldGenerationConfig fallback = config("fallback", null); + private static AiFieldGenerationConfig route(final String prompt, final AiCondition cond, final int priority) { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + c.setPromptKey(prompt); + c.setAiDefinitionKey(MODEL); + c.setCondition(cond); + c.setPriority(priority); + return c; + } - final AiFieldGenerationConfig selected = selector.selectForFileName(Arrays.asList(java, fallback), "Foo.java"); + private static AiFieldGenerationConfig skipRule(final AiCondition cond, final int priority) { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + c.setSkip(true); + c.setCondition(cond); + c.setPriority(priority); + return c; + } - assertThat(selected.getPromptKey(), is(equalTo("java"))); + private static AiFieldGenerationConfig fallback(final String prompt) { + final AiFieldGenerationConfig c = new AiFieldGenerationConfig(); + c.setPromptKey(prompt); + c.setAiDefinitionKey(MODEL); + c.setFallback(true); + return c; } - @Test - public void selectForFileName_specificWinsOverEarlierFallback() { - final AiFieldGenerationConfig fallback = config("fallback", null); - final AiFieldGenerationConfig java = config("java", Arrays.asList(".java")); + private static AiFileContext ctx(final String fileName) { + return new AiFileContext(fileName, "src/" + fileName, 500L, 10, 1000L); + } - final AiFieldGenerationConfig selected = selector.selectForFileName(Arrays.asList(fallback, java), "Foo.java"); + // + @Test + public void select_conditionMatch() { + final AiFieldGenerationConfig java = route("java", extCond(".java"), 0); + assertThat( + selector.select(Arrays.asList(java, fallback("fb")), ctx("Foo.java")) + .getPromptKey(), + is(equalTo("java"))); + } - assertThat(selected.getPromptKey(), is(equalTo("java"))); + @Test + public void select_higherPriorityWinsRegardlessOfOrder() { + final AiFieldGenerationConfig low = route("low", extCond(".java"), 1); + final AiFieldGenerationConfig high = route("high", extCond(".java"), 10); + assertThat(selector.select(Arrays.asList(low, high), ctx("Foo.java")).getPromptKey(), is(equalTo("high"))); + assertThat(selector.select(Arrays.asList(high, low), ctx("Foo.java")).getPromptKey(), is(equalTo("high"))); } @Test - public void selectForFileName_firstSpecificMatchWins() { - final AiFieldGenerationConfig first = config("first", Arrays.asList(".java")); - final AiFieldGenerationConfig second = config("second", Arrays.asList(".java")); + public void select_tieBrokenByDeclarationOrder() { + final AiFieldGenerationConfig first = route("first", extCond(".java"), 5); + final AiFieldGenerationConfig second = route("second", extCond(".java"), 5); + assertThat( + selector.select(Arrays.asList(first, second), ctx("Foo.java")).getPromptKey(), is(equalTo("first"))); + } - final AiFieldGenerationConfig selected = selector.selectForFileName(Arrays.asList(first, second), "Foo.java"); + @Test + public void select_skipRuleCanWinByPriority() { + final AiFieldGenerationConfig route = route("route", extCond(".java"), 0); + final AiFieldGenerationConfig skip = skipRule(extCond(".java"), 10); + assertThat(selector.select(Arrays.asList(route, skip), ctx("Foo.java")).isSkip(), is(true)); + } - assertThat(selected.getPromptKey(), is(equalTo("first"))); + @Test + public void select_fallbackUsedWhenNoMatch() { + final AiFieldGenerationConfig java = route("java", extCond(".java"), 0); + assertThat( + selector.select(Arrays.asList(java, fallback("fb")), ctx("data.json")) + .getPromptKey(), + is(equalTo("fb"))); } @Test - public void selectForFileName_anyOfMultipleExtensionsMatches() { - final AiFieldGenerationConfig sql = config("sql", Arrays.asList(".sql", ".ddl")); + public void select_noMatchNoFallback_returnsNull() { + final AiFieldGenerationConfig java = route("java", extCond(".java"), 0); + assertThat(selector.select(Collections.singletonList(java), ctx("data.json")), is(nullValue())); + } - final AiFieldGenerationConfig selected = - selector.selectForFileName(Collections.singletonList(sql), "schema.ddl"); + @Test + public void select_nullEntrySkipped() { + final AiFieldGenerationConfig java = route("java", extCond(".java"), 0); + assertThat( + selector.select(Arrays.asList(null, java), ctx("Foo.java")) + .getPromptKey(), + is(equalTo("java"))); + } - assertThat(selected.getPromptKey(), is(equalTo("sql"))); + @Test + public void select_firstFallbackWinsWhenSeveral() { + assertThat( + selector.select(Arrays.asList(fallback("first"), fallback("second")), ctx("x.txt")) + .getPromptKey(), + is(equalTo("first"))); } // - // + // @Test - public void selectForFileName_noSpecificMatch_returnsFallback() { - final AiFieldGenerationConfig java = config("java", Arrays.asList(".java")); - final AiFieldGenerationConfig fallback = config("fallback", null); - - final AiFieldGenerationConfig selected = selector.selectForFileName(Arrays.asList(java, fallback), "data.json"); - - assertThat(selected.getPromptKey(), is(equalTo("fallback"))); + public void validate_validRuleSetPasses() { + assertDoesNotThrow(() -> selector.validate( + Arrays.asList(route("java", extCond(".java"), 0), skipRule(extCond(".tmp"), 10), fallback("fb")))); } @Test - public void selectForFileName_emptyExtensionListIsFallback() { - final AiFieldGenerationConfig empty = config("empty", Collections.emptyList()); - - final AiFieldGenerationConfig selected = - selector.selectForFileName(Collections.singletonList(empty), "anything.xyz"); - - assertThat(selected.getPromptKey(), is(equalTo("empty"))); + public void validate_nullEntryIgnored() { + assertDoesNotThrow(() -> + selector.validate(Arrays.asList(null, route("java", extCond(".java"), 0)))); } @Test - public void selectForFileName_firstFallbackWins() { - final AiFieldGenerationConfig first = config("first", null); - final AiFieldGenerationConfig second = config("second", Collections.emptyList()); + public void validate_moreThanOneFallback_throws() { + assertThrows( + IllegalArgumentException.class, () -> selector.validate(Arrays.asList(fallback("a"), fallback("b")))); + } - final AiFieldGenerationConfig selected = selector.selectForFileName(Arrays.asList(first, second), "data.json"); + @Test + public void validate_nonFallbackWithoutCondition_throws() { + final AiFieldGenerationConfig noCond = new AiFieldGenerationConfig(); + noCond.setPromptKey("p"); + noCond.setAiDefinitionKey(MODEL); + assertThrows(IllegalArgumentException.class, () -> selector.validate(Collections.singletonList(noCond))); + } - assertThat(selected.getPromptKey(), is(equalTo("first"))); + @Test + public void validate_fallbackWithCondition_throws() { + final AiFieldGenerationConfig fb = fallback("p"); + fb.setCondition(extCond(".java")); + assertThrows(IllegalArgumentException.class, () -> selector.validate(Collections.singletonList(fb))); } - // - // @Test - public void selectForFileName_noMatchNoFallback_returnsNull() { - final AiFieldGenerationConfig java = config("java", Arrays.asList(".java")); + public void validate_fallbackThatIsAlsoSkip_throws() { + final AiFieldGenerationConfig fb = fallback("p"); + fb.setSkip(true); + assertThrows(IllegalArgumentException.class, () -> selector.validate(Collections.singletonList(fb))); + } - final AiFieldGenerationConfig selected = - selector.selectForFileName(Collections.singletonList(java), "data.json"); + @Test + public void validate_routeMissingPromptKey_throws() { + final AiFieldGenerationConfig bad = new AiFieldGenerationConfig(); + bad.setAiDefinitionKey(MODEL); + bad.setCondition(extCond(".java")); + assertThrows(IllegalArgumentException.class, () -> selector.validate(Collections.singletonList(bad))); + } - assertThat(selected, is(nullValue())); + @Test + public void validate_routeMissingModel_throws() { + final AiFieldGenerationConfig bad = new AiFieldGenerationConfig(); + bad.setPromptKey("p"); + bad.setCondition(extCond(".java")); + assertThrows(IllegalArgumentException.class, () -> selector.validate(Collections.singletonList(bad))); } @Test - public void selectForFileName_nullEntrySkipped() { - final AiFieldGenerationConfig java = config("java", Arrays.asList(".java")); + public void validate_fallbackMissingKeys_throws() { + final AiFieldGenerationConfig bad = new AiFieldGenerationConfig(); + bad.setFallback(true); + assertThrows(IllegalArgumentException.class, () -> selector.validate(Collections.singletonList(bad))); + } - final AiFieldGenerationConfig selected = - selector.selectForFileName(Arrays.asList(null, java), "Foo.java"); + @Test + public void validate_skipRuleNeedsNoKeysButNeedsCondition() { + assertDoesNotThrow(() -> selector.validate(Collections.singletonList(skipRule(extCond(".tmp"), 0)))); + } - assertThat(selected.getPromptKey(), is(equalTo("java"))); + @Test + public void validate_invalidConditionInRule_throws() { + // a condition with no branch set is invalid -> selector.validate must propagate the error + final AiFieldGenerationConfig bad = route("p", new AiCondition(), 0); + assertThrows(IllegalArgumentException.class, () -> selector.validate(Collections.singletonList(bad))); } // } diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFileContextTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFileContextTest.java new file mode 100644 index 0000000..63138a9 --- /dev/null +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiFileContextTest.java @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +public class AiFileContextTest { + + @Test + public void accessorsReturnConstructorValues() { + final AiFileContext c = new AiFileContext("Foo.java", "src/Foo.java", 1234L, 56, 7890L); + assertThat(c.fileName(), is(equalTo("Foo.java"))); + assertThat(c.relativePath(), is(equalTo("src/Foo.java"))); + assertThat(c.sizeBytes(), is(equalTo(1234L))); + assertThat(c.lineCount(), is(equalTo(56))); + assertThat(c.lastModifiedEpochMilli(), is(equalTo(7890L))); + } +} diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfigTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfigTest.java index 519719b..1fa3bff 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfigTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiGenerationConfigTest.java @@ -51,4 +51,175 @@ public void setStopStringsNullResetsToEmptyList() { // null arg resets to an EMPTY (non-null) list — kills the negate mutant on the setter ternary. assertThat(c.getStopStrings(), is(Collections.emptyList())); } + + @Test + public void cachePromptDefaultsTrueAndTogglesFalse() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default true kills the false-default / "return false" getter mutants. + assertThat(c.isCachePrompt(), is(true)); + c.setCachePrompt(false); + // Observing false after the setter kills the "return true" getter mutant and the + // removed-assignment setter mutant. + assertThat(c.isCachePrompt(), is(false)); + } + + @Test + public void reasoningEffortDefaultsLowAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default "low" kills the empty/null return mutants on the getter. + assertThat(c.getReasoningEffort(), is("low")); + c.setReasoningEffort("high"); + // Round-tripped value kills the removed-assignment setter mutant. + assertThat(c.getReasoningEffort(), is("high")); + } + + @Test + public void minPDefaultsDisabledAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default 0.0 (disabled) kills the inline-constant and "return 1.0" getter mutants. + assertThat(c.getMinP(), is(0.0f)); + c.setMinP(0.05f); + // Round-tripped non-zero value kills the "return 0" getter and removed-assignment setter mutants. + assertThat(c.getMinP(), is(0.05f)); + } + + @Test + public void topNSigmaDefaultsDisabledAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default -1.0 (disabled) kills the inline-constant / "return 0" getter mutants. + assertThat(c.getTopNSigma(), is(-1.0f)); + c.setTopNSigma(1.5f); + // Round-tripped value kills the getter "return 0" and removed-assignment setter mutants. + assertThat(c.getTopNSigma(), is(1.5f)); + } + + @Test + public void swaFullDefaultsTrueAndTogglesFalse() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default true (E4 batch default) kills the "return false" getter mutant. + assertThat(c.isSwaFull(), is(true)); + c.setSwaFull(false); + // Observing false kills the "return true" getter and removed-assignment setter mutants. + assertThat(c.isSwaFull(), is(false)); + } + + @Test + public void cacheReuseDefaultsTwoFiftySixAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default 256 (E4 batch default) kills the inline-constant / "return 0" getter mutants. + assertThat(c.getCacheReuse(), is(256)); + c.setCacheReuse(128); + // Round-tripped distinct value kills the removed-assignment setter mutant. + assertThat(c.getCacheReuse(), is(128)); + } + + @Test + public void gpuLayersDefaultsMinusOneAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default -1 (leave binding/build default) kills the inline-constant / "return 0" getter mutants. + assertThat(c.getGpuLayers(), is(-1)); + c.setGpuLayers(33); + // Round-tripped value kills the "return 0" getter and removed-assignment setter mutants. + assertThat(c.getGpuLayers(), is(33)); + } + + @Test + public void mainGpuDefaultsMinusOneAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default -1 (leave binding/build default) kills the inline-constant / "return 0" getter mutants. + assertThat(c.getMainGpu(), is(-1)); + c.setMainGpu(1); + // Round-tripped value kills the "return 0" getter and removed-assignment setter mutants. + assertThat(c.getMainGpu(), is(1)); + } + + @Test + public void devicesDefaultsEmptyAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default "" (leave binding/build default) kills the null/non-empty return mutants on the getter. + assertThat(c.getDevices(), is("")); + c.setDevices("Vulkan1"); + // Round-tripped value kills the empty-return getter and removed-assignment setter mutants. + assertThat(c.getDevices(), is("Vulkan1")); + } + + @Test + public void setDevicesNullResetsToEmpty() { + AiGenerationConfig c = new AiGenerationConfig(); + c.setDevices("CUDA0"); + c.setDevices(null); + // null arg resets to "" — kills the negate mutant on the setter ternary (which would store null). + assertThat(c.getDevices(), is("")); + } + + @Test + public void reasoningBudgetTokensDefaultsUnrestrictedAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default -1 (unrestricted) kills the inline-constant / "return 0" getter mutants. + assertThat(c.getReasoningBudgetTokens(), is(-1)); + c.setReasoningBudgetTokens(2048); + // Round-tripped value kills the "return 0" getter and removed-assignment setter mutants. + assertThat(c.getReasoningBudgetTokens(), is(2048)); + } + + @Test + public void dryMultiplierDefaultsDisabledAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + // Default 0.0 (disabled) kills the inline-constant / "return 1.0" getter mutants. + assertThat(c.getDryMultiplier(), is(0.0f)); + c.setDryMultiplier(0.8f); + // Round-tripped non-zero value kills the "return 0" getter and removed-assignment setter mutants. + assertThat(c.getDryMultiplier(), is(0.8f)); + } + + @Test + public void dryBaseDefaultsAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + assertThat(c.getDryBase(), is(1.75f)); + c.setDryBase(1.5f); + assertThat(c.getDryBase(), is(1.5f)); + } + + @Test + public void dryAllowedLengthDefaultsAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + assertThat(c.getDryAllowedLength(), is(2)); + c.setDryAllowedLength(5); + assertThat(c.getDryAllowedLength(), is(5)); + } + + @Test + public void dryPenaltyLastNDefaultsWholeContextAndRoundTrips() { + AiGenerationConfig c = new AiGenerationConfig(); + assertThat(c.getDryPenaltyLastN(), is(-1)); + c.setDryPenaltyLastN(256); + assertThat(c.getDryPenaltyLastN(), is(256)); + } + + @Test + public void drySequenceBreakersEmptyByDefault() { + // Defaults to an empty (non-null) list. Asserting non-null/empty kills the negate mutant + // on the getDrySequenceBreakers null path and the setter ternary. + assertThat(new AiGenerationConfig().getDrySequenceBreakers(), is(Collections.emptyList())); + } + + @Test + public void drySequenceBreakersRoundTripUnmodifiable() { + AiGenerationConfig c = new AiGenerationConfig(); + c.setDrySequenceBreakers(Arrays.asList("\n", ":")); + assertThat(c.getDrySequenceBreakers(), hasItem("\n")); + assertThat(c.getDrySequenceBreakers(), hasItem(":")); + assertThrows( + UnsupportedOperationException.class, + () -> c.getDrySequenceBreakers().add("x")); + } + + @Test + public void setDrySequenceBreakersNullResetsToEmptyList() { + AiGenerationConfig c = new AiGenerationConfig(); + c.setDrySequenceBreakers(Collections.singletonList("a")); + c.setDrySequenceBreakers(null); + // null arg resets to an EMPTY (non-null) list — kills the negate mutant on the setter ternary. + assertThat(c.getDrySequenceBreakers(), is(Collections.emptyList())); + } } diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupportTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupportTest.java index 579c029..329c34e 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupportTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionSupportTest.java @@ -47,11 +47,24 @@ public void getConfig_knownKey_propagatesAllFields() { definition.setThreads(4); definition.setCharsPerToken(3); definition.setWarnOnTrim(false); - definition.setMaxRetries(5); - definition.setRetryTemperatureIncrement(0.2f); definition.setChatTemplateEnableThinking(false); + definition.setCachePrompt(false); + definition.setSwaFull(false); + definition.setCacheReuse(128); + definition.setGpuLayers(20); + definition.setMainGpu(1); + definition.setDevices("Vulkan1"); + definition.setReasoningEffort("high"); + definition.setReasoningBudgetTokens(512); + definition.setDryMultiplier(0.7f); + definition.setDryBase(1.5f); + definition.setDryAllowedLength(4); + definition.setDryPenaltyLastN(128); + definition.setDrySequenceBreakers(Arrays.asList("\n", ":")); definition.setTopP(0.55f); definition.setTopK(21); + definition.setMinP(0.09f); + definition.setTopNSigma(1.3f); definition.setRepeatPenalty(1.15f); definition.setStopStrings(Arrays.asList("", "STOP")); final AiModelDefinitionSupport support = new AiModelDefinitionSupport(Arrays.asList(definition)); @@ -67,15 +80,34 @@ public void getConfig_knownKey_propagatesAllFields() { assertThat(config.getThreads(), is(equalTo(4))); assertThat(config.getCharsPerToken(), is(equalTo(3))); assertThat(config.isWarnOnTrim(), is(false)); - assertThat(config.getMaxRetries(), is(equalTo(5))); - assertThat(config.getRetryTemperatureIncrement(), is(equalTo(0.2f))); assertThat(config.isChatTemplateEnableThinking(), is(false)); // topP/topK/repeatPenalty/stopStrings are propagated too — kills the void-call mutants // that would drop those setter calls from toConfig(). assertThat(config.getTopP(), is(equalTo(0.55f))); assertThat(config.getTopK(), is(equalTo(21))); + assertThat(config.getMinP(), is(equalTo(0.09f))); + assertThat(config.getTopNSigma(), is(equalTo(1.3f))); assertThat(config.getRepeatPenalty(), is(equalTo(1.15f))); assertThat(config.getStopStrings(), is(equalTo(Arrays.asList("", "STOP")))); + // Non-default cachePrompt propagates — kills the void-call mutant that would drop the + // setCachePrompt(...) copy from toConfig(). + assertThat(config.isCachePrompt(), is(false)); + // Non-default swaFull (false; the shipped default is now true) propagates. + assertThat(config.isSwaFull(), is(false)); + assertThat(config.getCacheReuse(), is(equalTo(128))); + assertThat(config.getGpuLayers(), is(equalTo(20))); + // mainGpu/devices propagate — kill the dropped-setter void-call mutants in toConfig(). + assertThat(config.getMainGpu(), is(equalTo(1))); + assertThat(config.getDevices(), is(equalTo("Vulkan1"))); + // Non-default reasoningEffort propagates — kills the dropped-setReasoningEffort void-call mutant. + assertThat(config.getReasoningEffort(), is(equalTo("high"))); + assertThat(config.getReasoningBudgetTokens(), is(equalTo(512))); + // DRY knobs propagate — kill the dropped-setter void-call mutants in toConfig(). + assertThat(config.getDryMultiplier(), is(equalTo(0.7f))); + assertThat(config.getDryBase(), is(equalTo(1.5f))); + assertThat(config.getDryAllowedLength(), is(equalTo(4))); + assertThat(config.getDryPenaltyLastN(), is(equalTo(128))); + assertThat(config.getDrySequenceBreakers(), is(equalTo(Arrays.asList("\n", ":")))); } @Test @@ -97,11 +129,22 @@ public void getConfig_defaultValues_matchAiGenerationConfigDefaults() { assertThat(config.getCharsPerToken(), is(equalTo(AiGenerationConfig.DEFAULT_CHARS_PER_TOKEN))); assertThat(config.getMaxInputChars(), is(equalTo(AiGenerationConfig.DEFAULT_MAX_INPUT_CHARS))); assertThat(config.isWarnOnTrim(), is(AiGenerationConfig.DEFAULT_WARN_ON_TRIM)); - assertThat(config.getMaxRetries(), is(equalTo(AiGenerationConfig.DEFAULT_MAX_RETRIES))); - assertThat( - config.getRetryTemperatureIncrement(), - is(equalTo(AiGenerationConfig.DEFAULT_RETRY_TEMPERATURE_INCREMENT))); assertThat(config.isChatTemplateEnableThinking(), is(AiGenerationConfig.DEFAULT_CHAT_TEMPLATE_ENABLE_THINKING)); + assertThat(config.isCachePrompt(), is(AiGenerationConfig.DEFAULT_CACHE_PROMPT)); + assertThat(config.isSwaFull(), is(AiGenerationConfig.DEFAULT_SWA_FULL)); + assertThat(config.getCacheReuse(), is(equalTo(AiGenerationConfig.DEFAULT_CACHE_REUSE))); + assertThat(config.getGpuLayers(), is(equalTo(AiGenerationConfig.DEFAULT_GPU_LAYERS))); + assertThat(config.getMainGpu(), is(equalTo(AiGenerationConfig.DEFAULT_MAIN_GPU))); + assertThat(config.getDevices(), is(equalTo(AiGenerationConfig.DEFAULT_DEVICES))); + assertThat(config.getReasoningEffort(), is(equalTo(AiGenerationConfig.DEFAULT_REASONING_EFFORT))); + assertThat(config.getReasoningBudgetTokens(), is(equalTo(AiGenerationConfig.DEFAULT_REASONING_BUDGET_TOKENS))); + assertThat(config.getMinP(), is(equalTo(AiGenerationConfig.DEFAULT_MIN_P))); + assertThat(config.getTopNSigma(), is(equalTo(AiGenerationConfig.DEFAULT_TOP_N_SIGMA))); + assertThat(config.getDryMultiplier(), is(equalTo(AiGenerationConfig.DEFAULT_DRY_MULTIPLIER))); + assertThat(config.getDryBase(), is(equalTo(AiGenerationConfig.DEFAULT_DRY_BASE))); + assertThat(config.getDryAllowedLength(), is(equalTo(AiGenerationConfig.DEFAULT_DRY_ALLOWED_LENGTH))); + assertThat(config.getDryPenaltyLastN(), is(equalTo(AiGenerationConfig.DEFAULT_DRY_PENALTY_LAST_N))); + assertThat(config.getDrySequenceBreakers(), is(Collections.emptyList())); } @Test @@ -137,11 +180,11 @@ public void getConfig_multipleDefinitions_returnsCorrectOne() { // arrange final AiModelDefinition defA = new AiModelDefinition(); defA.setKey("model-a"); - defA.setMaxRetries(1); + defA.setMaxOutputTokens(1); final AiModelDefinition defB = new AiModelDefinition(); defB.setKey("model-b"); - defB.setMaxRetries(7); + defB.setMaxOutputTokens(7); final AiModelDefinitionSupport support = new AiModelDefinitionSupport(Arrays.asList(defA, defB)); @@ -150,8 +193,8 @@ public void getConfig_multipleDefinitions_returnsCorrectOne() { final AiGenerationConfig configB = support.getConfig("model-b"); // assert - assertThat(configA.getMaxRetries(), is(equalTo(1))); - assertThat(configB.getMaxRetries(), is(equalTo(7))); + assertThat(configA.getMaxOutputTokens(), is(equalTo(1))); + assertThat(configB.getMaxOutputTokens(), is(equalTo(7))); } @Test diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionTest.java index 573e67d..7d327d0 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiModelDefinitionTest.java @@ -47,4 +47,154 @@ public void setStopStringsNullClearsToNull() { d.setStopStrings(null); assertThat(d.getStopStrings(), is(nullValue())); } + + @Test + public void cachePromptDefaultsTrueAndTogglesFalse() { + AiModelDefinition d = new AiModelDefinition(); + // Default true kills the false-default / "return false" getter mutants. + assertThat(d.isCachePrompt(), is(true)); + d.setCachePrompt(false); + // Observing false after the setter kills the "return true" getter mutant and the + // removed-assignment setter mutant. + assertThat(d.isCachePrompt(), is(false)); + } + + @Test + public void reasoningEffortDefaultsLowAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + // Default "low" kills the empty/null return mutants on the getter. + assertThat(d.getReasoningEffort(), is("low")); + d.setReasoningEffort("medium"); + // Round-tripped value kills the removed-assignment setter mutant. + assertThat(d.getReasoningEffort(), is("medium")); + } + + @Test + public void minPDefaultsDisabledAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + // Default 0.0 (disabled) kills the inline-constant / "return 1.0" getter mutants. + assertThat(d.getMinP(), is(0.0f)); + d.setMinP(0.05f); + // Round-tripped non-zero value kills the "return 0" getter and removed-assignment setter mutants. + assertThat(d.getMinP(), is(0.05f)); + } + + @Test + public void topNSigmaDefaultsDisabledAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + // Default -1.0 (disabled) kills the inline-constant / "return 0" getter mutants. + assertThat(d.getTopNSigma(), is(-1.0f)); + d.setTopNSigma(1.5f); + // Round-tripped value kills the getter "return 0" and removed-assignment setter mutants. + assertThat(d.getTopNSigma(), is(1.5f)); + } + + @Test + public void swaFullDefaultsTrueAndTogglesFalse() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.isSwaFull(), is(true)); + d.setSwaFull(false); + assertThat(d.isSwaFull(), is(false)); + } + + @Test + public void cacheReuseDefaultsTwoFiftySixAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.getCacheReuse(), is(256)); + d.setCacheReuse(128); + assertThat(d.getCacheReuse(), is(128)); + } + + @Test + public void gpuLayersDefaultsMinusOneAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.getGpuLayers(), is(-1)); + d.setGpuLayers(33); + assertThat(d.getGpuLayers(), is(33)); + } + + @Test + public void mainGpuDefaultsMinusOneAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.getMainGpu(), is(-1)); + d.setMainGpu(1); + assertThat(d.getMainGpu(), is(1)); + } + + @Test + public void devicesDefaultsEmptyAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.getDevices(), is("")); + d.setDevices("Vulkan1"); + assertThat(d.getDevices(), is("Vulkan1")); + } + + @Test + public void setDevicesNullResetsToEmpty() { + AiModelDefinition d = new AiModelDefinition(); + d.setDevices("CUDA0"); + d.setDevices(null); + assertThat(d.getDevices(), is("")); + } + + @Test + public void reasoningBudgetTokensDefaultsUnrestrictedAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.getReasoningBudgetTokens(), is(-1)); + d.setReasoningBudgetTokens(2048); + assertThat(d.getReasoningBudgetTokens(), is(2048)); + } + + @Test + public void dryMultiplierDefaultsDisabledAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.getDryMultiplier(), is(0.0f)); + d.setDryMultiplier(0.8f); + assertThat(d.getDryMultiplier(), is(0.8f)); + } + + @Test + public void dryBaseDefaultsAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.getDryBase(), is(1.75f)); + d.setDryBase(1.5f); + assertThat(d.getDryBase(), is(1.5f)); + } + + @Test + public void dryAllowedLengthDefaultsAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.getDryAllowedLength(), is(2)); + d.setDryAllowedLength(5); + assertThat(d.getDryAllowedLength(), is(5)); + } + + @Test + public void dryPenaltyLastNDefaultsWholeContextAndRoundTrips() { + AiModelDefinition d = new AiModelDefinition(); + assertThat(d.getDryPenaltyLastN(), is(-1)); + d.setDryPenaltyLastN(256); + assertThat(d.getDryPenaltyLastN(), is(256)); + } + + @Test + public void drySequenceBreakersNullByDefault() { + assertThat(new AiModelDefinition().getDrySequenceBreakers(), is(nullValue())); + } + + @Test + public void drySequenceBreakersRoundTrip() { + AiModelDefinition d = new AiModelDefinition(); + d.setDrySequenceBreakers(Arrays.asList("\n", ":")); + assertThat(d.getDrySequenceBreakers(), hasItem("\n")); + assertThat(d.getDrySequenceBreakers(), hasItem(":")); + } + + @Test + public void setDrySequenceBreakersNullClearsToNull() { + AiModelDefinition d = new AiModelDefinition(); + d.setDrySequenceBreakers(Arrays.asList("a")); + d.setDrySequenceBreakers(null); + assertThat(d.getDrySequenceBreakers(), is(nullValue())); + } } diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiRangeConditionTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiRangeConditionTest.java new file mode 100644 index 0000000..d597226 --- /dev/null +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/config/AiRangeConditionTest.java @@ -0,0 +1,69 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.config; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +public class AiRangeConditionTest { + + @Test + public void minMaxRoundTrip() { + final AiRangeCondition r = new AiRangeCondition(); + assertThat(r.getMin(), is(equalTo(0L))); + assertThat(r.getMax(), is(equalTo(0L))); + r.setMin(16384L); + r.setMax(49152L); + assertThat(r.getMin(), is(equalTo(16384L))); + assertThat(r.getMax(), is(equalTo(49152L))); + } + + @Test + public void contains_minExclusiveMaxInclusive() { + final AiRangeCondition r = new AiRangeCondition(); + r.setMin(1000L); + r.setMax(2000L); + assertThat(r.contains(1000L), is(false)); // min exclusive + assertThat(r.contains(1001L), is(true)); + assertThat(r.contains(2000L), is(true)); // max inclusive + assertThat(r.contains(2001L), is(false)); + } + + @Test + public void contains_unbounded() { + final AiRangeCondition r = new AiRangeCondition(); + assertThat(r.contains(0L), is(true)); + assertThat(r.contains(Long.MAX_VALUE), is(true)); + } + + @Test + public void contains_onlyMin() { + final AiRangeCondition r = new AiRangeCondition(); + r.setMin(1000L); + assertThat(r.contains(1000L), is(false)); + assertThat(r.contains(1001L), is(true)); + } + + @Test + public void contains_onlyMax() { + final AiRangeCondition r = new AiRangeCondition(); + r.setMax(1000L); + assertThat(r.contains(1000L), is(true)); + assertThat(r.contains(1001L), is(false)); + } + + @Test + public void hasBound() { + assertThat(new AiRangeCondition().hasBound(), is(false)); + final AiRangeCondition min = new AiRangeCondition(); + min.setMin(1L); + assertThat(min.hasBound(), is(true)); + final AiRangeCondition max = new AiRangeCondition(); + max.setMax(1L); + assertThat(max.hasBound(), is(true)); + } +} diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupportTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupportTest.java index a22f2d6..47ac267 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupportTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiFieldGenerationSupportTest.java @@ -11,14 +11,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import net.ladenthin.maven.llamacpp.aiindex.CommonTestFixtures; -import net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig; -import net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig; -import net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinition; -import net.ladenthin.maven.llamacpp.aiindex.config.AiModelDefinitionSupport; import net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest; import net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationResult; import net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader; @@ -193,8 +188,7 @@ public void processFieldGenerations_providerReturnsEmpty_resultBodyIsEmpty() thr } @Test - public void processFieldGenerations_providerReturnEmptyThenNonEmpty_noWarningLoggedAndResultBodyIsNonEmpty() - throws Exception { + public void processFieldGenerations_providerReturnsEmpty_callsProviderOnceWarnsOnceAndBodyEmpty() throws Exception { // arrange final Path contextFile = Files.createTempFile("Test", ".java"); final AiMdHeader header = new AiMdHeader( @@ -208,59 +202,12 @@ public void processFieldGenerations_providerReturnEmptyThenNonEmpty_noWarningLog AiMdHeaderCodec.NODE_TYPE_FILE); final AiPromptSupport promptSupport = new AiPromptSupport(CommonTestFixtures.createFilePromptDefinitions()); final AtomicInteger callCount = new AtomicInteger(0); - // Returns empty on the first call, a real summary on the first retry - final AiGenerationProvider eventualProvider = new AiGenerationProvider() { - @Override - public String generate(final AiGenerationRequest request) { - callCount.incrementAndGet(); - return ""; - } - - @Override - public String generate(final AiGenerationRequest request, final float temperatureOverride) { - callCount.incrementAndGet(); - return "Summary on retry."; - } - }; - final AiFieldGenerationSupport support = new AiFieldGenerationSupport( - capturingLog, - eventualProvider, - new AiPromptPreparationSupport(promptSupport), - CommonTestFixtures.createDefaultAiModelDefinitionSupport()); - - // act - final AiGenerationResult result = support.processFieldGenerations( - CommonTestFixtures.createFileFieldGenerations(), contextFile, "file", "public class Test {}", header); - - // assert — warning suppressed because retry succeeded - assertThat(capturingLog.getCapturedWarnings().isEmpty(), is(true)); - assertThat(result.body(), is(equalTo("Summary on retry."))); - } - - @Test - public void processFieldGenerations_providerAlwaysEmpty_retriesDefaultMaxRetriesTimes() throws Exception { - // arrange - final Path contextFile = Files.createTempFile("Test", ".java"); - final AiMdHeader header = new AiMdHeader( - "Test.java", - "1.0", - "ABCD1234", - "2026-01-01T00:00:00Z", - "2026-01-01T00:01:00Z", - "0.1.0", - "0.0.0", - AiMdHeaderCodec.NODE_TYPE_FILE); - final AiPromptSupport promptSupport = new AiPromptSupport(CommonTestFixtures.createFilePromptDefinitions()); - final AtomicInteger retryCallCount = new AtomicInteger(0); + // The retry mechanism was removed: an empty body now fails fast with a single warning + // instead of re-inferring (see docs/ai-index-benchmark/gpt-oss-tuning.md, E2). final AiGenerationProvider alwaysEmptyProvider = new AiGenerationProvider() { @Override public String generate(final AiGenerationRequest request) { - return ""; - } - - @Override - public String generate(final AiGenerationRequest request, final float temperatureOverride) { - retryCallCount.incrementAndGet(); + callCount.incrementAndGet(); return ""; } }; @@ -271,15 +218,17 @@ public String generate(final AiGenerationRequest request, final float temperatur CommonTestFixtures.createDefaultAiModelDefinitionSupport()); // act - support.processFieldGenerations( + final AiGenerationResult result = support.processFieldGenerations( CommonTestFixtures.createFileFieldGenerations(), contextFile, "file", "public class Test {}", header); - // assert — retry was invoked exactly DEFAULT_MAX_RETRIES times - assertThat(retryCallCount.get(), is(equalTo(AiGenerationConfig.DEFAULT_MAX_RETRIES))); + // assert — provider invoked exactly once (no retries), one warning, empty body + assertThat(callCount.get(), is(equalTo(1))); + assertThat(capturingLog.getCapturedWarnings().size(), is(equalTo(1))); + assertThat(result.body(), is(equalTo(""))); } @Test - public void processFieldGenerations_providerAlwaysEmpty_logsRetryInfoMessages() throws Exception { + public void processFieldGenerations_providerReturnsEmpty_logsProcessingAndGenerationOnlyNoRetry() throws Exception { // arrange final Path contextFile = Files.createTempFile("Test", ".java"); final AiMdHeader header = new AiMdHeader( @@ -297,11 +246,6 @@ public void processFieldGenerations_providerAlwaysEmpty_logsRetryInfoMessages() public String generate(final AiGenerationRequest request) { return ""; } - - @Override - public String generate(final AiGenerationRequest request, final float temperatureOverride) { - return ""; - } }; final AiFieldGenerationSupport support = new AiFieldGenerationSupport( capturingLog, @@ -313,76 +257,35 @@ public String generate(final AiGenerationRequest request, final float temperatur support.processFieldGenerations( CommonTestFixtures.createFileFieldGenerations(), contextFile, "file", "public class Test {}", header); - // assert — one INFO log per retry attempt + one for the initial generation attempt + // assert — exactly three INFO lines: the per-file processing/ETA line, the generation line, + // and the measured actual-duration line. No retry lines (the retry mechanism was removed). final List infos = capturingLog.getCapturedInfos(); - assertThat(infos.size(), is(equalTo(AiGenerationConfig.DEFAULT_MAX_RETRIES + 1))); - - // First message: initial generation attempt with config details - final String firstMsg = infos.get(0); - assertThat(firstMsg, containsString("Generating field '" + CommonTestFixtures.PROMPT_KEY_FILE_BODY + "'")); - assertThat(firstMsg, containsString("temperature=0.15")); - assertThat(firstMsg, containsString("maxRetries=3")); - assertThat(firstMsg, containsString("retryTemperatureIncrement=0.1")); - assertThat(firstMsg, containsString("maxInputChars=")); - - // Remaining messages: retry attempts - for (int i = 1; i < infos.size(); i++) { - final String retryMsg = infos.get(i); - assertThat(retryMsg, containsString("Retrying AI generation (attempt " + i + "/3)")); - assertThat(retryMsg, containsString("field '" + CommonTestFixtures.PROMPT_KEY_FILE_BODY + "'")); - assertThat(retryMsg, containsString("temperature=")); - assertThat(retryMsg, containsString("baseTemp=0.15")); + assertThat(infos.size(), is(equalTo(3))); + + // First message: the per-file processing line with size + token + duration estimate + final String processingMsg = infos.get(0); + assertThat(processingMsg, containsString("Processing file")); + assertThat(processingMsg, containsString("tokens")); + assertThat(processingMsg, containsString("estimated")); + + // Second message: the single generation line — temperature + maxInputChars, no retry config + final String generatingMsg = infos.get(1); + assertThat(generatingMsg, containsString("Generating field '" + CommonTestFixtures.PROMPT_KEY_FILE_BODY + "'")); + assertThat(generatingMsg, containsString("temperature=0.15")); + assertThat(generatingMsg, containsString("maxInputChars=")); + assertThat(generatingMsg.contains("maxRetries"), is(false)); + assertThat(generatingMsg.contains("retryTemperatureIncrement"), is(false)); + + // Third message: the measured actual-duration line (real wall time vs the estimate) + final String generatedMsg = infos.get(2); + assertThat(generatedMsg, containsString("Generated file")); + assertThat(generatedMsg, containsString("in ")); + assertThat(generatedMsg, containsString("(actual; estimated ")); + + // No INFO line mentions a retry + for (final String info : infos) { + assertThat(info.contains("Retrying"), is(false)); } } - - @Test - public void processFieldGenerations_zeroMaxRetries_providerCalledOnce() throws Exception { - // arrange - final Path contextFile = Files.createTempFile("Test", ".java"); - final AiMdHeader header = new AiMdHeader( - "Test.java", - "1.0", - "ABCD1234", - "2026-01-01T00:00:00Z", - "2026-01-01T00:01:00Z", - "0.1.0", - "0.0.0", - AiMdHeaderCodec.NODE_TYPE_FILE); - final AiPromptSupport promptSupport = new AiPromptSupport(CommonTestFixtures.createFilePromptDefinitions()); - final AtomicInteger retryCallCount = new AtomicInteger(0); - final AiGenerationProvider alwaysEmptyProvider = new AiGenerationProvider() { - @Override - public String generate(final AiGenerationRequest request) { - return ""; - } - - @Override - public String generate(final AiGenerationRequest request, final float temperatureOverride) { - retryCallCount.incrementAndGet(); - return ""; - } - }; - // Build a model definition with maxRetries=0 and reference it by key - final String zeroRetriesKey = "zero-retries"; - final AiModelDefinition zeroRetriesDef = new AiModelDefinition(); - zeroRetriesDef.setKey(zeroRetriesKey); - zeroRetriesDef.setMaxRetries(0); - final AiModelDefinitionSupport modelSupport = new AiModelDefinitionSupport(Arrays.asList(zeroRetriesDef)); - - final AiFieldGenerationConfig fieldConfig = new AiFieldGenerationConfig(); - fieldConfig.setPromptKey(CommonTestFixtures.PROMPT_KEY_FILE_BODY); - fieldConfig.setAiDefinitionKey(zeroRetriesKey); - - final AiFieldGenerationSupport support = new AiFieldGenerationSupport( - capturingLog, alwaysEmptyProvider, new AiPromptPreparationSupport(promptSupport), modelSupport); - - // act - support.processFieldGenerations( - Arrays.asList(fieldConfig), contextFile, "file", "public class Test {}", header); - - // assert — no retry calls when maxRetries=0 - assertThat(retryCallCount.get(), is(equalTo(0))); - assertThat(capturingLog.getCapturedWarnings().size(), is(equalTo(1))); - } // } diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiIndexPlanTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiIndexPlanTest.java new file mode 100644 index 0000000..539484d --- /dev/null +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiIndexPlanTest.java @@ -0,0 +1,118 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.indexer; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.nio.file.Path; +import java.nio.file.Paths; +import net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig; +import org.junit.jupiter.api.Test; + +public class AiIndexPlanTest { + + private static AiFieldGenerationConfig rule(final String promptKey) { + final AiFieldGenerationConfig config = new AiFieldGenerationConfig(); + config.setPromptKey(promptKey); + return config; + } + + private static AiFieldGenerationConfig rule(final String id, final String promptKey) { + final AiFieldGenerationConfig config = new AiFieldGenerationConfig(); + config.setId(id); + config.setPromptKey(promptKey); + return config; + } + + @Test + public void routedCountAndPerModelGrouping() { + final AiIndexPlan plan = new AiIndexPlan(); + plan.addRoute("modelA", Paths.get("a/Foo.java"), rule("p1"), 60); + plan.addRoute("modelA", Paths.get("a/Bar.java"), rule("p1"), 120); + plan.addRoute("modelB", Paths.get("b/Baz.java"), rule("p2"), 30); + + assertThat(plan.routedCount(), is(equalTo(3))); + assertThat(plan.routesByModel().get("modelA").size(), is(equalTo(2))); + assertThat(plan.routesByModel().get("modelB").size(), is(equalTo(1))); + } + + @Test + public void totalEstimatedSecondsSumsAllEntries() { + final AiIndexPlan plan = new AiIndexPlan(); + plan.addRoute("modelA", Paths.get("a/Foo.java"), rule("p1"), 60); + plan.addRoute("modelA", Paths.get("a/Bar.java"), rule("p1"), 120); + plan.addRoute("modelB", Paths.get("b/Baz.java"), rule("p2"), 30); + + assertThat(plan.totalEstimatedSeconds(), is(equalTo(210L))); + } + + @Test + public void renderMarkdown_containsModelSectionsFilesAndTotals() { + final Path base = Paths.get(""); + final AiIndexPlan plan = new AiIndexPlan(); + plan.addRoute("modelA", Paths.get("Foo.java"), rule("java-small", "file-body-java"), 60); + plan.addSkipped(Paths.get("Generated.java")); + plan.addUnmatched(Paths.get("weird.txt")); + + final String md = plan.renderMarkdown(base); + + assertThat(md, containsString("## AI index plan")); + assertThat(md, containsString("**Total:**")); + assertThat(md, containsString("### Model `modelA`")); + assertThat(md, containsString("| File | Rule | Prompt | Window | Est. |")); + assertThat(md, containsString("Foo.java")); + assertThat(md, containsString("java-small")); // the rule id shows in its own column + assertThat(md, containsString("file-body-java")); + assertThat(md, containsString("Skipped (1)")); + assertThat(md, containsString("Generated.java")); + assertThat(md, containsString("Unmatched")); + assertThat(md, containsString("weird.txt")); + } + + @Test + public void windowExceededCount_countsOnlyOverWindowEntries() { + final AiIndexPlan plan = new AiIndexPlan(); + // fits: source 1000 <= budget 5000 + plan.addRoute("modelA", Paths.get("Small.java"), rule("p1"), 10, 1000L, 5000L); + // exceeds: source 9000 > budget 5000 + plan.addRoute("modelA", Paths.get("Huge.java"), rule("p1"), 20, 9000L, 5000L); + // unchecked (4-arg) never counts as over-window + plan.addRoute("modelB", Paths.get("Plain.java"), rule("p2"), 5); + + assertThat(plan.windowExceededCount(), is(equalTo(1))); + assertThat(plan.routesByModel().get("modelA").get(0).exceedsWindow(), is(false)); + assertThat(plan.routesByModel().get("modelA").get(1).exceedsWindow(), is(true)); + assertThat(plan.routesByModel().get("modelB").get(0).windowChecked(), is(false)); + } + + @Test + public void renderMarkdown_flagsOverWindowFilesAndCells() { + final Path base = Paths.get(""); + final AiIndexPlan plan = new AiIndexPlan(); + plan.addRoute("modelA", Paths.get("Small.java"), rule("r1", "p1"), 10, 1000L, 5000L); + plan.addRoute("modelA", Paths.get("Huge.java"), rule("r1", "p1"), 20, 9000L, 5000L); + + final String md = plan.renderMarkdown(base); + + assertThat(md, containsString("1 over window")); + assertThat(md, containsString("ok")); // the fitting file's window cell + assertThat(md, containsString("(!) 9000>5000")); // the over-window file's window cell + assertThat(md, containsString("Over window")); + assertThat(md, containsString("Huge.java -> model `modelA`")); + } + + @Test + public void renderMarkdown_noWindowSectionWhenNothingExceeds() { + final AiIndexPlan plan = new AiIndexPlan(); + plan.addRoute("modelA", Paths.get("Small.java"), rule("r1", "p1"), 10, 1000L, 5000L); + + final String md = plan.renderMarkdown(Paths.get("")); + + assertThat(md, containsString("0 over window")); + assertThat(md.contains("### (!) Over window"), is(false)); + } +} diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiInputWindowCalculatorTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiInputWindowCalculatorTest.java new file mode 100644 index 0000000..d7657b4 --- /dev/null +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/AiInputWindowCalculatorTest.java @@ -0,0 +1,85 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.indexer; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import net.ladenthin.maven.llamacpp.aiindex.config.AiGenerationConfig; +import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport; +import org.junit.jupiter.api.Test; + +public class AiInputWindowCalculatorTest { + + private static AiGenerationConfig config( + final int contextSize, final int charsPerToken, final int maxOutputTokens) { + final AiGenerationConfig config = new AiGenerationConfig(); + config.setContextSize(contextSize); + config.setCharsPerToken(charsPerToken); + config.setMaxOutputTokens(maxOutputTokens); + return config; + } + + @Test + public void eofMarkerLengthAssumptionForConcreteCases() { + // The concrete numbers in maxInputChars_computesFromContextWindow assume this length; this guard + // makes any future EOF-marker change fail loudly here rather than silently shift the math. + assertThat(AiPromptPreparationSupport.EOF_MARKER_LENGTH, is(35)); + } + + @Test + public void maxInputChars_charsPerTokenZero_usesStaticFallback() { + final AiGenerationConfig config = config(2048, 0, 128); + config.setMaxInputChars(12345); + // charsPerToken <= 0 -> the static maxInputChars fallback is returned verbatim. + assertThat(AiInputWindowCalculator.maxInputChars(config, 999), is(12345)); + } + + @Test + public void maxInputChars_computesFromContextWindow() { + // total = 1000 * 4 = 4000; overhead = base 165 + EOF 35 + output 100*4=400 + safety 500 = 1100; + // available = 2900; rounded down to a 100-multiple = 2900. + final AiGenerationConfig config = config(1000, 4, 100); + assertThat(AiInputWindowCalculator.maxInputChars(config, 165), is(2900)); + } + + @Test + public void maxInputChars_roundsDownAndCountsEveryOverheadTerm() { + // total = 1000*4 = 4000; overhead = base 105 + EOF 35 + output 400 + safety 500 = 1040; + // available = 2960 (NOT a 100-multiple) -> rounded down to 2900. The non-multiple value makes the + // rounding observable, and 2960 sits so that dropping/flipping the 35-char EOF term (a +-70 shift) + // crosses the 100-boundary to 3000 -> any such mutation changes the result and is killed. + final AiGenerationConfig config = config(1000, 4, 100); + assertThat(AiInputWindowCalculator.maxInputChars(config, 105), is(2900)); + } + + @Test + public void maxInputChars_neverNegative_whenOverheadExceedsWindow() { + // Tiny context: overhead dwarfs the window, so the budget clamps to 0 (not negative). + final AiGenerationConfig config = config(10, 4, 100); + assertThat(AiInputWindowCalculator.maxInputChars(config, 165), is(0)); + } + + @Test + public void availableSourceChars_isBudgetMinusBasePrompt() { + // maxInputChars 2900 - basePromptLength 165 = 2735. + final AiGenerationConfig config = config(1000, 4, 100); + assertThat(AiInputWindowCalculator.availableSourceChars(config, 165), is(2735L)); + } + + @Test + public void availableSourceChars_neverNegative() { + // maxInputChars clamps to 0; subtracting basePromptLength still clamps to 0 (not negative). + final AiGenerationConfig config = config(10, 4, 100); + assertThat(AiInputWindowCalculator.availableSourceChars(config, 165), is(0L)); + } + + @Test + public void exceedsWindow_isTrueOnlyAboveTheSourceBudget() { + // availableSourceChars = 2735 here. + final AiGenerationConfig config = config(1000, 4, 100); + assertThat(AiInputWindowCalculator.exceedsWindow(config, 165, 2735L), is(false)); + assertThat(AiInputWindowCalculator.exceedsWindow(config, 165, 2736L), is(true)); + } +} diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexerTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexerTest.java index 00ea9f4..26871ed 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexerTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/indexer/SourceFileIndexerTest.java @@ -4,27 +4,24 @@ package net.ladenthin.maven.llamacpp.aiindex.indexer; import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import net.ladenthin.maven.llamacpp.aiindex.CommonTestFixtures; +import net.ladenthin.maven.llamacpp.aiindex.config.AiCondition; import net.ladenthin.maven.llamacpp.aiindex.config.AiFieldGenerationConfig; -import net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest; import net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocument; import net.ladenthin.maven.llamacpp.aiindex.document.AiMdDocumentCodec; -import net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeaderCodec; -import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptDefinition; +import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptPreparationSupport; import net.ladenthin.maven.llamacpp.aiindex.prompt.AiPromptSupport; -import net.ladenthin.maven.llamacpp.aiindex.provider.AiGenerationProvider; import net.ladenthin.maven.llamacpp.aiindex.provider.MockAiGenerationProvider; import org.apache.maven.plugin.logging.SystemStreamLog; import org.junit.jupiter.api.Test; @@ -33,30 +30,13 @@ public class SourceFileIndexerTest { private final AiMdDocumentCodec documentCodec = new AiMdDocumentCodec(); - // - @Test - public void indexSourceRoot_singleJavaFile_createsAiMdFile() throws Exception { - // arrange - final Path temp = Files.createTempDirectory("ai-index-test"); - final Path baseDirectory = temp; - final Path outputRoot = temp.resolve("src/site/ai"); - final Path sourceRoot = temp.resolve("src/main/java"); - final Path sourceFile = sourceRoot.resolve("com/example/Test.java"); - final Path aiFile = outputRoot.resolve("main/java/com/example/Test.java.ai.md"); - - Files.createDirectories(sourceFile.getParent()); - Files.write( - sourceFile, - ("package com.example;\n" + "\n" - + "public class Test {\n" - + " public String hello(final String name) {\n" - + " return \"Hello \" + name;\n" - + " }\n" - + "}\n") - .getBytes(StandardCharsets.UTF_8)); - - final AiPromptSupport promptSupport = new AiPromptSupport(CommonTestFixtures.createFilePromptDefinitions()); - final SourceFileIndexer indexer = new SourceFileIndexer( + private SourceFileIndexer indexer( + final Path baseDirectory, + final Path outputRoot, + final List excludes, + final long minSizeBytes, + final long maxSizeBytes) { + return new SourceFileIndexer( new SystemStreamLog(), baseDirectory, outputRoot, @@ -64,183 +44,190 @@ public void indexSourceRoot_singleJavaFile_createsAiMdFile() throws Exception { "1.0.0", "0.0.0", Collections.emptyList(), - Collections.emptyList(), - false, + excludes, + minSizeBytes, + maxSizeBytes, + false); + } + + private AiFieldGenerationSupport mockSupport() { + final AiPromptSupport promptSupport = new AiPromptSupport(CommonTestFixtures.createFilePromptDefinitions()); + return new AiFieldGenerationSupport( + new SystemStreamLog(), new MockAiGenerationProvider(), - CommonTestFixtures.createFileFieldGenerations(), - promptSupport, + new AiPromptPreparationSupport(promptSupport), CommonTestFixtures.createDefaultAiModelDefinitionSupport()); + } - // act - final int indexed = indexer.indexSourceRoot(sourceRoot); + private static void writeJava(final Path file, final String body) throws Exception { + Files.createDirectories(file.getParent()); + Files.write(file, body.getBytes(StandardCharsets.UTF_8)); + } - // pre-assert - assertThat(Files.exists(aiFile), is(true)); + /** Writes a {@code .java} file padded with a line comment to exactly {@code totalBytes} bytes. */ + private static void writeSizedJava(final Path file, final int totalBytes) throws Exception { + Files.createDirectories(file.getParent()); + final StringBuilder sb = new StringBuilder(totalBytes); + sb.append("// "); + while (sb.length() < totalBytes) { + sb.append('x'); + } + sb.setLength(totalBytes); + Files.write(file, sb.toString().getBytes(StandardCharsets.UTF_8)); + } - // assert - assertThat(indexed, is(equalTo(1))); + private static AiFieldGenerationConfig rule( + final String promptKey, final List extensions, final boolean skip, final boolean fallback) { + final AiFieldGenerationConfig config = new AiFieldGenerationConfig(); + config.setPromptKey(promptKey); + config.setAiDefinitionKey(CommonTestFixtures.AI_DEFINITION_KEY_DEFAULT); + config.setSkip(skip); + config.setFallback(fallback); + // fallback rules carry no condition; route/skip rules match by extension + if (!fallback) { + final AiCondition condition = new AiCondition(); + condition.setExtensions(extensions); + config.setCondition(condition); + } + return config; + } - final AiMdDocument document = documentCodec.read(aiFile); + // + @Test + public void collectCandidates_returnsMatchingJavaFile() throws Exception { + final Path temp = Files.createTempDirectory("ai-index-test"); + final Path sourceRoot = temp.resolve("src/main/java"); + writeJava(sourceRoot.resolve("com/example/Foo.java"), "class Foo {}\n"); - // pre-assert - assertThat(document, is(notNullValue())); + final List candidates = indexer(temp, temp.resolve("out"), Collections.emptyList(), 0L, 0L) + .collectCandidates(sourceRoot); - // assert - assertThat(document.header().title(), is(equalTo("Test.java"))); - assertThat(document.header().h(), is(equalTo(AiMdHeaderCodec.HEADER_VERSION_1_0))); - assertThat(document.header().x(), is(equalTo(AiMdHeaderCodec.NODE_TYPE_FILE))); - assertThat(document.header().g(), is(equalTo("1.0.0"))); - assertThat(document.header().a(), is(equalTo("0.0.0"))); - assertThat(document.header().c().trim().isEmpty(), is(false)); - assertThat(document.header().d().trim().isEmpty(), is(false)); - assertThat(document.header().t().trim().isEmpty(), is(false)); - assertThat(document.body().trim().isEmpty(), is(false)); + assertThat(candidates.size(), is(equalTo(1))); + assertThat(candidates.get(0).getFileName().toString(), is(equalTo("Foo.java"))); } - // - // @Test - public void indexSourceRoot_selectsPromptByFileExtension() throws Exception { - // arrange: a .java source; config maps .java -> java prompt, .sql -> sql, plus a fallback + public void collectCandidates_excludesGlobAndSizeBand() throws Exception { final Path temp = Files.createTempDirectory("ai-index-test"); - final Path outputRoot = temp.resolve("src/site/ai"); final Path sourceRoot = temp.resolve("src/main/java"); - Files.createDirectories(sourceRoot.resolve("com/example")); - Files.write( - sourceRoot.resolve("com/example/Foo.java"), - "package com.example;\nclass Foo {}\n".getBytes(StandardCharsets.UTF_8)); - - final AiPromptSupport promptSupport = new AiPromptSupport(Arrays.asList( - promptDefinition("file-body-java"), - promptDefinition("file-body-sql"), - promptDefinition("file-body-fallback"))); - final CapturingProvider provider = new CapturingProvider(); - final SourceFileIndexer indexer = new SourceFileIndexer( - new SystemStreamLog(), - temp, - outputRoot, - Arrays.asList(".java"), - "1.0.0", - "0.0.0", - Collections.emptyList(), - Collections.emptyList(), - false, - provider, - Arrays.asList( - fieldGeneration("file-body-java", Arrays.asList(".java")), - fieldGeneration("file-body-sql", Arrays.asList(".sql")), - fieldGeneration("file-body-fallback", null)), - promptSupport, - CommonTestFixtures.createDefaultAiModelDefinitionSupport()); + writeJava(sourceRoot.resolve("com/example/Foo.java"), "class Foo {}\n"); + writeJava(sourceRoot.resolve("com/example/package-info.java"), "package com.example;\n"); + writeSizedJava(sourceRoot.resolve("com/example/Big.java"), 5000); - // act - indexer.indexSourceRoot(sourceRoot); + // exclude package-info, and a max band of 1000 bytes drops Big.java + final List candidates = indexer( + temp, temp.resolve("out"), Arrays.asList("**/package-info.java"), 0L, 1000L) + .collectCandidates(sourceRoot); - // assert: only the java prompt ran for the .java file - assertThat(provider.promptKeys(), is(equalTo(Arrays.asList("file-body-java")))); + assertThat(candidates.size(), is(equalTo(1))); + assertThat(candidates.get(0).getFileName().toString(), is(equalTo("Foo.java"))); } @Test - public void indexSourceRoot_noMatchingExtensionAndNoFallback_throws() throws Exception { - // arrange: a .java file, but the only field generation targets .sql with no fallback + public void collectCandidates_sizeBandBoundaryMinExclusiveMaxInclusive() throws Exception { final Path temp = Files.createTempDirectory("ai-index-test"); - final Path outputRoot = temp.resolve("src/site/ai"); final Path sourceRoot = temp.resolve("src/main/java"); - Files.createDirectories(sourceRoot.resolve("com/example")); - Files.write( - sourceRoot.resolve("com/example/Foo.java"), - "package com.example;\nclass Foo {}\n".getBytes(StandardCharsets.UTF_8)); - - final AiPromptSupport promptSupport = - new AiPromptSupport(Collections.singletonList(promptDefinition("file-body-sql"))); - final SourceFileIndexer indexer = new SourceFileIndexer( - new SystemStreamLog(), - temp, - outputRoot, - Arrays.asList(".java"), - "1.0.0", - "0.0.0", - Collections.emptyList(), - Collections.emptyList(), - false, - new MockAiGenerationProvider(), - Collections.singletonList(fieldGeneration("file-body-sql", Arrays.asList(".sql"))), - promptSupport, - CommonTestFixtures.createDefaultAiModelDefinitionSupport()); - - // act + assert - assertThrows(IllegalArgumentException.class, () -> indexer.indexSourceRoot(sourceRoot)); + writeSizedJava(sourceRoot.resolve("com/example/Edge.java"), 1000); + + // max=1000 includes it (inclusive); min=1000 excludes it (exclusive) + assertThat( + indexer(temp, temp.resolve("a"), Collections.emptyList(), 0L, 1000L) + .collectCandidates(sourceRoot) + .size(), + is(equalTo(1))); + assertThat( + indexer(temp, temp.resolve("b"), Collections.emptyList(), 1000L, 0L) + .collectCandidates(sourceRoot) + .size(), + is(equalTo(0))); } // - // + // @Test - public void indexSourceRoot_excludedFileIsSkipped() throws Exception { - // arrange: two .java files; exclude package-info.java by glob + public void classify_routesByExtensionToPrompt() throws Exception { final Path temp = Files.createTempDirectory("ai-index-test"); - final Path outputRoot = temp.resolve("src/site/ai"); - final Path sourceRoot = temp.resolve("src/main/java"); - Files.createDirectories(sourceRoot.resolve("com/example")); - Files.write( - sourceRoot.resolve("com/example/Foo.java"), - "package com.example;\nclass Foo {}\n".getBytes(StandardCharsets.UTF_8)); - Files.write( - sourceRoot.resolve("com/example/package-info.java"), - "package com.example;\n".getBytes(StandardCharsets.UTF_8)); + final Path foo = temp.resolve("src/main/java/com/example/Foo.java"); + writeJava(foo, "class Foo {}\n"); + + final List rules = + Arrays.asList(rule("java", Arrays.asList(".java"), false, false), rule("fallback", null, false, true)); + + final AiIndexPlan plan = indexer(temp, temp.resolve("out"), Collections.emptyList(), 0L, 0L) + .classify(Arrays.asList(foo), rules); + + assertThat(plan.unmatched().isEmpty(), is(true)); + assertThat(plan.routedCount(), is(equalTo(1))); + assertThat( + plan.routesByModel() + .get(CommonTestFixtures.AI_DEFINITION_KEY_DEFAULT) + .get(0) + .rule() + .getPromptKey(), + is(equalTo("java"))); + } - final AiPromptSupport promptSupport = new AiPromptSupport(CommonTestFixtures.createFilePromptDefinitions()); - final SourceFileIndexer indexer = new SourceFileIndexer( - new SystemStreamLog(), - temp, - outputRoot, - Arrays.asList(".java"), - "1.0.0", - "0.0.0", - Collections.emptyList(), - Arrays.asList("**/package-info.java"), - false, - new MockAiGenerationProvider(), - CommonTestFixtures.createFileFieldGenerations(), - promptSupport, - CommonTestFixtures.createDefaultAiModelDefinitionSupport()); + @Test + public void classify_skipRuleSendsFileToSkipped() throws Exception { + final Path temp = Files.createTempDirectory("ai-index-test"); + final Path generated = temp.resolve("src/main/java/com/example/Generated.java"); + writeJava(generated, "class Generated {}\n"); - // act - final int indexed = indexer.indexSourceRoot(sourceRoot); + final List rules = Arrays.asList( + rule(null, Arrays.asList(".java"), true, false), // skip all .java + rule("fallback", null, false, true)); - // assert: only Foo.java was indexed; package-info.java was excluded - assertThat(indexed, is(equalTo(1))); - assertThat(Files.exists(outputRoot.resolve("main/java/com/example/Foo.java.ai.md")), is(true)); - assertThat(Files.exists(outputRoot.resolve("main/java/com/example/package-info.java.ai.md")), is(false)); - } - // + final AiIndexPlan plan = indexer(temp, temp.resolve("out"), Collections.emptyList(), 0L, 0L) + .classify(Arrays.asList(generated), rules); - private static AiPromptDefinition promptDefinition(final String key) { - final AiPromptDefinition definition = new AiPromptDefinition(); - definition.setKey(key); - definition.setTemplate("Summarize.\nFile: %s\nSource:\n%s\n"); - return definition; + assertThat(plan.skipped(), hasItem(generated)); + assertThat(plan.routedCount(), is(equalTo(0))); } - private static AiFieldGenerationConfig fieldGeneration(final String promptKey, final List extensions) { - final AiFieldGenerationConfig config = new AiFieldGenerationConfig(); - config.setPromptKey(promptKey); - config.setAiDefinitionKey(CommonTestFixtures.AI_DEFINITION_KEY_DEFAULT); - config.setFileExtensions(extensions); - return config; + @Test + public void classify_noRuleAndNoFallback_recordsUnmatched() throws Exception { + final Path temp = Files.createTempDirectory("ai-index-test"); + final Path foo = temp.resolve("src/main/java/com/example/Foo.java"); + writeJava(foo, "class Foo {}\n"); + + final List rules = + Collections.singletonList(rule("sql", Arrays.asList(".sql"), false, false)); + + final AiIndexPlan plan = indexer(temp, temp.resolve("out"), Collections.emptyList(), 0L, 0L) + .classify(Arrays.asList(foo), rules); + + assertThat(plan.unmatched(), hasItem(foo)); + assertThat(plan.routedCount(), is(equalTo(0))); } + // - /** Test provider that records the prompt key of each request so prompt selection can be asserted. */ - private static final class CapturingProvider implements AiGenerationProvider { - private final List promptKeys = new ArrayList<>(); + // + @Test + public void indexFile_writesAiMd_thenSkipsUnchanged() throws Exception { + final Path temp = Files.createTempDirectory("ai-index-test"); + final Path outputRoot = temp.resolve("src/site/ai"); + final Path foo = temp.resolve("src/main/java/com/example/Foo.java"); + writeJava(foo, "package com.example;\nclass Foo {}\n"); - @Override - public String generate(final AiGenerationRequest request) { - promptKeys.add(request.promptKey()); - return "body for " + request.promptKey(); - } + final SourceFileIndexer indexer = indexer(temp, outputRoot, Collections.emptyList(), 0L, 0L); + final AiFieldGenerationConfig rule = + CommonTestFixtures.createFileFieldGenerations().get(0); + final AiFieldGenerationSupport support = mockSupport(); - List promptKeys() { - return promptKeys; - } + // first write + final boolean wrote = indexer.indexFile(foo, rule, support); + final Path aiFile = outputRoot.resolve("main/java/com/example/Foo.java.ai.md"); + + assertThat(wrote, is(true)); + assertThat(Files.exists(aiFile), is(true)); + final AiMdDocument document = documentCodec.read(aiFile); + assertThat(document, is(notNullValue())); + assertThat(document.header().title(), is(equalTo("Foo.java"))); + assertThat(document.body().trim().isEmpty(), is(false)); + + // second write — unchanged source, so it is skipped + final boolean wroteAgain = indexer.indexFile(foo, rule, support); + assertThat(wroteAgain, is(false)); } + // } diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupportTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupportTest.java index 98a96cd..f984c31 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupportTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptPreparationSupportTest.java @@ -95,5 +95,73 @@ public void preparePrompt_overheadAlreadyExceedsLimit_sourceTrimmedToEmpty() { assertThat(preparedPrompt.trimmedSourceLength(), is(equalTo(0))); assertThat(preparedPrompt.availableSourceChars(), is(equalTo(0))); } + + @Test + public void preparePrompt_lengthExactlyAtLimit_notTrimmed() { + // arrange + final AiPromptSupport promptSupport = createPromptSupport(); + final AiPromptPreparationSupport support = new AiPromptPreparationSupport(promptSupport); + final String sourceText = "public class Test {}\n"; + final AiGenerationRequest request = + new AiGenerationRequest("file-summary", Paths.get("Test.java"), sourceText, buildHeader()); + // limit set to EXACTLY the full prompt length: the <= guard must treat this as "fits". + final int exactLimit = promptSupport + .buildPrompt("file-summary", Paths.get("Test.java"), sourceText) + .length(); + + // act + final AiPreparedPrompt prepared = support.preparePrompt(request, exactLimit); + + // assert — kills the "<=" -> "<" conditional-boundary mutant on the fits-within-limit check. + assertThat(prepared.trimmed(), is(false)); + } + // + + // + @Test + public void getBasePromptLength_returnsRenderedBaseLength() { + final AiPromptSupport promptSupport = createPromptSupport(); + final AiPromptPreparationSupport support = new AiPromptPreparationSupport(promptSupport); + final int expected = promptSupport + .buildPrompt("file-summary", Paths.get("Test.java"), "") + .length(); + // Exact, non-zero base length kills the "return 0" primitive-return mutant. + assertThat(support.getBasePromptLength("file-summary", Paths.get("Test.java")), is(equalTo(expected))); + assertThat(expected > 0, is(true)); + } + // + + // + @Test + public void trim_targetAtOrBeyondLength_returnsFullSource() { + final AiPromptPreparationSupport support = new AiPromptPreparationSupport(createPromptSupport()); + // targetIndex == length: "a\nb" distinguishes the ">=" boundary from ">" (the mutant would + // fall through and cut at the newline, yielding "a\n"). Also covers the "return source" path. + assertThat(support.trimSourceAtLineBreak("a\nb", 3), is(equalTo("a\nb"))); + // targetIndex > length: kills the empty-object return mutant on the "return sourceText" path. + assertThat(support.trimSourceAtLineBreak("abc", 5), is(equalTo("abc"))); + } + + @Test + public void trim_noNewlineBeforeTarget_cutsAtTarget() { + final AiPromptPreparationSupport support = new AiPromptPreparationSupport(createPromptSupport()); + // lastNewline < 0 branch -> substring(0, target). Exact value kills the empty-return mutant. + assertThat(support.trimSourceAtLineBreak("abcdef", 3), is(equalTo("abc"))); + } + + @Test + public void trim_newlineBeforeTarget_cutsAtLineBoundary() { + final AiPromptPreparationSupport support = new AiPromptPreparationSupport(createPromptSupport()); + // Newline at index 1 -> substring(0, lastNewline + 1) = "a\n". Exact value kills the math + // mutant on (lastNewline + 1) and the empty-return mutant; covers the newline branch (was NO_COVERAGE). + assertThat(support.trimSourceAtLineBreak("a\nbcd", 3), is(equalTo("a\n"))); + } + + @Test + public void trim_newlineAtStart_distinguishesConditionalBoundary() { + final AiPromptPreparationSupport support = new AiPromptPreparationSupport(createPromptSupport()); + // lastNewline == 0 distinguishes "< 0" from the "<= 0" boundary mutant ("\n" vs "\nab"). + assertThat(support.trimSourceAtLineBreak("\nabc", 3), is(equalTo("\n"))); + } // } diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupportTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupportTest.java index 59c9b47..37c988b 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupportTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupportTest.java @@ -23,37 +23,74 @@ private static AiPromptDefinition def(String key, String template) { return d; } + // @Test - public void buildPromptRendersFileNameAndSource() { - AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("summary", "File %s: %s"))); - String prompt = support.buildPrompt("summary", Paths.get("a", "Foo.java"), "the source"); - assertThat(prompt, is("File Foo.java: the source")); + public void systemPromptReturnsTemplateVerbatim() { + AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("summary", "INSTRUCTIONS %x"))); + // The template is the system message, returned verbatim — no placeholder substitution. + assertThat(support.systemPrompt("summary"), is("INSTRUCTIONS %x")); } @Test - public void buildPromptUsesFullPathWhenFileNameNull() { - AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("summary", "[%s] %s"))); - // A root path has a null getFileName() on every OS, so buildPrompt falls back to the full - // path string. Derive the expected separator from the same Path so the assertion holds on - // Windows too (the root renders with the platform separator: "/" on POSIX, "\" on Windows). + public void systemPromptThrowsWhenKeyUnknown() { + AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("summary", "tpl"))); + // template == null branch. + assertThrows(IllegalArgumentException.class, () -> support.systemPrompt("missing")); + } + + @Test + public void systemPromptThrowsWhenTemplateBlank() { + AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("blank", " "))); + // isBlank(template) branch — kills the negate mutant on the template guard. + assertThrows(IllegalArgumentException.class, () -> support.systemPrompt("blank")); + } + // + + // + @Test + public void userMessagePutsNameThenBlankLineThenBody() { + AiPromptSupport support = new AiPromptSupport(Collections.emptyList()); + // Exact form: file name, a blank line, then the body. Kills the separator and the + // getFileName()-vs-full-path mutants. + assertThat(support.userMessage(Paths.get("a", "Foo.java"), "the source"), is("Foo.java\n\nthe source")); + } + + @Test + public void userMessageUsesFullPathWhenFileNameNull() { + AiPromptSupport support = new AiPromptSupport(Collections.emptyList()); + // A root path has a null getFileName() on every OS, so userMessage falls back to the full + // path. Derive the expected separator from the same Path so the assertion holds on Windows. Path root = Paths.get("/"); - assertThat(support.buildPrompt("summary", root, "x"), is("[" + root + "] x")); + assertThat(support.userMessage(root, "x"), is(root + "\n\nx")); } + // + // @Test - public void buildPromptThrowsWhenKeyUnknown() { - AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("summary", "x %s %s"))); - // template == null branch. - assertThrows(IllegalArgumentException.class, () -> support.buildPrompt("missing", Paths.get("F"), "s")); + public void buildPromptCombinesSystemThenUser() { + AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("summary", "SYS"))); + // Combined length proxy = systemPrompt + "\n\n" + userMessage. Exact form kills the + // join-separator mutant. + assertThat(support.buildPrompt("summary", Paths.get("Foo.java"), "BODY"), is("SYS\n\nFoo.java\n\nBODY")); } @Test - public void buildPromptThrowsWhenTemplateBlank() { - AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("blank", " "))); - // isBlank(template) branch — kills the negate mutant on the template guard. - assertThrows(IllegalArgumentException.class, () -> support.buildPrompt("blank", Paths.get("F"), "s")); + public void buildPromptIncludesBothSystemAndUserParts() { + AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("summary", "HEADER-INSTRUCTIONS"))); + String combined = support.buildPrompt("summary", Paths.get("Bar.java"), "class Bar {}"); + assertThat(combined, containsString("HEADER-INSTRUCTIONS")); + assertThat(combined, containsString("Bar.java")); + assertThat(combined, containsString("class Bar {}")); + } + + @Test + public void buildPromptThrowsWhenKeyUnknown() { + AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("summary", "x"))); + assertThrows(IllegalArgumentException.class, () -> support.buildPrompt("missing", Paths.get("F"), "s")); } + // + // @Test public void nullKeyInDefinitionThrowsNamedNpe() { // Exercises the requireNonNull(key) message supplier lambda. @@ -73,13 +110,14 @@ public void nullTemplateInDefinitionThrowsNamedNpe() { @Test public void nullDefinitionsListIsTreatedAsEmpty() { AiPromptSupport support = new AiPromptSupport(null); - assertThrows(IllegalArgumentException.class, () -> support.buildPrompt("any", Paths.get("F"), "s")); + assertThrows(IllegalArgumentException.class, () -> support.systemPrompt("any")); } @Test public void multipleDefinitionsAreAllRegistered() { - AiPromptSupport support = new AiPromptSupport(Arrays.asList(def("a", "A %s %s"), def("b", "B %s %s"))); - assertThat(support.buildPrompt("a", Paths.get("F"), "s"), is("A F s")); - assertThat(support.buildPrompt("b", Paths.get("F"), "s"), is("B F s")); + AiPromptSupport support = new AiPromptSupport(Arrays.asList(def("a", "A-TPL"), def("b", "B-TPL"))); + assertThat(support.systemPrompt("a"), is("A-TPL")); + assertThat(support.systemPrompt("b"), is("B-TPL")); } + // } diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactoryTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactoryTest.java index 4223fcd..e55fec7 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactoryTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/AiGenerationProviderFactoryTest.java @@ -19,7 +19,32 @@ public class AiGenerationProviderFactoryTest { private static LlamaCppJniConfig jniConfig() { return new LlamaCppJniConfig( - null, "model.gguf", 2048, 128, 0.15f, 2, 0.9f, 40, 1.1f, false, Collections.emptyList()); + null, + "model.gguf", + 2048, + 128, + 0.15f, + 2, + 0.9f, + 40, + 0.0f, + -1.0f, + 1.1f, + false, + true, + false, + 0, + -1, + -1, + "", + "low", + -1, + 0.0f, + 1.75f, + 2, + -1, + Collections.emptyList(), + Collections.emptyList()); } @Test diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProviderTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProviderTest.java index b99976e..50fc200 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProviderTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/LlamaCppJniAiGenerationProviderTest.java @@ -43,8 +43,23 @@ public void generate_realProvider_returnsNonEmptyResponse() throws Exception { 8, AiGenerationConfig.DEFAULT_TOP_P, AiGenerationConfig.DEFAULT_TOP_K, + AiGenerationConfig.DEFAULT_MIN_P, + AiGenerationConfig.DEFAULT_TOP_N_SIGMA, AiGenerationConfig.DEFAULT_REPEAT_PENALTY, AiGenerationConfig.DEFAULT_CHAT_TEMPLATE_ENABLE_THINKING, + AiGenerationConfig.DEFAULT_CACHE_PROMPT, + AiGenerationConfig.DEFAULT_SWA_FULL, + AiGenerationConfig.DEFAULT_CACHE_REUSE, + AiGenerationConfig.DEFAULT_GPU_LAYERS, + AiGenerationConfig.DEFAULT_MAIN_GPU, + AiGenerationConfig.DEFAULT_DEVICES, + AiGenerationConfig.DEFAULT_REASONING_EFFORT, + AiGenerationConfig.DEFAULT_REASONING_BUDGET_TOKENS, + AiGenerationConfig.DEFAULT_DRY_MULTIPLIER, + AiGenerationConfig.DEFAULT_DRY_BASE, + AiGenerationConfig.DEFAULT_DRY_ALLOWED_LENGTH, + AiGenerationConfig.DEFAULT_DRY_PENALTY_LAST_N, + Collections.emptyList(), Collections.emptyList()); final AiPromptSupport promptSupport = new AiPromptSupport(CommonTestFixtures.createFilePromptDefinitions()); diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProviderTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProviderTest.java index b1f94b9..5d1843b 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProviderTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProviderTest.java @@ -38,12 +38,4 @@ public void generateFallsBackToFullPathWhenFileNameNull() throws IOException { AiGenerationRequest request = new AiGenerationRequest("summary", root, "src", HEADER); assertThat(provider.generate(request), is("Mock summary for " + root)); } - - @Test - public void temperatureOverrideDelegatesToPlainGenerate() throws IOException { - // Exercises AiGenerationProvider's default generate(request, temperature) which delegates - // to generate(request) — kills the empty-string return mutant on the interface default. - AiGenerationRequest request = new AiGenerationRequest("summary", Paths.get("Foo.java"), "src", HEADER); - assertThat(provider.generate(request, 0.9f), is("Mock summary for Foo.java")); - } } diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/support/AiGenerationTimeEstimatorTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/support/AiGenerationTimeEstimatorTest.java new file mode 100644 index 0000000..26d3b27 --- /dev/null +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/support/AiGenerationTimeEstimatorTest.java @@ -0,0 +1,93 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.support; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.number.IsCloseTo.closeTo; + +import org.junit.jupiter.api.Test; + +public class AiGenerationTimeEstimatorTest { + + private final AiGenerationTimeEstimator estimator = new AiGenerationTimeEstimator(); + + // + @Test + public void estimatePromptTokens_addsTemplateOverheadToScaledChars() { + // 4200 / 4.8 = 875 source tokens, + 700 template overhead = 1575. + assertThat(estimator.estimatePromptTokens(4200), is(1575)); + } + + @Test + public void estimatePromptTokens_zeroChars_isJustTemplateOverhead() { + assertThat(estimator.estimatePromptTokens(0), is(AiGenerationTimeEstimator.PROMPT_TEMPLATE_TOKEN_OVERHEAD)); + } + // + + // + @Test + public void estimatePrefillMillis_appliesLinearPlusQuadraticTerms() { + // 24.4*1000 + 0.000674*1000^2 = 24400 + 674 = 25074. + assertThat(estimator.estimatePrefillMillis(1000), is(closeTo(25074.0d, 1e-6d))); + } + + @Test + public void estimateDecodeMillis_scalesOutputByLinearPlusContextTerm() { + // 800 * (56.8 + 0.01568*1000) = 800 * 72.48 = 57984. + assertThat(estimator.estimateDecodeMillis(1000, 800), is(closeTo(57984.0d, 1e-6d))); + } + // + + // + @Test + public void estimateSeconds_combinesPrefillAndDecodeRoundedToSeconds() { + // n=1575: prefill=40101.94 ms + decode(800)=65196.8 ms = 105298.74 ms; ×1.15 margin / 1000 -> 121 s. + assertThat(estimator.estimateSeconds(4200, 800), is(121L)); + } + + @Test + public void estimateSeconds_defaultOverload_usesDefaultExpectedOutputTokens() { + assertThat( + estimator.estimateSeconds(4200), + is(estimator.estimateSeconds(4200, AiGenerationTimeEstimator.DEFAULT_EXPECTED_OUTPUT_TOKENS))); + } + // + + // + @Test + public void formatDuration_belowThreshold_rendersSeconds() { + assertThat(estimator.formatDuration(89L), is("~89 s")); + } + + @Test + public void formatDuration_atThreshold_rendersMinutesRoundedHalfUp() { + // 90 s / 60 = 1.5 -> rounds to 2. + assertThat(estimator.formatDuration(90L), is("~2 min")); + } + + @Test + public void formatDuration_zero_rendersSeconds() { + assertThat(estimator.formatDuration(0L), is("~0 s")); + } + // + + // + @Test + public void estimatePrefillMillis_reproducesMeasuredReferencePoints() { + // The quadratic model was fitted to three end-to-end CPU measurements + // (Ryzen 7 5800H, gpt-oss-20b UD-Q4_K_XL). It must reproduce each measured + // prefill within 5 %, otherwise the calibration constants have drifted. + assertPrefillWithinFivePercent(3309, 88254.16d); + assertPrefillWithinFivePercent(24081, 978040.23d); + assertPrefillWithinFivePercent(61484, 4053373.24d); + } + + private void assertPrefillWithinFivePercent(final int promptTokens, final double measuredMillis) { + final double predicted = estimator.estimatePrefillMillis(promptTokens); + final double tolerance = measuredMillis * 0.05d; + assertThat(predicted, is(closeTo(measuredMillis, tolerance))); + } + // +} diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/support/AiProgressBarTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/support/AiProgressBarTest.java new file mode 100644 index 0000000..d0d05c6 --- /dev/null +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/support/AiProgressBarTest.java @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: 2026 Bernard Ladenthin +// +// SPDX-License-Identifier: Apache-2.0 +package net.ladenthin.maven.llamacpp.aiindex.support; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +public class AiProgressBarTest { + + @Test + public void empty_zeroCompleted_isAllSpacesAndZeroPercent() { + assertThat(AiProgressBar.render(0, 100, 10), is("[ ] 0%")); + } + + @Test + public void full_completedEqualsTotal_isAllHashesAndHundredPercent() { + assertThat(AiProgressBar.render(100, 100, 10), is("[##########] 100%")); + } + + @Test + public void partial_roundsPercentAndFillCells() { + // 42/100 -> 42%; round(0.42*10) = 4 filled cells, 6 empty. + assertThat(AiProgressBar.render(42, 100, 10), is("[#### ] 42%")); + } + + @Test + public void partial_halfway() { + // 50/100 -> 50%; round(0.5*10) = 5 filled cells. + assertThat(AiProgressBar.render(50, 100, 10), is("[##### ] 50%")); + } + + @Test + public void nonPositiveTotal_rendersFullBar() { + // Nothing to do -> 100% rather than a divide-by-zero. + assertThat(AiProgressBar.render(0, 0, 10), is("[##########] 100%")); + } + + @Test + public void completedAboveTotal_clampsToFull() { + // Out-of-range high input clamps to 100% and a full bar (no overflow). + assertThat(AiProgressBar.render(150, 100, 10), is("[##########] 100%")); + } + + @Test + public void negativeCompleted_clampsToEmpty() { + // Out-of-range low input clamps to 0% and an empty bar. + assertThat(AiProgressBar.render(-5, 100, 10), is("[ ] 0%")); + } + + @Test + public void negativeWidth_treatedAsZeroCells() { + // No cells, but the percent is still computed. + assertThat(AiProgressBar.render(50, 100, -3), is("[] 50%")); + } + + @Test + public void defaultWidthIsTwenty() { + // The convenience overload uses DEFAULT_WIDTH (20) cells. + final String bar = AiProgressBar.render(100, 100); + assertThat(bar, is("[####################] 100%")); + assertThat(AiProgressBar.DEFAULT_WIDTH, is(20)); + } +}