Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,34 @@ METADATA_EXTRACTION_MODE=keyword
# METADATA_EXTRACTION_MODE=ollama). Pull it first:
# ollama pull qwen3:0.6b
OLLAMA_CLASSIFY_MODEL=qwen3:0.6b

# ── Codebase map: Magika file-type detection ────────────────────────
# Path to the Magika CLI binary. Install via `brew install magika`.
# If not found, falls back to suffix-based detection.
# MAGIKA_BINARY=magika

# ── Codebase map: document similarity threshold ─────────────────────
# Cosine similarity threshold for document graph edges (default 0.85).
# Lower = more edges, higher = fewer edges. Needs calibration experiment.
# DOC_SIMILARITY_THRESHOLD=0.85

# ── Codebase map: cache directory ───────────────────────────────────
# Per-project cache for codebase map, keyed by git commit hash.
# CODEBASE_MAP_CACHE_DIR=.opencode

# ── Codebase map: file count and depth limits ───────────────────────
# Maximum number of files to scan before truncating (default 5000).
# CODEBASE_MAP_MAX_FILES=5000
# Maximum directory depth for recursive scanning (default 10).
# CODEBASE_MAP_MAX_DEPTH=10

# ── Document backend selection ──────────────────────────────────────
# Controls document parsing backend. Accepted: "local" (default), "azure".
# "local" uses LiteParse → pypdfium2 → pypdf chain.
# "azure" uses Azure Document Intelligence with automatic fallback to local.
DOCUMENT_BACKEND=local

# Azure Document Intelligence credentials (only needed when DOCUMENT_BACKEND=azure).
# AZURE_DOC_INTELLIGENCE_ENDPOINT=https://<resource>.cognitiveservices.azure.com/
# AZURE_DOC_INTELLIGENCE_KEY=
# AZURE_DOC_INTELLIGENCE_MODEL=prebuilt-layout
43 changes: 31 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
extra: ['', 'pdf-liteparse']
exclude:
- os: ubuntu-latest
extra: pdf-liteparse # LiteParse native binary is macOS arm64 only for now

steps:
- uses: actions/checkout@v5
Expand All @@ -30,20 +26,43 @@ jobs:
run: pip install uv

- name: Install dependencies
run: |
if [ -n "${{ matrix.extra }}" ]; then
uv sync --extra ${{ matrix.extra }}
else
uv sync
fi
run: uv sync

- name: Run tests (fast)
env:
PDF_READER: pypdf
run: uv run pytest -m "not slow" --tb=short -q

- name: Run tests (slow, liteparse only)
if: matrix.extra == 'pdf-liteparse'
- name: Run tests (slow, liteparse on macOS)
if: matrix.os == 'macos-latest'
env:
PDF_READER: liteparse
run: uv run pytest -m "slow" --tb=short -q || echo "Slow tests skipped (Ollama not available in CI)"

sonarcloud:
name: SonarCloud Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: uv sync

- name: Run tests with coverage
run: uv run pytest -m "not slow" --cov=rag_mcp --cov-report=xml

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,16 @@ coverage.xml
*.swo
*~

# Codebase map cache (per-project, keyed by git commit)
.opencode/codebase-graph.json
.opencode/magika-inventory.json

# Generated knowledge graph artifacts
graphify-out/

# OS
.DS_Store
Thumbs.db

# Project Management
/niftypm
21 changes: 17 additions & 4 deletions .opencode/opencode.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
".opencode/plugins/graphify.js"
]
}
"plugin": [".opencode/plugins/graphify.js"],
"mcp": {
"sonarqube": {
"type": "local",
"command": [
"java",
"-jar",
"/Users/aizat/Development/PROJECTS/sonarqube-mcp-server/build/libs/sonarqube-mcp-server-1.22-SNAPSHOT.jar"
],
"env": {
"STORAGE_PATH": "/Users/aizat/Development/PROJECTS/sonarqube-mcp-server/storage",
"SONARQUBE_TOKEN": "${SONARQUBE_CLI_TOKEN}",
"SONARQUBE_ORG": "${SONARQUBE_CLI_ORG}"
}
}
}
}
43 changes: 43 additions & 0 deletions .opencode/plugins/fast-context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Fast Context Codebase Map Plugin for OpenCode.
*
* Injects a compact codebase map into the agent's system prompt at the
* start of each session. The map is fetched once per session via the
* `get_codebase_map` MCP tool and cached for the session duration.
*
* Auto-discovered when placed in `.opencode/plugins/`.
*/

import type { Plugin } from "@opencode-ai/plugin";

const injected = new Set<string>();

export const FastContextPlugin: Plugin = async ({ directory, $ }) => {
return {
"experimental.chat.system.transform": async (input, output) => {
const sessionID = input.sessionID;
if (!sessionID || injected.has(sessionID)) {
return;
}

try {
const proc =
$`uv run python -c "from rag_mcp.codebase_map import get_codebase_map_text; print(get_codebase_map_text(path='.', refresh=False))"`
.cwd(directory)
.quiet()
.nothrow();
const result = await proc.text();

if (result && !result.includes('"status": "error"')) {
output.system.push(`# Codebase Map\n\n${result}`);
injected.add(sessionID);
}
} catch (err) {
// Silently fail — the map is a convenience, not a requirement.
console.error("[fast-context] Failed to fetch codebase map:", err);
}
},
};
};

export default FastContextPlugin;
5 changes: 5 additions & 0 deletions .sonarlint/connectedMode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sonarCloudOrganization": "cmdaltctr",
"projectKey": "cmdaltctr_llamaindex-rag-mcp",
"region": "EU"
}
Loading
Loading