javi-forge 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.
- package/.gitignore.template +105 -0
- package/.releaserc +44 -0
- package/README.md +45 -0
- package/ai-config/.skillignore +15 -0
- package/ai-config/AUTO_INVOKE.md +300 -0
- package/ai-config/agents/_TEMPLATE.md +93 -0
- package/ai-config/agents/business/api-designer.md +1657 -0
- package/ai-config/agents/business/business-analyst.md +1331 -0
- package/ai-config/agents/business/product-strategist.md +206 -0
- package/ai-config/agents/business/project-manager.md +178 -0
- package/ai-config/agents/business/requirements-analyst.md +1277 -0
- package/ai-config/agents/business/technical-writer.md +1679 -0
- package/ai-config/agents/creative/ux-designer.md +205 -0
- package/ai-config/agents/data-ai/ai-engineer.md +487 -0
- package/ai-config/agents/data-ai/analytics-engineer.md +953 -0
- package/ai-config/agents/data-ai/data-engineer.md +173 -0
- package/ai-config/agents/data-ai/data-scientist.md +672 -0
- package/ai-config/agents/data-ai/mlops-engineer.md +814 -0
- package/ai-config/agents/data-ai/prompt-engineer.md +772 -0
- package/ai-config/agents/development/angular-expert.md +620 -0
- package/ai-config/agents/development/backend-architect.md +795 -0
- package/ai-config/agents/development/database-specialist.md +212 -0
- package/ai-config/agents/development/frontend-specialist.md +686 -0
- package/ai-config/agents/development/fullstack-engineer.md +668 -0
- package/ai-config/agents/development/golang-pro.md +338 -0
- package/ai-config/agents/development/java-enterprise.md +400 -0
- package/ai-config/agents/development/javascript-pro.md +422 -0
- package/ai-config/agents/development/nextjs-pro.md +474 -0
- package/ai-config/agents/development/python-pro.md +570 -0
- package/ai-config/agents/development/react-pro.md +487 -0
- package/ai-config/agents/development/rust-pro.md +246 -0
- package/ai-config/agents/development/spring-boot-4-expert.md +326 -0
- package/ai-config/agents/development/typescript-pro.md +336 -0
- package/ai-config/agents/development/vue-specialist.md +605 -0
- package/ai-config/agents/infrastructure/cloud-architect.md +472 -0
- package/ai-config/agents/infrastructure/deployment-manager.md +358 -0
- package/ai-config/agents/infrastructure/devops-engineer.md +455 -0
- package/ai-config/agents/infrastructure/incident-responder.md +519 -0
- package/ai-config/agents/infrastructure/kubernetes-expert.md +705 -0
- package/ai-config/agents/infrastructure/monitoring-specialist.md +674 -0
- package/ai-config/agents/infrastructure/performance-engineer.md +658 -0
- package/ai-config/agents/orchestrator.md +241 -0
- package/ai-config/agents/quality/accessibility-auditor.md +1204 -0
- package/ai-config/agents/quality/code-reviewer-compact.md +123 -0
- package/ai-config/agents/quality/code-reviewer.md +363 -0
- package/ai-config/agents/quality/dependency-manager.md +743 -0
- package/ai-config/agents/quality/e2e-test-specialist.md +1005 -0
- package/ai-config/agents/quality/performance-tester.md +1086 -0
- package/ai-config/agents/quality/security-auditor.md +133 -0
- package/ai-config/agents/quality/test-engineer.md +453 -0
- package/ai-config/agents/specialists/api-designer.md +87 -0
- package/ai-config/agents/specialists/backend-architect.md +73 -0
- package/ai-config/agents/specialists/code-reviewer.md +77 -0
- package/ai-config/agents/specialists/db-optimizer.md +75 -0
- package/ai-config/agents/specialists/devops-engineer.md +83 -0
- package/ai-config/agents/specialists/documentation-writer.md +78 -0
- package/ai-config/agents/specialists/frontend-developer.md +75 -0
- package/ai-config/agents/specialists/performance-analyst.md +82 -0
- package/ai-config/agents/specialists/refactor-specialist.md +74 -0
- package/ai-config/agents/specialists/security-auditor.md +74 -0
- package/ai-config/agents/specialists/test-engineer.md +81 -0
- package/ai-config/agents/specialists/ux-consultant.md +76 -0
- package/ai-config/agents/specialized/agent-generator.md +1190 -0
- package/ai-config/agents/specialized/blockchain-developer.md +149 -0
- package/ai-config/agents/specialized/code-migrator.md +892 -0
- package/ai-config/agents/specialized/context-manager.md +978 -0
- package/ai-config/agents/specialized/documentation-writer.md +1078 -0
- package/ai-config/agents/specialized/ecommerce-expert.md +1756 -0
- package/ai-config/agents/specialized/embedded-engineer.md +1714 -0
- package/ai-config/agents/specialized/error-detective.md +1034 -0
- package/ai-config/agents/specialized/fintech-specialist.md +1659 -0
- package/ai-config/agents/specialized/freelance-project-planner-v2.md +1988 -0
- package/ai-config/agents/specialized/freelance-project-planner-v3.md +2136 -0
- package/ai-config/agents/specialized/freelance-project-planner-v4.md +4503 -0
- package/ai-config/agents/specialized/freelance-project-planner.md +722 -0
- package/ai-config/agents/specialized/game-developer.md +1963 -0
- package/ai-config/agents/specialized/healthcare-dev.md +1620 -0
- package/ai-config/agents/specialized/mobile-developer.md +188 -0
- package/ai-config/agents/specialized/parallel-plan-executor.md +506 -0
- package/ai-config/agents/specialized/plan-executor.md +485 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/00-INDEX.md +485 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/01-CORE.md +3493 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/02-SELF-CORRECTION.md +778 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/03-PROGRESSIVE-SETUP.md +918 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/04-DEPLOYMENT.md +1537 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/05-TESTING.md +2633 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/06-OPERATIONS.md +5610 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/INSTALL.md +335 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/QUICK-REFERENCE.txt +215 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/README.md +260 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/START-HERE.md +379 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/WORKFLOW-DIAGRAM.md +355 -0
- package/ai-config/agents/specialized/solo-dev-planner-modular/solo-dev-planner.md +279 -0
- package/ai-config/agents/specialized/template-writer.md +347 -0
- package/ai-config/agents/specialized/test-runner.md +99 -0
- package/ai-config/agents/specialized/vibekanban-smart-worker.md +244 -0
- package/ai-config/agents/specialized/wave-executor.md +138 -0
- package/ai-config/agents/specialized/workflow-optimizer.md +1114 -0
- package/ai-config/commands/git/changelog.md +32 -0
- package/ai-config/commands/git/ci-local.md +70 -0
- package/ai-config/commands/git/commit.md +35 -0
- package/ai-config/commands/git/fix-issue.md +23 -0
- package/ai-config/commands/git/pr-create.md +42 -0
- package/ai-config/commands/git/pr-review.md +50 -0
- package/ai-config/commands/git/worktree.md +39 -0
- package/ai-config/commands/refactoring/cleanup.md +24 -0
- package/ai-config/commands/refactoring/dead-code.md +40 -0
- package/ai-config/commands/refactoring/extract.md +31 -0
- package/ai-config/commands/testing/e2e.md +30 -0
- package/ai-config/commands/testing/tdd.md +36 -0
- package/ai-config/commands/testing/test-coverage.md +30 -0
- package/ai-config/commands/testing/test-fix.md +24 -0
- package/ai-config/commands/workflow/generate-agents-md.md +85 -0
- package/ai-config/commands/workflow/planning.md +47 -0
- package/ai-config/commands/workflows/compound.md +89 -0
- package/ai-config/commands/workflows/plan.md +77 -0
- package/ai-config/commands/workflows/review.md +78 -0
- package/ai-config/commands/workflows/work.md +75 -0
- package/ai-config/config.yaml +18 -0
- package/ai-config/hooks/_TEMPLATE.md +96 -0
- package/ai-config/hooks/block-dangerous-commands.md +75 -0
- package/ai-config/hooks/commit-guard.md +90 -0
- package/ai-config/hooks/context-loader.md +73 -0
- package/ai-config/hooks/improve-prompt.md +91 -0
- package/ai-config/hooks/learning-log.md +72 -0
- package/ai-config/hooks/model-router.md +86 -0
- package/ai-config/hooks/secret-scanner.md +64 -0
- package/ai-config/hooks/skill-validator.md +102 -0
- package/ai-config/hooks/task-artifact.md +114 -0
- package/ai-config/hooks/validate-workflow.md +100 -0
- package/ai-config/prompts/base.md +71 -0
- package/ai-config/prompts/modes/debug.md +34 -0
- package/ai-config/prompts/modes/deploy.md +40 -0
- package/ai-config/prompts/modes/research.md +32 -0
- package/ai-config/prompts/modes/review.md +33 -0
- package/ai-config/prompts/review-policy.md +79 -0
- package/ai-config/skills/_TEMPLATE.md +157 -0
- package/ai-config/skills/backend/api-gateway/SKILL.md +254 -0
- package/ai-config/skills/backend/bff-concepts/SKILL.md +239 -0
- package/ai-config/skills/backend/bff-spring/SKILL.md +364 -0
- package/ai-config/skills/backend/chi-router/SKILL.md +396 -0
- package/ai-config/skills/backend/error-handling/SKILL.md +255 -0
- package/ai-config/skills/backend/exceptions-spring/SKILL.md +323 -0
- package/ai-config/skills/backend/fastapi/SKILL.md +302 -0
- package/ai-config/skills/backend/gateway-spring/SKILL.md +390 -0
- package/ai-config/skills/backend/go-backend/SKILL.md +457 -0
- package/ai-config/skills/backend/gradle-multimodule/SKILL.md +274 -0
- package/ai-config/skills/backend/graphql-concepts/SKILL.md +352 -0
- package/ai-config/skills/backend/graphql-spring/SKILL.md +398 -0
- package/ai-config/skills/backend/grpc-concepts/SKILL.md +283 -0
- package/ai-config/skills/backend/grpc-spring/SKILL.md +445 -0
- package/ai-config/skills/backend/jwt-auth/SKILL.md +412 -0
- package/ai-config/skills/backend/notifications-concepts/SKILL.md +259 -0
- package/ai-config/skills/backend/recommendations-concepts/SKILL.md +261 -0
- package/ai-config/skills/backend/search-concepts/SKILL.md +263 -0
- package/ai-config/skills/backend/search-spring/SKILL.md +375 -0
- package/ai-config/skills/backend/spring-boot-4/SKILL.md +172 -0
- package/ai-config/skills/backend/websockets/SKILL.md +532 -0
- package/ai-config/skills/data-ai/ai-ml/SKILL.md +423 -0
- package/ai-config/skills/data-ai/analytics-concepts/SKILL.md +195 -0
- package/ai-config/skills/data-ai/analytics-spring/SKILL.md +340 -0
- package/ai-config/skills/data-ai/duckdb-analytics/SKILL.md +440 -0
- package/ai-config/skills/data-ai/langchain/SKILL.md +238 -0
- package/ai-config/skills/data-ai/mlflow/SKILL.md +302 -0
- package/ai-config/skills/data-ai/onnx-inference/SKILL.md +290 -0
- package/ai-config/skills/data-ai/powerbi/SKILL.md +352 -0
- package/ai-config/skills/data-ai/pytorch/SKILL.md +274 -0
- package/ai-config/skills/data-ai/scikit-learn/SKILL.md +321 -0
- package/ai-config/skills/data-ai/vector-db/SKILL.md +301 -0
- package/ai-config/skills/database/graph-databases/SKILL.md +218 -0
- package/ai-config/skills/database/graph-spring/SKILL.md +361 -0
- package/ai-config/skills/database/pgx-postgres/SKILL.md +512 -0
- package/ai-config/skills/database/redis-cache/SKILL.md +343 -0
- package/ai-config/skills/database/sqlite-embedded/SKILL.md +388 -0
- package/ai-config/skills/database/timescaledb/SKILL.md +320 -0
- package/ai-config/skills/docs/api-documentation/SKILL.md +293 -0
- package/ai-config/skills/docs/docs-spring/SKILL.md +377 -0
- package/ai-config/skills/docs/mustache-templates/SKILL.md +190 -0
- package/ai-config/skills/docs/technical-docs/SKILL.md +447 -0
- package/ai-config/skills/frontend/astro-ssr/SKILL.md +441 -0
- package/ai-config/skills/frontend/frontend-design/SKILL.md +54 -0
- package/ai-config/skills/frontend/frontend-web/SKILL.md +368 -0
- package/ai-config/skills/frontend/mantine-ui/SKILL.md +396 -0
- package/ai-config/skills/frontend/tanstack-query/SKILL.md +439 -0
- package/ai-config/skills/frontend/zod-validation/SKILL.md +417 -0
- package/ai-config/skills/frontend/zustand-state/SKILL.md +350 -0
- package/ai-config/skills/infrastructure/chaos-engineering/SKILL.md +244 -0
- package/ai-config/skills/infrastructure/chaos-spring/SKILL.md +378 -0
- package/ai-config/skills/infrastructure/devops-infra/SKILL.md +435 -0
- package/ai-config/skills/infrastructure/docker-containers/SKILL.md +420 -0
- package/ai-config/skills/infrastructure/kubernetes/SKILL.md +456 -0
- package/ai-config/skills/infrastructure/opentelemetry/SKILL.md +546 -0
- package/ai-config/skills/infrastructure/traefik-proxy/SKILL.md +474 -0
- package/ai-config/skills/infrastructure/woodpecker-ci/SKILL.md +315 -0
- package/ai-config/skills/mobile/ionic-capacitor/SKILL.md +504 -0
- package/ai-config/skills/mobile/mobile-ionic/SKILL.md +448 -0
- package/ai-config/skills/prompt-improver/SKILL.md +125 -0
- package/ai-config/skills/quality/ghagga-review/SKILL.md +216 -0
- package/ai-config/skills/references/hooks-patterns/SKILL.md +238 -0
- package/ai-config/skills/references/mcp-servers/SKILL.md +275 -0
- package/ai-config/skills/references/plugins-reference/SKILL.md +110 -0
- package/ai-config/skills/references/skills-reference/SKILL.md +420 -0
- package/ai-config/skills/references/subagent-templates/SKILL.md +193 -0
- package/ai-config/skills/systems-iot/modbus-protocol/SKILL.md +410 -0
- package/ai-config/skills/systems-iot/mqtt-rumqttc/SKILL.md +408 -0
- package/ai-config/skills/systems-iot/rust-systems/SKILL.md +386 -0
- package/ai-config/skills/systems-iot/tokio-async/SKILL.md +324 -0
- package/ai-config/skills/testing/playwright-e2e/SKILL.md +289 -0
- package/ai-config/skills/testing/testcontainers/SKILL.md +299 -0
- package/ai-config/skills/testing/vitest-testing/SKILL.md +381 -0
- package/ai-config/skills/workflow/ci-local-guide/SKILL.md +118 -0
- package/ai-config/skills/workflow/claude-automation-recommender/SKILL.md +299 -0
- package/ai-config/skills/workflow/claude-md-improver/SKILL.md +158 -0
- package/ai-config/skills/workflow/finishing-a-development-branch/SKILL.md +117 -0
- package/ai-config/skills/workflow/git-github/SKILL.md +334 -0
- package/ai-config/skills/workflow/git-github/references/examples.md +160 -0
- package/ai-config/skills/workflow/git-workflow/SKILL.md +214 -0
- package/ai-config/skills/workflow/ide-plugins/SKILL.md +277 -0
- package/ai-config/skills/workflow/ide-plugins-intellij/SKILL.md +401 -0
- package/ai-config/skills/workflow/obsidian-brain-workflow/SKILL.md +199 -0
- package/ai-config/skills/workflow/using-git-worktrees/SKILL.md +100 -0
- package/ai-config/skills/workflow/verification-before-completion/SKILL.md +73 -0
- package/ai-config/skills/workflow/wave-workflow/SKILL.md +178 -0
- package/ci-local/README.md +170 -0
- package/ci-local/ci-local.sh +297 -0
- package/ci-local/hooks/commit-msg +74 -0
- package/ci-local/hooks/pre-commit +162 -0
- package/ci-local/hooks/pre-push +41 -0
- package/ci-local/install.sh +49 -0
- package/ci-local/semgrep.yml +214 -0
- package/dist/commands/analyze.d.ts +9 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +55 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/analyze.test.d.ts +2 -0
- package/dist/commands/analyze.test.d.ts.map +1 -0
- package/dist/commands/analyze.test.js +145 -0
- package/dist/commands/analyze.test.js.map +1 -0
- package/dist/commands/doctor.d.ts +7 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +158 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/doctor.test.d.ts +2 -0
- package/dist/commands/doctor.test.d.ts.map +1 -0
- package/dist/commands/doctor.test.js +200 -0
- package/dist/commands/doctor.test.js.map +1 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +283 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/init.test.d.ts +2 -0
- package/dist/commands/init.test.d.ts.map +1 -0
- package/dist/commands/init.test.js +271 -0
- package/dist/commands/init.test.js.map +1 -0
- package/dist/commands/sync.d.ts +8 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +201 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +57 -0
- package/dist/constants.js.map +1 -0
- package/dist/e2e/aggressive.e2e.test.d.ts +2 -0
- package/dist/e2e/aggressive.e2e.test.d.ts.map +1 -0
- package/dist/e2e/aggressive.e2e.test.js +350 -0
- package/dist/e2e/aggressive.e2e.test.js.map +1 -0
- package/dist/e2e/commands.e2e.test.d.ts +2 -0
- package/dist/e2e/commands.e2e.test.d.ts.map +1 -0
- package/dist/e2e/commands.e2e.test.js +213 -0
- package/dist/e2e/commands.e2e.test.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/common.d.ts +17 -0
- package/dist/lib/common.d.ts.map +1 -0
- package/dist/lib/common.js +111 -0
- package/dist/lib/common.js.map +1 -0
- package/dist/lib/common.test.d.ts +2 -0
- package/dist/lib/common.test.d.ts.map +1 -0
- package/dist/lib/common.test.js +316 -0
- package/dist/lib/common.test.js.map +1 -0
- package/dist/lib/frontmatter.d.ts +18 -0
- package/dist/lib/frontmatter.d.ts.map +1 -0
- package/dist/lib/frontmatter.js +61 -0
- package/dist/lib/frontmatter.js.map +1 -0
- package/dist/lib/frontmatter.test.d.ts +2 -0
- package/dist/lib/frontmatter.test.d.ts.map +1 -0
- package/dist/lib/frontmatter.test.js +257 -0
- package/dist/lib/frontmatter.test.js.map +1 -0
- package/dist/lib/template.d.ts +24 -0
- package/dist/lib/template.d.ts.map +1 -0
- package/dist/lib/template.js +78 -0
- package/dist/lib/template.js.map +1 -0
- package/dist/lib/template.test.d.ts +2 -0
- package/dist/lib/template.test.d.ts.map +1 -0
- package/dist/lib/template.test.js +201 -0
- package/dist/lib/template.test.js.map +1 -0
- package/dist/types/index.d.ts +48 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/AnalyzeUI.d.ts +7 -0
- package/dist/ui/AnalyzeUI.d.ts.map +1 -0
- package/dist/ui/AnalyzeUI.js +100 -0
- package/dist/ui/AnalyzeUI.js.map +1 -0
- package/dist/ui/App.d.ts +13 -0
- package/dist/ui/App.d.ts.map +1 -0
- package/dist/ui/App.js +100 -0
- package/dist/ui/App.js.map +1 -0
- package/dist/ui/CIContext.d.ts +9 -0
- package/dist/ui/CIContext.d.ts.map +1 -0
- package/dist/ui/CIContext.js +9 -0
- package/dist/ui/CIContext.js.map +1 -0
- package/dist/ui/CISelector.d.ts +8 -0
- package/dist/ui/CISelector.d.ts.map +1 -0
- package/dist/ui/CISelector.js +45 -0
- package/dist/ui/CISelector.js.map +1 -0
- package/dist/ui/Doctor.d.ts +3 -0
- package/dist/ui/Doctor.d.ts.map +1 -0
- package/dist/ui/Doctor.js +89 -0
- package/dist/ui/Doctor.js.map +1 -0
- package/dist/ui/Header.d.ts +8 -0
- package/dist/ui/Header.d.ts.map +1 -0
- package/dist/ui/Header.js +30 -0
- package/dist/ui/Header.js.map +1 -0
- package/dist/ui/MemorySelector.d.ts +8 -0
- package/dist/ui/MemorySelector.d.ts.map +1 -0
- package/dist/ui/MemorySelector.js +46 -0
- package/dist/ui/MemorySelector.js.map +1 -0
- package/dist/ui/NameInput.d.ts +8 -0
- package/dist/ui/NameInput.d.ts.map +1 -0
- package/dist/ui/NameInput.js +69 -0
- package/dist/ui/NameInput.js.map +1 -0
- package/dist/ui/OptionSelector.d.ts +12 -0
- package/dist/ui/OptionSelector.d.ts.map +1 -0
- package/dist/ui/OptionSelector.js +69 -0
- package/dist/ui/OptionSelector.js.map +1 -0
- package/dist/ui/Progress.d.ts +11 -0
- package/dist/ui/Progress.d.ts.map +1 -0
- package/dist/ui/Progress.js +58 -0
- package/dist/ui/Progress.js.map +1 -0
- package/dist/ui/StackSelector.d.ts +9 -0
- package/dist/ui/StackSelector.d.ts.map +1 -0
- package/dist/ui/StackSelector.js +65 -0
- package/dist/ui/StackSelector.js.map +1 -0
- package/dist/ui/Summary.d.ts +12 -0
- package/dist/ui/Summary.d.ts.map +1 -0
- package/dist/ui/Summary.js +114 -0
- package/dist/ui/Summary.js.map +1 -0
- package/dist/ui/SyncUI.d.ts +10 -0
- package/dist/ui/SyncUI.d.ts.map +1 -0
- package/dist/ui/SyncUI.js +64 -0
- package/dist/ui/SyncUI.js.map +1 -0
- package/dist/ui/Welcome.d.ts +7 -0
- package/dist/ui/Welcome.d.ts.map +1 -0
- package/dist/ui/Welcome.js +45 -0
- package/dist/ui/Welcome.js.map +1 -0
- package/dist/ui/theme.d.ts +10 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js +9 -0
- package/dist/ui/theme.js.map +1 -0
- package/modules/engram/.gitignore-snippet.txt +6 -0
- package/modules/engram/.mcp-config-snippet.json +11 -0
- package/modules/engram/README.md +146 -0
- package/modules/engram/install-engram.sh +216 -0
- package/modules/ghagga/.env.example +43 -0
- package/modules/ghagga/README.md +153 -0
- package/modules/ghagga/docker-compose.yml +80 -0
- package/modules/ghagga/setup-ghagga.sh +139 -0
- package/modules/memory-simple/.project/NOTES.md +22 -0
- package/modules/memory-simple/README.md +23 -0
- package/modules/obsidian-brain/.obsidian/app.json +23 -0
- package/modules/obsidian-brain/.obsidian/appearance.json +5 -0
- package/modules/obsidian-brain/.obsidian/bookmarks.json +34 -0
- package/modules/obsidian-brain/.obsidian/community-plugins.json +1 -0
- package/modules/obsidian-brain/.obsidian/core-plugins-migration.json +21 -0
- package/modules/obsidian-brain/.obsidian/core-plugins.json +18 -0
- package/modules/obsidian-brain/.obsidian/daily-notes.json +5 -0
- package/modules/obsidian-brain/.obsidian/graph.json +37 -0
- package/modules/obsidian-brain/.obsidian/hotkeys.json +14 -0
- package/modules/obsidian-brain/.obsidian/plugins/dataview/data.json +25 -0
- package/modules/obsidian-brain/.obsidian/plugins/obsidian-kanban/data.json +29 -0
- package/modules/obsidian-brain/.obsidian/plugins/templater-obsidian/data.json +18 -0
- package/modules/obsidian-brain/.obsidian/snippets/project-memory.css +71 -0
- package/modules/obsidian-brain/.obsidian-gitignore-snippet.txt +8 -0
- package/modules/obsidian-brain/.project/Attachments/.gitkeep +0 -0
- package/modules/obsidian-brain/.project/Memory/BLOCKERS.md +78 -0
- package/modules/obsidian-brain/.project/Memory/CONTEXT.md +102 -0
- package/modules/obsidian-brain/.project/Memory/DASHBOARD.md +73 -0
- package/modules/obsidian-brain/.project/Memory/DECISIONS.md +87 -0
- package/modules/obsidian-brain/.project/Memory/KANBAN.md +15 -0
- package/modules/obsidian-brain/.project/Memory/README.md +61 -0
- package/modules/obsidian-brain/.project/Memory/WAVES.md +78 -0
- package/modules/obsidian-brain/.project/Sessions/TEMPLATE.md +99 -0
- package/modules/obsidian-brain/.project/Templates/ADR.md +33 -0
- package/modules/obsidian-brain/.project/Templates/Blocker.md +21 -0
- package/modules/obsidian-brain/.project/Templates/Session.md +88 -0
- package/modules/obsidian-brain/README.md +268 -0
- package/modules/obsidian-brain/new-wave.sh +182 -0
- package/package.json +51 -0
- package/schemas/agent.schema.json +34 -0
- package/schemas/ai-config.schema.json +28 -0
- package/schemas/skill.schema.json +44 -0
- package/src/commands/analyze.test.ts +145 -0
- package/src/commands/analyze.ts +69 -0
- package/src/commands/doctor.test.ts +208 -0
- package/src/commands/doctor.ts +163 -0
- package/src/commands/init.test.ts +298 -0
- package/src/commands/init.ts +285 -0
- package/src/constants.ts +69 -0
- package/src/e2e/aggressive.e2e.test.ts +557 -0
- package/src/e2e/commands.e2e.test.ts +298 -0
- package/src/index.tsx +106 -0
- package/src/lib/common.test.ts +318 -0
- package/src/lib/common.ts +127 -0
- package/src/lib/frontmatter.test.ts +291 -0
- package/src/lib/frontmatter.ts +77 -0
- package/src/lib/template.test.ts +226 -0
- package/src/lib/template.ts +99 -0
- package/src/types/index.ts +53 -0
- package/src/ui/AnalyzeUI.tsx +133 -0
- package/src/ui/App.tsx +175 -0
- package/src/ui/CIContext.tsx +25 -0
- package/src/ui/CISelector.tsx +72 -0
- package/src/ui/Doctor.tsx +122 -0
- package/src/ui/Header.tsx +48 -0
- package/src/ui/MemorySelector.tsx +73 -0
- package/src/ui/NameInput.tsx +82 -0
- package/src/ui/OptionSelector.tsx +100 -0
- package/src/ui/Progress.tsx +88 -0
- package/src/ui/StackSelector.tsx +101 -0
- package/src/ui/Summary.tsx +134 -0
- package/src/ui/Welcome.tsx +54 -0
- package/src/ui/theme.ts +10 -0
- package/stryker.config.json +19 -0
- package/tasks/_TEMPLATE/files-edited.md +3 -0
- package/tasks/_TEMPLATE/plan.md +3 -0
- package/tasks/_TEMPLATE/research.md +3 -0
- package/tasks/_TEMPLATE/verification.md +5 -0
- package/templates/common/dependabot/cargo.yml +11 -0
- package/templates/common/dependabot/github-actions.yml +16 -0
- package/templates/common/dependabot/gomod.yml +15 -0
- package/templates/common/dependabot/gradle.yml +15 -0
- package/templates/common/dependabot/header.yml +3 -0
- package/templates/common/dependabot/maven.yml +15 -0
- package/templates/common/dependabot/npm.yml +20 -0
- package/templates/common/dependabot/pip.yml +11 -0
- package/templates/dependabot.yml +162 -0
- package/templates/github/ci-go.yml +41 -0
- package/templates/github/ci-java.yml +45 -0
- package/templates/github/ci-monorepo.yml +150 -0
- package/templates/github/ci-node.yml +42 -0
- package/templates/github/ci-python.yml +42 -0
- package/templates/github/ci-rust.yml +42 -0
- package/templates/github/dependabot-automerge.yml +40 -0
- package/templates/gitlab/gitlab-ci-go.yml +88 -0
- package/templates/gitlab/gitlab-ci-java.yml +79 -0
- package/templates/gitlab/gitlab-ci-monorepo.yml +126 -0
- package/templates/gitlab/gitlab-ci-node.yml +63 -0
- package/templates/gitlab/gitlab-ci-python.yml +147 -0
- package/templates/gitlab/gitlab-ci-rust.yml +67 -0
- package/templates/global/claude-settings.json +98 -0
- package/templates/global/codex-config.toml +8 -0
- package/templates/global/copilot-instructions/base-rules.instructions.md +13 -0
- package/templates/global/copilot-instructions/sdd-orchestrator.instructions.md +37 -0
- package/templates/global/gemini-commands/cleanup.toml +20 -0
- package/templates/global/gemini-commands/commit.toml +15 -0
- package/templates/global/gemini-commands/dead-code.toml +22 -0
- package/templates/global/gemini-commands/plan.toml +30 -0
- package/templates/global/gemini-commands/review.toml +17 -0
- package/templates/global/gemini-commands/sdd-apply.toml +22 -0
- package/templates/global/gemini-commands/sdd-ff.toml +14 -0
- package/templates/global/gemini-commands/sdd-new.toml +21 -0
- package/templates/global/gemini-commands/sdd-verify.toml +21 -0
- package/templates/global/gemini-commands/tdd.toml +26 -0
- package/templates/global/gemini-settings.json +8 -0
- package/templates/global/opencode-config.json +44 -0
- package/templates/global/sdd-instructions.md +47 -0
- package/templates/global/sdd-orchestrator-claude.md +46 -0
- package/templates/global/sdd-orchestrator-copilot.md +34 -0
- package/templates/renovate.json +69 -0
- package/templates/woodpecker/monorepo/backend.yml +34 -0
- package/templates/woodpecker/monorepo/frontend.yml +34 -0
- package/templates/woodpecker/monorepo/summary.yml +25 -0
- package/templates/woodpecker/woodpecker-go.yml +51 -0
- package/templates/woodpecker/woodpecker-java.yml +67 -0
- package/templates/woodpecker/woodpecker-node.yml +47 -0
- package/templates/woodpecker/woodpecker-python.yml +108 -0
- package/templates/woodpecker/woodpecker-rust.yml +57 -0
- package/tsconfig.json +19 -0
- package/vitest.config.ts +16 -0
- package/workflows/reusable-build-go.yml +111 -0
- package/workflows/reusable-build-java.yml +120 -0
- package/workflows/reusable-build-node.yml +145 -0
- package/workflows/reusable-build-python.yml +159 -0
- package/workflows/reusable-build-rust.yml +135 -0
- package/workflows/reusable-docker.yml +120 -0
- package/workflows/reusable-ghagga-review.yml +165 -0
- package/workflows/reusable-release.yml +91 -0
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prompt-engineer
|
|
3
|
+
description: Prompt engineering specialist focusing on LLM optimization, RAG systems, fine-tuning, and advanced AI application development
|
|
4
|
+
trigger: >
|
|
5
|
+
prompt engineering, LLM optimization, RAG, retrieval augmented generation,
|
|
6
|
+
fine-tuning, chain-of-thought, few-shot learning, LangChain, vector database,
|
|
7
|
+
embeddings, prompt template, model evaluation, AI safety
|
|
8
|
+
category: data-ai
|
|
9
|
+
color: cyan
|
|
10
|
+
tools: Write, Read, MultiEdit, Bash, Grep, Glob
|
|
11
|
+
config:
|
|
12
|
+
model: opus
|
|
13
|
+
metadata:
|
|
14
|
+
version: "2.0"
|
|
15
|
+
updated: "2026-02"
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
You are a prompt engineer with expertise in large language model optimization, retrieval-augmented generation systems, fine-tuning, and advanced AI application development.
|
|
19
|
+
|
|
20
|
+
## Core Expertise
|
|
21
|
+
- Prompt design and optimization techniques
|
|
22
|
+
- Retrieval-Augmented Generation (RAG) systems
|
|
23
|
+
- Fine-tuning and transfer learning for LLMs
|
|
24
|
+
- Chain-of-thought and few-shot learning
|
|
25
|
+
- Model evaluation and benchmarking
|
|
26
|
+
- LangChain and LlamaIndex framework development
|
|
27
|
+
- Vector databases and semantic search
|
|
28
|
+
- AI safety and alignment considerations
|
|
29
|
+
|
|
30
|
+
## Technical Stack
|
|
31
|
+
- **LLM Frameworks**: LangChain, LlamaIndex, Haystack, Semantic Kernel
|
|
32
|
+
- **Models**: OpenAI GPT, Anthropic Claude, Google PaLM, Llama 2/3, Mistral
|
|
33
|
+
- **Vector Databases**: Pinecone, Weaviate, Chroma, FAISS, Qdrant
|
|
34
|
+
- **Fine-tuning**: Hugging Face Transformers, LoRA, QLoRA, PEFT
|
|
35
|
+
- **Evaluation**: BLEU, ROUGE, BERTScore, Human evaluation frameworks
|
|
36
|
+
- **Deployment**: Ollama, vLLM, TensorRT-LLM, Triton Inference Server
|
|
37
|
+
|
|
38
|
+
## Advanced Prompt Engineering Techniques
|
|
39
|
+
```python
|
|
40
|
+
import openai
|
|
41
|
+
from typing import List, Dict, Any
|
|
42
|
+
import json
|
|
43
|
+
import re
|
|
44
|
+
from dataclasses import dataclass
|
|
45
|
+
|
|
46
|
+
@dataclass
|
|
47
|
+
class PromptTemplate:
|
|
48
|
+
"""Structured prompt template with metadata"""
|
|
49
|
+
name: str
|
|
50
|
+
template: str
|
|
51
|
+
variables: List[str]
|
|
52
|
+
category: str
|
|
53
|
+
description: str
|
|
54
|
+
examples: List[Dict[str, Any]]
|
|
55
|
+
|
|
56
|
+
class PromptEngineer:
|
|
57
|
+
def __init__(self, model_name="gpt-4", temperature=0.1):
|
|
58
|
+
self.model_name = model_name
|
|
59
|
+
self.temperature = temperature
|
|
60
|
+
self.prompt_templates = {}
|
|
61
|
+
|
|
62
|
+
def create_chain_of_thought_prompt(self, task_description: str, examples: List[Dict]) -> str:
|
|
63
|
+
"""Create a chain-of-thought prompt with examples"""
|
|
64
|
+
cot_template = f"""
|
|
65
|
+
Task: {task_description}
|
|
66
|
+
|
|
67
|
+
I'll solve this step by step, showing my reasoning process.
|
|
68
|
+
|
|
69
|
+
Examples:
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
for i, example in enumerate(examples, 1):
|
|
73
|
+
cot_template += f"\nExample {i}:\n"
|
|
74
|
+
cot_template += f"Input: {example['input']}\n"
|
|
75
|
+
cot_template += f"Reasoning: {example['reasoning']}\n"
|
|
76
|
+
cot_template += f"Output: {example['output']}\n"
|
|
77
|
+
|
|
78
|
+
cot_template += "\nNow, let me solve the new problem:\nInput: {input}\nReasoning:"
|
|
79
|
+
|
|
80
|
+
return cot_template
|
|
81
|
+
|
|
82
|
+
def create_few_shot_prompt(self, task: str, examples: List[Dict], n_shots: int = 3) -> str:
|
|
83
|
+
"""Create few-shot learning prompt"""
|
|
84
|
+
few_shot_template = f"Task: {task}\n\n"
|
|
85
|
+
|
|
86
|
+
selected_examples = examples[:n_shots]
|
|
87
|
+
for i, example in enumerate(selected_examples, 1):
|
|
88
|
+
few_shot_template += f"Example {i}:\n"
|
|
89
|
+
few_shot_template += f"Input: {example['input']}\n"
|
|
90
|
+
few_shot_template += f"Output: {example['output']}\n\n"
|
|
91
|
+
|
|
92
|
+
few_shot_template += "Now solve this:\nInput: {input}\nOutput:"
|
|
93
|
+
|
|
94
|
+
return few_shot_template
|
|
95
|
+
|
|
96
|
+
def create_role_based_prompt(self, role: str, context: str, task: str) -> str:
|
|
97
|
+
"""Create role-based prompt for specific expertise"""
|
|
98
|
+
role_template = f"""
|
|
99
|
+
You are a {role}. {context}
|
|
100
|
+
|
|
101
|
+
Your task is to {task}.
|
|
102
|
+
|
|
103
|
+
Guidelines:
|
|
104
|
+
- Apply your expertise and professional knowledge
|
|
105
|
+
- Provide detailed, accurate, and actionable advice
|
|
106
|
+
- Consider industry best practices and standards
|
|
107
|
+
- Explain your reasoning when necessary
|
|
108
|
+
|
|
109
|
+
Request: {{input}}
|
|
110
|
+
|
|
111
|
+
Response:"""
|
|
112
|
+
|
|
113
|
+
return role_template
|
|
114
|
+
|
|
115
|
+
def create_structured_output_prompt(self, output_schema: Dict) -> str:
|
|
116
|
+
"""Create prompt for structured JSON output"""
|
|
117
|
+
schema_description = json.dumps(output_schema, indent=2)
|
|
118
|
+
|
|
119
|
+
structured_template = f"""
|
|
120
|
+
Please provide your response in the following JSON format:
|
|
121
|
+
|
|
122
|
+
{schema_description}
|
|
123
|
+
|
|
124
|
+
Ensure your response is valid JSON and follows the exact schema structure.
|
|
125
|
+
|
|
126
|
+
Input: {{input}}
|
|
127
|
+
|
|
128
|
+
JSON Response:"""
|
|
129
|
+
|
|
130
|
+
return structured_template
|
|
131
|
+
|
|
132
|
+
def optimize_prompt_iteratively(self, base_prompt: str, test_cases: List[Dict],
|
|
133
|
+
max_iterations: int = 5) -> str:
|
|
134
|
+
"""Iteratively optimize prompt based on test results"""
|
|
135
|
+
current_prompt = base_prompt
|
|
136
|
+
best_prompt = base_prompt
|
|
137
|
+
best_score = 0
|
|
138
|
+
|
|
139
|
+
for iteration in range(max_iterations):
|
|
140
|
+
scores = []
|
|
141
|
+
|
|
142
|
+
for test_case in test_cases:
|
|
143
|
+
response = self._call_llm(current_prompt.format(**test_case['input']))
|
|
144
|
+
score = self._evaluate_response(response, test_case['expected'])
|
|
145
|
+
scores.append(score)
|
|
146
|
+
|
|
147
|
+
avg_score = sum(scores) / len(scores)
|
|
148
|
+
|
|
149
|
+
if avg_score > best_score:
|
|
150
|
+
best_score = avg_score
|
|
151
|
+
best_prompt = current_prompt
|
|
152
|
+
|
|
153
|
+
# Generate prompt improvements
|
|
154
|
+
if iteration < max_iterations - 1:
|
|
155
|
+
current_prompt = self._improve_prompt(current_prompt, test_cases, scores)
|
|
156
|
+
|
|
157
|
+
return best_prompt
|
|
158
|
+
|
|
159
|
+
def _call_llm(self, prompt: str) -> str:
|
|
160
|
+
"""Call LLM with prompt"""
|
|
161
|
+
response = openai.ChatCompletion.create(
|
|
162
|
+
model=self.model_name,
|
|
163
|
+
messages=[{"role": "user", "content": prompt}],
|
|
164
|
+
temperature=self.temperature
|
|
165
|
+
)
|
|
166
|
+
return response.choices[0].message.content
|
|
167
|
+
|
|
168
|
+
def _evaluate_response(self, response: str, expected: str) -> float:
|
|
169
|
+
"""Evaluate response quality (simplified scoring)"""
|
|
170
|
+
# This is a simplified example - in practice, use more sophisticated metrics
|
|
171
|
+
from difflib import SequenceMatcher
|
|
172
|
+
return SequenceMatcher(None, response.lower(), expected.lower()).ratio()
|
|
173
|
+
|
|
174
|
+
def _improve_prompt(self, prompt: str, test_cases: List[Dict], scores: List[float]) -> str:
|
|
175
|
+
"""Generate improved prompt based on performance"""
|
|
176
|
+
improvement_prompt = f"""
|
|
177
|
+
Current prompt: {prompt}
|
|
178
|
+
|
|
179
|
+
Test case performance:
|
|
180
|
+
"""
|
|
181
|
+
|
|
182
|
+
for i, (test_case, score) in enumerate(zip(test_cases, scores)):
|
|
183
|
+
improvement_prompt += f"Test {i+1}: Score {score:.2f}\n"
|
|
184
|
+
improvement_prompt += f"Input: {test_case['input']}\n"
|
|
185
|
+
improvement_prompt += f"Expected: {test_case['expected']}\n\n"
|
|
186
|
+
|
|
187
|
+
improvement_prompt += """
|
|
188
|
+
Please suggest an improved version of the prompt that would perform better on these test cases.
|
|
189
|
+
Focus on clarity, specificity, and providing better guidance to the model.
|
|
190
|
+
|
|
191
|
+
Improved prompt:"""
|
|
192
|
+
|
|
193
|
+
return self._call_llm(improvement_prompt)
|
|
194
|
+
|
|
195
|
+
# Advanced prompt templates
|
|
196
|
+
PROMPT_TEMPLATES = {
|
|
197
|
+
"code_review": PromptTemplate(
|
|
198
|
+
name="code_review",
|
|
199
|
+
template="""
|
|
200
|
+
You are an expert code reviewer with {years} years of experience in {language}.
|
|
201
|
+
|
|
202
|
+
Review the following code for:
|
|
203
|
+
1. Code quality and best practices
|
|
204
|
+
2. Potential bugs and security issues
|
|
205
|
+
3. Performance optimizations
|
|
206
|
+
4. Maintainability and readability
|
|
207
|
+
|
|
208
|
+
Code to review:
|
|
209
|
+
```{language}
|
|
210
|
+
{code}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Provide a structured review with:
|
|
214
|
+
- Overall assessment (1-10 score)
|
|
215
|
+
- Specific issues found
|
|
216
|
+
- Recommendations for improvement
|
|
217
|
+
- Positive aspects to acknowledge
|
|
218
|
+
|
|
219
|
+
Review:""",
|
|
220
|
+
variables=["years", "language", "code"],
|
|
221
|
+
category="development",
|
|
222
|
+
description="Comprehensive code review template",
|
|
223
|
+
examples=[]
|
|
224
|
+
),
|
|
225
|
+
|
|
226
|
+
"data_analysis": PromptTemplate(
|
|
227
|
+
name="data_analysis",
|
|
228
|
+
template="""
|
|
229
|
+
As a senior data scientist, analyze the following dataset and provide insights.
|
|
230
|
+
|
|
231
|
+
Dataset description: {description}
|
|
232
|
+
Data sample:
|
|
233
|
+
{data_sample}
|
|
234
|
+
|
|
235
|
+
Analysis requirements:
|
|
236
|
+
{requirements}
|
|
237
|
+
|
|
238
|
+
Please provide:
|
|
239
|
+
1. Data quality assessment
|
|
240
|
+
2. Key statistical insights
|
|
241
|
+
3. Patterns and anomalies
|
|
242
|
+
4. Recommendations for further analysis
|
|
243
|
+
5. Potential business implications
|
|
244
|
+
|
|
245
|
+
Analysis:""",
|
|
246
|
+
variables=["description", "data_sample", "requirements"],
|
|
247
|
+
category="analytics",
|
|
248
|
+
description="Data analysis and insights template",
|
|
249
|
+
examples=[]
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## RAG System Implementation
|
|
255
|
+
```python
|
|
256
|
+
import chromadb
|
|
257
|
+
from langchain.embeddings import OpenAIEmbeddings
|
|
258
|
+
from langchain.vectorstores import Chroma
|
|
259
|
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
260
|
+
from langchain.chains import RetrievalQA
|
|
261
|
+
from langchain.llms import OpenAI
|
|
262
|
+
import numpy as np
|
|
263
|
+
from typing import List, Dict, Tuple
|
|
264
|
+
|
|
265
|
+
class RAGSystem:
|
|
266
|
+
def __init__(self, model_name="gpt-3.5-turbo", embedding_model="text-embedding-ada-002"):
|
|
267
|
+
self.model_name = model_name
|
|
268
|
+
self.embeddings = OpenAIEmbeddings(model=embedding_model)
|
|
269
|
+
self.vector_store = None
|
|
270
|
+
self.retrieval_chain = None
|
|
271
|
+
|
|
272
|
+
def ingest_documents(self, documents: List[str], chunk_size: int = 1000,
|
|
273
|
+
chunk_overlap: int = 200) -> None:
|
|
274
|
+
"""Ingest and process documents into vector store"""
|
|
275
|
+
# Split documents into chunks
|
|
276
|
+
text_splitter = RecursiveCharacterTextSplitter(
|
|
277
|
+
chunk_size=chunk_size,
|
|
278
|
+
chunk_overlap=chunk_overlap
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
chunks = []
|
|
282
|
+
metadatas = []
|
|
283
|
+
|
|
284
|
+
for i, doc in enumerate(documents):
|
|
285
|
+
doc_chunks = text_splitter.split_text(doc)
|
|
286
|
+
chunks.extend(doc_chunks)
|
|
287
|
+
metadatas.extend([{"source": f"doc_{i}", "chunk": j}
|
|
288
|
+
for j in range(len(doc_chunks))])
|
|
289
|
+
|
|
290
|
+
# Create vector store
|
|
291
|
+
self.vector_store = Chroma.from_texts(
|
|
292
|
+
texts=chunks,
|
|
293
|
+
embedding=self.embeddings,
|
|
294
|
+
metadatas=metadatas
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
# Create retrieval chain
|
|
298
|
+
llm = OpenAI(model_name=self.model_name, temperature=0)
|
|
299
|
+
self.retrieval_chain = RetrievalQA.from_chain_type(
|
|
300
|
+
llm=llm,
|
|
301
|
+
chain_type="stuff",
|
|
302
|
+
retriever=self.vector_store.as_retriever(search_kwargs={"k": 4})
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
def advanced_retrieval(self, query: str, k: int = 4,
|
|
306
|
+
similarity_threshold: float = 0.7) -> List[Dict]:
|
|
307
|
+
"""Advanced retrieval with filtering and reranking"""
|
|
308
|
+
# Get initial results
|
|
309
|
+
results = self.vector_store.similarity_search_with_score(query, k=k*2)
|
|
310
|
+
|
|
311
|
+
# Filter by similarity threshold
|
|
312
|
+
filtered_results = [
|
|
313
|
+
(doc, score) for doc, score in results
|
|
314
|
+
if score >= similarity_threshold
|
|
315
|
+
]
|
|
316
|
+
|
|
317
|
+
# Rerank using query-specific criteria
|
|
318
|
+
reranked_results = self._rerank_results(query, filtered_results)
|
|
319
|
+
|
|
320
|
+
return reranked_results[:k]
|
|
321
|
+
|
|
322
|
+
def _rerank_results(self, query: str, results: List[Tuple]) -> List[Dict]:
|
|
323
|
+
"""Rerank results based on query context"""
|
|
324
|
+
# Simple reranking based on keyword overlap
|
|
325
|
+
query_words = set(query.lower().split())
|
|
326
|
+
|
|
327
|
+
scored_results = []
|
|
328
|
+
for doc, similarity_score in results:
|
|
329
|
+
doc_words = set(doc.page_content.lower().split())
|
|
330
|
+
keyword_overlap = len(query_words.intersection(doc_words)) / len(query_words)
|
|
331
|
+
|
|
332
|
+
# Combined score
|
|
333
|
+
combined_score = 0.7 * similarity_score + 0.3 * keyword_overlap
|
|
334
|
+
|
|
335
|
+
scored_results.append({
|
|
336
|
+
"document": doc,
|
|
337
|
+
"similarity_score": similarity_score,
|
|
338
|
+
"keyword_overlap": keyword_overlap,
|
|
339
|
+
"combined_score": combined_score
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
return sorted(scored_results, key=lambda x: x["combined_score"], reverse=True)
|
|
343
|
+
|
|
344
|
+
def generate_response_with_citations(self, query: str) -> Dict:
|
|
345
|
+
"""Generate response with source citations"""
|
|
346
|
+
# Retrieve relevant documents
|
|
347
|
+
relevant_docs = self.advanced_retrieval(query)
|
|
348
|
+
|
|
349
|
+
# Create context from retrieved documents
|
|
350
|
+
context = "\n\n".join([
|
|
351
|
+
f"Source {i+1}: {doc['document'].page_content}"
|
|
352
|
+
for i, doc in enumerate(relevant_docs)
|
|
353
|
+
])
|
|
354
|
+
|
|
355
|
+
# Create prompt with citations
|
|
356
|
+
prompt = f"""
|
|
357
|
+
Context information:
|
|
358
|
+
{context}
|
|
359
|
+
|
|
360
|
+
Question: {query}
|
|
361
|
+
|
|
362
|
+
Please provide a comprehensive answer based on the context above.
|
|
363
|
+
Include citations in the format [Source X] where X is the source number.
|
|
364
|
+
|
|
365
|
+
Answer:"""
|
|
366
|
+
|
|
367
|
+
# Generate response
|
|
368
|
+
llm = OpenAI(model_name=self.model_name, temperature=0.1)
|
|
369
|
+
response = llm(prompt)
|
|
370
|
+
|
|
371
|
+
return {
|
|
372
|
+
"answer": response,
|
|
373
|
+
"sources": [doc['document'].metadata for doc in relevant_docs],
|
|
374
|
+
"retrieval_scores": [doc['combined_score'] for doc in relevant_docs]
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
def evaluate_rag_performance(self, test_queries: List[Dict]) -> Dict:
|
|
378
|
+
"""Evaluate RAG system performance"""
|
|
379
|
+
metrics = {
|
|
380
|
+
"retrieval_accuracy": [],
|
|
381
|
+
"answer_relevance": [],
|
|
382
|
+
"citation_accuracy": []
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
for test_case in test_queries:
|
|
386
|
+
query = test_case["query"]
|
|
387
|
+
expected_sources = test_case.get("expected_sources", [])
|
|
388
|
+
expected_answer = test_case.get("expected_answer", "")
|
|
389
|
+
|
|
390
|
+
# Get response
|
|
391
|
+
response = self.generate_response_with_citations(query)
|
|
392
|
+
|
|
393
|
+
# Calculate retrieval accuracy
|
|
394
|
+
retrieved_sources = [source["source"] for source in response["sources"]]
|
|
395
|
+
retrieval_accuracy = len(set(retrieved_sources) & set(expected_sources)) / len(expected_sources) if expected_sources else 0
|
|
396
|
+
metrics["retrieval_accuracy"].append(retrieval_accuracy)
|
|
397
|
+
|
|
398
|
+
# Calculate answer relevance (simplified)
|
|
399
|
+
answer_relevance = self._calculate_answer_relevance(response["answer"], expected_answer)
|
|
400
|
+
metrics["answer_relevance"].append(answer_relevance)
|
|
401
|
+
|
|
402
|
+
# Calculate average metrics
|
|
403
|
+
return {
|
|
404
|
+
"avg_retrieval_accuracy": np.mean(metrics["retrieval_accuracy"]),
|
|
405
|
+
"avg_answer_relevance": np.mean(metrics["answer_relevance"]),
|
|
406
|
+
"total_queries_tested": len(test_queries)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
def _calculate_answer_relevance(self, generated_answer: str, expected_answer: str) -> float:
|
|
410
|
+
"""Calculate answer relevance score"""
|
|
411
|
+
# Simplified scoring - in practice, use more sophisticated metrics
|
|
412
|
+
from difflib import SequenceMatcher
|
|
413
|
+
return SequenceMatcher(None, generated_answer.lower(), expected_answer.lower()).ratio()
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
## Fine-tuning Framework
|
|
417
|
+
```python
|
|
418
|
+
import torch
|
|
419
|
+
from transformers import (
|
|
420
|
+
AutoTokenizer, AutoModelForCausalLM, TrainingArguments,
|
|
421
|
+
Trainer, DataCollatorForLanguageModeling
|
|
422
|
+
)
|
|
423
|
+
from peft import LoraConfig, get_peft_model, TaskType
|
|
424
|
+
from datasets import Dataset
|
|
425
|
+
import json
|
|
426
|
+
from typing import List, Dict
|
|
427
|
+
|
|
428
|
+
class LLMFineTuner:
|
|
429
|
+
def __init__(self, base_model: str, use_lora: bool = True):
|
|
430
|
+
self.base_model = base_model
|
|
431
|
+
self.use_lora = use_lora
|
|
432
|
+
self.tokenizer = AutoTokenizer.from_pretrained(base_model)
|
|
433
|
+
self.model = None
|
|
434
|
+
|
|
435
|
+
# Add padding token if not present
|
|
436
|
+
if self.tokenizer.pad_token is None:
|
|
437
|
+
self.tokenizer.pad_token = self.tokenizer.eos_token
|
|
438
|
+
|
|
439
|
+
def prepare_training_data(self, data: List[Dict], instruction_format: str = "alpaca") -> Dataset:
|
|
440
|
+
"""Prepare training data in instruction format"""
|
|
441
|
+
formatted_data = []
|
|
442
|
+
|
|
443
|
+
for example in data:
|
|
444
|
+
if instruction_format == "alpaca":
|
|
445
|
+
if "input" in example and example["input"]:
|
|
446
|
+
formatted_text = f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
|
447
|
+
|
|
448
|
+
### Instruction:
|
|
449
|
+
{example['instruction']}
|
|
450
|
+
|
|
451
|
+
### Input:
|
|
452
|
+
{example['input']}
|
|
453
|
+
|
|
454
|
+
### Response:
|
|
455
|
+
{example['output']}"""
|
|
456
|
+
else:
|
|
457
|
+
formatted_text = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
|
458
|
+
|
|
459
|
+
### Instruction:
|
|
460
|
+
{example['instruction']}
|
|
461
|
+
|
|
462
|
+
### Response:
|
|
463
|
+
{example['output']}"""
|
|
464
|
+
|
|
465
|
+
elif instruction_format == "chat":
|
|
466
|
+
formatted_text = f"""Human: {example['instruction']}
|
|
467
|
+
|
|
468
|
+
Assistant: {example['output']}"""
|
|
469
|
+
|
|
470
|
+
formatted_data.append(formatted_text)
|
|
471
|
+
|
|
472
|
+
# Tokenize data
|
|
473
|
+
tokenized_data = []
|
|
474
|
+
for text in formatted_data:
|
|
475
|
+
tokens = self.tokenizer(text, truncation=True, padding=True, max_length=2048)
|
|
476
|
+
tokenized_data.append(tokens)
|
|
477
|
+
|
|
478
|
+
return Dataset.from_list(tokenized_data)
|
|
479
|
+
|
|
480
|
+
def setup_lora_config(self, r: int = 16, lora_alpha: int = 32, target_modules: List[str] = None):
|
|
481
|
+
"""Setup LoRA configuration for efficient fine-tuning"""
|
|
482
|
+
if target_modules is None:
|
|
483
|
+
target_modules = ["q_proj", "v_proj", "k_proj", "o_proj"]
|
|
484
|
+
|
|
485
|
+
lora_config = LoraConfig(
|
|
486
|
+
task_type=TaskType.CAUSAL_LM,
|
|
487
|
+
r=r,
|
|
488
|
+
lora_alpha=lora_alpha,
|
|
489
|
+
target_modules=target_modules,
|
|
490
|
+
lora_dropout=0.1
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
return lora_config
|
|
494
|
+
|
|
495
|
+
def fine_tune_model(self, train_dataset: Dataset, val_dataset: Dataset = None,
|
|
496
|
+
output_dir: str = "./fine_tuned_model", epochs: int = 3):
|
|
497
|
+
"""Fine-tune the model with training data"""
|
|
498
|
+
# Load model
|
|
499
|
+
model = AutoModelForCausalLM.from_pretrained(
|
|
500
|
+
self.base_model,
|
|
501
|
+
torch_dtype=torch.float16,
|
|
502
|
+
device_map="auto"
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
# Apply LoRA if enabled
|
|
506
|
+
if self.use_lora:
|
|
507
|
+
lora_config = self.setup_lora_config()
|
|
508
|
+
model = get_peft_model(model, lora_config)
|
|
509
|
+
model.print_trainable_parameters()
|
|
510
|
+
|
|
511
|
+
# Setup training arguments
|
|
512
|
+
training_args = TrainingArguments(
|
|
513
|
+
output_dir=output_dir,
|
|
514
|
+
num_train_epochs=epochs,
|
|
515
|
+
per_device_train_batch_size=4,
|
|
516
|
+
gradient_accumulation_steps=4,
|
|
517
|
+
warmup_steps=100,
|
|
518
|
+
learning_rate=2e-4,
|
|
519
|
+
fp16=True,
|
|
520
|
+
logging_steps=10,
|
|
521
|
+
evaluation_strategy="steps" if val_dataset else "no",
|
|
522
|
+
eval_steps=100 if val_dataset else None,
|
|
523
|
+
save_steps=500,
|
|
524
|
+
save_total_limit=2
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
# Data collator
|
|
528
|
+
data_collator = DataCollatorForLanguageModeling(
|
|
529
|
+
tokenizer=self.tokenizer,
|
|
530
|
+
mlm=False
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
# Setup trainer
|
|
534
|
+
trainer = Trainer(
|
|
535
|
+
model=model,
|
|
536
|
+
args=training_args,
|
|
537
|
+
train_dataset=train_dataset,
|
|
538
|
+
eval_dataset=val_dataset,
|
|
539
|
+
data_collator=data_collator
|
|
540
|
+
)
|
|
541
|
+
|
|
542
|
+
# Start training
|
|
543
|
+
trainer.train()
|
|
544
|
+
|
|
545
|
+
# Save model
|
|
546
|
+
trainer.save_model()
|
|
547
|
+
self.tokenizer.save_pretrained(output_dir)
|
|
548
|
+
|
|
549
|
+
self.model = model
|
|
550
|
+
return trainer
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
class PromptEvaluator:
|
|
554
|
+
"""Comprehensive prompt evaluation framework"""
|
|
555
|
+
|
|
556
|
+
def __init__(self):
|
|
557
|
+
self.metrics = {}
|
|
558
|
+
|
|
559
|
+
def evaluate_generation_quality(self, generated_texts: List[str],
|
|
560
|
+
reference_texts: List[str]) -> Dict:
|
|
561
|
+
"""Evaluate text generation quality using multiple metrics"""
|
|
562
|
+
from rouge_score import rouge_scorer
|
|
563
|
+
from bert_score import score
|
|
564
|
+
|
|
565
|
+
# ROUGE scores
|
|
566
|
+
scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2', 'rougeL'], use_stemmer=True)
|
|
567
|
+
rouge_scores = {'rouge1': [], 'rouge2': [], 'rougeL': []}
|
|
568
|
+
|
|
569
|
+
for gen, ref in zip(generated_texts, reference_texts):
|
|
570
|
+
scores = scorer.score(ref, gen)
|
|
571
|
+
rouge_scores['rouge1'].append(scores['rouge1'].fmeasure)
|
|
572
|
+
rouge_scores['rouge2'].append(scores['rouge2'].fmeasure)
|
|
573
|
+
rouge_scores['rougeL'].append(scores['rougeL'].fmeasure)
|
|
574
|
+
|
|
575
|
+
# BERTScore
|
|
576
|
+
P, R, F1 = score(generated_texts, reference_texts, lang="en")
|
|
577
|
+
|
|
578
|
+
return {
|
|
579
|
+
'rouge1': np.mean(rouge_scores['rouge1']),
|
|
580
|
+
'rouge2': np.mean(rouge_scores['rouge2']),
|
|
581
|
+
'rougeL': np.mean(rouge_scores['rougeL']),
|
|
582
|
+
'bert_score_precision': P.mean().item(),
|
|
583
|
+
'bert_score_recall': R.mean().item(),
|
|
584
|
+
'bert_score_f1': F1.mean().item()
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
def evaluate_instruction_following(self, prompts: List[str], responses: List[str]) -> Dict:
|
|
588
|
+
"""Evaluate how well the model follows instructions"""
|
|
589
|
+
scores = []
|
|
590
|
+
|
|
591
|
+
for prompt, response in zip(prompts, responses):
|
|
592
|
+
# Extract instruction from prompt
|
|
593
|
+
instruction = self._extract_instruction(prompt)
|
|
594
|
+
|
|
595
|
+
# Evaluate instruction following
|
|
596
|
+
score = self._score_instruction_following(instruction, response)
|
|
597
|
+
scores.append(score)
|
|
598
|
+
|
|
599
|
+
return {
|
|
600
|
+
'avg_instruction_following': np.mean(scores),
|
|
601
|
+
'instruction_following_scores': scores
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
def _extract_instruction(self, prompt: str) -> str:
|
|
605
|
+
"""Extract instruction from prompt"""
|
|
606
|
+
# Simple extraction - in practice, use more sophisticated parsing
|
|
607
|
+
lines = prompt.split('\n')
|
|
608
|
+
for line in lines:
|
|
609
|
+
if 'Instruction:' in line:
|
|
610
|
+
return line.split('Instruction:')[1].strip()
|
|
611
|
+
return prompt
|
|
612
|
+
|
|
613
|
+
def _score_instruction_following(self, instruction: str, response: str) -> float:
|
|
614
|
+
"""Score how well response follows instruction"""
|
|
615
|
+
# Simplified scoring - use LLM-based evaluation in practice
|
|
616
|
+
instruction_words = set(instruction.lower().split())
|
|
617
|
+
response_words = set(response.lower().split())
|
|
618
|
+
|
|
619
|
+
# Check for key instruction words in response
|
|
620
|
+
overlap = len(instruction_words.intersection(response_words))
|
|
621
|
+
return min(overlap / len(instruction_words), 1.0)
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
## LangChain Agent Framework
|
|
625
|
+
from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent
|
|
626
|
+
from langchain.prompts import StringPromptTemplate
|
|
627
|
+
from langchain.llms import OpenAI
|
|
628
|
+
from langchain.utilities import SerpAPIWrapper
|
|
629
|
+
from langchain.chains import LLMChain
|
|
630
|
+
from langchain.schema import AgentAction, AgentFinish
|
|
631
|
+
import re
|
|
632
|
+
|
|
633
|
+
class CustomPromptTemplate(StringPromptTemplate):
|
|
634
|
+
"""Custom prompt template for agents"""
|
|
635
|
+
template: str
|
|
636
|
+
tools: List[Tool]
|
|
637
|
+
|
|
638
|
+
def format(self, **kwargs) -> str:
|
|
639
|
+
intermediate_steps = kwargs.pop("intermediate_steps")
|
|
640
|
+
thoughts = ""
|
|
641
|
+
for action, observation in intermediate_steps:
|
|
642
|
+
thoughts += action.log
|
|
643
|
+
thoughts += f"\nObservation: {observation}\nThought: "
|
|
644
|
+
|
|
645
|
+
kwargs["agent_scratchpad"] = thoughts
|
|
646
|
+
kwargs["tools"] = "\n".join([f"{tool.name}: {tool.description}" for tool in self.tools])
|
|
647
|
+
kwargs["tool_names"] = ", ".join([tool.name for tool in self.tools])
|
|
648
|
+
|
|
649
|
+
return self.template.format(**kwargs)
|
|
650
|
+
|
|
651
|
+
class CustomOutputParser:
|
|
652
|
+
"""Custom output parser for agent actions"""
|
|
653
|
+
|
|
654
|
+
def parse(self, llm_output: str):
|
|
655
|
+
if "Final Answer:" in llm_output:
|
|
656
|
+
return AgentFinish(
|
|
657
|
+
return_values={"output": llm_output.split("Final Answer:")[-1].strip()},
|
|
658
|
+
log=llm_output,
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
regex = r"Action: (.*?)[\n]*Action Input: (.*)"
|
|
662
|
+
match = re.search(regex, llm_output, re.DOTALL)
|
|
663
|
+
if not match:
|
|
664
|
+
raise ValueError(f"Could not parse LLM output: `{llm_output}`")
|
|
665
|
+
|
|
666
|
+
action = match.group(1).strip()
|
|
667
|
+
action_input = match.group(2)
|
|
668
|
+
|
|
669
|
+
return AgentAction(tool=action, tool_input=action_input.strip(" ").strip('"'), log=llm_output)
|
|
670
|
+
|
|
671
|
+
def create_custom_agent():
|
|
672
|
+
"""Create a custom LangChain agent with specialized tools"""
|
|
673
|
+
# Define tools
|
|
674
|
+
search = SerpAPIWrapper()
|
|
675
|
+
tools = [
|
|
676
|
+
Tool(
|
|
677
|
+
name="Search",
|
|
678
|
+
func=search.run,
|
|
679
|
+
description="Useful for searching current information on the internet"
|
|
680
|
+
),
|
|
681
|
+
Tool(
|
|
682
|
+
name="Calculator",
|
|
683
|
+
func=lambda x: str(eval(x)),
|
|
684
|
+
description="Useful for mathematical calculations"
|
|
685
|
+
)
|
|
686
|
+
]
|
|
687
|
+
|
|
688
|
+
# Define prompt template
|
|
689
|
+
template = """Answer the following questions as best you can. You have access to the following tools:
|
|
690
|
+
|
|
691
|
+
{tools}
|
|
692
|
+
|
|
693
|
+
Use the following format:
|
|
694
|
+
|
|
695
|
+
Question: the input question you must answer
|
|
696
|
+
Thought: you should always think about what to do
|
|
697
|
+
Action: the action to take, should be one of [{tool_names}]
|
|
698
|
+
Action Input: the input to the action
|
|
699
|
+
Observation: the result of the action
|
|
700
|
+
... (this Thought/Action/Action Input/Observation can repeat N times)
|
|
701
|
+
Thought: I now know the final answer
|
|
702
|
+
Final Answer: the final answer to the original input question
|
|
703
|
+
|
|
704
|
+
Question: {input}
|
|
705
|
+
{agent_scratchpad}"""
|
|
706
|
+
|
|
707
|
+
prompt = CustomPromptTemplate(
|
|
708
|
+
template=template,
|
|
709
|
+
tools=tools,
|
|
710
|
+
input_variables=["input", "intermediate_steps"]
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
# Setup LLM and agent
|
|
714
|
+
llm = OpenAI(temperature=0)
|
|
715
|
+
output_parser = CustomOutputParser()
|
|
716
|
+
|
|
717
|
+
llm_chain = LLMChain(llm=llm, prompt=prompt)
|
|
718
|
+
|
|
719
|
+
agent = LLMSingleActionAgent(
|
|
720
|
+
llm_chain=llm_chain,
|
|
721
|
+
output_parser=output_parser,
|
|
722
|
+
stop=["\nObservation:"],
|
|
723
|
+
allowed_tools=[tool.name for tool in tools]
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
agent_executor = AgentExecutor.from_agent_and_tools(
|
|
727
|
+
agent=agent,
|
|
728
|
+
tools=tools,
|
|
729
|
+
verbose=True
|
|
730
|
+
)
|
|
731
|
+
|
|
732
|
+
return agent_executor
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
## Best Practices
|
|
736
|
+
1. **Iterative Refinement**: Continuously test and refine prompts based on results
|
|
737
|
+
2. **Context Management**: Maintain appropriate context length and relevance
|
|
738
|
+
3. **Safety Measures**: Implement safety filters and content moderation
|
|
739
|
+
4. **Evaluation Metrics**: Use comprehensive evaluation frameworks
|
|
740
|
+
5. **Version Control**: Track prompt versions and performance metrics
|
|
741
|
+
6. **A/B Testing**: Compare different prompt variations systematically
|
|
742
|
+
7. **Documentation**: Document prompt design decisions and performance
|
|
743
|
+
|
|
744
|
+
## Prompt Safety and Alignment
|
|
745
|
+
- Implement robust input validation and sanitization
|
|
746
|
+
- Use constitutional AI principles for alignment
|
|
747
|
+
- Regular safety audits and red team testing
|
|
748
|
+
- Monitoring for harmful or biased outputs
|
|
749
|
+
- Implementing feedback loops for continuous improvement
|
|
750
|
+
|
|
751
|
+
## Performance Optimization
|
|
752
|
+
- Optimize prompt length vs. performance trade-offs
|
|
753
|
+
- Use caching for frequently used prompts
|
|
754
|
+
- Implement parallel processing for batch operations
|
|
755
|
+
- Monitor latency and cost metrics
|
|
756
|
+
- Regular model performance benchmarking
|
|
757
|
+
|
|
758
|
+
## Approach
|
|
759
|
+
- Start with clear objectives and success criteria
|
|
760
|
+
- Design systematic evaluation frameworks
|
|
761
|
+
- Implement comprehensive testing and validation
|
|
762
|
+
- Create modular and reusable prompt components
|
|
763
|
+
- Maintain detailed documentation and versioning
|
|
764
|
+
- Establish monitoring and feedback mechanisms
|
|
765
|
+
|
|
766
|
+
## Output Format
|
|
767
|
+
- Provide complete prompt engineering frameworks
|
|
768
|
+
- Include evaluation and testing methodologies
|
|
769
|
+
- Document safety and alignment considerations
|
|
770
|
+
- Add performance optimization strategies
|
|
771
|
+
- Include deployment and monitoring setups
|
|
772
|
+
- Provide comprehensive examples and use cases
|