@vivantel/rag-core 0.1.0

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 (114) hide show
  1. package/.github/config/release-please.json +38 -0
  2. package/.github/dependabot.yaml +28 -0
  3. package/.github/workflows/ci.yaml +119 -0
  4. package/.github/workflows/publish.yaml +151 -0
  5. package/.github/workflows/release.yaml +150 -0
  6. package/.versionrc.json +19 -0
  7. package/CHANGELOG.md +21 -0
  8. package/README.md +62 -0
  9. package/bin/rag-update.ts +49 -0
  10. package/dist/config-loader.d.ts +3 -0
  11. package/dist/config-loader.d.ts.map +1 -0
  12. package/dist/config-loader.js +13 -0
  13. package/dist/config-loader.js.map +1 -0
  14. package/dist/core/chunk-processor.d.ts +12 -0
  15. package/dist/core/chunk-processor.d.ts.map +1 -0
  16. package/dist/core/chunk-processor.js +65 -0
  17. package/dist/core/chunk-processor.js.map +1 -0
  18. package/dist/core/embedder.d.ts +19 -0
  19. package/dist/core/embedder.d.ts.map +1 -0
  20. package/dist/core/embedder.js +139 -0
  21. package/dist/core/embedder.js.map +1 -0
  22. package/dist/core/git-tracker.d.ts +25 -0
  23. package/dist/core/git-tracker.d.ts.map +1 -0
  24. package/dist/core/git-tracker.js +164 -0
  25. package/dist/core/git-tracker.js.map +1 -0
  26. package/dist/core/orchestrator.d.ts +22 -0
  27. package/dist/core/orchestrator.d.ts.map +1 -0
  28. package/dist/core/orchestrator.js +57 -0
  29. package/dist/core/orchestrator.js.map +1 -0
  30. package/dist/core/uploader.d.ts +15 -0
  31. package/dist/core/uploader.d.ts.map +1 -0
  32. package/dist/core/uploader.js +79 -0
  33. package/dist/core/uploader.js.map +1 -0
  34. package/dist/core/utils.d.ts +6 -0
  35. package/dist/core/utils.d.ts.map +1 -0
  36. package/dist/core/utils.js +23 -0
  37. package/dist/core/utils.js.map +1 -0
  38. package/dist/helpers/create-chunker.d.ts +9 -0
  39. package/dist/helpers/create-chunker.d.ts.map +1 -0
  40. package/dist/helpers/create-chunker.js +24 -0
  41. package/dist/helpers/create-chunker.js.map +1 -0
  42. package/dist/index.d.ts +11 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +16 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/interfaces/chunker.d.ts +46 -0
  47. package/dist/interfaces/chunker.d.ts.map +1 -0
  48. package/dist/interfaces/chunker.js +5 -0
  49. package/dist/interfaces/chunker.js.map +1 -0
  50. package/dist/interfaces/embedder.d.ts +28 -0
  51. package/dist/interfaces/embedder.d.ts.map +1 -0
  52. package/dist/interfaces/embedder.js +5 -0
  53. package/dist/interfaces/embedder.js.map +1 -0
  54. package/dist/interfaces/index.d.ts +4 -0
  55. package/dist/interfaces/index.d.ts.map +1 -0
  56. package/dist/interfaces/index.js +4 -0
  57. package/dist/interfaces/index.js.map +1 -0
  58. package/dist/interfaces/vector-store.d.ts +53 -0
  59. package/dist/interfaces/vector-store.d.ts.map +1 -0
  60. package/dist/interfaces/vector-store.js +5 -0
  61. package/dist/interfaces/vector-store.js.map +1 -0
  62. package/dist/strategies/chunk/index.d.ts +5 -0
  63. package/dist/strategies/chunk/index.d.ts.map +1 -0
  64. package/dist/strategies/chunk/index.js +5 -0
  65. package/dist/strategies/chunk/index.js.map +1 -0
  66. package/dist/strategies/chunk/markdown-headers.d.ts +7 -0
  67. package/dist/strategies/chunk/markdown-headers.d.ts.map +1 -0
  68. package/dist/strategies/chunk/markdown-headers.js +89 -0
  69. package/dist/strategies/chunk/markdown-headers.js.map +1 -0
  70. package/dist/strategies/chunk/semantic.d.ts +7 -0
  71. package/dist/strategies/chunk/semantic.d.ts.map +1 -0
  72. package/dist/strategies/chunk/semantic.js +62 -0
  73. package/dist/strategies/chunk/semantic.js.map +1 -0
  74. package/dist/strategies/chunk/token.d.ts +12 -0
  75. package/dist/strategies/chunk/token.d.ts.map +1 -0
  76. package/dist/strategies/chunk/token.js +56 -0
  77. package/dist/strategies/chunk/token.js.map +1 -0
  78. package/dist/strategies/chunk/whole-file.d.ts +3 -0
  79. package/dist/strategies/chunk/whole-file.d.ts.map +1 -0
  80. package/dist/strategies/chunk/whole-file.js +31 -0
  81. package/dist/strategies/chunk/whole-file.js.map +1 -0
  82. package/eslint.config.js +25 -0
  83. package/package.json +102 -0
  84. package/src/config-loader.ts +21 -0
  85. package/src/core/chunk-processor.test.ts +36 -0
  86. package/src/core/chunk-processor.ts +92 -0
  87. package/src/core/embedder.ts +189 -0
  88. package/src/core/git-tracker.test.ts +64 -0
  89. package/src/core/git-tracker.ts +202 -0
  90. package/src/core/orchestrator.test.ts +53 -0
  91. package/src/core/orchestrator.ts +97 -0
  92. package/src/core/uploader.ts +123 -0
  93. package/src/core/utils.ts +27 -0
  94. package/src/helpers/create-chunker.test.ts +31 -0
  95. package/src/helpers/create-chunker.ts +40 -0
  96. package/src/index.test.ts +33 -0
  97. package/src/index.ts +30 -0
  98. package/src/interfaces/chunker.ts +59 -0
  99. package/src/interfaces/embedder.ts +36 -0
  100. package/src/interfaces/index.test.ts +9 -0
  101. package/src/interfaces/index.ts +3 -0
  102. package/src/interfaces/vector-store.ts +71 -0
  103. package/src/strategies/chunk/index.ts +4 -0
  104. package/src/strategies/chunk/markdown-headers.test.ts +37 -0
  105. package/src/strategies/chunk/markdown-headers.ts +106 -0
  106. package/src/strategies/chunk/semantic.test.ts +21 -0
  107. package/src/strategies/chunk/semantic.ts +80 -0
  108. package/src/strategies/chunk/token.test.ts +41 -0
  109. package/src/strategies/chunk/token.ts +72 -0
  110. package/src/strategies/chunk/whole-file.test.ts +24 -0
  111. package/src/strategies/chunk/whole-file.ts +35 -0
  112. package/tsconfig.json +21 -0
  113. package/typedoc.json +11 -0
  114. package/vitest.config.ts +19 -0
