@vivantel/rag-core 1.1.2 → 1.1.3

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.
Files changed (62) hide show
  1. package/dist/config-loader.d.ts.map +1 -1
  2. package/dist/config-loader.js +0 -2
  3. package/dist/config-loader.js.map +1 -1
  4. package/dist/core/chunk-processor.d.ts.map +1 -1
  5. package/dist/core/chunk-processor.js +27 -20
  6. package/dist/core/chunk-processor.js.map +1 -1
  7. package/dist/core/embedder.d.ts.map +1 -1
  8. package/dist/core/embedder.js +10 -3
  9. package/dist/core/embedder.js.map +1 -1
  10. package/dist/core/git-tracker.d.ts.map +1 -1
  11. package/dist/core/git-tracker.js +9 -59
  12. package/dist/core/git-tracker.js.map +1 -1
  13. package/dist/core/orchestrator.d.ts.map +1 -1
  14. package/dist/core/orchestrator.js +22 -1
  15. package/dist/core/orchestrator.js.map +1 -1
  16. package/dist/core/uploader.d.ts.map +1 -1
  17. package/dist/core/uploader.js +13 -4
  18. package/dist/core/uploader.js.map +1 -1
  19. package/dist/strategies/chunk/token.js +1 -1
  20. package/dist/strategies/chunk/token.js.map +1 -1
  21. package/package.json +5 -1
  22. package/.github/config/release-please.json +0 -38
  23. package/.github/dependabot.yaml +0 -28
  24. package/.github/workflows/ci.yaml +0 -119
  25. package/.github/workflows/publish.yaml +0 -155
  26. package/.github/workflows/release.yaml +0 -54
  27. package/.release-please-manifest.json +0 -3
  28. package/.versionrc.json +0 -19
  29. package/CHANGELOG.md +0 -51
  30. package/bin/rag-update.ts +0 -49
  31. package/eslint.config.js +0 -25
  32. package/src/config-loader.ts +0 -21
  33. package/src/core/chunk-processor.test.ts +0 -36
  34. package/src/core/chunk-processor.ts +0 -92
  35. package/src/core/embedder.ts +0 -189
  36. package/src/core/git-tracker.test.ts +0 -64
  37. package/src/core/git-tracker.ts +0 -202
  38. package/src/core/orchestrator.test.ts +0 -53
  39. package/src/core/orchestrator.ts +0 -97
  40. package/src/core/uploader.ts +0 -123
  41. package/src/core/utils.ts +0 -27
  42. package/src/helpers/create-chunker.test.ts +0 -31
  43. package/src/helpers/create-chunker.ts +0 -40
  44. package/src/index.test.ts +0 -33
  45. package/src/index.ts +0 -30
  46. package/src/interfaces/chunker.ts +0 -59
  47. package/src/interfaces/embedder.ts +0 -36
  48. package/src/interfaces/index.test.ts +0 -9
  49. package/src/interfaces/index.ts +0 -3
  50. package/src/interfaces/vector-store.ts +0 -71
  51. package/src/strategies/chunk/index.ts +0 -4
  52. package/src/strategies/chunk/markdown-headers.test.ts +0 -37
  53. package/src/strategies/chunk/markdown-headers.ts +0 -106
  54. package/src/strategies/chunk/semantic.test.ts +0 -21
  55. package/src/strategies/chunk/semantic.ts +0 -80
  56. package/src/strategies/chunk/token.test.ts +0 -41
  57. package/src/strategies/chunk/token.ts +0 -72
  58. package/src/strategies/chunk/whole-file.test.ts +0 -24
  59. package/src/strategies/chunk/whole-file.ts +0 -35
  60. package/tsconfig.json +0 -21
  61. package/typedoc.json +0 -11
  62. package/vitest.config.ts +0 -19
