@devilsdev/rag-pipeline-utils 2.1.5 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -674
- package/README.md +395 -179
- package/bin/cli.js +14 -62
- package/contracts/embedder-contract.json +52 -0
- package/contracts/llm-contract.json +36 -0
- package/contracts/loader-contract.json +43 -0
- package/contracts/retriever-contract.json +68 -0
- package/dist/index.cjs +67 -0
- package/dist/index.mjs +51 -0
- package/package.json +108 -22
- package/.codecov.yml +0 -21
- package/.dockerignore +0 -14
- package/.eslintignore +0 -5
- package/.eslintrc.json +0 -28
- package/.github/PROJECT_ROADMAP.md +0 -102
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -8
- package/.github/release-template.md +0 -20
- package/.github/workflows/changelog-auto-commit.yml +0 -37
- package/.github/workflows/ci.yml +0 -53
- package/.github/workflows/docs-ci.yml +0 -46
- package/.github/workflows/docs-deploy.yml +0 -55
- package/.github/workflows/enforce-release-review.yml +0 -47
- package/.github/workflows/publish-release-blog.yml +0 -47
- package/.github/workflows/release-sync.yml +0 -50
- package/.github/workflows/roadmap-label-sync.yml +0 -35
- package/.github/workflows/roadmap-labels.yml +0 -67
- package/.github/workflows/roadmap-sync.yml +0 -44
- package/.github/workflows/sync-roadmap.yml +0 -62
- package/.husky/pre-commit +0 -6
- package/CHANGELOG.md +0 -97
- package/Dockerfile +0 -22
- package/Use-Cases.md +0 -134
- package/__tests__/fixtures/.ragrc.json +0 -8
- package/__tests__/fixtures/invalid-ragrc.json +0 -4
- package/__tests__/fixtures/sample-eval-dataset.json +0 -15
- package/__tests__/fixtures/sample.pdf +0 -1
- package/__tests__/fixtures/src/mocks/openai-embedder.js +0 -16
- package/__tests__/fixtures/src/mocks/openai-llm.js +0 -9
- package/__tests__/fixtures/src/mocks/pdf-loader.js +0 -17
- package/__tests__/fixtures/src/mocks/pinecone-retriever.js +0 -26
- package/__tests__/fixtures/valid-ragrc.json +0 -16
- package/__tests__/integration/cli/config-flow.test.js +0 -98
- package/__tests__/integration/config/load-config.test.js +0 -67
- package/__tests__/scripts/ensure-roadmap-labels.test.js +0 -64
- package/__tests__/unit/config/validate-schema.test.js +0 -121
- package/__tests__/unit/core/plugin-registry.test.js +0 -55
- package/__tests__/unit/reranker/__snapshots__/reranker.snapshot.test.js.snap +0 -15
- package/__tests__/unit/reranker/llm-reranker.test.js +0 -18
- package/__tests__/unit/reranker/reranker.enriched.test.js +0 -19
- package/__tests__/unit/reranker/reranker.fallback.test.js +0 -15
- package/__tests__/unit/reranker/reranker.snapshot.test.js +0 -15
- package/__tests__/unit/reranker/reranker.structured-output.test.js +0 -17
- package/codecov +0 -0
- package/codecov.SHA256SUM +0 -1
- package/codecov.SHA256SUM.sig +0 -16
- package/docs-site/README.md +0 -41
- package/docs-site/blog/2025-04-18-architecture-overview.md +0 -16
- package/docs-site/blog/2025-04-18-release-v2.1.1.md +0 -13
- package/docs-site/blog/2025-04-19-prompt-engineering-best-practices.md +0 -16
- package/docs-site/blog/2025-04-20-image-showcase.md +0 -14
- package/docs-site/blog/2025-04-20-release-2.1.1.md +0 -21
- package/docs-site/blog/2025-04-21-release-v2.1.3.md +0 -13
- package/docs-site/blog/2025-04-21-release-v2.1.4.md +0 -13
- package/docs-site/blog/authors.yml +0 -5
- package/docs-site/blog/tags.yml +0 -60
- package/docs-site/docs/Architecture.md +0 -76
- package/docs-site/docs/CLI.md +0 -69
- package/docs-site/docs/Evaluation.md +0 -61
- package/docs-site/docs/FAQ.md +0 -50
- package/docs-site/docs/Introduction.md +0 -58
- package/docs-site/docs/Plugins.md +0 -61
- package/docs-site/docs/Tutorials.md +0 -106
- package/docs-site/docs/Usage.md +0 -72
- package/docs-site/docs/Use-Cases.md +0 -77
- package/docs-site/docs/intro.mdx +0 -6
- package/docs-site/docusaurus.config.js +0 -88
- package/docs-site/package-lock.json +0 -17914
- package/docs-site/package.json +0 -47
- package/docs-site/sidebars.js +0 -39
- package/docs-site/src/components/HomepageFeatures/index.js +0 -56
- package/docs-site/src/components/HomepageFeatures/index.module.css +0 -57
- package/docs-site/src/components/HomepageHeader/index.js +0 -46
- package/docs-site/src/components/HomepageHeader/index.module.css +0 -77
- package/docs-site/src/css/custom.css +0 -104
- package/docs-site/src/pages/index.js +0 -20
- package/docs-site/src/pages/index.module.css +0 -23
- package/docs-site/src/pages/markdown-page.md +0 -7
- package/docs-site/static/.nojekyll +0 -0
- package/docs-site/static/img/authors/ali.jpg +0 -0
- package/docs-site/static/img/hero.jpg +0 -0
- package/docs-site/static/img/logo.png +0 -0
- package/docs-site/static/img/logo.svg +0 -6
- package/docs-site/static/img/social-card.jpg +0 -0
- package/jest.config.js +0 -24
- package/plugin.config.json +0 -14
- package/public/index.html +0 -0
- package/public/results/sample-eval.json +0 -0
- package/public/src/App.jsx +0 -57
- package/release.config.js +0 -36
- package/scripts/banner-injector.js +0 -102
- package/scripts/ci-runner.js +0 -51
- package/scripts/close-done-roadmap-issues.js +0 -65
- package/scripts/create-roadmap-issues.js +0 -47
- package/scripts/ensure-roadmap-labels.js +0 -73
- package/scripts/fix-mdx-blog-imports.js +0 -50
- package/scripts/fix-mdx-image-imports.js +0 -27
- package/scripts/generate-release-note.js +0 -40
- package/scripts/label-roadmap-issues.js +0 -125
- package/scripts/manual-test-checklist.md +0 -90
- package/scripts/repair-fixtures.js +0 -30
- package/scripts/setup.js +0 -31
- package/scripts/sync-labels.js +0 -71
- package/scripts/sync-roadmap-labels.js +0 -21
- package/scripts/tag-release.js +0 -64
- package/scripts/test-global-setup.js +0 -18
- package/scripts/validate-changelog-version.js +0 -48
- package/scripts/verify-fixture-mocks.js +0 -45
- package/scripts/verify-fixtures.js +0 -36
- package/server.js +0 -31
- package/src/config/load-config.js +0 -33
- package/src/config/load-plugin-config.js +0 -56
- package/src/config/validate-plugin-schema.js +0 -28
- package/src/config/validate-schema.js +0 -107
- package/src/core/create-pipeline.js +0 -96
- package/src/core/plugin-contracts.js +0 -21
- package/src/core/plugin-registry.js +0 -48
- package/src/dag/dag-engine.js +0 -70
- package/src/evaluate/evaluator.js +0 -44
- package/src/evaluate/scoring.js +0 -74
- package/src/loader/csv-loader.js +0 -30
- package/src/loader/directory-loader.js +0 -38
- package/src/loader/html-loader.js +0 -57
- package/src/loader/markdown-loader.js +0 -58
- package/src/mocks/openai-embedder.js +0 -30
- package/src/mocks/openai-llm.js +0 -18
- package/src/mocks/pdf-loader.js +0 -17
- package/src/mocks/pinecone-retriever.js +0 -25
- package/src/reranker/llm-reranker.js +0 -34
- package/src/utils/ci/diagnostic-reporter.js +0 -36
- package/src/utils/logger.js +0 -29
- package/src/utils/retry.js +0 -42
- package/src/utils/validate-plugin-contract.js +0 -36
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 1.0.0
|
|
3
|
-
* Description: Auto-repairs mock plugin fixtures for integration tests
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { mkdirSync, copyFileSync, existsSync } from 'fs';
|
|
8
|
-
import { resolve, join } from 'path';
|
|
9
|
-
|
|
10
|
-
const MOCKS = [
|
|
11
|
-
'pdf-loader.js',
|
|
12
|
-
'openai-embedder.js',
|
|
13
|
-
'pinecone-retriever.js',
|
|
14
|
-
'openai-llm.js'
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
const SRC_FIXTURES = resolve('__tests__/fixtures/src/mocks');
|
|
18
|
-
const DEST_FIXTURES = resolve('__tests__/__temp__/cli-config-fallback/src/mocks');
|
|
19
|
-
|
|
20
|
-
mkdirSync(DEST_FIXTURES, { recursive: true });
|
|
21
|
-
|
|
22
|
-
MOCKS.forEach((file) => {
|
|
23
|
-
const src = join(SRC_FIXTURES, file);
|
|
24
|
-
const dest = join(DEST_FIXTURES, file);
|
|
25
|
-
if (!existsSync(src)) throw new Error(`[FIXTURE MISSING] ${src}`);
|
|
26
|
-
copyFileSync(src, dest);
|
|
27
|
-
console.log(`[COPIED] ${file}`);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
console.log('✅ Fixture mocks successfully repaired.');
|
package/scripts/setup.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 1.1.0
|
|
3
|
-
* Description: Test setup script to ensure fixtures exist and validate mocks before running tests.
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
import { execSync } from 'child_process';
|
|
11
|
-
|
|
12
|
-
// Resolve __dirname in ES module scope
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
-
const __dirname = path.dirname(__filename);
|
|
15
|
-
|
|
16
|
-
const fixturePath = path.resolve(__dirname, '../__tests__/fixtures/sample.pdf');
|
|
17
|
-
|
|
18
|
-
// Ensure PDF test fixture
|
|
19
|
-
if (!fs.existsSync(fixturePath)) {
|
|
20
|
-
fs.mkdirSync(path.dirname(fixturePath), { recursive: true });
|
|
21
|
-
fs.writeFileSync(fixturePath, 'Dummy PDF content for test');
|
|
22
|
-
console.log('[setup] Created sample.pdf fixture');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Validate plugin fixture presence
|
|
26
|
-
try {
|
|
27
|
-
execSync('node ./scripts/verify-fixtures.js', { stdio: 'inherit' });
|
|
28
|
-
} catch (err) {
|
|
29
|
-
console.error('[setup] Fixture verification failed. Please check missing mocks.');
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
package/scripts/sync-labels.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 1.1.0
|
|
3
|
-
* Description: Syncs GitHub labels based on roadmap-labels.yml; updates existing, creates missing.
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import yaml from 'js-yaml';
|
|
10
|
-
import { Octokit } from '@octokit/rest';
|
|
11
|
-
|
|
12
|
-
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
|
|
13
|
-
const REPO = process.env.GITHUB_REPOSITORY;
|
|
14
|
-
|
|
15
|
-
if (!GITHUB_TOKEN || !REPO) {
|
|
16
|
-
console.error('❌ GITHUB_TOKEN or GITHUB_REPOSITORY not defined in environment.');
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const [owner, repo] = REPO.split('/');
|
|
21
|
-
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
|
22
|
-
|
|
23
|
-
const LABELS_FILE = path.join('.github', 'roadmap-labels.yml');
|
|
24
|
-
|
|
25
|
-
function loadLabelsFromYAML(filePath) {
|
|
26
|
-
try {
|
|
27
|
-
const file = fs.readFileSync(filePath, 'utf8');
|
|
28
|
-
return yaml.load(file);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
console.error('❌ Failed to load roadmap-labels.yml:', err);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function syncLabels() {
|
|
36
|
-
const labels = loadLabelsFromYAML(LABELS_FILE);
|
|
37
|
-
const existingLabels = await octokit.paginate(octokit.rest.issues.listLabelsForRepo, {
|
|
38
|
-
owner,
|
|
39
|
-
repo,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
for (const label of labels) {
|
|
43
|
-
const existing = existingLabels.find(l => l.name === label.name);
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
if (existing) {
|
|
47
|
-
console.log(`🔁 Updating label: ${label.name}`);
|
|
48
|
-
await octokit.rest.issues.updateLabel({
|
|
49
|
-
owner,
|
|
50
|
-
repo,
|
|
51
|
-
name: label.name,
|
|
52
|
-
color: label.color,
|
|
53
|
-
description: label.description,
|
|
54
|
-
});
|
|
55
|
-
} else {
|
|
56
|
-
console.log(`➕ Creating label: ${label.name}`);
|
|
57
|
-
await octokit.rest.issues.createLabel({
|
|
58
|
-
owner,
|
|
59
|
-
repo,
|
|
60
|
-
name: label.name,
|
|
61
|
-
color: label.color,
|
|
62
|
-
description: label.description,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
} catch (err) {
|
|
66
|
-
console.error(`❌ Failed to process label: ${label.name}`, err.message);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
syncLabels();
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// scripts/sync-roadmap-labels.js
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Version: 1.1.0
|
|
5
|
-
* Description: Sync roadmap labels and issues
|
|
6
|
-
* Author: Ali Kahwaji
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { ensureRoadmapLabels } from './ensure-roadmap-labels.js';
|
|
10
|
-
import { createRoadmapIssues } from './create-roadmap-issues.js';
|
|
11
|
-
|
|
12
|
-
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
|
|
13
|
-
const token = process.env.GITHUB_TOKEN;
|
|
14
|
-
|
|
15
|
-
if (!token) {
|
|
16
|
-
console.error('❌ Missing GITHUB_TOKEN');
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
await ensureRoadmapLabels({ token, owner, repo });
|
|
21
|
-
await createRoadmapIssues({ token, owner, repo });
|
package/scripts/tag-release.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 2.0.0
|
|
3
|
-
* Description: Tags release, updates changelog, optionally opens blog preview
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { execSync } from 'child_process';
|
|
10
|
-
import readline from 'readline';
|
|
11
|
-
|
|
12
|
-
const VERSION = process.argv[2];
|
|
13
|
-
const PREVIEW = process.argv.includes('--preview');
|
|
14
|
-
|
|
15
|
-
if (!VERSION) {
|
|
16
|
-
console.error('❌ Usage: node release-tag.js <version> [--preview]');
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const tag = `v${VERSION}`;
|
|
21
|
-
const blogPath = path.join('docs-site', 'blog');
|
|
22
|
-
|
|
23
|
-
// Step 1: Run changelog injection
|
|
24
|
-
execSync(`node scripts/generate-release-note.js ${VERSION}`, { stdio: 'inherit' });
|
|
25
|
-
|
|
26
|
-
// Step 2: Find generated blog file
|
|
27
|
-
const date = new Date().toISOString().split('T')[0];
|
|
28
|
-
const file = path.join(blogPath, `${date}-release-${tag}.md`);
|
|
29
|
-
|
|
30
|
-
if (!fs.existsSync(file)) {
|
|
31
|
-
console.error(`❌ Blog post not generated: ${file}`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Step 3: Preview if enabled
|
|
36
|
-
if (PREVIEW) {
|
|
37
|
-
const editor = process.env.EDITOR || 'code'; // fallback to VS Code
|
|
38
|
-
try {
|
|
39
|
-
execSync(`${editor} ${file}`, { stdio: 'inherit' });
|
|
40
|
-
} catch (err) {
|
|
41
|
-
console.warn('⚠️ Failed to open in editor. Please review manually:', file);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
45
|
-
rl.question(`✅ Ready to commit and push ${tag}? (y/n): `, (answer) => {
|
|
46
|
-
rl.close();
|
|
47
|
-
if (answer.toLowerCase() !== 'y') {
|
|
48
|
-
console.log('❌ Aborted. No tag pushed.');
|
|
49
|
-
process.exit(0);
|
|
50
|
-
}
|
|
51
|
-
finalizeRelease();
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
finalizeRelease();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Final tagging + push
|
|
58
|
-
function finalizeRelease() {
|
|
59
|
-
execSync(`git add CHANGELOG.md ${file}`);
|
|
60
|
-
execSync(`git commit -m "release: v${VERSION}"`);
|
|
61
|
-
execSync(`git tag ${tag}`);
|
|
62
|
-
execSync('git push && git push --tags');
|
|
63
|
-
console.log(`🎉 Release ${tag} published and blog post staged!`);
|
|
64
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// __tests__/setup/global.js
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
|
|
6
|
-
// __dirname polyfill for ESM
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
|
|
10
|
-
const pdfPath = path.resolve(__dirname, '../fixtures/sample.pdf');
|
|
11
|
-
|
|
12
|
-
// Ensure the fixtures directory exists
|
|
13
|
-
fs.mkdirSync(path.dirname(pdfPath), { recursive: true });
|
|
14
|
-
|
|
15
|
-
// Create a minimal valid PDF file if it doesn't exist
|
|
16
|
-
if (!fs.existsSync(pdfPath)) {
|
|
17
|
-
fs.writeFileSync(pdfPath, '%PDF-1.4\n%EOF');
|
|
18
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 1.1.0
|
|
3
|
-
* Description: Ensures CHANGELOG.md contains the current version and auto-corrects format if needed.
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
import { execSync } from 'child_process';
|
|
11
|
-
|
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
const __dirname = path.dirname(__filename);
|
|
14
|
-
|
|
15
|
-
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json')));
|
|
16
|
-
const version = pkg.version;
|
|
17
|
-
const changelogPath = path.resolve(__dirname, '../CHANGELOG.md');
|
|
18
|
-
|
|
19
|
-
let changelog = fs.readFileSync(changelogPath, 'utf-8');
|
|
20
|
-
|
|
21
|
-
// Step 1: Normalize invalid headings like "# [2.0.0](...)"
|
|
22
|
-
const normalized = changelog.replace(/^# \[([0-9]+\.[0-9]+\.[0-9]+)\]\([^)]+\)/gm, (match, v) => {
|
|
23
|
-
const today = new Date().toISOString().split('T')[0];
|
|
24
|
-
return `## [${v}] - ${today}`;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Step 2: Update file if normalization occurred
|
|
28
|
-
if (normalized !== changelog) {
|
|
29
|
-
fs.writeFileSync(changelogPath, normalized);
|
|
30
|
-
console.log(`🛠️ CHANGELOG.md heading normalized for version ${version}`);
|
|
31
|
-
changelog = normalized;
|
|
32
|
-
|
|
33
|
-
// Auto-stage if in git project (Husky compatibility)
|
|
34
|
-
try {
|
|
35
|
-
execSync(`git add ${changelogPath}`);
|
|
36
|
-
console.log('CHANGELOG.md staged after correction');
|
|
37
|
-
} catch {
|
|
38
|
-
// Non-fatal
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Step 3: Validate presence of correct heading
|
|
43
|
-
const headingPattern = new RegExp(`^## \\[${version}\\]`, 'm');
|
|
44
|
-
if (!headingPattern.test(changelog)) {
|
|
45
|
-
throw new Error(`❌ CHANGELOG.md does not contain a properly formatted entry for version ${version}`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
console.log(`✅ CHANGELOG.md contains a valid entry for version ${version}`);
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 1.0.0
|
|
3
|
-
* Description: Verifies that plugin mock implementations expose required methods
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { readdirSync, statSync } from 'fs';
|
|
8
|
-
import { resolve, join, extname } from 'path';
|
|
9
|
-
import { pathToFileURL } from 'url';
|
|
10
|
-
|
|
11
|
-
const MOCKS_DIR = resolve('__tests__/fixtures/src/mocks');
|
|
12
|
-
|
|
13
|
-
const pluginContracts = {
|
|
14
|
-
'openai-embedder.js': ['embed', 'embedQuery'],
|
|
15
|
-
'openai-llm.js': ['ask'],
|
|
16
|
-
'pdf-loader.js': ['load'],
|
|
17
|
-
'pinecone-retriever.js': ['store', 'search'],
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const failures = [];
|
|
21
|
-
|
|
22
|
-
for (const file of readdirSync(MOCKS_DIR)) {
|
|
23
|
-
const fullPath = join(MOCKS_DIR, file);
|
|
24
|
-
const isFile = statSync(fullPath).isFile();
|
|
25
|
-
if (!isFile || extname(file) !== '.js') continue;
|
|
26
|
-
|
|
27
|
-
const expectedMethods = pluginContracts[file];
|
|
28
|
-
if (!expectedMethods) continue;
|
|
29
|
-
|
|
30
|
-
const mod = await import(pathToFileURL(fullPath).href);
|
|
31
|
-
const plugin = new mod.default();
|
|
32
|
-
|
|
33
|
-
for (const method of expectedMethods) {
|
|
34
|
-
if (typeof plugin[method] !== 'function') {
|
|
35
|
-
failures.push(`❌ ${file} failed: [${file}] missing method: ${method}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (failures.length > 0) {
|
|
41
|
-
failures.forEach(msg => console.error(msg));
|
|
42
|
-
process.exit(1);
|
|
43
|
-
} else {
|
|
44
|
-
console.log('✅ All plugin mocks verified.');
|
|
45
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 1.0.0
|
|
3
|
-
* Description: Script to verify presence of all expected fixture plugins before running integration tests.
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
* File: scripts/verify-fixtures.js
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { existsSync } from 'fs';
|
|
9
|
-
import { resolve } from 'path';
|
|
10
|
-
|
|
11
|
-
const REQUIRED_FIXTURES = [
|
|
12
|
-
'__tests__/fixtures/sample.pdf',
|
|
13
|
-
'__tests__/fixtures/.ragrc.json',
|
|
14
|
-
'__tests__/fixtures/src/mocks/pdf-loader.js',
|
|
15
|
-
'__tests__/fixtures/src/mocks/openai-embedder.js',
|
|
16
|
-
'__tests__/fixtures/src/mocks/pinecone-retriever.js',
|
|
17
|
-
'__tests__/fixtures/src/mocks/openai-llm.js'
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
let missing = [];
|
|
21
|
-
for (const file of REQUIRED_FIXTURES) {
|
|
22
|
-
const fullPath = resolve(file);
|
|
23
|
-
if (!existsSync(fullPath)) {
|
|
24
|
-
missing.push(fullPath);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (missing.length) {
|
|
29
|
-
console.error('[ERROR] Missing test fixture files:');
|
|
30
|
-
for (const f of missing) {
|
|
31
|
-
console.error(' -', f);
|
|
32
|
-
}
|
|
33
|
-
process.exit(1);
|
|
34
|
-
} else {
|
|
35
|
-
console.log('[OK] All fixture files are present.');
|
|
36
|
-
}
|
package/server.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 0.1.0
|
|
3
|
-
* Path: /server.js
|
|
4
|
-
* Description: Local static server for serving evaluation dashboard
|
|
5
|
-
* Author: Ali Kahwaji
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import express from 'express';
|
|
9
|
-
import path from 'path';
|
|
10
|
-
import { fileURLToPath } from 'url';
|
|
11
|
-
|
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
const __dirname = path.dirname(__filename);
|
|
14
|
-
|
|
15
|
-
const app = express();
|
|
16
|
-
const port = process.env.PORT || 3000;
|
|
17
|
-
|
|
18
|
-
// Serve evaluation results statically
|
|
19
|
-
app.use('/results', express.static(path.join(__dirname, '__tests__/fixtures')));
|
|
20
|
-
|
|
21
|
-
// Serve public frontend assets
|
|
22
|
-
app.use(express.static(path.join(__dirname, 'public')));
|
|
23
|
-
|
|
24
|
-
// Fallback to index.html
|
|
25
|
-
app.get('*', (req, res) => {
|
|
26
|
-
res.sendFile(path.join(__dirname, 'public/index.html'));
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
app.listen(port, () => {
|
|
30
|
-
console.log(` Dashboard running at http://localhost:${port}`);
|
|
31
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 1.1.0
|
|
3
|
-
* Description: Loads validated .ragrc.json config from disk
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { validateRagrcSchema } from './validate-schema.js';
|
|
10
|
-
import { logger } from '../utils/logger.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Loads and validates a RAG config file.
|
|
14
|
-
* @param {string} configPath - Absolute path to .ragrc.json
|
|
15
|
-
* @returns {object} Parsed config object
|
|
16
|
-
* @throws {Error} If file is missing or invalid
|
|
17
|
-
*/
|
|
18
|
-
export function loadRagConfig(configPath) {
|
|
19
|
-
if (!fs.existsSync(configPath)) {
|
|
20
|
-
throw new Error(`Config file not found: ${configPath}`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const raw = fs.readFileSync(configPath, 'utf-8');
|
|
24
|
-
const parsed = JSON.parse(raw);
|
|
25
|
-
|
|
26
|
-
const result = validateRagrcSchema(parsed);
|
|
27
|
-
if (!result.valid) {
|
|
28
|
-
logger.error({ errors: result.errors }, 'Invalid .ragrc.json schema');
|
|
29
|
-
throw new Error('Config validation failed');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return parsed;
|
|
33
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 1.1.1
|
|
3
|
-
* Description: Dynamic plugin loader with direct type:name registry mapping
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { pathToFileURL } from 'url';
|
|
10
|
-
import registry from '../core/plugin-registry.js';
|
|
11
|
-
import { validatePluginSchema } from './validate-schema.js';
|
|
12
|
-
import { logger } from '../utils/logger.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Loads plugins from validated config path and registers them.
|
|
16
|
-
* @param {string} configPath
|
|
17
|
-
*/
|
|
18
|
-
export async function loadPluginsFromJson(configPath) {
|
|
19
|
-
if (!fs.existsSync(configPath)) {
|
|
20
|
-
throw new Error(`Plugin config missing: ${configPath}`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const raw = fs.readFileSync(configPath, 'utf-8');
|
|
24
|
-
const config = JSON.parse(raw);
|
|
25
|
-
|
|
26
|
-
const validation = validatePluginSchema(config);
|
|
27
|
-
if (!validation.valid) {
|
|
28
|
-
logger.error({ errors: validation.errors }, 'Invalid plugin config');
|
|
29
|
-
throw new Error('Plugin config validation failed');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
for (const [type, namedPlugins] of Object.entries(config)) {
|
|
33
|
-
if (!['loader', 'embedder', 'retriever', 'llm'].includes(type)) continue;
|
|
34
|
-
|
|
35
|
-
for (const [name, relPath] of Object.entries(namedPlugins)) {
|
|
36
|
-
const absPath = path.resolve(path.dirname(configPath), relPath);
|
|
37
|
-
const fileUrl = pathToFileURL(absPath).href;
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
const mod = await import(fileUrl);
|
|
41
|
-
const PluginClass = mod?.default;
|
|
42
|
-
if (typeof PluginClass !== 'function') {
|
|
43
|
-
throw new Error(`Invalid export in plugin [${type}:${name}] at ${absPath}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const instance = new PluginClass();
|
|
47
|
-
registry.register(type, name, instance);
|
|
48
|
-
|
|
49
|
-
logger.info({ type, name }, `Registered plugin: ${type}:${name}`);
|
|
50
|
-
} catch (err) {
|
|
51
|
-
logger.error({ type, name, err }, `Failed to register plugin [${type}:${name}]`);
|
|
52
|
-
throw err;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 0.1.0
|
|
3
|
-
* Description: Schema validator for plugin.config.json
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export function validatePluginSchema(config) {
|
|
8
|
-
const validTypes = ['loader', 'embedder', 'retriever', 'llm'];
|
|
9
|
-
const errors = [];
|
|
10
|
-
|
|
11
|
-
for (const type of Object.keys(config)) {
|
|
12
|
-
if (!validTypes.includes(type)) {
|
|
13
|
-
errors.push(`Unknown plugin type: ${type}`);
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
for (const [name, modulePath] of Object.entries(config[type])) {
|
|
17
|
-
if (typeof name !== 'string' || typeof modulePath !== 'string') {
|
|
18
|
-
errors.push(`Invalid plugin definition for type "${type}" and name "${name}"`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
valid: errors.length === 0,
|
|
25
|
-
errors
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version: 1.3.0
|
|
3
|
-
* Description: AJV-powered validators for .ragrc.json full config and plugin-only structure
|
|
4
|
-
* Author: Ali Kahwaji
|
|
5
|
-
* File: /src/config/validate-schema.js
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import Ajv from 'ajv';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Full .ragrc.json schema (used in load-config.js)
|
|
12
|
-
*/
|
|
13
|
-
const ragrcSchema = {
|
|
14
|
-
type: 'object',
|
|
15
|
-
required: ['loader', 'embedder', 'retriever', 'llm', 'namespace', 'pipeline'],
|
|
16
|
-
properties: {
|
|
17
|
-
loader: {
|
|
18
|
-
type: 'object',
|
|
19
|
-
minProperties: 1,
|
|
20
|
-
additionalProperties: { type: 'string' }
|
|
21
|
-
},
|
|
22
|
-
embedder: {
|
|
23
|
-
type: 'object',
|
|
24
|
-
minProperties: 1,
|
|
25
|
-
additionalProperties: { type: 'string' }
|
|
26
|
-
},
|
|
27
|
-
retriever: {
|
|
28
|
-
type: 'object',
|
|
29
|
-
minProperties: 1,
|
|
30
|
-
additionalProperties: { type: 'string' }
|
|
31
|
-
},
|
|
32
|
-
llm: {
|
|
33
|
-
type: 'object',
|
|
34
|
-
minProperties: 1,
|
|
35
|
-
additionalProperties: { type: 'string' }
|
|
36
|
-
},
|
|
37
|
-
namespace: {
|
|
38
|
-
type: 'string',
|
|
39
|
-
minLength: 1
|
|
40
|
-
},
|
|
41
|
-
pipeline: {
|
|
42
|
-
type: 'array',
|
|
43
|
-
items: {
|
|
44
|
-
type: 'string',
|
|
45
|
-
enum: ['loader', 'embedder', 'retriever']
|
|
46
|
-
},
|
|
47
|
-
minItems: 1,
|
|
48
|
-
uniqueItems: true
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
additionalProperties: false
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Minimal plugin-only schema (used in load-plugin-config.js)
|
|
56
|
-
*/
|
|
57
|
-
const pluginSchema = {
|
|
58
|
-
type: 'object',
|
|
59
|
-
required: ['loader', 'embedder', 'retriever', 'llm'],
|
|
60
|
-
properties: {
|
|
61
|
-
loader: {
|
|
62
|
-
type: 'object',
|
|
63
|
-
minProperties: 1,
|
|
64
|
-
additionalProperties: { type: 'string' }
|
|
65
|
-
},
|
|
66
|
-
embedder: {
|
|
67
|
-
type: 'object',
|
|
68
|
-
minProperties: 1,
|
|
69
|
-
additionalProperties: { type: 'string' }
|
|
70
|
-
},
|
|
71
|
-
retriever: {
|
|
72
|
-
type: 'object',
|
|
73
|
-
minProperties: 1,
|
|
74
|
-
additionalProperties: { type: 'string' }
|
|
75
|
-
},
|
|
76
|
-
llm: {
|
|
77
|
-
type: 'object',
|
|
78
|
-
minProperties: 1,
|
|
79
|
-
additionalProperties: { type: 'string' }
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
additionalProperties: true // allow namespace, pipeline, etc.
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Validates the full .ragrc.json config structure
|
|
87
|
-
* @param {object} config
|
|
88
|
-
* @returns {{ valid: boolean, errors?: any[] }}
|
|
89
|
-
*/
|
|
90
|
-
export function validateRagrcSchema(config) {
|
|
91
|
-
const ajv = new Ajv({ allErrors: true });
|
|
92
|
-
const validate = ajv.compile(ragrcSchema);
|
|
93
|
-
const valid = validate(config);
|
|
94
|
-
return valid ? { valid: true } : { valid: false, errors: validate.errors };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Validates a plugin-only structure (for runtime plugin loading)
|
|
99
|
-
* @param {object} config
|
|
100
|
-
* @returns {{ valid: boolean, errors?: any[] }}
|
|
101
|
-
*/
|
|
102
|
-
export function validatePluginSchema(config) {
|
|
103
|
-
const ajv = new Ajv({ allErrors: true });
|
|
104
|
-
const validate = ajv.compile(pluginSchema);
|
|
105
|
-
const valid = validate(config);
|
|
106
|
-
return valid ? { valid: true } : { valid: false, errors: validate.errors };
|
|
107
|
-
}
|