@mytechtoday/augment-extensions 0.1.2 → 0.4.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.
- package/README.md +614 -39
- package/augment-extensions/coding-standards/bash/README.md +196 -0
- package/augment-extensions/coding-standards/bash/module.json +163 -0
- package/augment-extensions/coding-standards/bash/rules/naming-conventions.md +336 -0
- package/augment-extensions/coding-standards/bash/rules/universal-standards.md +289 -0
- package/augment-extensions/coding-standards/css/README.md +40 -0
- package/augment-extensions/coding-standards/css/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/css/module.json +44 -0
- package/augment-extensions/coding-standards/css/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/css/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html/README.md +40 -0
- package/augment-extensions/coding-standards/html/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html/module.json +44 -0
- package/augment-extensions/coding-standards/html/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/README.md +194 -0
- package/augment-extensions/coding-standards/html-css-js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/html-css-js/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/html-css-js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/html-css-js/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html-css-js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/html-css-js/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html-css-js/module.json +48 -0
- package/augment-extensions/coding-standards/html-css-js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html-css-js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/html-css-js/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/html-css-js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/html-css-js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/js/README.md +46 -0
- package/augment-extensions/coding-standards/js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/js/module.json +49 -0
- package/augment-extensions/coding-standards/js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/php/README.md +248 -0
- package/augment-extensions/coding-standards/php/examples/api-endpoint-example.php +204 -0
- package/augment-extensions/coding-standards/php/examples/cli-command-example.php +206 -0
- package/augment-extensions/coding-standards/php/examples/legacy-refactoring-example.php +234 -0
- package/augment-extensions/coding-standards/php/examples/web-application-example.php +211 -0
- package/augment-extensions/coding-standards/php/examples/woocommerce-extension-example.php +215 -0
- package/augment-extensions/coding-standards/php/examples/wordpress-plugin-example.php +189 -0
- package/augment-extensions/coding-standards/php/module.json +166 -0
- package/augment-extensions/coding-standards/php/rules/api-development.md +480 -0
- package/augment-extensions/coding-standards/php/rules/category-configuration.md +332 -0
- package/augment-extensions/coding-standards/php/rules/cli-tools.md +472 -0
- package/augment-extensions/coding-standards/php/rules/cms-integration.md +561 -0
- package/augment-extensions/coding-standards/php/rules/code-quality.md +402 -0
- package/augment-extensions/coding-standards/php/rules/documentation.md +425 -0
- package/augment-extensions/coding-standards/php/rules/ecommerce.md +627 -0
- package/augment-extensions/coding-standards/php/rules/error-handling.md +336 -0
- package/augment-extensions/coding-standards/php/rules/legacy-migration.md +677 -0
- package/augment-extensions/coding-standards/php/rules/naming-conventions.md +279 -0
- package/augment-extensions/coding-standards/php/rules/performance.md +392 -0
- package/augment-extensions/coding-standards/php/rules/psr-standards.md +186 -0
- package/augment-extensions/coding-standards/php/rules/security.md +358 -0
- package/augment-extensions/coding-standards/php/rules/testing.md +403 -0
- package/augment-extensions/coding-standards/php/rules/type-declarations.md +331 -0
- package/augment-extensions/coding-standards/php/rules/web-applications.md +426 -0
- package/augment-extensions/coding-standards/powershell/README.md +154 -0
- package/augment-extensions/coding-standards/powershell/examples/admin-example.ps1 +272 -0
- package/augment-extensions/coding-standards/powershell/examples/automation-example.ps1 +173 -0
- package/augment-extensions/coding-standards/powershell/examples/cloud-example.ps1 +243 -0
- package/augment-extensions/coding-standards/powershell/examples/cross-platform-example.ps1 +297 -0
- package/augment-extensions/coding-standards/powershell/examples/dsc-example.ps1 +224 -0
- package/augment-extensions/coding-standards/powershell/examples/legacy-migration-example.ps1 +340 -0
- package/augment-extensions/coding-standards/powershell/examples/module-example.psm1 +255 -0
- package/augment-extensions/coding-standards/powershell/module.json +165 -0
- package/augment-extensions/coding-standards/powershell/rules/administrative-tools.md +439 -0
- package/augment-extensions/coding-standards/powershell/rules/automation-scripts.md +240 -0
- package/augment-extensions/coding-standards/powershell/rules/cloud-orchestration.md +384 -0
- package/augment-extensions/coding-standards/powershell/rules/configuration-schema.md +383 -0
- package/augment-extensions/coding-standards/powershell/rules/cross-platform-scripts.md +482 -0
- package/augment-extensions/coding-standards/powershell/rules/dsc-configurations.md +296 -0
- package/augment-extensions/coding-standards/powershell/rules/error-handling.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/legacy-migrations.md +466 -0
- package/augment-extensions/coding-standards/powershell/rules/modules-functions.md +244 -0
- package/augment-extensions/coding-standards/powershell/rules/naming-conventions.md +266 -0
- package/augment-extensions/coding-standards/powershell/rules/performance-optimization.md +209 -0
- package/augment-extensions/coding-standards/powershell/rules/security-practices.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/testing-guidelines.md +268 -0
- package/augment-extensions/coding-standards/powershell/rules/universal-standards.md +197 -0
- package/augment-extensions/coding-standards/python/README.md +12 -8
- package/augment-extensions/coding-standards/python/examples/best-practices.py +373 -0
- package/augment-extensions/coding-standards/python/module.json +8 -4
- package/augment-extensions/coding-standards/python/rules/async-patterns.md +884 -0
- package/augment-extensions/coding-standards/python/rules/documentation.md +831 -0
- package/augment-extensions/coding-standards/python/rules/error-handling.md +855 -68
- package/augment-extensions/coding-standards/python/rules/testing.md +409 -0
- package/augment-extensions/coding-standards/python/rules/tooling.md +446 -0
- package/augment-extensions/coding-standards/python/rules/type-hints.md +115 -50
- package/augment-extensions/collections/html-css-js/README.md +82 -0
- package/augment-extensions/collections/html-css-js/collection.json +41 -0
- package/augment-extensions/domain-rules/database/README.md +161 -0
- package/augment-extensions/domain-rules/database/examples/flat-database-example.md +793 -0
- package/augment-extensions/domain-rules/database/examples/hybrid-database-example.md +1132 -0
- package/augment-extensions/domain-rules/database/examples/nosql-document-example.md +868 -0
- package/augment-extensions/domain-rules/database/examples/nosql-graph-example.md +805 -0
- package/augment-extensions/domain-rules/database/examples/relational-schema-example.md +621 -0
- package/augment-extensions/domain-rules/database/examples/vector-database-example.md +965 -0
- package/augment-extensions/domain-rules/database/module.json +28 -0
- package/augment-extensions/domain-rules/database/rules/flat-databases.md +624 -0
- package/augment-extensions/domain-rules/database/rules/nosql-databases.md +588 -0
- package/augment-extensions/domain-rules/database/rules/nosql-document-stores.md +856 -0
- package/augment-extensions/domain-rules/database/rules/nosql-graph-databases.md +778 -0
- package/augment-extensions/domain-rules/database/rules/nosql-key-value-stores.md +963 -0
- package/augment-extensions/domain-rules/database/rules/performance-optimization.md +1076 -0
- package/augment-extensions/domain-rules/database/rules/relational-databases.md +697 -0
- package/augment-extensions/domain-rules/database/rules/relational-indexing.md +671 -0
- package/augment-extensions/domain-rules/database/rules/relational-query-optimization.md +607 -0
- package/augment-extensions/domain-rules/database/rules/relational-schema-design.md +907 -0
- package/augment-extensions/domain-rules/database/rules/relational-transactions.md +783 -0
- package/augment-extensions/domain-rules/database/rules/security-standards.md +980 -0
- package/augment-extensions/domain-rules/database/rules/universal-best-practices.md +485 -0
- package/augment-extensions/domain-rules/database/rules/vector-databases.md +521 -0
- package/augment-extensions/domain-rules/database/rules/vector-embeddings.md +858 -0
- package/augment-extensions/domain-rules/database/rules/vector-indexing.md +934 -0
- package/augment-extensions/domain-rules/mcp/README.md +150 -0
- package/augment-extensions/domain-rules/mcp/examples/compressed-example.md +522 -0
- package/augment-extensions/domain-rules/mcp/examples/graph-augmented-example.md +520 -0
- package/augment-extensions/domain-rules/mcp/examples/hybrid-example.md +570 -0
- package/augment-extensions/domain-rules/mcp/examples/state-based-example.md +427 -0
- package/augment-extensions/domain-rules/mcp/examples/token-based-example.md +435 -0
- package/augment-extensions/domain-rules/mcp/examples/vector-based-example.md +502 -0
- package/augment-extensions/domain-rules/mcp/module.json +49 -0
- package/augment-extensions/domain-rules/mcp/rules/compressed-mcp.md +595 -0
- package/augment-extensions/domain-rules/mcp/rules/configuration.md +345 -0
- package/augment-extensions/domain-rules/mcp/rules/graph-augmented-mcp.md +687 -0
- package/augment-extensions/domain-rules/mcp/rules/hybrid-mcp.md +636 -0
- package/augment-extensions/domain-rules/mcp/rules/state-based-mcp.md +484 -0
- package/augment-extensions/domain-rules/mcp/rules/testing-validation.md +360 -0
- package/augment-extensions/domain-rules/mcp/rules/token-based-mcp.md +393 -0
- package/augment-extensions/domain-rules/mcp/rules/universal-rules.md +194 -0
- package/augment-extensions/domain-rules/mcp/rules/vector-based-mcp.md +625 -0
- package/augment-extensions/domain-rules/wordpress/README.md +163 -0
- package/augment-extensions/domain-rules/wordpress/module.json +32 -0
- package/augment-extensions/domain-rules/wordpress/rules/coding-standards.md +617 -0
- package/augment-extensions/domain-rules/wordpress/rules/directory-structure.md +270 -0
- package/augment-extensions/domain-rules/wordpress/rules/file-patterns.md +423 -0
- package/augment-extensions/domain-rules/wordpress/rules/gutenberg-blocks.md +493 -0
- package/augment-extensions/domain-rules/wordpress/rules/performance.md +568 -0
- package/augment-extensions/domain-rules/wordpress/rules/plugin-development.md +510 -0
- package/augment-extensions/domain-rules/wordpress/rules/project-detection.md +251 -0
- package/augment-extensions/domain-rules/wordpress/rules/rest-api.md +501 -0
- package/augment-extensions/domain-rules/wordpress/rules/security.md +564 -0
- package/augment-extensions/domain-rules/wordpress/rules/theme-development.md +388 -0
- package/augment-extensions/domain-rules/wordpress/rules/woocommerce.md +441 -0
- package/augment-extensions/domain-rules/wordpress-plugin/README.md +139 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/ajax-plugin.md +1599 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/custom-post-type-plugin.md +1727 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block-plugin.md +428 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block.md +422 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/mvc-plugin.md +1623 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/object-oriented-plugin.md +1343 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/rest-endpoint.md +734 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/settings-page-plugin.md +1350 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/simple-procedural-plugin.md +503 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/singleton-plugin.md +971 -0
- package/augment-extensions/domain-rules/wordpress-plugin/module.json +53 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/activation-hooks.md +770 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/admin-interface.md +874 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/ajax-handlers.md +629 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/asset-management.md +559 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/context-providers.md +709 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/cron-jobs.md +736 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/database-management.md +1057 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/documentation-standards.md +463 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/frontend-functionality.md +478 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/gutenberg-blocks.md +818 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/internationalization.md +416 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/migration.md +667 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/performance-optimization.md +878 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-architecture.md +693 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-structure.md +352 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/rest-api.md +818 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/scaffolding-workflow.md +624 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/security-best-practices.md +866 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/testing-patterns.md +1165 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/testing.md +414 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/vscode-integration.md +751 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/woocommerce-integration.md +949 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/wordpress-org-submission.md +458 -0
- package/augment-extensions/examples/gutenberg-block-plugin/README.md +101 -0
- package/augment-extensions/examples/gutenberg-block-plugin/examples/testimonial-block.md +428 -0
- package/augment-extensions/examples/gutenberg-block-plugin/module.json +40 -0
- package/augment-extensions/examples/rest-api-plugin/README.md +98 -0
- package/augment-extensions/examples/rest-api-plugin/examples/task-manager-api.md +1299 -0
- package/augment-extensions/examples/rest-api-plugin/module.json +40 -0
- package/augment-extensions/examples/woocommerce-extension/README.md +98 -0
- package/augment-extensions/examples/woocommerce-extension/examples/product-customizer.md +763 -0
- package/augment-extensions/examples/woocommerce-extension/module.json +40 -0
- package/augment-extensions/workflows/beads/module.json +4 -3
- package/augment-extensions/workflows/database/README.md +195 -0
- package/augment-extensions/workflows/database/ai-prompt-testing.md +295 -0
- package/augment-extensions/workflows/database/examples/migration-example.md +498 -0
- package/augment-extensions/workflows/database/examples/optimization-example.md +496 -0
- package/augment-extensions/workflows/database/examples/schema-design-example.md +444 -0
- package/augment-extensions/workflows/database/module.json +42 -0
- package/augment-extensions/workflows/database/rules/data-migration.md +249 -0
- package/augment-extensions/workflows/database/rules/documentation-standards.md +339 -0
- package/augment-extensions/workflows/database/rules/migration-workflow.md +352 -0
- package/augment-extensions/workflows/database/rules/optimization-workflow.md +435 -0
- package/augment-extensions/workflows/database/rules/schema-design-workflow.md +535 -0
- package/augment-extensions/workflows/database/rules/testing-patterns.md +305 -0
- package/augment-extensions/workflows/database/rules/workflow.md +458 -0
- package/augment-extensions/workflows/openspec/module.json +4 -3
- package/augment-extensions/workflows/wordpress-plugin/README.md +232 -0
- package/augment-extensions/workflows/wordpress-plugin/ai-prompts.md +839 -0
- package/augment-extensions/workflows/wordpress-plugin/bead-decomposition-patterns.md +854 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/complete-plugin-example.md +540 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/custom-post-type-example.md +1083 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/feature-addition-workflow.md +669 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/plugin-creation-workflow.md +597 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/secure-form-handler-example.md +925 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/security-audit-workflow.md +752 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/wordpress-org-submission-workflow.md +773 -0
- package/augment-extensions/workflows/wordpress-plugin/module.json +49 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/best-practices.md +942 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/development-workflow.md +702 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/submission-workflow.md +728 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/testing-workflow.md +775 -0
- package/augment-extensions/writing-standards/screenplay/README.md +171 -0
- package/augment-extensions/writing-standards/screenplay/examples/aaa-hollywood-scene.fountain +164 -0
- package/augment-extensions/writing-standards/screenplay/module.json +124 -0
- package/augment-extensions/writing-standards/screenplay/rules/universal-formatting.md +339 -0
- package/cli/MODULES.md +302 -0
- package/cli/dist/cli.js +142 -9
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/catalog.d.ts +13 -0
- package/cli/dist/commands/catalog.d.ts.map +1 -0
- package/cli/dist/commands/catalog.js +104 -0
- package/cli/dist/commands/catalog.js.map +1 -0
- package/cli/dist/commands/gui.d.ts +6 -0
- package/cli/dist/commands/gui.d.ts.map +1 -0
- package/cli/dist/commands/gui.js +211 -0
- package/cli/dist/commands/gui.js.map +1 -0
- package/cli/dist/commands/init.d.ts.map +1 -1
- package/cli/dist/commands/init.js +12 -0
- package/cli/dist/commands/init.js.map +1 -1
- package/cli/dist/commands/install-rules.d.ts +14 -0
- package/cli/dist/commands/install-rules.d.ts.map +1 -0
- package/cli/dist/commands/install-rules.js +127 -0
- package/cli/dist/commands/install-rules.js.map +1 -0
- package/cli/dist/commands/link.d.ts.map +1 -1
- package/cli/dist/commands/link.js +9 -11
- package/cli/dist/commands/link.js.map +1 -1
- package/cli/dist/commands/list.d.ts.map +1 -1
- package/cli/dist/commands/list.js +11 -28
- package/cli/dist/commands/list.js.map +1 -1
- package/cli/dist/commands/mcp.d.ts +48 -0
- package/cli/dist/commands/mcp.d.ts.map +1 -0
- package/cli/dist/commands/mcp.js +229 -0
- package/cli/dist/commands/mcp.js.map +1 -0
- package/cli/dist/commands/self-remove.d.ts +7 -0
- package/cli/dist/commands/self-remove.d.ts.map +1 -0
- package/cli/dist/commands/self-remove.js +179 -0
- package/cli/dist/commands/self-remove.js.map +1 -0
- package/cli/dist/commands/show.d.ts.map +1 -1
- package/cli/dist/commands/show.js +42 -71
- package/cli/dist/commands/show.js.map +1 -1
- package/cli/dist/commands/skill.d.ts +67 -0
- package/cli/dist/commands/skill.d.ts.map +1 -0
- package/cli/dist/commands/skill.js +513 -0
- package/cli/dist/commands/skill.js.map +1 -0
- package/cli/dist/commands/unlink.d.ts +6 -0
- package/cli/dist/commands/unlink.d.ts.map +1 -0
- package/cli/dist/commands/unlink.js +115 -0
- package/cli/dist/commands/unlink.js.map +1 -0
- package/cli/dist/commands/validate.d.ts +6 -0
- package/cli/dist/commands/validate.d.ts.map +1 -0
- package/cli/dist/commands/validate.js +159 -0
- package/cli/dist/commands/validate.js.map +1 -0
- package/cli/dist/utils/catalog-sync.d.ts +22 -0
- package/cli/dist/utils/catalog-sync.d.ts.map +1 -0
- package/cli/dist/utils/catalog-sync.js +157 -0
- package/cli/dist/utils/catalog-sync.js.map +1 -0
- package/cli/dist/utils/character-count.d.ts +56 -0
- package/cli/dist/utils/character-count.d.ts.map +1 -0
- package/cli/dist/utils/character-count.js +190 -0
- package/cli/dist/utils/character-count.js.map +1 -0
- package/cli/dist/utils/documentation-validator.d.ts +18 -0
- package/cli/dist/utils/documentation-validator.d.ts.map +1 -0
- package/cli/dist/utils/documentation-validator.js +233 -0
- package/cli/dist/utils/documentation-validator.js.map +1 -0
- package/cli/dist/utils/install-rules.d.ts +32 -0
- package/cli/dist/utils/install-rules.d.ts.map +1 -0
- package/cli/dist/utils/install-rules.js +375 -0
- package/cli/dist/utils/install-rules.js.map +1 -0
- package/cli/dist/utils/mcp-integration.d.ts +70 -0
- package/cli/dist/utils/mcp-integration.d.ts.map +1 -0
- package/cli/dist/utils/mcp-integration.js +292 -0
- package/cli/dist/utils/mcp-integration.js.map +1 -0
- package/cli/dist/utils/module-system.d.ts +153 -0
- package/cli/dist/utils/module-system.d.ts.map +1 -0
- package/cli/dist/utils/module-system.js +528 -0
- package/cli/dist/utils/module-system.js.map +1 -0
- package/cli/dist/utils/modules-catalog.d.ts +33 -0
- package/cli/dist/utils/modules-catalog.d.ts.map +1 -0
- package/cli/dist/utils/modules-catalog.js +163 -0
- package/cli/dist/utils/modules-catalog.js.map +1 -0
- package/cli/dist/utils/rule-install-hooks.d.ts +19 -0
- package/cli/dist/utils/rule-install-hooks.d.ts.map +1 -0
- package/cli/dist/utils/rule-install-hooks.js +224 -0
- package/cli/dist/utils/rule-install-hooks.js.map +1 -0
- package/cli/dist/utils/skill-system.d.ts +95 -0
- package/cli/dist/utils/skill-system.d.ts.map +1 -0
- package/cli/dist/utils/skill-system.js +313 -0
- package/cli/dist/utils/skill-system.js.map +1 -0
- package/modules.md +534 -70
- package/package.json +12 -3
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
# Vector-Based MCP Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
**Vector-based MCP** uses semantic embeddings and vector databases to enable efficient retrieval of relevant context from large knowledge bases. This is the foundation of Retrieval-Augmented Generation (RAG).
|
|
6
|
+
|
|
7
|
+
**Key Challenge**: Balancing retrieval quality, latency, and cost while maintaining semantic relevance across diverse content types.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Embedding Model Selection
|
|
12
|
+
|
|
13
|
+
### Model Characteristics
|
|
14
|
+
|
|
15
|
+
Choose embedding models based on use case:
|
|
16
|
+
|
|
17
|
+
| Model | Dimensions | Max Tokens | Use Case |
|
|
18
|
+
|-------|-----------|------------|----------|
|
|
19
|
+
| text-embedding-3-small | 1536 | 8191 | General purpose, cost-effective |
|
|
20
|
+
| text-embedding-3-large | 3072 | 8191 | High accuracy, semantic search |
|
|
21
|
+
| voyage-2 | 1024 | 16000 | Long documents, code |
|
|
22
|
+
| cohere-embed-v3 | 1024 | 512 | Multilingual, classification |
|
|
23
|
+
|
|
24
|
+
**Best Practices**:
|
|
25
|
+
- Use smaller models for high-volume, cost-sensitive applications
|
|
26
|
+
- Use larger models for complex semantic matching
|
|
27
|
+
- Consider domain-specific models (e.g., code embeddings for technical docs)
|
|
28
|
+
- Benchmark on your specific data
|
|
29
|
+
|
|
30
|
+
### Embedding Generation
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from openai import OpenAI
|
|
34
|
+
|
|
35
|
+
def generate_embeddings(texts: list[str], model="text-embedding-3-small"):
|
|
36
|
+
"""Generate embeddings with batching"""
|
|
37
|
+
client = OpenAI()
|
|
38
|
+
|
|
39
|
+
# Batch for efficiency (max 2048 texts per request)
|
|
40
|
+
batch_size = 2048
|
|
41
|
+
embeddings = []
|
|
42
|
+
|
|
43
|
+
for i in range(0, len(texts), batch_size):
|
|
44
|
+
batch = texts[i:i + batch_size]
|
|
45
|
+
response = client.embeddings.create(
|
|
46
|
+
input=batch,
|
|
47
|
+
model=model
|
|
48
|
+
)
|
|
49
|
+
embeddings.extend([item.embedding for item in response.data])
|
|
50
|
+
|
|
51
|
+
return embeddings
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Best Practices**:
|
|
55
|
+
- Batch embedding requests for efficiency
|
|
56
|
+
- Cache embeddings to avoid recomputation
|
|
57
|
+
- Normalize embeddings for cosine similarity
|
|
58
|
+
- Handle rate limits and retries
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 2. Chunking and Indexing
|
|
63
|
+
|
|
64
|
+
### Chunking Strategies
|
|
65
|
+
|
|
66
|
+
**Fixed-size chunking**:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
def fixed_size_chunk(text: str, chunk_size=512, overlap=50):
|
|
70
|
+
"""Split text into fixed-size chunks with overlap"""
|
|
71
|
+
words = text.split()
|
|
72
|
+
chunks = []
|
|
73
|
+
|
|
74
|
+
for i in range(0, len(words), chunk_size - overlap):
|
|
75
|
+
chunk = ' '.join(words[i:i + chunk_size])
|
|
76
|
+
chunks.append(chunk)
|
|
77
|
+
|
|
78
|
+
return chunks
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Semantic chunking**:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
def semantic_chunk(text: str, model="text-embedding-3-small", threshold=0.5):
|
|
85
|
+
"""Split text at semantic boundaries"""
|
|
86
|
+
sentences = split_sentences(text)
|
|
87
|
+
embeddings = generate_embeddings(sentences, model)
|
|
88
|
+
|
|
89
|
+
chunks = []
|
|
90
|
+
current_chunk = [sentences[0]]
|
|
91
|
+
|
|
92
|
+
for i in range(1, len(sentences)):
|
|
93
|
+
similarity = cosine_similarity(embeddings[i-1], embeddings[i])
|
|
94
|
+
|
|
95
|
+
if similarity < threshold:
|
|
96
|
+
# Low similarity = semantic boundary
|
|
97
|
+
chunks.append(' '.join(current_chunk))
|
|
98
|
+
current_chunk = [sentences[i]]
|
|
99
|
+
else:
|
|
100
|
+
current_chunk.append(sentences[i])
|
|
101
|
+
|
|
102
|
+
chunks.append(' '.join(current_chunk))
|
|
103
|
+
return chunks
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Document-structure chunking**:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
def structure_chunk(markdown_text: str):
|
|
110
|
+
"""Chunk by document structure (headers, sections)"""
|
|
111
|
+
sections = []
|
|
112
|
+
current_section = []
|
|
113
|
+
current_header = None
|
|
114
|
+
|
|
115
|
+
for line in markdown_text.split('\n'):
|
|
116
|
+
if line.startswith('#'):
|
|
117
|
+
if current_section:
|
|
118
|
+
sections.append({
|
|
119
|
+
'header': current_header,
|
|
120
|
+
'content': '\n'.join(current_section)
|
|
121
|
+
})
|
|
122
|
+
current_header = line
|
|
123
|
+
current_section = []
|
|
124
|
+
else:
|
|
125
|
+
current_section.append(line)
|
|
126
|
+
|
|
127
|
+
if current_section:
|
|
128
|
+
sections.append({
|
|
129
|
+
'header': current_header,
|
|
130
|
+
'content': '\n'.join(current_section)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
return sections
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Best Practices**:
|
|
137
|
+
- Use semantic chunking for narrative content
|
|
138
|
+
- Use structure chunking for technical docs
|
|
139
|
+
- Maintain chunk overlap (10-20%) for context continuity
|
|
140
|
+
- Keep chunks between 256-1024 tokens
|
|
141
|
+
- Preserve metadata (source, section, page number)
|
|
142
|
+
|
|
143
|
+
### Indexing Patterns
|
|
144
|
+
|
|
145
|
+
**Hierarchical indexing**:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
def hierarchical_index(document: str):
|
|
149
|
+
"""Create multi-level index"""
|
|
150
|
+
# Level 1: Document summary
|
|
151
|
+
doc_summary = summarize(document, max_tokens=200)
|
|
152
|
+
doc_embedding = generate_embeddings([doc_summary])[0]
|
|
153
|
+
|
|
154
|
+
# Level 2: Section summaries
|
|
155
|
+
sections = structure_chunk(document)
|
|
156
|
+
section_embeddings = []
|
|
157
|
+
|
|
158
|
+
for section in sections:
|
|
159
|
+
summary = summarize(section['content'], max_tokens=100)
|
|
160
|
+
embedding = generate_embeddings([summary])[0]
|
|
161
|
+
section_embeddings.append({
|
|
162
|
+
'header': section['header'],
|
|
163
|
+
'summary': summary,
|
|
164
|
+
'embedding': embedding
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
# Level 3: Chunk embeddings
|
|
168
|
+
chunks = []
|
|
169
|
+
for section in sections:
|
|
170
|
+
section_chunks = fixed_size_chunk(section['content'])
|
|
171
|
+
chunk_embeddings = generate_embeddings(section_chunks)
|
|
172
|
+
|
|
173
|
+
for chunk, embedding in zip(section_chunks, chunk_embeddings):
|
|
174
|
+
chunks.append({
|
|
175
|
+
'text': chunk,
|
|
176
|
+
'section': section['header'],
|
|
177
|
+
'embedding': embedding
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
'document': {'summary': doc_summary, 'embedding': doc_embedding},
|
|
182
|
+
'sections': section_embeddings,
|
|
183
|
+
'chunks': chunks
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Best Practices**:
|
|
188
|
+
- Index at multiple granularities (document, section, chunk)
|
|
189
|
+
- Store metadata with embeddings
|
|
190
|
+
- Use hierarchical retrieval (coarse-to-fine)
|
|
191
|
+
- Update indexes incrementally
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 3. Retrieval Strategies
|
|
196
|
+
|
|
197
|
+
### Similarity Search
|
|
198
|
+
|
|
199
|
+
**Cosine similarity** (most common):
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
import numpy as np
|
|
203
|
+
|
|
204
|
+
def cosine_similarity(vec1, vec2):
|
|
205
|
+
"""Compute cosine similarity between two vectors"""
|
|
206
|
+
return np.dot(vec1, vec2) / (np.linalg.norm(vec1) * np.linalg.norm(vec2))
|
|
207
|
+
|
|
208
|
+
def retrieve_top_k(query_embedding, chunk_embeddings, k=5):
|
|
209
|
+
"""Retrieve top-k most similar chunks"""
|
|
210
|
+
similarities = [
|
|
211
|
+
cosine_similarity(query_embedding, chunk_emb)
|
|
212
|
+
for chunk_emb in chunk_embeddings
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
# Get top-k indices
|
|
216
|
+
top_k_indices = np.argsort(similarities)[-k:][::-1]
|
|
217
|
+
|
|
218
|
+
return [(idx, similarities[idx]) for idx in top_k_indices]
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Approximate Nearest Neighbor (ANN)**:
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
import faiss
|
|
225
|
+
|
|
226
|
+
def build_faiss_index(embeddings, dimension=1536):
|
|
227
|
+
"""Build FAISS index for fast similarity search"""
|
|
228
|
+
# Convert to numpy array
|
|
229
|
+
embeddings_np = np.array(embeddings).astype('float32')
|
|
230
|
+
|
|
231
|
+
# Create index (IVF with PQ for large datasets)
|
|
232
|
+
quantizer = faiss.IndexFlatL2(dimension)
|
|
233
|
+
index = faiss.IndexIVFPQ(quantizer, dimension, 100, 8, 8)
|
|
234
|
+
|
|
235
|
+
# Train and add vectors
|
|
236
|
+
index.train(embeddings_np)
|
|
237
|
+
index.add(embeddings_np)
|
|
238
|
+
|
|
239
|
+
return index
|
|
240
|
+
|
|
241
|
+
def search_faiss(index, query_embedding, k=5):
|
|
242
|
+
"""Search FAISS index"""
|
|
243
|
+
query_np = np.array([query_embedding]).astype('float32')
|
|
244
|
+
distances, indices = index.search(query_np, k)
|
|
245
|
+
return list(zip(indices[0], distances[0]))
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Best Practices**:
|
|
249
|
+
- Use exact search for small datasets (< 10k vectors)
|
|
250
|
+
- Use ANN (FAISS, Annoy) for large datasets (> 100k vectors)
|
|
251
|
+
- Tune ANN parameters (nprobe, nlist) for accuracy/speed tradeoff
|
|
252
|
+
- Monitor recall@k metrics
|
|
253
|
+
|
|
254
|
+
### Hybrid Search
|
|
255
|
+
|
|
256
|
+
Combine vector search with keyword search:
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
from rank_bm25 import BM25Okapi
|
|
260
|
+
|
|
261
|
+
def hybrid_search(query: str, chunks: list[str], chunk_embeddings, alpha=0.5, k=10):
|
|
262
|
+
"""Combine vector and keyword search"""
|
|
263
|
+
# Vector search
|
|
264
|
+
query_embedding = generate_embeddings([query])[0]
|
|
265
|
+
vector_scores = [
|
|
266
|
+
cosine_similarity(query_embedding, emb)
|
|
267
|
+
for emb in chunk_embeddings
|
|
268
|
+
]
|
|
269
|
+
|
|
270
|
+
# Keyword search (BM25)
|
|
271
|
+
tokenized_chunks = [chunk.split() for chunk in chunks]
|
|
272
|
+
bm25 = BM25Okapi(tokenized_chunks)
|
|
273
|
+
keyword_scores = bm25.get_scores(query.split())
|
|
274
|
+
|
|
275
|
+
# Normalize scores
|
|
276
|
+
vector_scores = normalize(vector_scores)
|
|
277
|
+
keyword_scores = normalize(keyword_scores)
|
|
278
|
+
|
|
279
|
+
# Combine scores
|
|
280
|
+
hybrid_scores = [
|
|
281
|
+
alpha * v + (1 - alpha) * k
|
|
282
|
+
for v, k in zip(vector_scores, keyword_scores)
|
|
283
|
+
]
|
|
284
|
+
|
|
285
|
+
# Get top-k
|
|
286
|
+
top_k_indices = np.argsort(hybrid_scores)[-k:][::-1]
|
|
287
|
+
return [(idx, hybrid_scores[idx]) for idx in top_k_indices]
|
|
288
|
+
|
|
289
|
+
def normalize(scores):
|
|
290
|
+
"""Min-max normalization"""
|
|
291
|
+
min_score = min(scores)
|
|
292
|
+
max_score = max(scores)
|
|
293
|
+
if max_score == min_score:
|
|
294
|
+
return [0.5] * len(scores)
|
|
295
|
+
return [(s - min_score) / (max_score - min_score) for s in scores]
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Best Practices**:
|
|
299
|
+
- Use hybrid search for keyword-heavy queries
|
|
300
|
+
- Tune alpha parameter (0.5 is a good default)
|
|
301
|
+
- Consider query type (semantic vs keyword)
|
|
302
|
+
- Use BM25 or Elasticsearch for keyword component
|
|
303
|
+
|
|
304
|
+
### Metadata Filtering
|
|
305
|
+
|
|
306
|
+
Filter by metadata before similarity search:
|
|
307
|
+
|
|
308
|
+
```python
|
|
309
|
+
def filtered_search(query_embedding, chunks, metadata, filters, k=5):
|
|
310
|
+
"""Search with metadata filters"""
|
|
311
|
+
# Apply filters
|
|
312
|
+
filtered_indices = []
|
|
313
|
+
for i, meta in enumerate(metadata):
|
|
314
|
+
if all(meta.get(key) == value for key, value in filters.items()):
|
|
315
|
+
filtered_indices.append(i)
|
|
316
|
+
|
|
317
|
+
# Search only filtered chunks
|
|
318
|
+
filtered_embeddings = [chunks[i]['embedding'] for i in filtered_indices]
|
|
319
|
+
similarities = [
|
|
320
|
+
cosine_similarity(query_embedding, emb)
|
|
321
|
+
for emb in filtered_embeddings
|
|
322
|
+
]
|
|
323
|
+
|
|
324
|
+
# Get top-k from filtered results
|
|
325
|
+
top_k_local = np.argsort(similarities)[-k:][::-1]
|
|
326
|
+
top_k_global = [filtered_indices[i] for i in top_k_local]
|
|
327
|
+
|
|
328
|
+
return [(idx, similarities[top_k_local[i]]) for i, idx in enumerate(top_k_global)]
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Best Practices**:
|
|
332
|
+
- Filter before similarity search for efficiency
|
|
333
|
+
- Index metadata for fast filtering
|
|
334
|
+
- Support multiple filter types (exact, range, contains)
|
|
335
|
+
- Combine filters with AND/OR logic
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## 4. Reranking Techniques
|
|
340
|
+
|
|
341
|
+
### Cross-Encoder Reranking
|
|
342
|
+
|
|
343
|
+
Use cross-encoders for final reranking:
|
|
344
|
+
|
|
345
|
+
```python
|
|
346
|
+
from sentence_transformers import CrossEncoder
|
|
347
|
+
|
|
348
|
+
def rerank_with_cross_encoder(query: str, candidates: list[str], top_k=5):
|
|
349
|
+
"""Rerank candidates using cross-encoder"""
|
|
350
|
+
model = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2')
|
|
351
|
+
|
|
352
|
+
# Score all query-candidate pairs
|
|
353
|
+
pairs = [[query, candidate] for candidate in candidates]
|
|
354
|
+
scores = model.predict(pairs)
|
|
355
|
+
|
|
356
|
+
# Get top-k
|
|
357
|
+
top_k_indices = np.argsort(scores)[-top_k:][::-1]
|
|
358
|
+
return [(idx, scores[idx]) for idx in top_k_indices]
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Best Practices**:
|
|
362
|
+
- Use bi-encoder for initial retrieval (fast)
|
|
363
|
+
- Use cross-encoder for reranking top-k (accurate)
|
|
364
|
+
- Typical pipeline: retrieve 50-100, rerank to 5-10
|
|
365
|
+
- Cache cross-encoder results when possible
|
|
366
|
+
|
|
367
|
+
### LLM-Based Reranking
|
|
368
|
+
|
|
369
|
+
Use LLM to judge relevance:
|
|
370
|
+
|
|
371
|
+
```python
|
|
372
|
+
def llm_rerank(query: str, candidates: list[str], top_k=5):
|
|
373
|
+
"""Rerank using LLM relevance scoring"""
|
|
374
|
+
prompt = f"""
|
|
375
|
+
Query: {query}
|
|
376
|
+
|
|
377
|
+
Rate the relevance of each passage to the query on a scale of 0-10.
|
|
378
|
+
|
|
379
|
+
Passages:
|
|
380
|
+
{chr(10).join(f"{i+1}. {c}" for i, c in enumerate(candidates))}
|
|
381
|
+
|
|
382
|
+
Return only a JSON array of scores: [score1, score2, ...]
|
|
383
|
+
"""
|
|
384
|
+
|
|
385
|
+
response = llm_call(prompt)
|
|
386
|
+
scores = json.loads(response)
|
|
387
|
+
|
|
388
|
+
# Get top-k
|
|
389
|
+
top_k_indices = np.argsort(scores)[-top_k:][::-1]
|
|
390
|
+
return [(idx, scores[idx]) for idx in top_k_indices]
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Best Practices**:
|
|
394
|
+
- Use for complex relevance judgments
|
|
395
|
+
- More expensive than cross-encoders
|
|
396
|
+
- Consider caching for repeated queries
|
|
397
|
+
- Validate JSON output
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 5. Vector Database Options
|
|
402
|
+
|
|
403
|
+
### Comparison
|
|
404
|
+
|
|
405
|
+
| Database | Type | Scale | Features |
|
|
406
|
+
|----------|------|-------|----------|
|
|
407
|
+
| **Pinecone** | Managed | Billions | Serverless, metadata filtering, hybrid search |
|
|
408
|
+
| **Weaviate** | Self-hosted/Managed | Millions | GraphQL, multi-tenancy, hybrid search |
|
|
409
|
+
| **Qdrant** | Self-hosted/Managed | Millions | Filtering, payload, quantization |
|
|
410
|
+
| **Chroma** | Embedded/Self-hosted | Millions | Simple API, local-first |
|
|
411
|
+
| **FAISS** | Library | Billions | Fast, in-memory, no persistence |
|
|
412
|
+
| **pgvector** | PostgreSQL extension | Millions | SQL integration, ACID |
|
|
413
|
+
|
|
414
|
+
### Pinecone Example
|
|
415
|
+
|
|
416
|
+
```python
|
|
417
|
+
import pinecone
|
|
418
|
+
|
|
419
|
+
# Initialize
|
|
420
|
+
pinecone.init(api_key="your-api-key", environment="us-west1-gcp")
|
|
421
|
+
|
|
422
|
+
# Create index
|
|
423
|
+
index = pinecone.Index("my-index")
|
|
424
|
+
|
|
425
|
+
# Upsert vectors
|
|
426
|
+
index.upsert(vectors=[
|
|
427
|
+
("id1", embedding1, {"source": "doc1.pdf", "page": 1}),
|
|
428
|
+
("id2", embedding2, {"source": "doc1.pdf", "page": 2}),
|
|
429
|
+
])
|
|
430
|
+
|
|
431
|
+
# Query with metadata filter
|
|
432
|
+
results = index.query(
|
|
433
|
+
vector=query_embedding,
|
|
434
|
+
top_k=5,
|
|
435
|
+
filter={"source": "doc1.pdf"}
|
|
436
|
+
)
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Weaviate Example
|
|
440
|
+
|
|
441
|
+
```python
|
|
442
|
+
import weaviate
|
|
443
|
+
|
|
444
|
+
# Initialize
|
|
445
|
+
client = weaviate.Client("http://localhost:8080")
|
|
446
|
+
|
|
447
|
+
# Create schema
|
|
448
|
+
schema = {
|
|
449
|
+
"class": "Document",
|
|
450
|
+
"vectorizer": "none",
|
|
451
|
+
"properties": [
|
|
452
|
+
{"name": "content", "dataType": ["text"]},
|
|
453
|
+
{"name": "source", "dataType": ["string"]},
|
|
454
|
+
]
|
|
455
|
+
}
|
|
456
|
+
client.schema.create_class(schema)
|
|
457
|
+
|
|
458
|
+
# Add objects
|
|
459
|
+
client.data_object.create(
|
|
460
|
+
data_object={"content": "...", "source": "doc1.pdf"},
|
|
461
|
+
class_name="Document",
|
|
462
|
+
vector=embedding
|
|
463
|
+
)
|
|
464
|
+
|
|
465
|
+
# Query
|
|
466
|
+
result = client.query.get("Document", ["content", "source"]) \
|
|
467
|
+
.with_near_vector({"vector": query_embedding}) \
|
|
468
|
+
.with_limit(5) \
|
|
469
|
+
.do()
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
**Best Practices**:
|
|
473
|
+
- Use managed services (Pinecone, Weaviate Cloud) for production
|
|
474
|
+
- Use embedded databases (Chroma, FAISS) for development
|
|
475
|
+
- Consider pgvector for existing PostgreSQL deployments
|
|
476
|
+
- Benchmark on your data and query patterns
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
## 6. Best Practices
|
|
481
|
+
|
|
482
|
+
### DO
|
|
483
|
+
|
|
484
|
+
✅ **Chunk appropriately**: 256-1024 tokens with 10-20% overlap
|
|
485
|
+
✅ **Use hierarchical indexing**: Document → Section → Chunk
|
|
486
|
+
✅ **Implement hybrid search**: Combine vector + keyword
|
|
487
|
+
✅ **Rerank top results**: Use cross-encoders or LLMs
|
|
488
|
+
✅ **Filter by metadata**: Reduce search space
|
|
489
|
+
✅ **Cache embeddings**: Avoid recomputation
|
|
490
|
+
✅ **Monitor retrieval quality**: Track precision@k, recall@k
|
|
491
|
+
✅ **Version embeddings**: Track model and version
|
|
492
|
+
|
|
493
|
+
### DON'T
|
|
494
|
+
|
|
495
|
+
❌ **Don't use fixed chunking for all content**: Adapt to structure
|
|
496
|
+
❌ **Don't skip reranking**: Initial retrieval is often noisy
|
|
497
|
+
❌ **Don't ignore metadata**: Filtering improves relevance
|
|
498
|
+
❌ **Don't use exact search for large datasets**: Use ANN
|
|
499
|
+
❌ **Don't forget to normalize**: Embeddings should be unit vectors
|
|
500
|
+
❌ **Don't over-retrieve**: More isn't always better (diminishing returns)
|
|
501
|
+
❌ **Don't ignore query type**: Semantic vs keyword queries differ
|
|
502
|
+
|
|
503
|
+
---
|
|
504
|
+
|
|
505
|
+
## 7. Common Pitfalls
|
|
506
|
+
|
|
507
|
+
### Chunking Too Large/Small
|
|
508
|
+
|
|
509
|
+
**Problem**: Large chunks dilute relevance; small chunks lose context
|
|
510
|
+
|
|
511
|
+
**Solution**:
|
|
512
|
+
- Target 256-1024 tokens per chunk
|
|
513
|
+
- Use semantic boundaries
|
|
514
|
+
- Maintain overlap for continuity
|
|
515
|
+
|
|
516
|
+
### Poor Retrieval Quality
|
|
517
|
+
|
|
518
|
+
**Problem**: Retrieved chunks not relevant to query
|
|
519
|
+
|
|
520
|
+
**Solution**:
|
|
521
|
+
- Use hybrid search (vector + keyword)
|
|
522
|
+
- Implement reranking
|
|
523
|
+
- Tune chunk size and overlap
|
|
524
|
+
- Use query expansion
|
|
525
|
+
|
|
526
|
+
### Slow Retrieval
|
|
527
|
+
|
|
528
|
+
**Problem**: High latency for similarity search
|
|
529
|
+
|
|
530
|
+
**Solution**:
|
|
531
|
+
- Use ANN algorithms (FAISS, Annoy)
|
|
532
|
+
- Implement caching
|
|
533
|
+
- Filter by metadata first
|
|
534
|
+
- Use hierarchical retrieval
|
|
535
|
+
|
|
536
|
+
### Embedding Drift
|
|
537
|
+
|
|
538
|
+
**Problem**: Embeddings become stale as content changes
|
|
539
|
+
|
|
540
|
+
**Solution**:
|
|
541
|
+
- Version embeddings with model version
|
|
542
|
+
- Implement incremental updates
|
|
543
|
+
- Monitor embedding quality over time
|
|
544
|
+
- Re-embed periodically
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
## 8. Integration with Token-Based MCP
|
|
549
|
+
|
|
550
|
+
Vector-based MCP complements token-based MCP:
|
|
551
|
+
|
|
552
|
+
```python
|
|
553
|
+
def rag_with_token_budget(query: str, token_budget=4096):
|
|
554
|
+
"""RAG with token budget management"""
|
|
555
|
+
# Retrieve candidates
|
|
556
|
+
query_embedding = generate_embeddings([query])[0]
|
|
557
|
+
candidates = retrieve_top_k(query_embedding, chunk_embeddings, k=20)
|
|
558
|
+
|
|
559
|
+
# Rerank
|
|
560
|
+
reranked = rerank_with_cross_encoder(query, [c[0] for c in candidates], top_k=10)
|
|
561
|
+
|
|
562
|
+
# Select chunks within token budget
|
|
563
|
+
selected_chunks = []
|
|
564
|
+
total_tokens = 0
|
|
565
|
+
|
|
566
|
+
for idx, score in reranked:
|
|
567
|
+
chunk = chunks[idx]
|
|
568
|
+
chunk_tokens = count_tokens(chunk)
|
|
569
|
+
|
|
570
|
+
if total_tokens + chunk_tokens <= token_budget:
|
|
571
|
+
selected_chunks.append(chunk)
|
|
572
|
+
total_tokens += chunk_tokens
|
|
573
|
+
else:
|
|
574
|
+
break
|
|
575
|
+
|
|
576
|
+
return selected_chunks, total_tokens
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
**Best Practices**:
|
|
580
|
+
- Always respect token budget
|
|
581
|
+
- Prioritize by relevance score
|
|
582
|
+
- Leave buffer for output
|
|
583
|
+
- Consider compression if needed
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
## Configuration Example
|
|
588
|
+
|
|
589
|
+
```json
|
|
590
|
+
{
|
|
591
|
+
"mcp": {
|
|
592
|
+
"type": "vector",
|
|
593
|
+
"embedding": {
|
|
594
|
+
"model": "text-embedding-3-small",
|
|
595
|
+
"dimensions": 1536,
|
|
596
|
+
"batchSize": 2048
|
|
597
|
+
},
|
|
598
|
+
"chunking": {
|
|
599
|
+
"strategy": "semantic",
|
|
600
|
+
"chunkSize": 512,
|
|
601
|
+
"overlap": 50,
|
|
602
|
+
"preserveStructure": true
|
|
603
|
+
},
|
|
604
|
+
"retrieval": {
|
|
605
|
+
"topK": 20,
|
|
606
|
+
"rerankTopK": 5,
|
|
607
|
+
"hybridAlpha": 0.5,
|
|
608
|
+
"useReranking": true,
|
|
609
|
+
"rerankModel": "cross-encoder/ms-marco-MiniLM-L-6-v2"
|
|
610
|
+
},
|
|
611
|
+
"vectorDatabase": {
|
|
612
|
+
"provider": "pinecone",
|
|
613
|
+
"index": "my-knowledge-base",
|
|
614
|
+
"namespace": "production"
|
|
615
|
+
},
|
|
616
|
+
"tokenBudget": {
|
|
617
|
+
"maxRetrievalTokens": 4096,
|
|
618
|
+
"outputBuffer": 2048
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
---
|
|
625
|
+
|