claude-autopm 2.8.1 → 2.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +399 -529
- package/bin/autopm.js +2 -0
- package/bin/commands/plugin.js +395 -0
- package/bin/commands/team.js +184 -10
- package/install/install.js +223 -4
- package/lib/plugins/PluginManager.js +1328 -0
- package/lib/plugins/PluginManager.old.js +400 -0
- package/package.json +5 -1
- package/packages/plugin-ai/LICENSE +21 -0
- package/packages/plugin-ai/README.md +316 -0
- package/packages/plugin-ai/agents/anthropic-claude-expert.md +579 -0
- package/packages/plugin-ai/agents/azure-openai-expert.md +1411 -0
- package/packages/plugin-ai/agents/google-a2a-expert.md +1445 -0
- package/packages/plugin-ai/agents/huggingface-expert.md +2131 -0
- package/packages/plugin-ai/agents/langchain-expert.md +1427 -0
- package/packages/plugin-ai/commands/a2a-setup.md +886 -0
- package/packages/plugin-ai/commands/ai-model-deployment.md +481 -0
- package/packages/plugin-ai/commands/anthropic-optimize.md +793 -0
- package/packages/plugin-ai/commands/huggingface-deploy.md +789 -0
- package/packages/plugin-ai/commands/langchain-optimize.md +807 -0
- package/packages/plugin-ai/commands/llm-optimize.md +348 -0
- package/packages/plugin-ai/commands/openai-optimize.md +863 -0
- package/packages/plugin-ai/commands/rag-optimize.md +841 -0
- package/packages/plugin-ai/commands/rag-setup-scaffold.md +382 -0
- package/packages/plugin-ai/package.json +66 -0
- package/packages/plugin-ai/plugin.json +519 -0
- package/packages/plugin-ai/rules/ai-model-standards.md +449 -0
- package/packages/plugin-ai/rules/prompt-engineering-standards.md +509 -0
- package/packages/plugin-ai/scripts/examples/huggingface-inference-example.py +145 -0
- package/packages/plugin-ai/scripts/examples/langchain-rag-example.py +366 -0
- package/packages/plugin-ai/scripts/examples/mlflow-tracking-example.py +224 -0
- package/packages/plugin-ai/scripts/examples/openai-chat-example.py +425 -0
- package/packages/plugin-cloud/README.md +268 -0
- package/packages/plugin-cloud/agents/gemini-api-expert.md +880 -0
- package/packages/plugin-cloud/agents/openai-python-expert.md +1087 -0
- package/packages/plugin-cloud/commands/cloud-cost-optimize.md +243 -0
- package/packages/plugin-cloud/commands/cloud-validate.md +196 -0
- package/packages/plugin-cloud/hooks/pre-cloud-deploy.js +456 -0
- package/packages/plugin-cloud/package.json +64 -0
- package/packages/plugin-cloud/plugin.json +338 -0
- package/packages/plugin-cloud/rules/cloud-security-compliance.md +313 -0
- package/packages/plugin-cloud/scripts/examples/aws-validate.sh +30 -0
- package/packages/plugin-cloud/scripts/examples/azure-setup.sh +33 -0
- package/packages/plugin-cloud/scripts/examples/gcp-setup.sh +39 -0
- package/packages/plugin-cloud/scripts/examples/k8s-validate.sh +40 -0
- package/packages/plugin-cloud/scripts/examples/terraform-init.sh +26 -0
- package/packages/plugin-core/README.md +274 -0
- package/packages/plugin-core/commands/code-rabbit.md +128 -0
- package/packages/plugin-core/commands/prompt.md +9 -0
- package/packages/plugin-core/commands/re-init.md +9 -0
- package/packages/plugin-core/hooks/context7-reminder.md +29 -0
- package/packages/plugin-core/hooks/enforce-agents.js +125 -0
- package/packages/plugin-core/hooks/enforce-agents.sh +35 -0
- package/packages/plugin-core/hooks/pre-agent-context7.js +224 -0
- package/packages/plugin-core/hooks/pre-command-context7.js +229 -0
- package/packages/plugin-core/hooks/strict-enforce-agents.sh +39 -0
- package/packages/plugin-core/hooks/test-hook.sh +21 -0
- package/packages/plugin-core/hooks/unified-context7-enforcement.sh +38 -0
- package/packages/plugin-core/package.json +45 -0
- package/packages/plugin-core/plugin.json +387 -0
- package/packages/plugin-core/rules/agent-coordination.md +549 -0
- package/packages/plugin-core/rules/agent-mandatory.md +170 -0
- package/packages/plugin-core/rules/command-pipelines.md +208 -0
- package/packages/plugin-core/rules/context-optimization.md +176 -0
- package/packages/plugin-core/rules/context7-enforcement.md +327 -0
- package/packages/plugin-core/rules/datetime.md +122 -0
- package/packages/plugin-core/rules/definition-of-done.md +272 -0
- package/packages/plugin-core/rules/development-environments.md +19 -0
- package/packages/plugin-core/rules/development-workflow.md +198 -0
- package/packages/plugin-core/rules/framework-path-rules.md +180 -0
- package/packages/plugin-core/rules/frontmatter-operations.md +64 -0
- package/packages/plugin-core/rules/git-strategy.md +237 -0
- package/packages/plugin-core/rules/golden-rules.md +181 -0
- package/packages/plugin-core/rules/naming-conventions.md +111 -0
- package/packages/plugin-core/rules/no-pr-workflow.md +183 -0
- package/packages/plugin-core/rules/pipeline-mandatory.md +109 -0
- package/packages/plugin-core/rules/security-checklist.md +318 -0
- package/packages/plugin-core/rules/standard-patterns.md +197 -0
- package/packages/plugin-core/rules/strip-frontmatter.md +85 -0
- package/packages/plugin-core/rules/tdd.enforcement.md +103 -0
- package/packages/plugin-core/rules/use-ast-grep.md +113 -0
- package/packages/plugin-core/scripts/lib/datetime-utils.sh +254 -0
- package/packages/plugin-core/scripts/lib/frontmatter-utils.sh +294 -0
- package/packages/plugin-core/scripts/lib/github-utils.sh +221 -0
- package/packages/plugin-core/scripts/lib/logging-utils.sh +199 -0
- package/packages/plugin-core/scripts/lib/validation-utils.sh +339 -0
- package/packages/plugin-core/scripts/mcp/add.sh +7 -0
- package/packages/plugin-core/scripts/mcp/disable.sh +12 -0
- package/packages/plugin-core/scripts/mcp/enable.sh +12 -0
- package/packages/plugin-core/scripts/mcp/list.sh +7 -0
- package/packages/plugin-core/scripts/mcp/sync.sh +8 -0
- package/packages/plugin-data/README.md +315 -0
- package/packages/plugin-data/agents/airflow-orchestration-expert.md +158 -0
- package/packages/plugin-data/agents/kedro-pipeline-expert.md +304 -0
- package/packages/plugin-data/agents/langgraph-workflow-expert.md +530 -0
- package/packages/plugin-data/commands/airflow-dag-scaffold.md +413 -0
- package/packages/plugin-data/commands/kafka-pipeline-scaffold.md +503 -0
- package/packages/plugin-data/package.json +66 -0
- package/packages/plugin-data/plugin.json +294 -0
- package/packages/plugin-data/rules/data-quality-standards.md +373 -0
- package/packages/plugin-data/rules/etl-pipeline-standards.md +255 -0
- package/packages/plugin-data/scripts/examples/airflow-dag-example.py +245 -0
- package/packages/plugin-data/scripts/examples/dbt-transform-example.sql +238 -0
- package/packages/plugin-data/scripts/examples/kafka-streaming-example.py +257 -0
- package/packages/plugin-data/scripts/examples/pandas-etl-example.py +332 -0
- package/packages/plugin-databases/README.md +330 -0
- package/{autopm/.claude/agents/databases → packages/plugin-databases/agents}/bigquery-expert.md +24 -15
- package/{autopm/.claude/agents/databases → packages/plugin-databases/agents}/cosmosdb-expert.md +22 -15
- package/{autopm/.claude/agents/databases → packages/plugin-databases/agents}/mongodb-expert.md +24 -15
- package/{autopm/.claude/agents/databases → packages/plugin-databases/agents}/postgresql-expert.md +23 -15
- package/{autopm/.claude/agents/databases → packages/plugin-databases/agents}/redis-expert.md +29 -7
- package/packages/plugin-databases/commands/db-optimize.md +612 -0
- package/packages/plugin-databases/package.json +60 -0
- package/packages/plugin-databases/plugin.json +237 -0
- package/packages/plugin-databases/rules/database-management-strategy.md +146 -0
- package/packages/plugin-databases/rules/database-pipeline.md +316 -0
- package/packages/plugin-databases/scripts/examples/bigquery-cost-analyze.sh +160 -0
- package/packages/plugin-databases/scripts/examples/cosmosdb-ru-optimize.sh +163 -0
- package/packages/plugin-databases/scripts/examples/mongodb-shard-check.sh +120 -0
- package/packages/plugin-databases/scripts/examples/postgres-index-analyze.sh +95 -0
- package/packages/plugin-databases/scripts/examples/redis-cache-stats.sh +121 -0
- package/packages/plugin-devops/README.md +367 -0
- package/{autopm/.claude/agents/devops → packages/plugin-devops/agents}/github-operations-specialist.md +1 -1
- package/packages/plugin-devops/commands/ci-pipeline-create.md +581 -0
- package/packages/plugin-devops/commands/docker-optimize.md +493 -0
- package/packages/plugin-devops/hooks/pre-docker-build.js +472 -0
- package/packages/plugin-devops/package.json +61 -0
- package/packages/plugin-devops/plugin.json +302 -0
- package/packages/plugin-devops/rules/github-operations.md +92 -0
- package/packages/plugin-devops/scripts/examples/docker-build-multistage.sh +43 -0
- package/packages/plugin-devops/scripts/examples/docker-compose-validate.sh +74 -0
- package/packages/plugin-devops/scripts/examples/github-workflow-validate.sh +48 -0
- package/packages/plugin-devops/scripts/examples/prometheus-health-check.sh +58 -0
- package/packages/plugin-devops/scripts/examples/ssh-key-setup.sh +74 -0
- package/packages/plugin-frameworks/README.md +309 -0
- package/{autopm/.claude/agents/frameworks → packages/plugin-frameworks/agents}/e2e-test-engineer.md +219 -0
- package/{autopm/.claude/agents/frameworks → packages/plugin-frameworks/agents}/react-frontend-engineer.md +176 -0
- package/{autopm/.claude/agents/frameworks → packages/plugin-frameworks/agents}/tailwindcss-expert.md +251 -0
- package/packages/plugin-frameworks/commands/nextjs-optimize.md +692 -0
- package/packages/plugin-frameworks/commands/react-optimize.md +583 -0
- package/packages/plugin-frameworks/package.json +59 -0
- package/packages/plugin-frameworks/plugin.json +224 -0
- package/packages/plugin-frameworks/rules/performance-guidelines.md +403 -0
- package/packages/plugin-frameworks/scripts/examples/react-component-perf.sh +34 -0
- package/packages/plugin-frameworks/scripts/examples/tailwind-optimize.sh +44 -0
- package/packages/plugin-frameworks/scripts/examples/vue-composition-check.sh +41 -0
- package/packages/plugin-languages/README.md +333 -0
- package/packages/plugin-languages/commands/javascript-optimize.md +636 -0
- package/packages/plugin-languages/commands/nodejs-api-scaffold.md +341 -0
- package/packages/plugin-languages/commands/nodejs-optimize.md +689 -0
- package/packages/plugin-languages/commands/python-api-scaffold.md +261 -0
- package/packages/plugin-languages/commands/python-optimize.md +593 -0
- package/packages/plugin-languages/package.json +65 -0
- package/packages/plugin-languages/plugin.json +265 -0
- package/packages/plugin-languages/rules/code-quality-standards.md +496 -0
- package/packages/plugin-languages/rules/testing-standards.md +768 -0
- package/packages/plugin-languages/scripts/examples/bash-production-script.sh +520 -0
- package/packages/plugin-languages/scripts/examples/javascript-es6-patterns.js +291 -0
- package/packages/plugin-languages/scripts/examples/nodejs-async-iteration.js +360 -0
- package/packages/plugin-languages/scripts/examples/python-async-patterns.py +289 -0
- package/packages/plugin-languages/scripts/examples/typescript-patterns.ts +432 -0
- package/packages/plugin-ml/README.md +430 -0
- package/packages/plugin-ml/agents/automl-expert.md +326 -0
- package/packages/plugin-ml/agents/computer-vision-expert.md +550 -0
- package/packages/plugin-ml/agents/gradient-boosting-expert.md +455 -0
- package/packages/plugin-ml/agents/neural-network-architect.md +1228 -0
- package/packages/plugin-ml/agents/nlp-transformer-expert.md +584 -0
- package/packages/plugin-ml/agents/pytorch-expert.md +412 -0
- package/packages/plugin-ml/agents/reinforcement-learning-expert.md +2088 -0
- package/packages/plugin-ml/agents/scikit-learn-expert.md +228 -0
- package/packages/plugin-ml/agents/tensorflow-keras-expert.md +509 -0
- package/packages/plugin-ml/agents/time-series-expert.md +303 -0
- package/packages/plugin-ml/commands/ml-automl.md +572 -0
- package/packages/plugin-ml/commands/ml-train-optimize.md +657 -0
- package/packages/plugin-ml/package.json +52 -0
- package/packages/plugin-ml/plugin.json +338 -0
- package/packages/plugin-pm/README.md +368 -0
- package/packages/plugin-pm/claudeautopm-plugin-pm-2.0.0.tgz +0 -0
- package/packages/plugin-pm/commands/github/workflow-create.md +42 -0
- package/packages/plugin-pm/package.json +57 -0
- package/packages/plugin-pm/plugin.json +503 -0
- package/packages/plugin-testing/README.md +401 -0
- package/{autopm/.claude/agents/testing → packages/plugin-testing/agents}/frontend-testing-engineer.md +373 -0
- package/packages/plugin-testing/commands/jest-optimize.md +800 -0
- package/packages/plugin-testing/commands/playwright-optimize.md +887 -0
- package/packages/plugin-testing/commands/test-coverage.md +512 -0
- package/packages/plugin-testing/commands/test-performance.md +1041 -0
- package/packages/plugin-testing/commands/test-setup.md +414 -0
- package/packages/plugin-testing/package.json +40 -0
- package/packages/plugin-testing/plugin.json +197 -0
- package/packages/plugin-testing/rules/test-coverage-requirements.md +581 -0
- package/packages/plugin-testing/rules/testing-standards.md +529 -0
- package/packages/plugin-testing/scripts/examples/react-testing-example.test.jsx +460 -0
- package/packages/plugin-testing/scripts/examples/vitest-config-example.js +352 -0
- package/packages/plugin-testing/scripts/examples/vue-testing-example.test.js +586 -0
- package/scripts/publish-plugins.sh +166 -0
- package/autopm/.claude/agents/data/airflow-orchestration-expert.md +0 -52
- package/autopm/.claude/agents/data/kedro-pipeline-expert.md +0 -50
- package/autopm/.claude/agents/integration/message-queue-engineer.md +0 -794
- package/autopm/.claude/commands/ai/langgraph-workflow.md +0 -65
- package/autopm/.claude/commands/ai/openai-chat.md +0 -65
- package/autopm/.claude/commands/playwright/test-scaffold.md +0 -38
- package/autopm/.claude/commands/python/api-scaffold.md +0 -50
- package/autopm/.claude/commands/python/docs-query.md +0 -48
- package/autopm/.claude/commands/testing/prime.md +0 -314
- package/autopm/.claude/commands/testing/run.md +0 -125
- package/autopm/.claude/commands/ui/bootstrap-scaffold.md +0 -65
- package/autopm/.claude/rules/database-management-strategy.md +0 -17
- package/autopm/.claude/rules/database-pipeline.md +0 -94
- package/autopm/.claude/rules/ux-design-rules.md +0 -209
- package/autopm/.claude/rules/visual-testing.md +0 -223
- package/autopm/.claude/scripts/azure/README.md +0 -192
- package/autopm/.claude/scripts/azure/active-work.js +0 -524
- package/autopm/.claude/scripts/azure/active-work.sh +0 -20
- package/autopm/.claude/scripts/azure/blocked.js +0 -520
- package/autopm/.claude/scripts/azure/blocked.sh +0 -20
- package/autopm/.claude/scripts/azure/daily.js +0 -533
- package/autopm/.claude/scripts/azure/daily.sh +0 -20
- package/autopm/.claude/scripts/azure/dashboard.js +0 -970
- package/autopm/.claude/scripts/azure/dashboard.sh +0 -20
- package/autopm/.claude/scripts/azure/feature-list.js +0 -254
- package/autopm/.claude/scripts/azure/feature-list.sh +0 -20
- package/autopm/.claude/scripts/azure/feature-show.js +0 -7
- package/autopm/.claude/scripts/azure/feature-show.sh +0 -20
- package/autopm/.claude/scripts/azure/feature-status.js +0 -604
- package/autopm/.claude/scripts/azure/feature-status.sh +0 -20
- package/autopm/.claude/scripts/azure/help.js +0 -342
- package/autopm/.claude/scripts/azure/help.sh +0 -20
- package/autopm/.claude/scripts/azure/next-task.js +0 -508
- package/autopm/.claude/scripts/azure/next-task.sh +0 -20
- package/autopm/.claude/scripts/azure/search.js +0 -469
- package/autopm/.claude/scripts/azure/search.sh +0 -20
- package/autopm/.claude/scripts/azure/setup.js +0 -745
- package/autopm/.claude/scripts/azure/setup.sh +0 -20
- package/autopm/.claude/scripts/azure/sprint-report.js +0 -1012
- package/autopm/.claude/scripts/azure/sprint-report.sh +0 -20
- package/autopm/.claude/scripts/azure/sync.js +0 -563
- package/autopm/.claude/scripts/azure/sync.sh +0 -20
- package/autopm/.claude/scripts/azure/us-list.js +0 -210
- package/autopm/.claude/scripts/azure/us-list.sh +0 -20
- package/autopm/.claude/scripts/azure/us-status.js +0 -238
- package/autopm/.claude/scripts/azure/us-status.sh +0 -20
- package/autopm/.claude/scripts/azure/validate.js +0 -626
- package/autopm/.claude/scripts/azure/validate.sh +0 -20
- package/autopm/.claude/scripts/azure/wrapper-template.sh +0 -20
- package/autopm/.claude/scripts/github/dependency-tracker.js +0 -554
- package/autopm/.claude/scripts/github/dependency-validator.js +0 -545
- package/autopm/.claude/scripts/github/dependency-visualizer.js +0 -477
- package/bin/node/azure-feature-show.js +0 -7
- /package/{autopm/.claude/agents/cloud → packages/plugin-ai/agents}/gemini-api-expert.md +0 -0
- /package/{autopm/.claude/agents/data → packages/plugin-ai/agents}/langgraph-workflow-expert.md +0 -0
- /package/{autopm/.claude/agents/cloud → packages/plugin-ai/agents}/openai-python-expert.md +0 -0
- /package/{autopm/.claude/agents/cloud → packages/plugin-cloud/agents}/README.md +0 -0
- /package/{autopm/.claude/agents/cloud → packages/plugin-cloud/agents}/aws-cloud-architect.md +0 -0
- /package/{autopm/.claude/agents/cloud → packages/plugin-cloud/agents}/azure-cloud-architect.md +0 -0
- /package/{autopm/.claude/agents/cloud → packages/plugin-cloud/agents}/gcp-cloud-architect.md +0 -0
- /package/{autopm/.claude/agents/cloud → packages/plugin-cloud/agents}/gcp-cloud-functions-engineer.md +0 -0
- /package/{autopm/.claude/agents/cloud → packages/plugin-cloud/agents}/kubernetes-orchestrator.md +0 -0
- /package/{autopm/.claude/agents/cloud → packages/plugin-cloud/agents}/terraform-infrastructure-expert.md +0 -0
- /package/{autopm/.claude/commands/cloud → packages/plugin-cloud/commands}/infra-deploy.md +0 -0
- /package/{autopm/.claude/commands/kubernetes/deploy.md → packages/plugin-cloud/commands/k8s-deploy.md} +0 -0
- /package/{autopm/.claude/commands/infrastructure → packages/plugin-cloud/commands}/ssh-security.md +0 -0
- /package/{autopm/.claude/commands/infrastructure → packages/plugin-cloud/commands}/traefik-setup.md +0 -0
- /package/{autopm/.claude → packages/plugin-cloud}/rules/infrastructure-pipeline.md +0 -0
- /package/{autopm/.claude → packages/plugin-core}/agents/core/agent-manager.md +0 -0
- /package/{autopm/.claude → packages/plugin-core}/agents/core/code-analyzer.md +0 -0
- /package/{autopm/.claude → packages/plugin-core}/agents/core/file-analyzer.md +0 -0
- /package/{autopm/.claude → packages/plugin-core}/agents/core/test-runner.md +0 -0
- /package/{autopm/.claude → packages/plugin-core}/rules/ai-integration-patterns.md +0 -0
- /package/{autopm/.claude → packages/plugin-core}/rules/performance-guidelines.md +0 -0
- /package/{autopm/.claude/agents/databases → packages/plugin-databases/agents}/README.md +0 -0
- /package/{autopm/.claude/agents/devops → packages/plugin-devops/agents}/README.md +0 -0
- /package/{autopm/.claude/agents/devops → packages/plugin-devops/agents}/azure-devops-specialist.md +0 -0
- /package/{autopm/.claude/agents/devops → packages/plugin-devops/agents}/docker-containerization-expert.md +0 -0
- /package/{autopm/.claude/agents/devops → packages/plugin-devops/agents}/mcp-context-manager.md +0 -0
- /package/{autopm/.claude/agents/devops → packages/plugin-devops/agents}/observability-engineer.md +0 -0
- /package/{autopm/.claude/agents/devops → packages/plugin-devops/agents}/ssh-operations-expert.md +0 -0
- /package/{autopm/.claude/agents/devops → packages/plugin-devops/agents}/traefik-proxy-expert.md +0 -0
- /package/{autopm/.claude/commands/github → packages/plugin-devops/commands}/workflow-create.md +0 -0
- /package/{autopm/.claude → packages/plugin-devops}/rules/ci-cd-kubernetes-strategy.md +0 -0
- /package/{autopm/.claude → packages/plugin-devops}/rules/devops-troubleshooting-playbook.md +0 -0
- /package/{autopm/.claude → packages/plugin-devops}/rules/docker-first-development.md +0 -0
- /package/{autopm/.claude/agents/frameworks → packages/plugin-frameworks/agents}/README.md +0 -0
- /package/{autopm/.claude/agents/frameworks → packages/plugin-frameworks/agents}/nats-messaging-expert.md +0 -0
- /package/{autopm/.claude/agents/frameworks → packages/plugin-frameworks/agents}/react-ui-expert.md +0 -0
- /package/{autopm/.claude/agents/frameworks → packages/plugin-frameworks/agents}/ux-design-expert.md +0 -0
- /package/{autopm/.claude/commands/react → packages/plugin-frameworks/commands}/app-scaffold.md +0 -0
- /package/{autopm/.claude/commands/ui → packages/plugin-frameworks/commands}/tailwind-system.md +0 -0
- /package/{autopm/.claude → packages/plugin-frameworks}/rules/ui-development-standards.md +0 -0
- /package/{autopm/.claude → packages/plugin-frameworks}/rules/ui-framework-rules.md +0 -0
- /package/{autopm/.claude/agents/languages → packages/plugin-languages/agents}/README.md +0 -0
- /package/{autopm/.claude/agents/languages → packages/plugin-languages/agents}/bash-scripting-expert.md +0 -0
- /package/{autopm/.claude/agents/languages → packages/plugin-languages/agents}/javascript-frontend-engineer.md +0 -0
- /package/{autopm/.claude/agents/languages → packages/plugin-languages/agents}/nodejs-backend-engineer.md +0 -0
- /package/{autopm/.claude/agents/languages → packages/plugin-languages/agents}/python-backend-engineer.md +0 -0
- /package/{autopm/.claude/agents/languages → packages/plugin-languages/agents}/python-backend-expert.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/COMMANDS.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/COMMAND_MAPPING.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/INTEGRATION_FIX.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/README.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/active-work.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/aliases.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/blocked-items.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/clean.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/docs-query.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/feature-decompose.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/feature-list.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/feature-new.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/feature-show.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/feature-start.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/fix-integration-example.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/help.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/import-us.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/init.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/next-task.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/search.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/sprint-status.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/standup.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/sync-all.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-analyze.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-close.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-edit.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-list.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-new.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-reopen.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-show.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-start.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-status.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/task-sync.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/us-edit.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/us-list.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/us-new.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/us-parse.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/us-show.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/us-status.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/validate.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/commands/azure/work-item-sync.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/blocked.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/clean.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/context-create.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/context-prime.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/context-update.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/context.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-close.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-decompose.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-edit.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-list.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-merge.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-oneshot.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-refresh.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-show.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-split.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-start.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-status.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-sync-modular.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-sync-original.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/epic-sync.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/help.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/import.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/in-progress.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/init.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/issue-analyze.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/issue-close.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/issue-edit.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/issue-reopen.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/issue-show.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/issue-start.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/issue-status.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/issue-sync.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/next.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/prd-edit.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/prd-list.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/prd-new.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/prd-parse.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/prd-status.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/search.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/standup.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/status.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/sync.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/test-reference-update.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/validate.md +0 -0
- /package/{autopm/.claude/commands/pm → packages/plugin-pm/commands}/what-next.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/analytics.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/blocked.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/blocked.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/clean.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/context-create.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/context-prime.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/context-update.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/context.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-close.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-edit.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-list.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-list.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-show.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-show.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-split.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-start/epic-start.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-start/epic-start.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-status.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-status.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-sync/README.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-sync/create-epic-issue.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-sync/create-task-issues.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-sync/update-epic-file.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-sync/update-references.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/epic-sync.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/help.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/help.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/in-progress.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/in-progress.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/init.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/init.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/issue-close.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/issue-edit.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/issue-show.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/issue-start.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/issue-sync/format-comment.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/issue-sync/gather-updates.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/issue-sync/post-comment.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/issue-sync/preflight-validation.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/issue-sync/update-frontmatter.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/lib/README.md +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/lib/epic-discovery.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/lib/logger.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/next.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/next.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/optimize.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/pr-create.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/pr-list.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/prd-list.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/prd-list.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/prd-new.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/prd-parse.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/prd-status.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/prd-status.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/release.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/search.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/search.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/standup.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/standup.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/status.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/status.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/sync-batch.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/sync.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/template-list.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/template-new.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/validate.js +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/validate.sh +0 -0
- /package/{autopm/.claude → packages/plugin-pm}/scripts/pm/what-next.js +0 -0
|
@@ -0,0 +1,1328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PluginManager - Core plugin management system
|
|
3
|
+
*
|
|
4
|
+
* Based on Context7 research:
|
|
5
|
+
* - Factory pattern from unplugin (/unjs/unplugin)
|
|
6
|
+
* - npm workspaces best practices (/websites/npmjs)
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Plugin discovery and loading
|
|
10
|
+
* - Dependency resolution with peer dependencies
|
|
11
|
+
* - Hook system for extensibility
|
|
12
|
+
* - Metadata-driven agent registration
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const os = require('os');
|
|
18
|
+
const { EventEmitter } = require('events');
|
|
19
|
+
|
|
20
|
+
class PluginManager extends EventEmitter {
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
super();
|
|
23
|
+
|
|
24
|
+
this.options = {
|
|
25
|
+
pluginDir: options.pluginDir || path.join(process.cwd(), 'node_modules'),
|
|
26
|
+
agentDir: options.agentDir || path.join(process.cwd(), '.claude', 'agents'),
|
|
27
|
+
scopePrefix: options.scopePrefix || '@claudeautopm',
|
|
28
|
+
minCoreVersion: options.minCoreVersion || '2.8.0',
|
|
29
|
+
projectRoot: options.projectRoot || process.cwd(),
|
|
30
|
+
...options
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Plugin registry
|
|
34
|
+
this.plugins = new Map();
|
|
35
|
+
this.agents = new Map();
|
|
36
|
+
this.hooks = new Map();
|
|
37
|
+
|
|
38
|
+
// State
|
|
39
|
+
this.initialized = false;
|
|
40
|
+
this.loadedPlugins = new Set();
|
|
41
|
+
|
|
42
|
+
// Registry file location
|
|
43
|
+
this.registryPath = path.join(
|
|
44
|
+
os.homedir(),
|
|
45
|
+
'.claudeautopm',
|
|
46
|
+
'plugins',
|
|
47
|
+
'registry.json'
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Load persistent registry
|
|
51
|
+
this.registry = this.loadRegistry();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Load plugin registry from disk
|
|
56
|
+
* Based on npm workspaces pattern - maintains state across sessions
|
|
57
|
+
*/
|
|
58
|
+
loadRegistry() {
|
|
59
|
+
try {
|
|
60
|
+
const registryDir = path.dirname(this.registryPath);
|
|
61
|
+
|
|
62
|
+
// Ensure directory exists
|
|
63
|
+
if (!fs.existsSync(registryDir)) {
|
|
64
|
+
fs.mkdirSync(registryDir, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (fs.existsSync(this.registryPath)) {
|
|
68
|
+
return JSON.parse(fs.readFileSync(this.registryPath, 'utf-8'));
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
this.emit('registry:load-error', { error: error.message });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Default registry structure
|
|
75
|
+
return {
|
|
76
|
+
version: '1.0.0',
|
|
77
|
+
installed: [],
|
|
78
|
+
enabled: [],
|
|
79
|
+
lastUpdate: new Date().toISOString()
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Save plugin registry to disk
|
|
85
|
+
*/
|
|
86
|
+
saveRegistry() {
|
|
87
|
+
try {
|
|
88
|
+
this.registry.lastUpdate = new Date().toISOString();
|
|
89
|
+
|
|
90
|
+
const registryDir = path.dirname(this.registryPath);
|
|
91
|
+
if (!fs.existsSync(registryDir)) {
|
|
92
|
+
fs.mkdirSync(registryDir, { recursive: true });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
fs.writeFileSync(
|
|
96
|
+
this.registryPath,
|
|
97
|
+
JSON.stringify(this.registry, null, 2),
|
|
98
|
+
'utf-8'
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
this.emit('registry:saved');
|
|
102
|
+
} catch (error) {
|
|
103
|
+
this.emit('registry:save-error', { error: error.message });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Initialize the plugin system
|
|
109
|
+
* Discovers and validates all installed plugins
|
|
110
|
+
*/
|
|
111
|
+
async initialize() {
|
|
112
|
+
if (this.initialized) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.emit('init:start');
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
await this.discoverPlugins();
|
|
120
|
+
await this.validatePlugins();
|
|
121
|
+
|
|
122
|
+
this.initialized = true;
|
|
123
|
+
this.emit('init:complete', {
|
|
124
|
+
pluginCount: this.plugins.size,
|
|
125
|
+
agentCount: this.agents.size
|
|
126
|
+
});
|
|
127
|
+
} catch (error) {
|
|
128
|
+
this.emit('init:error', error);
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Discover all installed plugins in node_modules
|
|
135
|
+
* Based on npm workspaces pattern from Context7
|
|
136
|
+
*/
|
|
137
|
+
async discoverPlugins() {
|
|
138
|
+
const pluginPattern = `${this.options.scopePrefix}/plugin-`;
|
|
139
|
+
const nodeModulesPath = this.options.pluginDir;
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
// Check if scoped directory exists
|
|
143
|
+
const scopePath = path.join(nodeModulesPath, this.options.scopePrefix);
|
|
144
|
+
|
|
145
|
+
if (!fs.existsSync(scopePath)) {
|
|
146
|
+
this.emit('discover:no-plugins', { scopePath });
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const scopedPackages = fs.readdirSync(scopePath);
|
|
151
|
+
|
|
152
|
+
for (const packageName of scopedPackages) {
|
|
153
|
+
if (!packageName.startsWith('plugin-')) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const pluginPath = path.join(scopePath, packageName);
|
|
158
|
+
const pluginJsonPath = path.join(pluginPath, 'plugin.json');
|
|
159
|
+
|
|
160
|
+
if (!fs.existsSync(pluginJsonPath)) {
|
|
161
|
+
this.emit('discover:skip', {
|
|
162
|
+
package: packageName,
|
|
163
|
+
reason: 'No plugin.json found'
|
|
164
|
+
});
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
const metadata = JSON.parse(fs.readFileSync(pluginJsonPath, 'utf-8'));
|
|
170
|
+
const fullName = `${this.options.scopePrefix}/${packageName}`;
|
|
171
|
+
|
|
172
|
+
this.plugins.set(fullName, {
|
|
173
|
+
name: fullName,
|
|
174
|
+
path: pluginPath,
|
|
175
|
+
metadata,
|
|
176
|
+
loaded: false
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
this.emit('discover:found', { name: fullName, metadata });
|
|
180
|
+
} catch (error) {
|
|
181
|
+
this.emit('discover:error', {
|
|
182
|
+
package: packageName,
|
|
183
|
+
error: error.message
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} catch (error) {
|
|
188
|
+
this.emit('discover:error', { error: error.message });
|
|
189
|
+
throw new Error(`Plugin discovery failed: ${error.message}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Validate plugin compatibility with core version
|
|
195
|
+
* Uses peer dependency pattern from Context7 npm docs
|
|
196
|
+
*/
|
|
197
|
+
async validatePlugins() {
|
|
198
|
+
const coreVersion = this.getCoreVersion();
|
|
199
|
+
|
|
200
|
+
for (const [name, plugin] of this.plugins.entries()) {
|
|
201
|
+
const { metadata } = plugin;
|
|
202
|
+
|
|
203
|
+
// Check compatibility
|
|
204
|
+
if (!this.isCompatible(coreVersion, metadata.compatibleWith)) {
|
|
205
|
+
this.emit('validate:incompatible', {
|
|
206
|
+
name,
|
|
207
|
+
required: metadata.compatibleWith,
|
|
208
|
+
current: coreVersion
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
plugin.compatible = false;
|
|
212
|
+
plugin.incompatibilityReason = `Requires core version ${metadata.compatibleWith}, but ${coreVersion} is installed`;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
plugin.compatible = true;
|
|
217
|
+
this.emit('validate:compatible', { name, metadata });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Load a specific plugin and register its agents
|
|
223
|
+
* Implements factory pattern from unplugin Context7 research
|
|
224
|
+
*/
|
|
225
|
+
async loadPlugin(pluginName) {
|
|
226
|
+
const plugin = this.plugins.get(pluginName);
|
|
227
|
+
|
|
228
|
+
if (!plugin) {
|
|
229
|
+
throw new Error(`Plugin not found: ${pluginName}`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (plugin.loaded) {
|
|
233
|
+
this.emit('load:already-loaded', { name: pluginName });
|
|
234
|
+
return plugin;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (!plugin.compatible) {
|
|
238
|
+
throw new Error(`Plugin incompatible: ${plugin.incompatibilityReason}`);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
this.emit('load:start', { name: pluginName });
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
// Register agents from plugin metadata
|
|
245
|
+
await this.registerAgents(plugin);
|
|
246
|
+
|
|
247
|
+
// Execute plugin hooks if defined
|
|
248
|
+
await this.executePluginHooks(plugin, 'onLoad');
|
|
249
|
+
|
|
250
|
+
plugin.loaded = true;
|
|
251
|
+
this.loadedPlugins.add(pluginName);
|
|
252
|
+
|
|
253
|
+
this.emit('load:complete', {
|
|
254
|
+
name: pluginName,
|
|
255
|
+
agentCount: plugin.metadata.agents.length
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
return plugin;
|
|
259
|
+
} catch (error) {
|
|
260
|
+
this.emit('load:error', { name: pluginName, error: error.message });
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Register agents from plugin metadata
|
|
267
|
+
*/
|
|
268
|
+
async registerAgents(plugin) {
|
|
269
|
+
const { metadata, path: pluginPath } = plugin;
|
|
270
|
+
|
|
271
|
+
for (const agentMeta of metadata.agents) {
|
|
272
|
+
const agentId = `${plugin.name}:${agentMeta.name}`;
|
|
273
|
+
const agentFilePath = path.join(pluginPath, agentMeta.file);
|
|
274
|
+
|
|
275
|
+
if (!fs.existsSync(agentFilePath)) {
|
|
276
|
+
this.emit('agent:missing', {
|
|
277
|
+
agentId,
|
|
278
|
+
path: agentFilePath
|
|
279
|
+
});
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
this.agents.set(agentId, {
|
|
284
|
+
id: agentId,
|
|
285
|
+
name: agentMeta.name,
|
|
286
|
+
plugin: plugin.name,
|
|
287
|
+
description: agentMeta.description,
|
|
288
|
+
tags: agentMeta.tags || [],
|
|
289
|
+
filePath: agentFilePath,
|
|
290
|
+
metadata: agentMeta
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
this.emit('agent:registered', {
|
|
294
|
+
agentId,
|
|
295
|
+
plugin: plugin.name
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Install plugin resources to project directories
|
|
302
|
+
* Supports: agents, commands, rules, hooks, scripts (Schema v2.0)
|
|
303
|
+
*/
|
|
304
|
+
async installPlugin(pluginName) {
|
|
305
|
+
const plugin = this.plugins.get(pluginName);
|
|
306
|
+
|
|
307
|
+
if (!plugin) {
|
|
308
|
+
throw new Error(`Plugin not found: ${pluginName}`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Ensure plugin is loaded
|
|
312
|
+
if (!plugin.loaded) {
|
|
313
|
+
await this.loadPlugin(pluginName);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
this.emit('install:start', { name: pluginName });
|
|
317
|
+
|
|
318
|
+
try {
|
|
319
|
+
const { metadata, path: pluginPath } = plugin;
|
|
320
|
+
const results = {
|
|
321
|
+
agents: [],
|
|
322
|
+
commands: [],
|
|
323
|
+
rules: [],
|
|
324
|
+
hooks: [],
|
|
325
|
+
scripts: []
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// Install agents (existing logic)
|
|
329
|
+
if (metadata.agents && metadata.agents.length > 0) {
|
|
330
|
+
results.agents = await this.installAgents(plugin, pluginPath);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Install commands (Schema v2.0)
|
|
334
|
+
if (metadata.commands && metadata.commands.length > 0) {
|
|
335
|
+
results.commands = await this.installCommands(plugin, pluginPath);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Install rules (Schema v2.0)
|
|
339
|
+
if (metadata.rules && metadata.rules.length > 0) {
|
|
340
|
+
results.rules = await this.installRules(plugin, pluginPath);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Install hooks (Schema v2.0)
|
|
344
|
+
if (metadata.hooks && metadata.hooks.length > 0) {
|
|
345
|
+
results.hooks = await this.installHooks(plugin, pluginPath);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Install scripts (Schema v2.0)
|
|
349
|
+
if (metadata.scripts && metadata.scripts.length > 0) {
|
|
350
|
+
results.scripts = await this.installScripts(plugin, pluginPath);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Update registry
|
|
354
|
+
const shortName = pluginName.replace(`${this.options.scopePrefix}/`, '');
|
|
355
|
+
if (!this.registry.installed.includes(shortName)) {
|
|
356
|
+
this.registry.installed.push(shortName);
|
|
357
|
+
}
|
|
358
|
+
if (!this.registry.enabled.includes(shortName)) {
|
|
359
|
+
this.registry.enabled.push(shortName);
|
|
360
|
+
}
|
|
361
|
+
this.saveRegistry();
|
|
362
|
+
|
|
363
|
+
this.emit('install:complete', {
|
|
364
|
+
name: pluginName,
|
|
365
|
+
results
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
return {
|
|
369
|
+
success: true,
|
|
370
|
+
pluginName: shortName,
|
|
371
|
+
displayName: metadata.displayName,
|
|
372
|
+
category: metadata.category,
|
|
373
|
+
agentsInstalled: results.agents.length,
|
|
374
|
+
commandsInstalled: results.commands.length,
|
|
375
|
+
rulesInstalled: results.rules.length,
|
|
376
|
+
hooksInstalled: results.hooks.length,
|
|
377
|
+
scriptsInstalled: results.scripts.length,
|
|
378
|
+
agents: results.agents,
|
|
379
|
+
commands: results.commands,
|
|
380
|
+
rules: results.rules,
|
|
381
|
+
hooks: results.hooks,
|
|
382
|
+
scripts: results.scripts
|
|
383
|
+
};
|
|
384
|
+
} catch (error) {
|
|
385
|
+
this.emit('install:error', {
|
|
386
|
+
name: pluginName,
|
|
387
|
+
error: error.message
|
|
388
|
+
});
|
|
389
|
+
throw error;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Install agents from plugin
|
|
395
|
+
*/
|
|
396
|
+
async installAgents(plugin, pluginPath) {
|
|
397
|
+
const { metadata } = plugin;
|
|
398
|
+
const category = metadata.category;
|
|
399
|
+
const targetDir = path.join(this.options.agentDir, category);
|
|
400
|
+
|
|
401
|
+
// Create category directory if it doesn't exist
|
|
402
|
+
if (!fs.existsSync(targetDir)) {
|
|
403
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const installed = [];
|
|
407
|
+
|
|
408
|
+
for (const agent of this.agents.values()) {
|
|
409
|
+
if (agent.plugin !== plugin.name) continue;
|
|
410
|
+
|
|
411
|
+
const targetPath = path.join(targetDir, path.basename(agent.filePath));
|
|
412
|
+
|
|
413
|
+
// Skip if already exists
|
|
414
|
+
if (fs.existsSync(targetPath)) {
|
|
415
|
+
this.emit('install:skip', {
|
|
416
|
+
type: 'agent',
|
|
417
|
+
name: agent.name,
|
|
418
|
+
reason: 'Already exists'
|
|
419
|
+
});
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
fs.copyFileSync(agent.filePath, targetPath);
|
|
424
|
+
installed.push({
|
|
425
|
+
name: agent.name,
|
|
426
|
+
file: targetPath,
|
|
427
|
+
description: agent.description
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
this.emit('install:agent', {
|
|
431
|
+
agent: agent.name,
|
|
432
|
+
path: targetPath
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return installed;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Install commands from plugin
|
|
441
|
+
*/
|
|
442
|
+
async installCommands(plugin, pluginPath) {
|
|
443
|
+
const { metadata } = plugin;
|
|
444
|
+
const targetDir = path.join(this.options.projectRoot, '.claude', 'commands');
|
|
445
|
+
|
|
446
|
+
// Create commands directory if it doesn't exist
|
|
447
|
+
if (!fs.existsSync(targetDir)) {
|
|
448
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const installed = [];
|
|
452
|
+
|
|
453
|
+
for (const command of metadata.commands) {
|
|
454
|
+
const sourcePath = path.join(pluginPath, command.file);
|
|
455
|
+
const targetPath = path.join(targetDir, path.basename(command.file));
|
|
456
|
+
|
|
457
|
+
if (!fs.existsSync(sourcePath)) {
|
|
458
|
+
this.emit('install:missing', {
|
|
459
|
+
type: 'command',
|
|
460
|
+
name: command.name,
|
|
461
|
+
path: sourcePath
|
|
462
|
+
});
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Skip if already exists
|
|
467
|
+
if (fs.existsSync(targetPath)) {
|
|
468
|
+
this.emit('install:skip', {
|
|
469
|
+
type: 'command',
|
|
470
|
+
name: command.name,
|
|
471
|
+
reason: 'Already exists'
|
|
472
|
+
});
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
477
|
+
installed.push({
|
|
478
|
+
name: command.name,
|
|
479
|
+
file: targetPath,
|
|
480
|
+
description: command.description
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
this.emit('install:command', {
|
|
484
|
+
command: command.name,
|
|
485
|
+
path: targetPath
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return installed;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Install rules from plugin
|
|
494
|
+
*/
|
|
495
|
+
async installRules(plugin, pluginPath) {
|
|
496
|
+
const { metadata } = plugin;
|
|
497
|
+
const targetDir = path.join(this.options.projectRoot, '.claude', 'rules');
|
|
498
|
+
|
|
499
|
+
// Create rules directory if it doesn't exist
|
|
500
|
+
if (!fs.existsSync(targetDir)) {
|
|
501
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const installed = [];
|
|
505
|
+
|
|
506
|
+
for (const rule of metadata.rules) {
|
|
507
|
+
const sourcePath = path.join(pluginPath, rule.file);
|
|
508
|
+
const targetPath = path.join(targetDir, path.basename(rule.file));
|
|
509
|
+
|
|
510
|
+
if (!fs.existsSync(sourcePath)) {
|
|
511
|
+
this.emit('install:missing', {
|
|
512
|
+
type: 'rule',
|
|
513
|
+
name: rule.name,
|
|
514
|
+
path: sourcePath
|
|
515
|
+
});
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Skip if already exists
|
|
520
|
+
if (fs.existsSync(targetPath)) {
|
|
521
|
+
this.emit('install:skip', {
|
|
522
|
+
type: 'rule',
|
|
523
|
+
name: rule.name,
|
|
524
|
+
reason: 'Already exists'
|
|
525
|
+
});
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
530
|
+
installed.push({
|
|
531
|
+
name: rule.name,
|
|
532
|
+
file: targetPath,
|
|
533
|
+
priority: rule.priority,
|
|
534
|
+
description: rule.description
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
this.emit('install:rule', {
|
|
538
|
+
rule: rule.name,
|
|
539
|
+
priority: rule.priority,
|
|
540
|
+
path: targetPath
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return installed;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Install hooks from plugin
|
|
549
|
+
* Supports both single-file and dual-language hooks
|
|
550
|
+
*/
|
|
551
|
+
async installHooks(plugin, pluginPath) {
|
|
552
|
+
const { metadata } = plugin;
|
|
553
|
+
const targetDir = path.join(this.options.projectRoot, '.claude', 'hooks');
|
|
554
|
+
|
|
555
|
+
// Create hooks directory if it doesn't exist
|
|
556
|
+
if (!fs.existsSync(targetDir)) {
|
|
557
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const installed = [];
|
|
561
|
+
|
|
562
|
+
for (const hook of metadata.hooks) {
|
|
563
|
+
const files = hook.dual && hook.files ? hook.files : [hook.file];
|
|
564
|
+
const installedFiles = [];
|
|
565
|
+
|
|
566
|
+
for (const file of files) {
|
|
567
|
+
const sourcePath = path.join(pluginPath, file);
|
|
568
|
+
const targetPath = path.join(targetDir, path.basename(file));
|
|
569
|
+
|
|
570
|
+
if (!fs.existsSync(sourcePath)) {
|
|
571
|
+
this.emit('install:missing', {
|
|
572
|
+
type: 'hook',
|
|
573
|
+
name: hook.name,
|
|
574
|
+
file: file,
|
|
575
|
+
path: sourcePath
|
|
576
|
+
});
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// Skip if already exists
|
|
581
|
+
if (fs.existsSync(targetPath)) {
|
|
582
|
+
this.emit('install:skip', {
|
|
583
|
+
type: 'hook',
|
|
584
|
+
name: hook.name,
|
|
585
|
+
file: file,
|
|
586
|
+
reason: 'Already exists'
|
|
587
|
+
});
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
592
|
+
|
|
593
|
+
// Make executable if shell script
|
|
594
|
+
if (file.endsWith('.sh')) {
|
|
595
|
+
fs.chmodSync(targetPath, 0o755);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
installedFiles.push(targetPath);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (installedFiles.length > 0) {
|
|
602
|
+
installed.push({
|
|
603
|
+
name: hook.name,
|
|
604
|
+
type: hook.type,
|
|
605
|
+
files: installedFiles,
|
|
606
|
+
dual: hook.dual || false,
|
|
607
|
+
blocking: hook.blocking,
|
|
608
|
+
description: hook.description
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
this.emit('install:hook', {
|
|
612
|
+
hook: hook.name,
|
|
613
|
+
type: hook.type,
|
|
614
|
+
paths: installedFiles,
|
|
615
|
+
dual: hook.dual
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return installed;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Install scripts from plugin
|
|
625
|
+
* Supports both single scripts and script collections (subdirectories)
|
|
626
|
+
*/
|
|
627
|
+
async installScripts(plugin, pluginPath) {
|
|
628
|
+
const { metadata } = plugin;
|
|
629
|
+
const targetBaseDir = path.join(this.options.projectRoot, 'scripts');
|
|
630
|
+
|
|
631
|
+
// Create scripts directory if it doesn't exist
|
|
632
|
+
if (!fs.existsSync(targetBaseDir)) {
|
|
633
|
+
fs.mkdirSync(targetBaseDir, { recursive: true });
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
const installed = [];
|
|
637
|
+
|
|
638
|
+
for (const script of metadata.scripts) {
|
|
639
|
+
// Handle script collection (subdirectory)
|
|
640
|
+
if (script.subdirectory && script.files) {
|
|
641
|
+
const installedFiles = [];
|
|
642
|
+
// Remove 'scripts/' prefix from subdirectory if present
|
|
643
|
+
const cleanSubdir = script.subdirectory.replace(/^scripts\//, '');
|
|
644
|
+
const targetDir = path.join(targetBaseDir, cleanSubdir);
|
|
645
|
+
|
|
646
|
+
// Create subdirectory
|
|
647
|
+
if (!fs.existsSync(targetDir)) {
|
|
648
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
for (const file of script.files) {
|
|
652
|
+
const sourcePath = path.join(pluginPath, script.subdirectory, file);
|
|
653
|
+
const targetPath = path.join(targetDir, file);
|
|
654
|
+
|
|
655
|
+
if (!fs.existsSync(sourcePath)) {
|
|
656
|
+
this.emit('install:missing', {
|
|
657
|
+
type: 'script',
|
|
658
|
+
name: script.name,
|
|
659
|
+
file: file,
|
|
660
|
+
path: sourcePath
|
|
661
|
+
});
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// Skip if already exists
|
|
666
|
+
if (fs.existsSync(targetPath)) {
|
|
667
|
+
this.emit('install:skip', {
|
|
668
|
+
type: 'script',
|
|
669
|
+
name: script.name,
|
|
670
|
+
file: file,
|
|
671
|
+
reason: 'Already exists'
|
|
672
|
+
});
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
677
|
+
|
|
678
|
+
// Make executable if shell script
|
|
679
|
+
if (file.endsWith('.sh')) {
|
|
680
|
+
fs.chmodSync(targetPath, 0o755);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
installedFiles.push(targetPath);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
if (installedFiles.length > 0) {
|
|
687
|
+
installed.push({
|
|
688
|
+
name: script.name,
|
|
689
|
+
type: script.type,
|
|
690
|
+
subdirectory: script.subdirectory,
|
|
691
|
+
files: installedFiles,
|
|
692
|
+
exported: script.exported,
|
|
693
|
+
description: script.description
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
this.emit('install:script-collection', {
|
|
697
|
+
script: script.name,
|
|
698
|
+
subdirectory: script.subdirectory,
|
|
699
|
+
paths: installedFiles
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
// Handle single script
|
|
704
|
+
else if (script.file) {
|
|
705
|
+
const sourcePath = path.join(pluginPath, script.file);
|
|
706
|
+
// Remove 'scripts/' prefix from file path if present
|
|
707
|
+
const cleanFile = script.file.replace(/^scripts\//, '');
|
|
708
|
+
const targetPath = path.join(targetBaseDir, cleanFile);
|
|
709
|
+
|
|
710
|
+
if (!fs.existsSync(sourcePath)) {
|
|
711
|
+
this.emit('install:missing', {
|
|
712
|
+
type: 'script',
|
|
713
|
+
name: script.name,
|
|
714
|
+
path: sourcePath
|
|
715
|
+
});
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// Create subdirectories if needed (e.g., lib/)
|
|
720
|
+
const targetDir = path.dirname(targetPath);
|
|
721
|
+
if (!fs.existsSync(targetDir)) {
|
|
722
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// Skip if already exists
|
|
726
|
+
if (fs.existsSync(targetPath)) {
|
|
727
|
+
this.emit('install:skip', {
|
|
728
|
+
type: 'script',
|
|
729
|
+
name: script.name,
|
|
730
|
+
reason: 'Already exists'
|
|
731
|
+
});
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
736
|
+
|
|
737
|
+
// Make executable if shell script
|
|
738
|
+
if (script.file.endsWith('.sh')) {
|
|
739
|
+
fs.chmodSync(targetPath, 0o755);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
installed.push({
|
|
743
|
+
name: script.name,
|
|
744
|
+
type: script.type,
|
|
745
|
+
file: targetPath,
|
|
746
|
+
exported: script.exported,
|
|
747
|
+
description: script.description
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
this.emit('install:script', {
|
|
751
|
+
script: script.name,
|
|
752
|
+
path: targetPath
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
return installed;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Uninstall plugin - remove all resources and update registry
|
|
762
|
+
* Supports: agents, commands, rules, hooks, scripts (Schema v2.0)
|
|
763
|
+
*/
|
|
764
|
+
async uninstallPlugin(pluginName) {
|
|
765
|
+
const fullName = pluginName.includes('/') ? pluginName : `${this.options.scopePrefix}/${pluginName}`;
|
|
766
|
+
const plugin = this.plugins.get(fullName);
|
|
767
|
+
|
|
768
|
+
if (!plugin) {
|
|
769
|
+
throw new Error(`Plugin not found: ${pluginName}`);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
this.emit('uninstall:start', { name: fullName });
|
|
773
|
+
|
|
774
|
+
try {
|
|
775
|
+
const { metadata } = plugin;
|
|
776
|
+
const results = {
|
|
777
|
+
agents: [],
|
|
778
|
+
commands: [],
|
|
779
|
+
rules: [],
|
|
780
|
+
hooks: [],
|
|
781
|
+
scripts: []
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
// Remove agents
|
|
785
|
+
if (metadata.agents && metadata.agents.length > 0) {
|
|
786
|
+
const targetDir = path.join(this.options.agentDir, metadata.category);
|
|
787
|
+
for (const agent of metadata.agents) {
|
|
788
|
+
const targetPath = path.join(targetDir, path.basename(agent.file));
|
|
789
|
+
if (fs.existsSync(targetPath)) {
|
|
790
|
+
fs.unlinkSync(targetPath);
|
|
791
|
+
results.agents.push(agent.name);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// Remove empty category directory
|
|
796
|
+
if (fs.existsSync(targetDir)) {
|
|
797
|
+
const remaining = fs.readdirSync(targetDir);
|
|
798
|
+
if (remaining.length === 0) {
|
|
799
|
+
fs.rmdirSync(targetDir);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
// Remove commands
|
|
805
|
+
if (metadata.commands && metadata.commands.length > 0) {
|
|
806
|
+
const targetDir = path.join(this.options.projectRoot, '.claude', 'commands');
|
|
807
|
+
for (const command of metadata.commands) {
|
|
808
|
+
const targetPath = path.join(targetDir, path.basename(command.file));
|
|
809
|
+
if (fs.existsSync(targetPath)) {
|
|
810
|
+
fs.unlinkSync(targetPath);
|
|
811
|
+
results.commands.push(command.name);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// Remove rules
|
|
817
|
+
if (metadata.rules && metadata.rules.length > 0) {
|
|
818
|
+
const targetDir = path.join(this.options.projectRoot, '.claude', 'rules');
|
|
819
|
+
for (const rule of metadata.rules) {
|
|
820
|
+
const targetPath = path.join(targetDir, path.basename(rule.file));
|
|
821
|
+
if (fs.existsSync(targetPath)) {
|
|
822
|
+
fs.unlinkSync(targetPath);
|
|
823
|
+
results.rules.push(rule.name);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// Remove hooks
|
|
829
|
+
if (metadata.hooks && metadata.hooks.length > 0) {
|
|
830
|
+
const targetDir = path.join(this.options.projectRoot, '.claude', 'hooks');
|
|
831
|
+
for (const hook of metadata.hooks) {
|
|
832
|
+
const files = hook.dual && hook.files ? hook.files : [hook.file];
|
|
833
|
+
for (const file of files) {
|
|
834
|
+
const targetPath = path.join(targetDir, path.basename(file));
|
|
835
|
+
if (fs.existsSync(targetPath)) {
|
|
836
|
+
fs.unlinkSync(targetPath);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
results.hooks.push(hook.name);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// Remove scripts
|
|
844
|
+
if (metadata.scripts && metadata.scripts.length > 0) {
|
|
845
|
+
const targetBaseDir = path.join(this.options.projectRoot, 'scripts');
|
|
846
|
+
for (const script of metadata.scripts) {
|
|
847
|
+
if (script.subdirectory && script.files) {
|
|
848
|
+
// Remove 'scripts/' prefix from subdirectory if present
|
|
849
|
+
const cleanSubdir = script.subdirectory.replace(/^scripts\//, '');
|
|
850
|
+
const targetDir = path.join(targetBaseDir, cleanSubdir);
|
|
851
|
+
for (const file of script.files) {
|
|
852
|
+
const targetPath = path.join(targetDir, file);
|
|
853
|
+
if (fs.existsSync(targetPath)) {
|
|
854
|
+
fs.unlinkSync(targetPath);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// Remove empty subdirectory
|
|
859
|
+
if (fs.existsSync(targetDir)) {
|
|
860
|
+
const remaining = fs.readdirSync(targetDir);
|
|
861
|
+
if (remaining.length === 0) {
|
|
862
|
+
fs.rmdirSync(targetDir);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
} else if (script.file) {
|
|
866
|
+
// Remove 'scripts/' prefix from file path if present
|
|
867
|
+
const cleanFile = script.file.replace(/^scripts\//, '');
|
|
868
|
+
const targetPath = path.join(targetBaseDir, cleanFile);
|
|
869
|
+
if (fs.existsSync(targetPath)) {
|
|
870
|
+
fs.unlinkSync(targetPath);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
results.scripts.push(script.name);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// Update registry
|
|
878
|
+
const shortName = pluginName.replace(`${this.options.scopePrefix}/`, '');
|
|
879
|
+
this.registry.installed = this.registry.installed.filter(p => p !== shortName);
|
|
880
|
+
this.registry.enabled = this.registry.enabled.filter(p => p !== shortName);
|
|
881
|
+
this.saveRegistry();
|
|
882
|
+
|
|
883
|
+
this.emit('uninstall:complete', {
|
|
884
|
+
name: fullName,
|
|
885
|
+
results
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
return {
|
|
889
|
+
success: true,
|
|
890
|
+
pluginName: shortName,
|
|
891
|
+
agentsRemoved: results.agents.length,
|
|
892
|
+
commandsRemoved: results.commands.length,
|
|
893
|
+
rulesRemoved: results.rules.length,
|
|
894
|
+
hooksRemoved: results.hooks.length,
|
|
895
|
+
scriptsRemoved: results.scripts.length,
|
|
896
|
+
agents: results.agents,
|
|
897
|
+
commands: results.commands,
|
|
898
|
+
rules: results.rules,
|
|
899
|
+
hooks: results.hooks,
|
|
900
|
+
scripts: results.scripts
|
|
901
|
+
};
|
|
902
|
+
} catch (error) {
|
|
903
|
+
this.emit('uninstall:error', {
|
|
904
|
+
name: fullName,
|
|
905
|
+
error: error.message
|
|
906
|
+
});
|
|
907
|
+
throw error;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Get list of installed plugins (from registry)
|
|
913
|
+
*/
|
|
914
|
+
getInstalledPlugins() {
|
|
915
|
+
return this.registry.installed;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Get list of enabled plugins (from registry)
|
|
920
|
+
*/
|
|
921
|
+
getEnabledPlugins() {
|
|
922
|
+
return this.registry.enabled;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Check if plugin is installed
|
|
927
|
+
*/
|
|
928
|
+
isInstalled(pluginName) {
|
|
929
|
+
const shortName = pluginName.replace(`${this.options.scopePrefix}/`, '').replace('plugin-', '');
|
|
930
|
+
return this.registry.installed.some(p => p === shortName || p === `plugin-${shortName}`);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Check if plugin is enabled
|
|
935
|
+
*/
|
|
936
|
+
isEnabled(pluginName) {
|
|
937
|
+
const shortName = pluginName.replace(`${this.options.scopePrefix}/`, '').replace('plugin-', '');
|
|
938
|
+
return this.registry.enabled.some(p => p === shortName || p === `plugin-${shortName}`);
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Enable plugin
|
|
943
|
+
*/
|
|
944
|
+
enablePlugin(pluginName) {
|
|
945
|
+
const shortName = pluginName.replace(`${this.options.scopePrefix}/`, '');
|
|
946
|
+
|
|
947
|
+
if (!this.isInstalled(shortName)) {
|
|
948
|
+
throw new Error(`Plugin not installed: ${pluginName}`);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
if (!this.registry.enabled.includes(shortName)) {
|
|
952
|
+
this.registry.enabled.push(shortName);
|
|
953
|
+
this.saveRegistry();
|
|
954
|
+
this.emit('plugin:enabled', { name: shortName });
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Disable plugin
|
|
960
|
+
*/
|
|
961
|
+
disablePlugin(pluginName) {
|
|
962
|
+
const shortName = pluginName.replace(`${this.options.scopePrefix}/`, '');
|
|
963
|
+
this.registry.enabled = this.registry.enabled.filter(p => p !== shortName);
|
|
964
|
+
this.saveRegistry();
|
|
965
|
+
this.emit('plugin:disabled', { name: shortName });
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Search plugins by keyword
|
|
970
|
+
*/
|
|
971
|
+
async searchPlugins(keyword) {
|
|
972
|
+
await this.initialize();
|
|
973
|
+
|
|
974
|
+
const lowerKeyword = keyword.toLowerCase();
|
|
975
|
+
const results = [];
|
|
976
|
+
|
|
977
|
+
for (const [name, plugin] of this.plugins.entries()) {
|
|
978
|
+
const { metadata } = plugin;
|
|
979
|
+
|
|
980
|
+
// Search in name
|
|
981
|
+
if (name.toLowerCase().includes(lowerKeyword)) {
|
|
982
|
+
results.push(this.formatPluginForSearch(name, plugin));
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// Search in display name
|
|
987
|
+
if (metadata.displayName.toLowerCase().includes(lowerKeyword)) {
|
|
988
|
+
results.push(this.formatPluginForSearch(name, plugin));
|
|
989
|
+
continue;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// Search in description
|
|
993
|
+
if (metadata.description.toLowerCase().includes(lowerKeyword)) {
|
|
994
|
+
results.push(this.formatPluginForSearch(name, plugin));
|
|
995
|
+
continue;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// Search in keywords
|
|
999
|
+
if (metadata.keywords && metadata.keywords.some(k => k.toLowerCase().includes(lowerKeyword))) {
|
|
1000
|
+
results.push(this.formatPluginForSearch(name, plugin));
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
// Search in agent names
|
|
1005
|
+
if (metadata.agents.some(a => a.name.toLowerCase().includes(lowerKeyword))) {
|
|
1006
|
+
results.push(this.formatPluginForSearch(name, plugin));
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
return results;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Format plugin for search results
|
|
1016
|
+
*/
|
|
1017
|
+
formatPluginForSearch(name, plugin) {
|
|
1018
|
+
const shortName = name.replace(`${this.options.scopePrefix}/`, '');
|
|
1019
|
+
return {
|
|
1020
|
+
pluginName: shortName,
|
|
1021
|
+
displayName: plugin.metadata.displayName,
|
|
1022
|
+
description: plugin.metadata.description,
|
|
1023
|
+
category: plugin.metadata.category,
|
|
1024
|
+
agents: plugin.metadata.agents,
|
|
1025
|
+
keywords: plugin.metadata.keywords || []
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Get plugin info with status
|
|
1031
|
+
*/
|
|
1032
|
+
async getPluginInfo(pluginName) {
|
|
1033
|
+
const fullName = pluginName.includes('/') ? pluginName : `${this.options.scopePrefix}/${pluginName}`;
|
|
1034
|
+
|
|
1035
|
+
// Ensure plugin is discovered
|
|
1036
|
+
if (!this.initialized) {
|
|
1037
|
+
await this.initialize();
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
const plugin = this.plugins.get(fullName);
|
|
1041
|
+
|
|
1042
|
+
if (!plugin) {
|
|
1043
|
+
throw new Error(`Plugin not found: ${pluginName}`);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
const shortName = fullName.replace(`${this.options.scopePrefix}/`, '');
|
|
1047
|
+
|
|
1048
|
+
return {
|
|
1049
|
+
...plugin.metadata,
|
|
1050
|
+
pluginName: shortName,
|
|
1051
|
+
path: plugin.path,
|
|
1052
|
+
installed: this.isInstalled(shortName),
|
|
1053
|
+
enabled: this.isEnabled(shortName),
|
|
1054
|
+
compatible: plugin.compatible
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Load plugin metadata (for CLI compatibility)
|
|
1060
|
+
*/
|
|
1061
|
+
async loadPluginMetadata(pluginName) {
|
|
1062
|
+
const fullName = pluginName.includes('/') ? pluginName : `${this.options.scopePrefix}/${pluginName}`;
|
|
1063
|
+
|
|
1064
|
+
if (!this.initialized) {
|
|
1065
|
+
await this.initialize();
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
const plugin = this.plugins.get(fullName);
|
|
1069
|
+
|
|
1070
|
+
if (!plugin) {
|
|
1071
|
+
throw new Error(`Plugin not found: ${pluginName}`);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
return {
|
|
1075
|
+
...plugin.metadata,
|
|
1076
|
+
pluginName: pluginName.replace(`${this.options.scopePrefix}/`, ''),
|
|
1077
|
+
path: plugin.path
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* List all available plugins
|
|
1083
|
+
*/
|
|
1084
|
+
listPlugins(options = {}) {
|
|
1085
|
+
const {
|
|
1086
|
+
loaded = null,
|
|
1087
|
+
compatible = null,
|
|
1088
|
+
category = null
|
|
1089
|
+
} = options;
|
|
1090
|
+
|
|
1091
|
+
let plugins = Array.from(this.plugins.values());
|
|
1092
|
+
|
|
1093
|
+
// Apply filters
|
|
1094
|
+
if (loaded !== null) {
|
|
1095
|
+
plugins = plugins.filter(p => p.loaded === loaded);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
if (compatible !== null) {
|
|
1099
|
+
plugins = plugins.filter(p => p.compatible === compatible);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
if (category !== null) {
|
|
1103
|
+
plugins = plugins.filter(p => p.metadata.category === category);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
return plugins.map(p => ({
|
|
1107
|
+
name: p.name,
|
|
1108
|
+
displayName: p.metadata.displayName,
|
|
1109
|
+
description: p.metadata.description,
|
|
1110
|
+
category: p.metadata.category,
|
|
1111
|
+
agentCount: p.metadata.agents.length,
|
|
1112
|
+
loaded: p.loaded,
|
|
1113
|
+
compatible: p.compatible,
|
|
1114
|
+
version: p.metadata.version
|
|
1115
|
+
}));
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* List all registered agents
|
|
1120
|
+
*/
|
|
1121
|
+
listAgents(options = {}) {
|
|
1122
|
+
const { plugin = null, tags = null } = options;
|
|
1123
|
+
|
|
1124
|
+
let agents = Array.from(this.agents.values());
|
|
1125
|
+
|
|
1126
|
+
// Apply filters
|
|
1127
|
+
if (plugin) {
|
|
1128
|
+
agents = agents.filter(a => a.plugin === plugin);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
if (tags && tags.length > 0) {
|
|
1132
|
+
agents = agents.filter(a =>
|
|
1133
|
+
tags.some(tag => a.tags.includes(tag))
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
return agents.map(a => ({
|
|
1138
|
+
id: a.id,
|
|
1139
|
+
name: a.name,
|
|
1140
|
+
plugin: a.plugin,
|
|
1141
|
+
description: a.description,
|
|
1142
|
+
tags: a.tags,
|
|
1143
|
+
filePath: a.filePath
|
|
1144
|
+
}));
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* Register a hook for plugin extensibility
|
|
1149
|
+
* Based on unplugin hooks pattern
|
|
1150
|
+
*/
|
|
1151
|
+
registerHook(hookName, handler) {
|
|
1152
|
+
if (!this.hooks.has(hookName)) {
|
|
1153
|
+
this.hooks.set(hookName, []);
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
this.hooks.get(hookName).push(handler);
|
|
1157
|
+
|
|
1158
|
+
this.emit('hook:registered', { hookName });
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Execute plugin hooks
|
|
1163
|
+
*/
|
|
1164
|
+
async executePluginHooks(plugin, hookName, data = {}) {
|
|
1165
|
+
const hooks = this.hooks.get(hookName) || [];
|
|
1166
|
+
|
|
1167
|
+
for (const hook of hooks) {
|
|
1168
|
+
try {
|
|
1169
|
+
await hook(plugin, data);
|
|
1170
|
+
} catch (error) {
|
|
1171
|
+
this.emit('hook:error', {
|
|
1172
|
+
hookName,
|
|
1173
|
+
plugin: plugin.name,
|
|
1174
|
+
error: error.message
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Get core version from package.json
|
|
1182
|
+
*/
|
|
1183
|
+
getCoreVersion() {
|
|
1184
|
+
try {
|
|
1185
|
+
const pkgPath = path.join(process.cwd(), 'package.json');
|
|
1186
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
1187
|
+
return pkg.version || this.options.minCoreVersion;
|
|
1188
|
+
} catch {
|
|
1189
|
+
return this.options.minCoreVersion;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Check version compatibility
|
|
1195
|
+
* Supports semver range syntax (>=, ^, ~)
|
|
1196
|
+
*/
|
|
1197
|
+
isCompatible(currentVersion, requiredVersion) {
|
|
1198
|
+
// Simple implementation - can be enhanced with semver library
|
|
1199
|
+
const cleanRequired = requiredVersion.replace(/[><=^~]/g, '');
|
|
1200
|
+
|
|
1201
|
+
if (requiredVersion.startsWith('>=')) {
|
|
1202
|
+
return this.compareVersions(currentVersion, cleanRequired) >= 0;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// Default: exact match or higher
|
|
1206
|
+
return this.compareVersions(currentVersion, cleanRequired) >= 0;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Compare semantic versions
|
|
1211
|
+
* Returns: -1 (less), 0 (equal), 1 (greater)
|
|
1212
|
+
*/
|
|
1213
|
+
compareVersions(v1, v2) {
|
|
1214
|
+
const parts1 = v1.split('.').map(Number);
|
|
1215
|
+
const parts2 = v2.split('.').map(Number);
|
|
1216
|
+
|
|
1217
|
+
for (let i = 0; i < 3; i++) {
|
|
1218
|
+
const p1 = parts1[i] || 0;
|
|
1219
|
+
const p2 = parts2[i] || 0;
|
|
1220
|
+
|
|
1221
|
+
if (p1 > p2) return 1;
|
|
1222
|
+
if (p1 < p2) return -1;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
return 0;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* Get plugin statistics
|
|
1230
|
+
*/
|
|
1231
|
+
getStats() {
|
|
1232
|
+
return {
|
|
1233
|
+
totalPlugins: this.plugins.size,
|
|
1234
|
+
loadedPlugins: this.loadedPlugins.size,
|
|
1235
|
+
totalAgents: this.agents.size,
|
|
1236
|
+
compatiblePlugins: Array.from(this.plugins.values())
|
|
1237
|
+
.filter(p => p.compatible).length,
|
|
1238
|
+
categories: Array.from(
|
|
1239
|
+
new Set(
|
|
1240
|
+
Array.from(this.plugins.values())
|
|
1241
|
+
.map(p => p.metadata.category)
|
|
1242
|
+
)
|
|
1243
|
+
)
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* Find which plugin contains a specific agent
|
|
1249
|
+
* @param {string} agentFileName - Agent file name (e.g., "react-ui-expert.md")
|
|
1250
|
+
* @returns {Object|null} - Plugin info or null if not found
|
|
1251
|
+
*/
|
|
1252
|
+
async findPluginForAgent(agentFileName) {
|
|
1253
|
+
// Ensure plugins are discovered
|
|
1254
|
+
if (!this.initialized) {
|
|
1255
|
+
await this.initialize();
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
// Normalize agent filename
|
|
1259
|
+
const normalizedName = agentFileName.endsWith('.md') ? agentFileName : `${agentFileName}.md`;
|
|
1260
|
+
|
|
1261
|
+
// Search through all plugins
|
|
1262
|
+
for (const [pluginName, plugin] of this.plugins.entries()) {
|
|
1263
|
+
const { metadata } = plugin;
|
|
1264
|
+
|
|
1265
|
+
// Skip if plugin has no agents
|
|
1266
|
+
if (!metadata.agents || !Array.isArray(metadata.agents)) {
|
|
1267
|
+
continue;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// Check if any agent in this plugin matches
|
|
1271
|
+
const matchingAgent = metadata.agents.find(agent => {
|
|
1272
|
+
const agentFile = path.basename(agent.file);
|
|
1273
|
+
return agentFile === normalizedName;
|
|
1274
|
+
});
|
|
1275
|
+
|
|
1276
|
+
if (matchingAgent) {
|
|
1277
|
+
const shortName = pluginName.replace(`${this.options.scopePrefix}/`, '');
|
|
1278
|
+
return {
|
|
1279
|
+
pluginName: shortName,
|
|
1280
|
+
fullPluginName: pluginName,
|
|
1281
|
+
displayName: metadata.displayName,
|
|
1282
|
+
category: metadata.category,
|
|
1283
|
+
agent: matchingAgent,
|
|
1284
|
+
installed: this.isInstalled(shortName),
|
|
1285
|
+
enabled: this.isEnabled(shortName)
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
return null;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Find plugins for multiple agents
|
|
1295
|
+
* @param {Array<string>} agentFileNames - Array of agent file names
|
|
1296
|
+
* @returns {Object} - Map of agents to plugin info, plus missing agents
|
|
1297
|
+
*/
|
|
1298
|
+
async findPluginsForAgents(agentFileNames) {
|
|
1299
|
+
const result = {
|
|
1300
|
+
found: new Map(), // agentFileName -> plugin info
|
|
1301
|
+
missing: [], // agents not found in any plugin
|
|
1302
|
+
byPlugin: new Map() // pluginName -> [agentFileNames]
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
for (const agentFileName of agentFileNames) {
|
|
1306
|
+
const pluginInfo = await this.findPluginForAgent(agentFileName);
|
|
1307
|
+
|
|
1308
|
+
if (pluginInfo) {
|
|
1309
|
+
result.found.set(agentFileName, pluginInfo);
|
|
1310
|
+
|
|
1311
|
+
// Group by plugin
|
|
1312
|
+
if (!result.byPlugin.has(pluginInfo.pluginName)) {
|
|
1313
|
+
result.byPlugin.set(pluginInfo.pluginName, {
|
|
1314
|
+
...pluginInfo,
|
|
1315
|
+
agents: []
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
result.byPlugin.get(pluginInfo.pluginName).agents.push(agentFileName);
|
|
1319
|
+
} else {
|
|
1320
|
+
result.missing.push(agentFileName);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
return result;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
module.exports = PluginManager;
|