@devilsdev/rag-pipeline-utils 2.0.0 → 2.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 (77) hide show
  1. package/.eslintrc.json +24 -18
  2. package/.github/workflows/docs-deploy.yml +46 -0
  3. package/.github/workflows/publish-release-blog.yml +53 -0
  4. package/.github/workflows/storybook-deploy.yml +33 -0
  5. package/.husky/pre-commit +1 -0
  6. package/.storybook/main.js +20 -0
  7. package/.storybook/preview.js +13 -0
  8. package/CHANGELOG.md +15 -1
  9. package/README.md +101 -72
  10. package/Use-Cases.md +134 -0
  11. package/docs-site/.plaiceholder-cache/img_hero.jpg.json +1 -0
  12. package/docs-site/.plaiceholder-cache/img_logo.png.json +1 -0
  13. package/docs-site/.storybook/preview.js +8 -0
  14. package/docs-site/blog/2021-08-26-welcome/index.md +0 -1
  15. package/docs-site/blog/2025-04-17-release-2.0.md +67 -0
  16. package/docs-site/blog/2025-04-17-release-v2.0.2.md +13 -0
  17. package/docs-site/blog/2025-04-18-architecture-overview.md +34 -0
  18. package/docs-site/blog/2025-04-18-release-2.0.0.md +21 -0
  19. package/docs-site/blog/2025-04-19-prompt-engineering-best-practices.md +31 -0
  20. package/docs-site/blog/2025-04-20-image-showcase.md +23 -0
  21. package/docs-site/blog/authors.yml +5 -23
  22. package/docs-site/blog/tags.yml +27 -16
  23. package/docs-site/docs/Architecture.md +4 -4
  24. package/docs-site/docs/CLI.md +3 -3
  25. package/docs-site/docs/Evaluation.md +7 -7
  26. package/docs-site/docs/FAQ.md +6 -6
  27. package/docs-site/docs/Introduction.md +9 -9
  28. package/docs-site/docs/Plugins.md +3 -3
  29. package/docs-site/docs/Tutorials.md +106 -0
  30. package/docs-site/docs/Usage.md +5 -5
  31. package/docs-site/docs/Use-Cases.md +77 -0
  32. package/docs-site/docs/components/BlogCardExample.mdx +7 -0
  33. package/docs-site/docusaurus.config.js +16 -2
  34. package/docs-site/package-lock.json +487 -2
  35. package/docs-site/package.json +7 -3
  36. package/docs-site/scripts/generate-placeholders.js +17 -0
  37. package/docs-site/scripts/watch-images.js +40 -0
  38. package/docs-site/sidebar-snippet.txt +5 -0
  39. package/docs-site/sidebars.js +26 -9
  40. package/docs-site/src/components/BlogCard.jsx +31 -0
  41. package/docs-site/src/components/BlogCard.stories.jsx +34 -0
  42. package/docs-site/src/components/BlogImage.jsx +58 -0
  43. package/docs-site/src/components/BlogImage.stories.jsx +20 -0
  44. package/docs-site/static/img/authors/ali.jpg +0 -0
  45. package/docs-site/static/img/hero.jpg +0 -0
  46. package/docs-site/utils/image.js +19 -0
  47. package/package.json +27 -3
  48. package/scripts/validate-changelog-version.js +48 -0
  49. package/src/stories/Button.jsx +39 -0
  50. package/src/stories/Button.stories.js +49 -0
  51. package/src/stories/Configure.mdx +364 -0
  52. package/src/stories/Header.jsx +56 -0
  53. package/src/stories/Header.stories.js +29 -0
  54. package/src/stories/Page.jsx +69 -0
  55. package/src/stories/Page.stories.js +28 -0
  56. package/src/stories/assets/accessibility.png +0 -0
  57. package/src/stories/assets/accessibility.svg +1 -0
  58. package/src/stories/assets/addon-library.png +0 -0
  59. package/src/stories/assets/assets.png +0 -0
  60. package/src/stories/assets/avif-test-image.avif +0 -0
  61. package/src/stories/assets/context.png +0 -0
  62. package/src/stories/assets/discord.svg +1 -0
  63. package/src/stories/assets/docs.png +0 -0
  64. package/src/stories/assets/figma-plugin.png +0 -0
  65. package/src/stories/assets/github.svg +1 -0
  66. package/src/stories/assets/share.png +0 -0
  67. package/src/stories/assets/styling.png +0 -0
  68. package/src/stories/assets/testing.png +0 -0
  69. package/src/stories/assets/theming.png +0 -0
  70. package/src/stories/assets/tutorials.svg +1 -0
  71. package/src/stories/assets/youtube.svg +1 -0
  72. package/src/stories/button.css +30 -0
  73. package/src/stories/header.css +32 -0
  74. package/src/stories/page.css +68 -0
  75. package/docs-site/blog/2019-05-28-first-blog-post.md +0 -12
  76. package/docs-site/blog/2019-05-29-long-blog-post.md +0 -44
  77. package/docs-site/blog/2021-08-01-mdx-blog-post.mdx +0 -24