@@ -0,0 +1,38 @@
1
+ {
2
+ "release-type": "node",
3
+ "bootstrap-sha": "main",
4
+ "separate-pull-requests": true,
5
+ "include-component-in-tag": false,
6
+ "tag-separator": "@",
7
+ "packages": {
8
+ ".": {
9
+ "package-name": "@vivantel/rag-core",
10
+ "changelog-path": "CHANGELOG.md",
11
+ "release-type": "node",
12
+ "bump-minor-pre-major": true,
13
+ "bump-patch-for-minor-pre-major": true,
14
+ "draft": false,
15
+ "prerelease": false
16
+ }
17
+ },
18
+ "plugins": [
19
+ {
20
+ "type": "node-workspace",
21
+ "merge": false
22
+ },
23
+ {
24
+ "type": "sentence-case",
25
+ "pull-request-title-pattern": "chore: release ${version}"
26
+ }
27
+ ],
28
+ "changelog-sections": [
29
+ {"type": "feat", "section": "Features", "hidden": false},
30
+ {"type": "fix", "section": "Bug Fixes", "hidden": false},
31
+ {"type": "perf", "section": "Performance Improvements", "hidden": false},
32
+ {"type": "refactor", "section": "Code Refactoring", "hidden": false},
33
+ {"type": "docs", "section": "Documentation", "hidden": false},
34
+ {"type": "style", "section": "Styles", "hidden": true},
35
+ {"type": "test", "section": "Tests", "hidden": true},
36
+ {"type": "chore", "section": "Miscellaneous Chores", "hidden": true}
37
+ ]
38
+ }
@@ -0,0 +1,28 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ day: "monday"
8
+ groups:
9
+ production-dependencies:
10
+ dependency-type: "production"
11
+ development-dependencies:
12
+ dependency-type: "development"
13
+ open-pull-requests-limit: 10
14
+ versioning-strategy: auto
15
+ labels:
16
+ - "dependencies"
17
+ - "automated"
18
+ commit-message:
19
+ prefix: "chore"
20
+ include: "scope"
21
+
22
+ - package-ecosystem: "github-actions"
23
+ directory: "/"
24
+ schedule:
25
+ interval: "weekly"
26
+ labels:
27
+ - "dependencies"
28
+ - "ci"
@@ -0,0 +1,119 @@
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
@@ -0,0 +1,151 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ permissions:
9
+ contents: write
10
+ pull-requests: write
11
+ issues: write
12
+ packages: write
13
+
14
+ jobs:
15
+ release-please:
16
+ name: Release Please
17
+ runs-on: ubuntu-latest
18
+
19
+ outputs:
20
+ release_created: ${{ steps.release.outputs.release_created }}
21
+ tag_name: ${{ steps.release.outputs.tag_name }}
22
+ version: ${{ steps.release.outputs.version }}
23
+
24
+ steps:
25
+ - name: Run Release Please
26
+ id: release
27
+ uses: googleapis/release-please-action@v5
28
+ with:
29
+ token: ${{ secrets.GITHUB_TOKEN }}
30
+ release-type: node
31
+ package-name: '@vivantel/rag-core'
32
+ config-file: .github/config/release-please.json
33
+ manifest-file: .release-please-manifest.json
34
+
35
+ publish-npm:
36
+ name: Publish to npm
37
+ needs: release-please
38
+ if: ${{ needs.release-please.outputs.release_created == 'true' }}
39
+ runs-on: ubuntu-latest
40
+
41
+ permissions:
42
+ contents: read
43
+ id-token: write # для npm provenance
44
+
45
+ steps:
46
+ - name: Checkout code
47
+ uses: actions/checkout@v6
48
+ with:
49
+ ref: ${{ needs.release-please.outputs.tag_name }}
50
+
51
+ - name: Setup Node.js
52
+ uses: actions/setup-node@v6
53
+ with:
54
+ node-version: 'lts/*'
55
+ registry-url: 'https://registry.npmjs.org'
56
+ cache: 'npm'
57
+
58
+ - name: Install dependencies
59
+ run: npm ci
60
+
61
+ - name: Build
62
+ run: npm run build
63
+
64
+ - name: Run tests
65
+ run: npm test
66
+
67
+ - name: Check package size
68
+ run: npx package-size
69
+
70
+ - name: Publish to npm
71
+ run: npm publish --provenance --access public
72
+ env:
73
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
74
+
75
+ - name: Create GitHub Release
76
+ uses: softprops/action-gh-release@v2
77
+ with:
78
+ tag_name: ${{ needs.release-please.outputs.tag_name }}
79
+ name: Release ${{ needs.release-please.outputs.version }}
80
+ body_path: CHANGELOG.md
81
+ draft: false
82
+ prerelease: false
83
+ generate_release_notes: true
84
+ env:
85
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86
+
87
+ create-github-package:
88
+ name: Publish to GitHub Packages
89
+ needs: release-please
90
+ if: ${{ needs.release-please.outputs.release_created == 'true' }}
91
+ runs-on: ubuntu-latest
92
+
93
+ permissions:
94
+ contents: read
95
+ packages: write
96
+
97
+ steps:
98
+ - name: Checkout code
99
+ uses: actions/checkout@v6
100
+ with:
101
+ ref: ${{ needs.release-please.outputs.tag_name }}
102
+
103
+ - name: Setup Node.js
104
+ uses: actions/setup-node@v6
105
+ with:
106
+ node-version: 'lts/*'
107
+ registry-url: 'https://npm.pkg.github.com'
108
+ cache: 'npm'
109
+
110
+ - name: Install dependencies
111
+ run: npm ci
112
+
113
+ - name: Build
114
+ run: npm run build
115
+
116
+ - name: Publish to GitHub Packages
117
+ run: npm publish
118
+ env:
119
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120
+
121
+ update-docs:
122
+ name: Update Documentation
123
+ needs: release-please
124
+ if: ${{ needs.release-please.outputs.release_created == 'true' }}
125
+ runs-on: ubuntu-latest
126
+
127
+ steps:
128
+ - name: Checkout code
129
+ uses: actions/checkout@v6
130
+ with:
131
+ ref: ${{ needs.release-please.outputs.tag_name }}
132
+
133
+ - name: Setup Node.js
134
+ uses: actions/setup-node@v6
135
+ with:
136
+ node-version: 'lts/*'
137
+ cache: 'npm'
138
+
139
+ - name: Install dependencies
140
+ run: npm ci
141
+
142
+ - name: Generate API documentation
143
+ run: npm run docs:generate
144
+
145
+ - name: Deploy to GitHub Pages
146
+ uses: peaceiris/actions-gh-pages@v4
147
+ with:
148
+ github_token: ${{ secrets.GITHUB_TOKEN }}
149
+ publish_dir: ./docs/api
150
+ destination_dir: ${{ needs.release-please.outputs.version }}
151
+ keep_files: false
@@ -0,0 +1,150 @@
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
+ packages: write
13
+
14
+ jobs:
15
+ release-please:
16
+ name: Release Please
17
+ runs-on: ubuntu-latest
18
+
19
+ outputs:
20
+ release_created: ${{ steps.release.outputs.release_created }}
21
+ tag_name: ${{ steps.release.outputs.tag_name }}
22
+ version: ${{ steps.release.outputs.version }}
23
+
24
+ steps:
25
+ - name: Run Release Please
26
+ id: release
27
+ uses: googleapis/release-please-action@v5
28
+ with:
29
+ token: ${{ secrets.GITHUB_TOKEN }}
30
+ release-type: node
31
+ package-name: '@vivantel/rag-core'
32
+ config-file: .github/config/release-please.json
33
+ manifest-file: .release-please-manifest.json
34
+
35
+ publish-npm:
36
+ name: Publish to npm
37
+ needs: release-please
38
+ if: ${{ needs.release-please.outputs.release_created == 'true' }}
39
+ runs-on: ubuntu-latest
40
+
41
+ permissions:
42
+ contents: read
43
+ id-token: write # для npm provenance
44
+
45
+ steps:
46
+ - name: Checkout code
47
+ uses: actions/checkout@v6
48
+ with:
49
+ ref: ${{ needs.release-please.outputs.tag_name }}
50
+
51
+ - name: Setup Node.js
52
+ uses: actions/setup-node@v6
53
+ with:
54
+ node-version: '20.x'
55
+ registry-url: 'https://registry.npmjs.org'
56
+ cache: 'npm'
57
+
58
+ - name: Install dependencies
59
+ run: npm ci
60
+
61
+ - name: Build
62
+ run: npm run build
63
+
64
+ - name: Run tests
65
+ run: npm test
66
+
67
+ - name: Check package size
68
+ run: npx package-size
69
+
70
+ - name: Publish to npm
71
+ run: npm publish --provenance --access public
72
+ env:
73
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
74
+
75
+ - name: Create GitHub Release
76
+ uses: softprops/action-gh-release@v1
77
+ with:
78
+ tag_name: ${{ needs.release-please.outputs.tag_name }}
79
+ name: Release ${{ needs.release-please.outputs.version }}
80
+ body_path: CHANGELOG.md
81
+ draft: false
82
+ prerelease: false
83
+ env:
84
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85
+
86
+ create-github-package:
87
+ name: Publish to GitHub Packages
88
+ needs: release-please
89
+ if: ${{ needs.release-please.outputs.release_created == 'true' }}
90
+ runs-on: ubuntu-latest
91
+
92
+ permissions:
93
+ contents: read
94
+ packages: write
95
+
96
+ steps:
97
+ - name: Checkout code
98
+ uses: actions/checkout@v6
99
+ with:
100
+ ref: ${{ needs.release-please.outputs.tag_name }}
101
+
102
+ - name: Setup Node.js
103
+ uses: actions/setup-node@v6
104
+ with:
105
+ node-version: '20.x'
106
+ registry-url: 'https://npm.pkg.github.com'
107
+ cache: 'npm'
108
+
109
+ - name: Install dependencies
110
+ run: npm ci
111
+
112
+ - name: Build
113
+ run: npm run build
114
+
115
+ - name: Publish to GitHub Packages
116
+ run: npm publish
117
+ env:
118
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119
+
120
+ update-docs:
121
+ name: Update Documentation
122
+ needs: release-please
123
+ if: ${{ needs.release-please.outputs.release_created == 'true' }}
124
+ runs-on: ubuntu-latest
125
+
126
+ steps:
127
+ - name: Checkout code
128
+ uses: actions/checkout@v6
129
+ with:
130
+ ref: ${{ needs.release-please.outputs.tag_name }}
131
+
132
+ - name: Setup Node.js
133
+ uses: actions/setup-node@v6
134
+ with:
135
+ node-version: '20.x'
136
+ cache: 'npm'
137
+
138
+ - name: Install dependencies
139
+ run: npm ci
140
+
141
+ - name: Generate API documentation
142
+ run: npm run docs:generate
143
+
144
+ - name: Deploy to GitHub Pages
145
+ uses: peaceiris/actions-gh-pages@v4
146
+ with:
147
+ github_token: ${{ secrets.GITHUB_TOKEN }}
148
+ publish_dir: ./docs/api
149
+ destination_dir: ${{ needs.release-please.outputs.version }}
150
+ keep_files: false
@@ -0,0 +1,19 @@
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 ADDED
@@ -0,0 +1,21 @@
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
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Initial release
12
+
13
+ ### Changed
14
+
15
+ ### Deprecated
16
+
17
+ ### Removed
18
+
19
+ ### Fixed
20
+
21
+ ### Security
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @vivantel/rag-core
2
+
3
+ Core RAG pipeline tools - universal chunking, embedding, and vector store orchestration.
4
+
5
+ [![CI](https://github.com/vivantel/rag-core/actions/workflows/ci.yaml/badge.svg)](https://github.com/vivantel/rag-core/actions/workflows/ci.yaml)
6
+ [![Release](https://github.com/vivantel/rag-core/actions/workflows/release.yaml/badge.svg)](https://github.com/vivantel/rag-core/actions/workflows/release.yaml)
7
+ [![npm version](https://img.shields.io/npm/v/@vivantel/rag-core.svg)](https://www.npmjs.com/package/@vivantel/rag-core)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @vivantel/rag-core
14
+ ```
15
+
16
+ ## Quick Start
17
+
18
+ ### 1. Create a config file (`rag.config.ts`)
19
+
20
+ ```typescript
21
+ import { defineConfig, createChunker, tokenStrategy } from '@vivantel/rag-core';
22
+ import { readFile } from 'fs/promises';
23
+
24
+ export default defineConfig({
25
+ chunkers: [
26
+ createChunker({
27
+ name: 'my-chunker',
28
+ patterns: ['docs/**/*.md'],
29
+ async process(content, filePath, commitHash) {
30
+ return [{
31
+ content,
32
+ metadata: { type: 'doc', file: filePath },
33
+ sourceFile: filePath,
34
+ commitHash
35
+ }];
36
+ }
37
+ })
38
+ ],
39
+
40
+ embedder: new MyEmbedderProvider({ apiKey: process.env.API_KEY }),
41
+ vectorStore: new MyVectorStore({ url: process.env.DB_URL })
42
+ });
43
+ ```
44
+
45
+ ### 2. Run the pipeline
46
+
47
+ ```bash
48
+ rag-update --config rag.config.ts
49
+ ```
50
+
51
+ ## Built-in Strategies
52
+
53
+ ### Chunk Strategies
54
+
55
+ - `tokenStrategy({ maxTokens, overlap })` - Split by approximate token count
56
+ - `markdownHeadersStrategy()` - Split by Markdown headers (##, ###)
57
+ - `semanticStrategy()` - Split by sentence boundaries
58
+ - `wholeFileStrategy()` - One chunk per file
59
+
60
+ ## License
61
+
62
+ MIT
@@ -0,0 +1,49 @@
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();
@@ -0,0 +1,3 @@
1
+ import { RAGPipelineConfig } from "./core/orchestrator.js";
2
+ export declare function loadConfig(configPath: string): Promise<RAGPipelineConfig>;
3
+ //# sourceMappingURL=config-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC,CAe5B"}
@@ -0,0 +1,13 @@
1
+ import { pathToFileURL } from "url";
2
+ export async function loadConfig(configPath) {
3
+ // Clear cache for hot reload
4
+ delete require.cache[require.resolve(configPath)];
5
+ const configUrl = pathToFileURL(configPath).href;
6
+ const configModule = await import(configUrl);
7
+ const config = configModule.default;
8
+ if (!config.chunkers || !config.embedder || !config.vectorStore) {
9
+ throw new Error("Invalid config: missing chunkers, embedder, or vectorStore");
10
+ }
11
+ return config;
12
+ }
13
+ //# sourceMappingURL=config-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAAkB;IAElB,6BAA6B;IAC7B,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAElD,MAAM,SAAS,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;IACjD,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC;IAEpC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Chunk, FileChunker } from "../interfaces/index.js";
2
+ export declare class ChunkProcessor {
3
+ private chunkers;
4
+ constructor(chunkers: FileChunker[]);
5
+ processFile(filePath: string, commitHash: string, chunker: FileChunker): Promise<Chunk[]>;
6
+ processFiles(files: string[], fileState: Map<string, {
7
+ commitHash: string;
8
+ chunker: FileChunker;
9
+ }>): Promise<Chunk[]>;
10
+ saveChunksLocal(chunks: Chunk[], outputFile: string): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=chunk-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-processor.d.ts","sourceRoot":"","sources":["../../src/core/chunk-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAO5D,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAA2B;gBAE/B,QAAQ,EAAE,WAAW,EAAE;IAI7B,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,KAAK,EAAE,CAAC;IAiBb,YAAY,CAChB,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,WAAW,CAAA;KAAE,CAAC,GACnE,OAAO,CAAC,KAAK,EAAE,CAAC;IA+Bb,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAsB1E"}