@@ -1,119 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [master, develop]
6
- pull_request:
7
- branches: [master]
8
-
9
- jobs:
10
- build-and-test:
11
- name: Build & Test
12
- runs-on: ubuntu-latest
13
-
14
- strategy:
15
- matrix:
16
- node-version: [22, 24, 26]
17
- fail-fast: false
18
-
19
- steps:
20
- - name: Checkout code
21
- uses: actions/checkout@v6
22
- with:
23
- fetch-depth: 0
24
-
25
- - name: Setup Node.js
26
- uses: actions/setup-node@v6
27
- with:
28
- node-version: ${{ matrix.node-version }}
29
- cache: "npm"
30
-
31
- - name: Install dependencies
32
- run: npm ci
33
-
34
- - name: Type check
35
- run: npm run type-check
36
-
37
- - name: Lint
38
- run: npm run lint
39
-
40
- - name: Run tests
41
- run: npm test
42
-
43
- - name: Build
44
- run: npm run build
45
-
46
- - name: Upload build artifacts
47
- uses: actions/upload-artifact@v4
48
- with:
49
- name: dist-node-${{ matrix.node-version }}
50
- path: dist/
51
- retention-days: 7
52
-
53
- code-quality:
54
- name: Code Quality
55
- runs-on: ubuntu-latest
56
-
57
- steps:
58
- - name: Checkout code
59
- uses: actions/checkout@v6
60
-
61
- - name: Setup Node.js
62
- uses: actions/setup-node@v6
63
- with:
64
- node-version: "lts/*"
65
- cache: "npm"
66
-
67
- - name: Install dependencies
68
- run: npm ci
69
-
70
- - name: Check formatting
71
- run: npx prettier --check "src/**/*.ts"
72
-
73
- - name: Run lint with fix check
74
- run: npx eslint src/ --max-warnings 0
75
-
76
- - name: Type coverage
77
- run: npx type-coverage --at-least 90
78
-
79
- - name: Audit dependencies
80
- run: npm audit --audit-level=moderate
81
-
82
- security:
83
- name: Security Scan
84
- runs-on: ubuntu-latest
85
- permissions:
86
- contents: read
87
- security-events: write
88
- actions: read
89
-
90
- steps:
91
- - name: Checkout code
92
- uses: actions/checkout@v6
93
-
94
- - name: Setup Node.js
95
- uses: actions/setup-node@v6
96
- with:
97
- node-version: "lts/*"
98
-
99
- - name: Run Trivy vulnerability scanner
100
- uses: aquasecurity/trivy-action@v0.36.0
101
- with:
102
- scan-type: "fs"
103
- scan-ref: "."
104
- format: "sarif"
105
- output: "trivy-results.sarif"
106
-
107
- - name: Upload Trivy results to GitHub Security tab
108
- uses: github/codeql-action/upload-sarif@v4
109
- with:
110
- sarif_file: "trivy-results.sarif"
111
-
112
- - name: Run npm audit
113
- run: npm audit --json > npm-audit.json || true
114
-
115
- - name: Upload npm audit results
116
- uses: actions/upload-artifact@v4
117
- with:
118
- name: npm-audit
119
- path: npm-audit.json
@@ -1,155 +0,0 @@
1
- name: Publish
2
-
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- version_type:
7
- description: "Version type"
8
- required: true
9
- type: choice
10
- options: [patch, minor, major]
11
-
12
- permissions:
13
- contents: write
14
- pull-requests: write
15
- issues: write
16
- packages: write
17
-
18
- jobs:
19
- release-please:
20
- name: Release Please
21
- runs-on: ubuntu-latest
22
-
23
- outputs:
24
- release_created: ${{ steps.release.outputs.release_created }}
25
- tag_name: ${{ steps.release.outputs.tag_name }}
26
- version: ${{ steps.release.outputs.version }}
27
-
28
- steps:
29
- - name: Run Release Please
30
- id: release
31
- uses: googleapis/release-please-action@v5
32
- with:
33
- token: ${{ secrets.GITHUB_TOKEN }}
34
- release-type: node
35
- package-name: "@vivantel/rag-core"
36
- config-file: .github/config/release-please.json
37
- manifest-file: .release-please-manifest.json
38
-
39
- publish-npm:
40
- name: Publish to npm
41
- needs: release-please
42
- if: ${{ needs.release-please.outputs.release_created == 'true' }}
43
- runs-on: ubuntu-latest
44
-
45
- permissions:
46
- contents: read
47
- id-token: write # для npm provenance
48
-
49
- steps:
50
- - name: Checkout code
51
- uses: actions/checkout@v6
52
- with:
53
- ref: ${{ needs.release-please.outputs.tag_name }}
54
-
55
- - name: Setup Node.js
56
- uses: actions/setup-node@v6
57
- with:
58
- node-version: "lts/*"
59
- registry-url: "https://registry.npmjs.org"
60
- cache: "npm"
61
-
62
- - name: Install dependencies
63
- run: npm ci
64
-
65
- - name: Build
66
- run: npm run build
67
-
68
- - name: Run tests
69
- run: npm test
70
-
71
- - name: Check package size
72
- run: npx package-size
73
-
74
- - name: Publish to npm
75
- run: npm publish --provenance --access public
76
- env:
77
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
78
-
79
- - name: Create GitHub Release
80
- uses: softprops/action-gh-release@v2
81
- with:
82
- tag_name: ${{ needs.release-please.outputs.tag_name }}
83
- name: Release ${{ needs.release-please.outputs.version }}
84
- body_path: CHANGELOG.md
85
- draft: false
86
- prerelease: false
87
- generate_release_notes: true
88
- env:
89
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90
-
91
- create-github-package:
92
- name: Publish to GitHub Packages
93
- needs: release-please
94
- if: ${{ needs.release-please.outputs.release_created == 'true' }}
95
- runs-on: ubuntu-latest
96
-
97
- permissions:
98
- contents: read
99
- packages: write
100
-
101
- steps:
102
- - name: Checkout code
103
- uses: actions/checkout@v6
104
- with:
105
- ref: ${{ needs.release-please.outputs.tag_name }}
106
-
107
- - name: Setup Node.js
108
- uses: actions/setup-node@v6
109
- with:
110
- node-version: "lts/*"
111
- registry-url: "https://npm.pkg.github.com"
112
- cache: "npm"
113
-
114
- - name: Install dependencies
115
- run: npm ci
116
-
117
- - name: Build
118
- run: npm run build
119
-
120
- - name: Publish to GitHub Packages
121
- run: npm publish
122
- env:
123
- NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124
-
125
- update-docs:
126
- name: Update Documentation
127
- needs: release-please
128
- if: ${{ needs.release-please.outputs.release_created == 'true' }}
129
- runs-on: ubuntu-latest
130
-
131
- steps:
132
- - name: Checkout code
133
- uses: actions/checkout@v6
134
- with:
135
- ref: ${{ needs.release-please.outputs.tag_name }}
136
-
137
- - name: Setup Node.js
138
- uses: actions/setup-node@v6
139
- with:
140
- node-version: "lts/*"
141
- cache: "npm"
142
-
143
- - name: Install dependencies
144
- run: npm ci
145
-
146
- - name: Generate API documentation
147
- run: npm run docs:generate
148
-
149
- - name: Deploy to GitHub Pages
150
- uses: peaceiris/actions-gh-pages@v4
151
- with:
152
- github_token: ${{ secrets.GITHUB_TOKEN }}
153
- publish_dir: ./docs/api
154
- destination_dir: ${{ needs.release-please.outputs.version }}
155
- keep_files: false
@@ -1,54 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- permissions:
9
- contents: write
10
- pull-requests: write
11
- issues: write
12
-
13
- jobs:
14
- release-please:
15
- runs-on: ubuntu-latest
16
- outputs:
17
- release_created: ${{ steps.release.outputs.release_created }}
18
- steps:
19
- - name: Run Release Please
20
- id: release
21
- uses: googleapis/release-please-action@v5
22
- with:
23
- token: ${{ secrets.RELEASE_TOKEN }}
24
- release-type: node
25
- config-file: .github/config/release-please.json
26
- manifest-file: .release-please-manifest.json
27
-
28
- publish-npm:
29
- needs: release-please
30
- if: ${{ needs.release-please.outputs.release_created == 'true' }}
31
- runs-on: ubuntu-latest
32
- permissions:
33
- contents: read
34
- id-token: write
35
- steps:
36
- - uses: actions/checkout@v4
37
- with:
38
- fetch-depth: 0
39
-
40
- - uses: actions/setup-node@v4
41
- with:
42
- node-version: '20.x'
43
- registry-url: 'https://registry.npmjs.org'
44
-
45
- - name: Install dependencies
46
- run: npm ci
47
-
48
- - name: Build
49
- run: npm run build
50
-
51
- - name: Publish to npm
52
- run: npm publish --provenance --access public
53
- env:
54
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,3 +0,0 @@
1
- {
2
- ".": "1.1.2"
3
- }
package/.versionrc.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "types": [
3
- {"type": "feat", "section": "Features"},
4
- {"type": "fix", "section": "Bug Fixes"},
5
- {"type": "perf", "section": "Performance Improvements"},
6
- {"type": "refactor", "section": "Code Refactoring"},
7
- {"type": "docs", "section": "Documentation"},
8
- {"type": "style", "hidden": true},
9
- {"type": "chore", "hidden": true},
10
- {"type": "test", "hidden": true}
11
- ],
12
- "releaseCommitMessageFormat": "chore: release {{currentTag}}",
13
- "skip": {
14
- "bump": false,
15
- "changelog": false,
16
- "commit": false,
17
- "tag": false
18
- }
19
- }
package/CHANGELOG.md DELETED
@@ -1,51 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [1.1.2](https://github.com/vivantel/rag_core/compare/v1.1.1...v1.1.2) (2026-05-31)
9
-
10
-
11
- ### Bug Fixes
12
-
13
- * add repository.url to package.json for npm provenance ([01f8164](https://github.com/vivantel/rag_core/commit/01f816412ce5643eaa1cc1acb6a689fa48c20bfc))
14
-
15
- ## [1.1.1](https://github.com/vivantel/rag_core/compare/v1.1.0...v1.1.1) (2026-05-31)
16
-
17
-
18
- ### Bug Fixes
19
-
20
- * add repository.url to package.json for npm provenance ([c468d1f](https://github.com/vivantel/rag_core/commit/c468d1f819579524795cf2f533871efe9931dd6f))
21
-
22
- ## [1.1.0](https://github.com/vivantel/rag_core/compare/v1.0.0...v1.1.0) (2026-05-31)
23
-
24
-
25
- ### Features
26
-
27
- * test trusted publisher automation ([7fd08b9](https://github.com/vivantel/rag_core/commit/7fd08b96f32e7f7c2c2c02ec7e2eebb761d5fa7f))
28
-
29
- ## 1.0.0 (2026-05-31)
30
-
31
-
32
- ### Features
33
-
34
- * test trusted publisher automation ([8a8cf1f](https://github.com/vivantel/rag_core/commit/8a8cf1f05ab420ebfcaba5653819d0d5e5c5fc2f))
35
- * test trusted publisher automation ([b2638cd](https://github.com/vivantel/rag_core/commit/b2638cd58abbfe073db51ef2fd0146594a99c55f))
36
- * test trusted publisher automation ([c524461](https://github.com/vivantel/rag_core/commit/c5244615cf7e5e91457446b43d62efdd7928273c))
37
-
38
- ## [Unreleased]
39
-
40
- ### Added
41
- - Initial release
42
-
43
- ### Changed
44
-
45
- ### Deprecated
46
-
47
- ### Removed
48
-
49
- ### Fixed
50
-
51
- ### Security
package/bin/rag-update.ts DELETED
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { Command } from 'commander';
4
- import { config } from 'dotenv';
5
- import { loadConfig } from '../src/config-loader.js';
6
- import { Orchestrator } from '../src/core/orchestrator.js';
7
-
8
- config();
9
-
10
- const program = new Command();
11
-
12
- program
13
- .name('rag-update')
14
- .description('Update RAG index with latest changes')
15
- .version('1.0.0')
16
- .option('-c, --config <path>', 'Path to config file', './rag.config.ts')
17
- .option('-f, --force', 'Force full rebuild', false)
18
- .option('--skip-upload', 'Skip upload to vector store', false)
19
- .option('--chunks-file <path>', 'Output path for chunks.json')
20
- .option('--embeddings-file <path>', 'Output path for embeddings.json')
21
- .parse();
22
-
23
- async function main() {
24
- const options = program.opts();
25
-
26
- console.log('🚀 RAG Update Tool\n');
27
-
28
- try {
29
- const config = await loadConfig(options.config);
30
-
31
- const orchestrator = new Orchestrator({
32
- ...config,
33
- options: {
34
- ...config.options,
35
- force: options.force || config.options?.force,
36
- skipUpload: options.skipUpload || config.options?.skipUpload,
37
- chunksFile: options.chunksFile || config.options?.chunksFile,
38
- embeddingsFile: options.embeddingsFile || config.options?.embeddingsFile
39
- }
40
- });
41
-
42
- await orchestrator.run();
43
- } catch (error) {
44
- console.error('❌ Error:', error instanceof Error ? error.message : error);
45
- process.exit(1);
46
- }
47
- }
48
-
49
- main();
package/eslint.config.js DELETED
@@ -1,25 +0,0 @@
1
- import js from '@eslint/js';
2
- import tseslint from 'typescript-eslint';
3
-
4
- export default tseslint.config(
5
- js.configs.recommended,
6
- ...tseslint.configs.recommended,
7
- {
8
- ignores: [
9
- 'dist/**',
10
- 'node_modules/**',
11
- 'coverage/**',
12
- '*.config.js',
13
- '*.config.ts'
14
- ]
15
- },
16
- {
17
- files: ['src/**/*.ts'],
18
- rules: {
19
- '@typescript-eslint/no-explicit-any': 'warn',
20
- '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
21
- 'no-console': 'off',
22
- 'no-undef': 'off'
23
- }
24
- }
25
- );
@@ -1,21 +0,0 @@
1
- import { pathToFileURL } from "url";
2
- import { RAGPipelineConfig } from "./core/orchestrator.js";
3
-
4
- export async function loadConfig(
5
- configPath: string,
6
- ): Promise<RAGPipelineConfig> {
7
- // Clear cache for hot reload
8
- delete require.cache[require.resolve(configPath)];
9
-
10
- const configUrl = pathToFileURL(configPath).href;
11
- const configModule = await import(configUrl);
12
- const config = configModule.default;
13
-
14
- if (!config.chunkers || !config.embedder || !config.vectorStore) {
15
- throw new Error(
16
- "Invalid config: missing chunkers, embedder, or vectorStore",
17
- );
18
- }
19
-
20
- return config;
21
- }
@@ -1,36 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { ChunkProcessor } from "./chunk-processor.js";
3
- import { FileChunker } from "../interfaces/index.js";
4
-
5
- describe("ChunkProcessor", () => {
6
- const mockChunker: FileChunker = {
7
- name: "test",
8
- patterns: ["**/*.txt"],
9
- chunk: vi.fn().mockResolvedValue([
10
- {
11
- content: "test content",
12
- metadata: { type: "test" },
13
- sourceFile: "test.txt",
14
- commitHash: "abc123",
15
- contentHash: "hash123",
16
- },
17
- ]),
18
- };
19
-
20
- it("should be instantiable", () => {
21
- const processor = new ChunkProcessor([mockChunker]);
22
- expect(processor).toBeInstanceOf(ChunkProcessor);
23
- });
24
-
25
- it("should have processFile method", () => {
26
- const processor = new ChunkProcessor([mockChunker]);
27
- expect(processor.processFile).toBeDefined();
28
- expect(typeof processor.processFile).toBe("function");
29
- });
30
-
31
- it("should have processFiles method", () => {
32
- const processor = new ChunkProcessor([mockChunker]);
33
- expect(processor.processFiles).toBeDefined();
34
- expect(typeof processor.processFiles).toBe("function");
35
- });
36
- });
@@ -1,92 +0,0 @@
1
- import { Chunk, FileChunker } from "../interfaces/index.js";
2
- import { createHash } from "crypto";
3
-
4
- function computeContentHash(content: string): string {
5
- return createHash("sha256").update(content).digest("hex").slice(0, 16);
6
- }
7
-
8
- export class ChunkProcessor {
9
- private chunkers: Map<string, FileChunker>;
10
-
11
- constructor(chunkers: FileChunker[]) {
12
- this.chunkers = new Map(chunkers.map((c) => [c.name, c]));
13
- }
14
-
15
- async processFile(
16
- filePath: string,
17
- commitHash: string,
18
- chunker: FileChunker,
19
- ): Promise<Chunk[]> {
20
- try {
21
- const chunks = await chunker.chunk(filePath, commitHash);
22
-
23
- for (const chunk of chunks) {
24
- chunk.contentHash = computeContentHash(chunk.content);
25
- chunk.sourceFile = filePath;
26
- chunk.commitHash = commitHash;
27
- }
28
-
29
- return chunks;
30
- } catch (error) {
31
- console.error(` ❌ Error processing ${filePath}: ${error}`);
32
- return [];
33
- }
34
- }
35
-
36
- async processFiles(
37
- files: string[],
38
- fileState: Map<string, { commitHash: string; chunker: FileChunker }>,
39
- ): Promise<Chunk[]> {
40
- const allChunks: Chunk[] = [];
41
-
42
- for (let i = 0; i < files.length; i++) {
43
- const filePath = files[i];
44
- const info = fileState.get(filePath);
45
-
46
- if (!info) {
47
- console.log(` ⚠️ No chunker for: ${filePath}`);
48
- continue;
49
- }
50
-
51
- console.log(` [${i + 1}/${files.length}] ${filePath}`);
52
-
53
- const chunks = await this.processFile(
54
- filePath,
55
- info.commitHash,
56
- info.chunker,
57
- );
58
-
59
- if (chunks.length > 0) {
60
- allChunks.push(...chunks);
61
- console.log(` ✅ Generated ${chunks.length} chunk(s)`);
62
- } else {
63
- console.log(` ⚠️ No chunks generated (skipped)`);
64
- }
65
- }
66
-
67
- return allChunks;
68
- }
69
-
70
- async saveChunksLocal(chunks: Chunk[], outputFile: string): Promise<void> {
71
- const { dirname } = await import("path");
72
- const { mkdir, writeFile, readFile } = await import("fs/promises");
73
-
74
- await mkdir(dirname(outputFile), { recursive: true });
75
-
76
- let existing: Chunk[] = [];
77
- try {
78
- const content = await readFile(outputFile, "utf-8");
79
- existing = JSON.parse(content);
80
- } catch {
81
- // File doesn't exist
82
- }
83
-
84
- const processedFiles = new Set(chunks.map((c) => c.sourceFile));
85
- const filtered = existing.filter((c) => !processedFiles.has(c.sourceFile));
86
-
87
- const allChunks = [...filtered, ...chunks];
88
-
89
- await writeFile(outputFile, JSON.stringify(allChunks, null, 2));
90
- console.log(`\n💾 Saved ${allChunks.length} chunks to ${outputFile}`);
91
- }
92
- }