@@ -2,21 +2,38 @@
2
2
 
3
3
  /**
4
4
  * Sidebar configuration for RAG Pipeline Utils documentation site
5
- * Generated manually for ordered navigation
5
+ * Version: 2.0.0
6
6
  * Author: Ali Kahwaji
7
+ * Updated: Structured for modular clarity and DX
7
8
  * @type {import('@docusaurus/plugin-content-docs').SidebarsConfig}
8
9
  */
9
10
 
10
11
  const sidebars = {
11
12
  tutorialSidebar: [
12
- 'Introduction',
13
- 'Usage',
14
- 'CLI',
15
- 'Architecture',
16
- 'Evaluation',
17
- 'Plugins',
18
- 'FAQ'
19
- ]
13
+ {
14
+ type: 'category',
15
+ label: 'Overview',
16
+ collapsed: false,
17
+ items: ['Introduction', 'Architecture', 'Tutorials', 'Use-Cases'],
18
+ },
19
+ {
20
+ type: 'category',
21
+ label: 'Developer Guide',
22
+ collapsed: false,
23
+ items: ['Usage', 'CLI', 'Plugins'],
24
+ },
25
+ {
26
+ type: 'category',
27
+ label: 'Advanced',
28
+ collapsed: true,
29
+ items: ['Evaluation', 'FAQ'],
30
+ },
31
+ {
32
+ type: 'link',
33
+ label: '📰 Blog',
34
+ href: '/blog',
35
+ },
36
+ ],
20
37
  };
21
38
 
22
39
  export default sidebars;
@@ -0,0 +1,31 @@
1
+ // Version: 1.0.0
2
+ // Description: Blog card with image placeholder using Plaiceholder LQIP
3
+ // Author: Ali Kahwaji
4
+
5
+ import React from 'react';
6
+ import styles from './BlogCard.module.css';
7
+ import placeholder from '../../.plaiceholder-cache/img_hero.jpg.json'; // ✅ Cached placeholder
8
+
9
+ export default function BlogCard({ title }) {
10
+ const { base64, img } = placeholder;
11
+
12
+ return (
13
+ <div className={styles.card}>
14
+ <img
15
+ src={img.src}
16
+ width={img.width}
17
+ height={img.height}
18
+ alt={title}
19
+ loading="lazy"
20
+ style={{
21
+ objectFit: 'cover',
22
+ borderRadius: 12,
23
+ background: `url(${base64})`,
24
+ backgroundSize: 'cover',
25
+ backgroundPosition: 'center',
26
+ }}
27
+ />
28
+ <h3>{title}</h3>
29
+ </div>
30
+ );
31
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Version: 1.0.0
3
+ * File: BlogCard.stories.jsx
4
+ * Description: Storybook entry for BlogCard with image placeholder integration
5
+ * Author: Ali Kahwaji
6
+ */
7
+
8
+ import React from 'react';
9
+ import BlogCard from './BlogCard';
10
+
11
+ export default {
12
+ title: 'Components/BlogCard',
13
+ component: BlogCard,
14
+ tags: ['autodocs'],
15
+ args: {
16
+ title: 'Composable Pipelines',
17
+ image: 'img/hero.jpg', // Path relative to /static
18
+ },
19
+ };
20
+
21
+ const Template = (args) => <BlogCard {...args} />;
22
+
23
+ export const Default = Template.bind({});
24
+
25
+ export const CustomTitle = Template.bind({});
26
+ CustomTitle.args = {
27
+ title: 'Flexible RAG Components',
28
+ };
29
+
30
+ export const WithAnotherImage = Template.bind({});
31
+ WithAnotherImage.args = {
32
+ title: 'LLM Plugin Architecture',
33
+ image: 'img/social-card.jpg',
34
+ };
@@ -0,0 +1,58 @@
1
+ // docs-site/src/components/BlogImage.jsx
2
+ // Version: 2.0.0
3
+ // Description: Resilient image renderer with LQIP blur fallback from Plaiceholder cache
4
+ // Author: Ali Kahwaji
5
+
6
+ import React from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import defaultPlaceholder from '../../.plaiceholder-cache/img_hero.jpg.json'; // Default fallback image
9
+
10
+ /**
11
+ * BlogImage
12
+ * Renders an image using precomputed LQIP placeholders
13
+ *
14
+ * @param {string} srcKey - Cache key (e.g., 'img_logo') without .json
15
+ * @param {string} alt - Image alt text
16
+ * @param {string} [className] - Optional className for custom styling
17
+ * @param {object} [style] - Optional inline styles
18
+ * @returns {JSX.Element}
19
+ */
20
+ export default function BlogImage({ srcKey, alt, className = '', style = {} }) {
21
+ let imageData;
22
+
23
+ try {
24
+ imageData = require(`../../.plaiceholder-cache/${srcKey}.json`);
25
+ } catch (e) {
26
+ console.warn(`⚠️ LQIP not found for ${srcKey}, using fallback.`);
27
+ imageData = defaultPlaceholder;
28
+ }
29
+
30
+ const { base64, img } = imageData;
31
+
32
+ return (
33
+ <img
34
+ src={img.src}
35
+ width={img.width}
36
+ height={img.height}
37
+ alt={alt}
38
+ loading="lazy"
39
+ className={className}
40
+ style={{
41
+ objectFit: 'cover',
42
+ background: `url(${base64})`,
43
+ backgroundSize: 'cover',
44
+ backgroundPosition: 'center',
45
+ borderRadius: '12px',
46
+ transition: 'opacity 0.3s ease',
47
+ ...style,
48
+ }}
49
+ />
50
+ );
51
+ }
52
+
53
+ BlogImage.propTypes = {
54
+ srcKey: PropTypes.string.isRequired,
55
+ alt: PropTypes.string.isRequired,
56
+ className: PropTypes.string,
57
+ style: PropTypes.object,
58
+ };
@@ -0,0 +1,20 @@
1
+ // Version: 1.0.0
2
+ // Description: Storybook story for BlogImage component
3
+ // Author: Ali Kahwaji
4
+
5
+ import React from 'react';
6
+ import BlogImage from '../BlogImage';
7
+
8
+ export default {
9
+ title: 'Components/BlogImage',
10
+ component: BlogImage,
11
+ };
12
+
13
+ const Template = (args) => <BlogImage {...args} />;
14
+
15
+ export const Default = Template.bind({});
16
+ Default.args = {
17
+ srcKey: 'img_hero',
18
+ alt: 'Default placeholder image',
19
+ className: '',
20
+ };
Binary file
@@ -0,0 +1,19 @@
1
+ // docs-site/utils/image.js
2
+ import { getPlaiceholder } from 'plaiceholder';
3
+ import fs from 'fs/promises';
4
+ import path from 'path';
5
+
6
+ /**
7
+ * Generates base64 placeholder and img props from local image file
8
+ * @param {string} imagePath - Relative path to image in /static/img
9
+ */
10
+ export async function generatePlaceholder(imagePath) {
11
+ const fullPath = path.join(process.cwd(), 'docs-site', 'static', imagePath);
12
+ const buffer = await fs.readFile(fullPath);
13
+ const { base64, img } = await getPlaiceholder(buffer);
14
+
15
+ return {
16
+ ...img,
17
+ blurDataURL: base64,
18
+ };
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devilsdev/rag-pipeline-utils",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "A modular toolkit for building RAG (Retrieval-Augmented Generation) pipelines in Node.js",
5
5
  "main": "src/core/create-pipeline.js",
6
6
  "bin": {
@@ -17,7 +17,15 @@
17
17
  "lint-staged": "lint-staged",
18
18
  "postinstall": "husky install",
19
19
  "verify:mocks": "node scripts/verify-fixture-mocks.js",
20
- "ci": "node scripts/ci-runner.js"
20
+ "build:docs": "npx docusaurus build docs-site",
21
+ "ci": "node scripts/ci-runner.js",
22
+ "docs:dev": "npx docusaurus start docs-site",
23
+ "docs:build": "npx docusaurus build docs-site",
24
+ "docs:deploy": "npx docusaurus deploy docs-site",
25
+ "docs:version": "npx docusaurus docs:version",
26
+ "docs:serve": "npx docusaurus serve docs-site",
27
+ "storybook": "storybook dev -p 6006",
28
+ "build-storybook": "storybook build"
21
29
  },
22
30
  "lint-staged": {
23
31
  "**/*.{js,ts}": [
@@ -48,23 +56,37 @@
48
56
  "access": "public"
49
57
  },
50
58
  "devDependencies": {
59
+ "@docusaurus/core": "^3.7.0",
60
+ "@docusaurus/preset-classic": "^3.7.0",
51
61
  "@semantic-release/changelog": "^6.0.3",
52
62
  "@semantic-release/commit-analyzer": "^13.0.1",
53
63
  "@semantic-release/git": "^10.0.1",
54
64
  "@semantic-release/github": "^9.2.6",
55
65
  "@semantic-release/npm": "^11.0.3",
56
66
  "@semantic-release/release-notes-generator": "^14.0.3",
67
+ "@storybook/addon-essentials": "^8.6.12",
68
+ "@storybook/addon-interactions": "^8.6.12",
69
+ "@storybook/addon-onboarding": "^8.6.12",
70
+ "@storybook/addon-webpack5-compiler-swc": "^3.0.0",
71
+ "@storybook/blocks": "^8.6.12",
72
+ "@storybook/react": "^8.6.12",
73
+ "@storybook/react-webpack5": "^8.6.12",
74
+ "@storybook/test": "^8.6.12",
57
75
  "@types/jest": "^29.5.14",
58
76
  "codecov": "^3.8.2",
59
77
  "cross-env": "^7.0.3",
78
+ "docusaurus": "^1.14.7",
60
79
  "esbuild": "^0.25.2",
61
80
  "eslint": "^8.57.1",
81
+ "eslint-plugin-storybook": "^0.12.0",
62
82
  "husky": "^8.0.3",
63
83
  "jest": "^29.7.0",
64
84
  "lint-staged": "^15.5.1",
65
85
  "prettier": "^3.5.3",
86
+ "prop-types": "^15.8.1",
66
87
  "rimraf": "^6.0.1",
67
88
  "semantic-release": "^21.1.2",
89
+ "storybook": "^8.6.12",
68
90
  "ts-jest": "^29.3.2"
69
91
  },
70
92
  "dependencies": {
@@ -77,6 +99,8 @@
77
99
  "fast-glob": "^3.3.3",
78
100
  "jsdom": "^26.1.0",
79
101
  "openai": "^4.93.0",
80
- "pino": "^9.6.0"
102
+ "pino": "^9.6.0",
103
+ "plaiceholder": "^3.0.0",
104
+ "sharp": "^0.34.1"
81
105
  }
82
106
  }
@@ -0,0 +1,48 @@
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}`);
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+
3
+ import PropTypes from 'prop-types';
4
+
5
+ import './button.css';
6
+
7
+ /** Primary UI component for user interaction */
8
+ export const Button = ({
9
+ primary = false,
10
+ backgroundColor = null,
11
+ size = 'medium',
12
+ label,
13
+ ...props
14
+ }) => {
15
+ const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
16
+ return (
17
+ <button
18
+ type="button"
19
+ className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
20
+ style={backgroundColor && { backgroundColor }}
21
+ {...props}
22
+ >
23
+ {label}
24
+ </button>
25
+ );
26
+ };
27
+
28
+ Button.propTypes = {
29
+ /** Is this the principal call to action on the page? */
30
+ primary: PropTypes.bool,
31
+ /** What background color to use */
32
+ backgroundColor: PropTypes.string,
33
+ /** How large should the button be? */
34
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
35
+ /** Button contents */
36
+ label: PropTypes.string.isRequired,
37
+ /** Optional click handler */
38
+ onClick: PropTypes.func,
39
+ };
@@ -0,0 +1,49 @@
1
+ import { fn } from '@storybook/test';
2
+
3
+ import { Button } from './Button';
4
+
5
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
6
+ export default {
7
+ title: 'Example/Button',
8
+ component: Button,
9
+ parameters: {
10
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
11
+ layout: 'centered',
12
+ },
13
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
14
+ tags: ['autodocs'],
15
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
16
+ argTypes: {
17
+ backgroundColor: { control: 'color' },
18
+ },
19
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
20
+ args: { onClick: fn() },
21
+ };
22
+
23
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
24
+ export const Primary = {
25
+ args: {
26
+ primary: true,
27
+ label: 'Button',
28
+ },
29
+ };
30
+
31
+ export const Secondary = {
32
+ args: {
33
+ label: 'Button',
34
+ },
35
+ };
36
+
37
+ export const Large = {
38
+ args: {
39
+ size: 'large',
40
+ label: 'Button',
41
+ },
42
+ };
43
+
44
+ export const Small = {
45
+ args: {
46
+ size: 'small',
47
+ label: 'Button',
48
+ },
49
+ };