mcp-efficiency-engine 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/.github/CODEOWNERS +40 -0
- package/.github/GITHUB_MCP_INTEGRATION.md +366 -0
- package/.github/ISSUE_TEMPLATE/bug.md +51 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +45 -0
- package/.github/ISSUE_TEMPLATE/question.md +18 -0
- package/.github/agents/backend.agent.md +18 -0
- package/.github/agents/community-manager.agent.md +18 -0
- package/.github/agents/dba.agent.md +18 -0
- package/.github/agents/frontend-agent.agent.md +18 -0
- package/.github/agents/github-repository-manager.agent.md +338 -0
- package/.github/agents/iot.agent.md +20 -0
- package/.github/agents/legacy.agent.md +18 -0
- package/.github/agents/rag-azure.agent.md +18 -0
- package/.github/agents/rag-local.agent.md +18 -0
- package/.github/agents/snapshot.agent.md +18 -0
- package/.github/agents/ux-ui.agent.md +18 -0
- package/.github/agents/wiki-agent.agent.md +23 -0
- package/.github/copilot-instructions.md +44 -0
- package/.github/instructions/always-on-optimization.instructions.md +54 -0
- package/.github/prompts/auto-route.prompt.md +33 -0
- package/.github/prompts/azure-rag.query.prompt.md +19 -0
- package/.github/prompts/backend.fix-bug.prompt.md +13 -0
- package/.github/prompts/cavecrew.prompt.md +16 -0
- package/.github/prompts/caveman-commit.prompt.md +14 -0
- package/.github/prompts/caveman-compress.prompt.md +15 -0
- package/.github/prompts/caveman-debug.prompt.md +13 -0
- package/.github/prompts/caveman-help.prompt.md +11 -0
- package/.github/prompts/caveman-review.prompt.md +15 -0
- package/.github/prompts/caveman-stats.prompt.md +11 -0
- package/.github/prompts/caveman.prompt.md +11 -0
- package/.github/prompts/community.post.prompt.md +14 -0
- package/.github/prompts/dba.query-review.prompt.md +15 -0
- package/.github/prompts/dev.fix-bug.prompt.md +13 -0
- package/.github/prompts/frontend.code.prompt.md +13 -0
- package/.github/prompts/legacy.impact-analysis.prompt.md +14 -0
- package/.github/prompts/project.kickoff-analysis.prompt.md +51 -0
- package/.github/prompts/rag.knowledge-answer.prompt.md +13 -0
- package/.github/prompts/token-saver-review.prompt.md +14 -0
- package/.github/prompts/ux-ui.review.prompt.md +14 -0
- package/.github/pull_request_template.md +71 -0
- package/.github/skills/ahorro-tokens/SKILL.md +36 -0
- package/.github/skills/azure-rag-enterprise/SKILL.md +24 -0
- package/.github/skills/backend-coding/SKILL.md +24 -0
- package/.github/skills/cavecrew/SKILL.md +17 -0
- package/.github/skills/caveman/SKILL.md +25 -0
- package/.github/skills/caveman-commit/SKILL.md +15 -0
- package/.github/skills/caveman-compress/SKILL.md +14 -0
- package/.github/skills/caveman-help/SKILL.md +19 -0
- package/.github/skills/caveman-mode/SKILL.md +43 -0
- package/.github/skills/caveman-review/SKILL.md +16 -0
- package/.github/skills/caveman-stats/SKILL.md +13 -0
- package/.github/skills/community-content/SKILL.md +22 -0
- package/.github/skills/database-analysis/SKILL.md +23 -0
- package/.github/skills/dev-coding/SKILL.md +24 -0
- package/.github/skills/frontend-coding/SKILL.md +24 -0
- package/.github/skills/human-in-the-loop/SKILL.md +47 -0
- package/.github/skills/iot-architecture/SKILL.md +22 -0
- package/.github/skills/legacy-migration/SKILL.md +22 -0
- package/.github/skills/rag-knowledge/SKILL.md +21 -0
- package/.github/skills/token-saver/SKILL.md +36 -0
- package/.github/skills/ux-ui-governance/SKILL.md +24 -0
- package/.github/skills/wiki-tools.json +24 -0
- package/.github/workflows/auto-devlog.yml +56 -0
- package/.github/workflows/auto-manage-issues.yml +64 -0
- package/.github/workflows/auto-sync.yml +54 -0
- package/.github/workflows/autodocs-sync.yml +114 -0
- package/.github/workflows/ci.yml +68 -0
- package/.github/workflows/pages.yml +59 -0
- package/.github/workflows/routing-evals.yml +59 -0
- package/.github/workflows/techriders-coverage-effective.yml +91 -0
- package/.vscode/mcp.json +44 -0
- package/AGENTS.md +160 -0
- package/ARCHITECTURE.md +57 -0
- package/FINAL_USAGE_GUIDE.md +106 -0
- package/LICENSE +21 -0
- package/README.md +385 -0
- package/README_WIKI.md +130 -0
- package/autodocs/README.md +22 -0
- package/autodocs/schema/wiki-node.schema.json +56 -0
- package/autolearning/feedback-loop.md +90 -0
- package/bin/install-host.js +326 -0
- package/bin/mcpee.js +116 -0
- package/context/repomix/repomix.config.json +20 -0
- package/memory/cross-memory-reasoning.md +17 -0
- package/memory/mempry-registry.yml +16 -0
- package/observability/evals/chat-token-usage-report.json +64 -0
- package/observability/evals/chat-token-usage-report.md +33 -0
- package/observability/evals/iteration-value-report.json +76 -0
- package/observability/evals/iteration-value-report.md +39 -0
- package/observability/evals/learning-loop-report.json +268 -0
- package/observability/evals/learning-loop-report.md +37 -0
- package/observability/evals/repo-intake-eval-cases.md +23 -0
- package/observability/evals/routing-eval-cases.json +68 -0
- package/observability/evals/routing-eval-cases.md +25 -0
- package/observability/evals/routing-eval-report.json +72 -0
- package/observability/evaluation.md +34 -0
- package/observability/logs/copilot-usage-ingest-report.json +13 -0
- package/observability/logs/iteration-metrics.jsonl +75 -0
- package/observability/logs/learning-feedback.jsonl +152 -0
- package/observability/logs/routing-decisions.jsonl +333 -0
- package/observability/logs/session/agent-pipeline-preflight-20260701-004146.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260701-005554.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260701-010351.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260704-145829.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260704-150021.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260704-154328.log +8 -0
- package/observability/logs/session/bye-20260629-221513.json +39 -0
- package/observability/logs/session/bye-20260629-221545.json +59 -0
- package/observability/logs/session/bye-20260629-222007.json +52 -0
- package/observability/logs/session/bye-20260629-222133.json +59 -0
- package/observability/logs/session/bye-20260629-222412.json +45 -0
- package/observability/logs/session/bye-20260629-223224.json +52 -0
- package/observability/logs/session/bye-20260629-224050.json +59 -0
- package/observability/logs/session/bye-20260630-105732.json +24 -0
- package/observability/logs/session/bye-20260630-211536.json +87 -0
- package/observability/logs/session/bye-20260630-223423.json +87 -0
- package/observability/logs/session/bye-20260630-232534.json +87 -0
- package/observability/logs/session/bye-20260701-003638.json +126 -0
- package/observability/logs/session/bye-20260701-003849.json +126 -0
- package/observability/logs/session/bye-20260701-004315.json +138 -0
- package/observability/logs/session/bye-20260701-004559.json +76 -0
- package/observability/logs/session/bye-20260701-005913.json +138 -0
- package/observability/logs/session/bye-20260701-010753.json +138 -0
- package/observability/logs/session/bye-20260703-194106.json +24 -0
- package/observability/logs/session/bye-20260703-233443.json +76 -0
- package/observability/logs/session/bye-20260703-233653.json +76 -0
- package/observability/logs/session/bye-20260704-150317.json +152 -0
- package/observability/logs/session/bye-20260704-150929.json +75 -0
- package/observability/logs/session/bye-20260704-151050.json +75 -0
- package/observability/logs/session/bye-20260705-115458.json +165 -0
- package/observability/logs/session/codegraph-status-20260701-004228.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-004310.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-005637.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-005908.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-010444.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-010747.log +39 -0
- package/observability/logs/session/codegraph-status-20260704-150137.log +26 -0
- package/observability/logs/session/codegraph-status-20260704-150313.log +28 -0
- package/observability/logs/session/codegraph-status-20260704-154445.log +26 -0
- package/observability/logs/session/codegraph-status-20260705-115454.log +27 -0
- package/observability/logs/session/codegraph-sync-20260701-004211.log +88 -0
- package/observability/logs/session/codegraph-sync-20260701-004241.log +82 -0
- package/observability/logs/session/codegraph-sync-20260701-005620.log +89 -0
- package/observability/logs/session/codegraph-sync-20260701-005840.log +88 -0
- package/observability/logs/session/codegraph-sync-20260701-010419.log +93 -0
- package/observability/logs/session/codegraph-sync-20260701-010609.log +90 -0
- package/observability/logs/session/codegraph-sync-20260704-145856.log +70 -0
- package/observability/logs/session/codegraph-sync-20260704-150047.log +53 -0
- package/observability/logs/session/codegraph-sync-20260704-150204.log +44 -0
- package/observability/logs/session/codegraph-sync-20260704-154353.log +26 -0
- package/observability/logs/session/codegraph-sync-20260705-115337.log +32 -0
- package/observability/logs/session/hi-20260629-221459.json +38 -0
- package/observability/logs/session/hi-20260629-221945.json +59 -0
- package/observability/logs/session/hi-20260629-222108.json +66 -0
- package/observability/logs/session/hi-20260629-222352.json +45 -0
- package/observability/logs/session/hi-20260629-225719.json +59 -0
- package/observability/logs/session/hi-20260629-233722.json +52 -0
- package/observability/logs/session/hi-20260629-233913.json +198 -0
- package/observability/logs/session/hi-20260630-110156.json +177 -0
- package/observability/logs/session/hi-20260630-191243.json +184 -0
- package/observability/logs/session/hi-20260630-230050.json +234 -0
- package/observability/logs/session/hi-20260630-230523.json +227 -0
- package/observability/logs/session/hi-20260630-230855.json +227 -0
- package/observability/logs/session/hi-20260630-231638.json +227 -0
- package/observability/logs/session/hi-20260630-231756.json +219 -0
- package/observability/logs/session/hi-20260701-002842.json +234 -0
- package/observability/logs/session/hi-20260701-003458.json +282 -0
- package/observability/logs/session/hi-20260701-004233.json +290 -0
- package/observability/logs/session/hi-20260701-004554.json +236 -0
- package/observability/logs/session/hi-20260701-005641.json +290 -0
- package/observability/logs/session/hi-20260701-010450.json +290 -0
- package/observability/logs/session/hi-20260703-233854.json +312 -0
- package/observability/logs/session/hi-20260703-234448.json +318 -0
- package/observability/logs/session/hi-20260704-145907.json +353 -0
- package/observability/logs/session/hi-20260704-150141.json +392 -0
- package/observability/logs/session/hi-20260704-154448.json +392 -0
- package/observability/logs/session/iteration-value-refresh-20260701-004309.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260701-005907.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260701-010747.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260704-150312.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260705-115453.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260701-004309.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260701-005906.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260701-010745.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260704-150309.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260705-115450.log +3 -0
- package/observability/logs/session/project-notes-refresh-20260701-004227.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-004308.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-005636.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-005906.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-010443.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-010744.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260704-150133.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260704-150309.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260704-154442.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260705-115449.log +1 -0
- package/observability/logs/session/repo-intake-20260701-004218.log +6 -0
- package/observability/logs/session/repo-intake-20260701-005626.log +6 -0
- package/observability/logs/session/repo-intake-20260701-010433.log +6 -0
- package/observability/logs/session/repo-intake-20260704-150053.log +6 -0
- package/observability/logs/session/repo-intake-20260704-154404.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260701-004247.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260701-005847.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260701-010615.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260704-150209.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260705-115342.log +6 -0
- package/observability/logs/session/repo-registry-validation-20260701-004234.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260701-004556.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260701-005833.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260701-010601.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260704-150155.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260705-115323.log +2 -0
- package/observability/logs/session/repomix-refresh-20260701-003823.log +4236 -0
- package/observability/logs/session/repomix-refresh-20260701-004251.log +4275 -0
- package/observability/logs/session/repomix-refresh-20260701-005850.log +4248 -0
- package/observability/logs/session/repomix-refresh-20260701-010619.log +6531 -0
- package/observability/logs/session/repomix-refresh-20260704-150239.log +652 -0
- package/observability/logs/session/repomix-refresh-20260705-115419.log +178 -0
- package/observability/logs/session/routing-evals-20260701-004221.log +2 -0
- package/observability/logs/session/routing-evals-20260701-004235.log +2 -0
- package/observability/logs/session/routing-evals-20260701-005629.log +2 -0
- package/observability/logs/session/routing-evals-20260701-005834.log +2 -0
- package/observability/logs/session/routing-evals-20260701-010437.log +2 -0
- package/observability/logs/session/routing-evals-20260701-010603.log +2 -0
- package/observability/logs/session/routing-evals-20260704-150125.log +2 -0
- package/observability/logs/session/routing-evals-20260704-150157.log +2 -0
- package/observability/logs/session/routing-evals-20260704-154434.log +2 -0
- package/observability/logs/session/routing-evals-20260705-115327.log +2 -0
- package/observability/logs/session/sibling-discovery-refresh-20260701-004250.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260701-005850.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260701-010618.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260704-150238.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260705-115418.log +3 -0
- package/observability/logs.schema.json +95 -0
- package/observability/logs.schema.md +26 -0
- package/observability/metrics.md +35 -0
- package/observability/routing-evaluator.md +37 -0
- package/observability/scoring-rubric.md +38 -0
- package/optimization/ALWAYS_ON_OPTIMIZATION.md +98 -0
- package/optimization/caveman-mode.md +62 -0
- package/optimization/examples/login-bug.md +25 -0
- package/optimization/examples/sla-query.md +25 -0
- package/optimization/optimization-routing.md +30 -0
- package/optimization/policies/response-style.policy.md +45 -0
- package/optimization/policies/token-budget.policy.md +28 -0
- package/optimization/profiles/always-on.profile.md +19 -0
- package/optimization/profiles/architecture.profile.md +20 -0
- package/optimization/profiles/debug.profile.md +20 -0
- package/optimization/profiles/enterprise-rag.profile.md +20 -0
- package/optimization/profiles/training.profile.md +20 -0
- package/optimization/token-saver.md +58 -0
- package/orchestrator/corporate-routing.md +51 -0
- package/orchestrator/decision-matrix.md +33 -0
- package/orchestrator/fallback.md +29 -0
- package/orchestrator/repo-routing.md +58 -0
- package/orchestrator/router.md +75 -0
- package/orchestrator/wiki/__init__.py +5 -0
- package/orchestrator/wiki/graph_consolidator.py +506 -0
- package/orchestrator/wiki/incremental_engine.py +57 -0
- package/orchestrator/wiki/plugin_manager.py +40 -0
- package/package.json +70 -0
- package/policies/context-policy.md +25 -0
- package/policies/cost-policy.md +25 -0
- package/policies/repo-intake-policy.md +36 -0
- package/policies/security-policy.md +25 -0
- package/repo-intake/README.md +81 -0
- package/repo-intake/templates/agent.template.md +4 -0
- package/repo-intake/templates/context-manifest.template.md +4 -0
- package/repo-intake/templates/skill.template.md +3 -0
- package/repo-registry/repos.schema.json +102 -0
- package/repo-registry/repos.template.json +26 -0
- package/requirements.txt +1 -0
- package/scripts/README.md +109 -0
- package/scripts/__init__.py +0 -0
- package/scripts/bootstrap-portable.cmd +4 -0
- package/scripts/bootstrap-portable.ps1 +90 -0
- package/scripts/context/azure-rag-mcp-adapter.py +1 -0
- package/scripts/context/build-graphify.ps1 +1 -0
- package/scripts/context/build-repomix.ps1 +1 -0
- package/scripts/discovery/discover-boost-repos.cmd +4 -0
- package/scripts/discovery/discover-boost-repos.py +186 -0
- package/scripts/discovery/refresh-project-notes.py +179 -0
- package/scripts/github/INSTALL.md +295 -0
- package/scripts/github/README.md +455 -0
- package/scripts/github/apply-boost-templates.ps1 +163 -0
- package/scripts/github/apply-single-repo.ps1 +85 -0
- package/scripts/github/create-devlog.ps1 +380 -0
- package/scripts/github/manage-issues.ps1 +332 -0
- package/scripts/github/sync-repo.ps1 +267 -0
- package/scripts/intake/agent-pipeline-preflight.py +151 -0
- package/scripts/intake/init-template-registry.cmd +4 -0
- package/scripts/intake/init-template-registry.ps1 +258 -0
- package/scripts/intake/repo-intake.py +354 -0
- package/scripts/intake/resolve-routing.py +620 -0
- package/scripts/intake/run-repo-intake.cmd +4 -0
- package/scripts/intake/run-repo-intake.ps1 +46 -0
- package/scripts/intake/run-routing-evals.py +147 -0
- package/scripts/intake/validate-database-routing.py +91 -0
- package/scripts/intake/validate-rag-routing.py +85 -0
- package/scripts/intake/validate-repo-registry.ps1 +20 -0
- package/scripts/intake/validate-repo-registry.py +286 -0
- package/scripts/intake/validate-security.py +170 -0
- package/scripts/learning/autolearning-gate.py +71 -0
- package/scripts/learning/chat-token-usage-report.py +326 -0
- package/scripts/learning/ingest-copilot-session-usage.py +421 -0
- package/scripts/learning/iteration-value-report.py +275 -0
- package/scripts/learning/learning-loop-report.py +272 -0
- package/scripts/learning/record-iteration-metrics.py +116 -0
- package/scripts/learning/record-learning-feedback.py +91 -0
- package/scripts/ops/bye.ps1 +620 -0
- package/scripts/ops/compare-demo-results.ps1 +826 -0
- package/scripts/ops/demo1.ps1 +11 -0
- package/scripts/ops/demo2.ps1 +11 -0
- package/scripts/ops/demo3.ps1 +11 -0
- package/scripts/ops/demo4.ps1 +11 -0
- package/scripts/ops/hi.ps1 +1045 -0
- package/scripts/ops/llm-token-probe.py +164 -0
- package/scripts/ops/run-all-demos.ps1 +39 -0
- package/scripts/ops/run-demo-block.ps1 +85 -0
- package/scripts/ops/run-demo-session.ps1 +532 -0
- package/scripts/setup/optimize-engines.ps1 +183 -0
- package/scripts/setup/setup-codegraph.ps1 +3 -0
- package/scripts/setup/setup-gitnexus.ps1 +3 -0
- package/scripts/setup/setup-graphify.ps1 +2 -0
- package/scripts/setup/setup-prerequisites.ps1 +205 -0
- package/scripts/setup/start-gitnexus.ps1 +71 -0
- package/scripts/setup/validate-context.ps1 +361 -0
- package/scripts/wiki/__init__.py +0 -0
- package/scripts/wiki/compiler_main.py +189 -0
- package/scripts/wiki/normalizer.py +206 -0
- package/scripts/wiki/providers/base_provider.py +25 -0
- package/scripts/wiki/providers/codegraph_provider.py +49 -0
- package/scripts/wiki/providers/graphify_provider.py +49 -0
- package/scripts/wiki/providers/repo_content_provider.py +408 -0
- package/scripts/wiki/query_autodocs.py +60 -0
- package/scripts/wiki/validator.py +183 -0
- package/scripts/wiki/wiki_compiler.py +5 -0
- package/specs/architecture.spec.md +32 -0
- package/specs/azure-rag.spec.md +28 -0
- package/specs/coding-standards.spec.md +24 -0
- package/specs/database.spec.md +29 -0
- package/specs/migration.spec.md +26 -0
- package/specs/observability.spec.md +24 -0
- package/specs/optimization.spec.md +31 -0
- package/specs/rag.spec.md +30 -0
- package/specs/repo-intake.spec.md +25 -0
- package/specs/routing.spec.md +24 -0
- package/specs/security.spec.md +30 -0
- package/specs/wiki/provider-contract.json +33 -0
- package/specs/wiki/unified-knowledge-graph.json +25 -0
- package/templates/BOOST_README_TEMPLATE.md +96 -0
- package/templates/CODEOWNERS_TEMPLATE.txt +29 -0
- package/templates/LICENSE_MIT_TEMPLATE.txt +21 -0
- package/templates/PERSONAL_README_TEMPLATE.md +90 -0
- package/templates/README_boost_RAG_Azure.md +46 -0
- package/templates/README_boost_azure_iot_edge.md +48 -0
- package/templates/README_boost_backend.md +47 -0
- package/templates/README_boost_dba.md +57 -0
- package/templates/ci.yml.template +73 -0
- package/tooling/tooling.manifest.json +72 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import subprocess
|
|
3
|
+
from typing import Any, Dict, Iterable, List, Tuple
|
|
4
|
+
|
|
5
|
+
from scripts.wiki.providers.base_provider import BaseWikiProvider
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RepoContentProvider(BaseWikiProvider):
|
|
9
|
+
provider_id = "repo-content"
|
|
10
|
+
|
|
11
|
+
def __init__(self, repo_root: Path) -> None:
|
|
12
|
+
super().__init__(repo_root)
|
|
13
|
+
self.repo_root = repo_root
|
|
14
|
+
|
|
15
|
+
def gather_knowledge(self) -> Dict[str, Any]:
|
|
16
|
+
entities: List[Dict[str, Any]] = []
|
|
17
|
+
entities.extend(self._collect_agents())
|
|
18
|
+
entities.extend(self._collect_skills())
|
|
19
|
+
entities.extend(self._collect_policies())
|
|
20
|
+
entities.extend(self._collect_specs())
|
|
21
|
+
entities.extend(self._collect_observability())
|
|
22
|
+
entities.extend(self._collect_projects())
|
|
23
|
+
entities.extend(self._collect_routing())
|
|
24
|
+
entities.extend(self._collect_reports())
|
|
25
|
+
self._enrich_relations(entities)
|
|
26
|
+
return {"provider_id": self.provider_id, "entities": entities}
|
|
27
|
+
|
|
28
|
+
def _collect_agents(self) -> List[Dict[str, Any]]:
|
|
29
|
+
agents_dir = self.repo_root / ".github" / "agents"
|
|
30
|
+
if not agents_dir.exists():
|
|
31
|
+
return []
|
|
32
|
+
files = sorted(agents_dir.glob("*.agent.md"))
|
|
33
|
+
return [self._entity_from_markdown(path, kind="agent", section="agents", domain="agents") for path in files]
|
|
34
|
+
|
|
35
|
+
def _collect_skills(self) -> List[Dict[str, Any]]:
|
|
36
|
+
skills_dir = self.repo_root / ".github" / "skills"
|
|
37
|
+
if not skills_dir.exists():
|
|
38
|
+
return []
|
|
39
|
+
entities: List[Dict[str, Any]] = []
|
|
40
|
+
for path in sorted(skills_dir.iterdir()):
|
|
41
|
+
if path.is_dir():
|
|
42
|
+
skill_file = path / "SKILL.md"
|
|
43
|
+
if skill_file.exists():
|
|
44
|
+
entities.append(self._entity_from_markdown(skill_file, kind="skill", section="skills", domain="skills"))
|
|
45
|
+
elif path.is_file() and path.suffix == ".json":
|
|
46
|
+
entities.append(self._entity_from_json(path, kind="skill", section="skills", domain="skills"))
|
|
47
|
+
return entities
|
|
48
|
+
|
|
49
|
+
def _collect_policies(self) -> List[Dict[str, Any]]:
|
|
50
|
+
policies_dir = self.repo_root / "policies"
|
|
51
|
+
if not policies_dir.exists():
|
|
52
|
+
return []
|
|
53
|
+
return [
|
|
54
|
+
self._entity_from_markdown(path, kind="policy", section="policies", domain="governance")
|
|
55
|
+
for path in sorted(policies_dir.glob("*.md"))
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
def _collect_specs(self) -> List[Dict[str, Any]]:
|
|
59
|
+
specs_dir = self.repo_root / "specs"
|
|
60
|
+
if not specs_dir.exists():
|
|
61
|
+
return []
|
|
62
|
+
return [
|
|
63
|
+
self._entity_from_markdown(path, kind="spec", section="specs", domain="specifications")
|
|
64
|
+
for path in sorted(specs_dir.rglob("*.md"))
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
def _collect_observability(self) -> List[Dict[str, Any]]:
|
|
68
|
+
observability_dir = self.repo_root / "observability"
|
|
69
|
+
if not observability_dir.exists():
|
|
70
|
+
return []
|
|
71
|
+
entities: List[Dict[str, Any]] = []
|
|
72
|
+
for path in sorted(observability_dir.glob("*.md")):
|
|
73
|
+
entities.append(self._entity_from_markdown(path, kind="report", section="observability", domain="observability"))
|
|
74
|
+
for path in sorted(observability_dir.glob("*.json")):
|
|
75
|
+
entities.append(self._entity_from_json(path, kind="report", section="observability", domain="observability"))
|
|
76
|
+
return entities
|
|
77
|
+
|
|
78
|
+
def _collect_projects(self) -> List[Dict[str, Any]]:
|
|
79
|
+
projects_dir = self.repo_root / "projects"
|
|
80
|
+
if not projects_dir.exists():
|
|
81
|
+
return []
|
|
82
|
+
entities: List[Dict[str, Any]] = []
|
|
83
|
+
for path in sorted(projects_dir.iterdir()):
|
|
84
|
+
if not path.is_dir():
|
|
85
|
+
continue
|
|
86
|
+
if not self._is_tracked(path):
|
|
87
|
+
continue
|
|
88
|
+
summary = f"Espacio de proyecto interno ubicado en {self._relative(path)}."
|
|
89
|
+
payload = {
|
|
90
|
+
"title": path.name,
|
|
91
|
+
"slug": self._slug_for("project", path),
|
|
92
|
+
"kind": "project",
|
|
93
|
+
"section": "projects",
|
|
94
|
+
"domain": "projects",
|
|
95
|
+
"summary": summary,
|
|
96
|
+
"owner": "repo",
|
|
97
|
+
"source_refs": [self._relative(path)],
|
|
98
|
+
"tags": ["project", "workspace"],
|
|
99
|
+
}
|
|
100
|
+
entities.append(self._entity(path.name, payload))
|
|
101
|
+
return entities
|
|
102
|
+
|
|
103
|
+
def _collect_routing(self) -> List[Dict[str, Any]]:
|
|
104
|
+
targets: List[Tuple[Path, str]] = [
|
|
105
|
+
(self.repo_root / "AGENTS.md", "Contrato global de routing y seleccion de motores."),
|
|
106
|
+
(self.repo_root / "ARCHITECTURE.md", "Vista de arquitectura y flujo de agentes y motores."),
|
|
107
|
+
(self.repo_root / "autodocs" / "site" / "guides" / "03-mcp-routing-guide.md", "Guia de routing corporativo del sistema."),
|
|
108
|
+
(self.repo_root / "orchestrator" / "router.md", "Contrato operativo del router."),
|
|
109
|
+
(self.repo_root / "orchestrator" / "corporate-routing.md", "Reglas corporativas de routing."),
|
|
110
|
+
(self.repo_root / "orchestrator" / "decision-matrix.md", "Matriz de decision de routing."),
|
|
111
|
+
(self.repo_root / "orchestrator" / "fallback.md", "Estrategias de fallback de routing."),
|
|
112
|
+
]
|
|
113
|
+
entities: List[Dict[str, Any]] = []
|
|
114
|
+
for path, fallback_summary in targets:
|
|
115
|
+
if not path.exists():
|
|
116
|
+
continue
|
|
117
|
+
entities.append(
|
|
118
|
+
self._entity_from_markdown(
|
|
119
|
+
path,
|
|
120
|
+
kind="report",
|
|
121
|
+
section="routing",
|
|
122
|
+
domain="routing",
|
|
123
|
+
fallback_summary=fallback_summary,
|
|
124
|
+
)
|
|
125
|
+
)
|
|
126
|
+
return entities
|
|
127
|
+
|
|
128
|
+
def _collect_reports(self) -> List[Dict[str, Any]]:
|
|
129
|
+
reports_dir = self.repo_root / "autodocs" / "analysis_mcpee"
|
|
130
|
+
if not reports_dir.exists():
|
|
131
|
+
return []
|
|
132
|
+
entities: List[Dict[str, Any]] = []
|
|
133
|
+
for path in sorted(reports_dir.iterdir()):
|
|
134
|
+
if path.suffix == ".md":
|
|
135
|
+
entities.append(self._entity_from_markdown(path, kind="report", section="reports", domain="autodocs"))
|
|
136
|
+
elif path.suffix == ".json":
|
|
137
|
+
entities.append(self._entity_from_json(path, kind="report", section="reports", domain="autodocs"))
|
|
138
|
+
return entities
|
|
139
|
+
|
|
140
|
+
def _entity_from_markdown(
|
|
141
|
+
self,
|
|
142
|
+
path: Path,
|
|
143
|
+
kind: str,
|
|
144
|
+
section: str,
|
|
145
|
+
domain: str,
|
|
146
|
+
fallback_summary: str = "",
|
|
147
|
+
) -> Dict[str, Any]:
|
|
148
|
+
content = path.read_text(encoding="utf-8")
|
|
149
|
+
title = self._extract_title(content) or path.stem
|
|
150
|
+
summary = self._extract_summary(content) or fallback_summary or f"Contenido {kind} en {self._relative(path)}."
|
|
151
|
+
payload = {
|
|
152
|
+
"title": title,
|
|
153
|
+
"slug": self._slug_for(kind, path),
|
|
154
|
+
"kind": kind,
|
|
155
|
+
"section": section,
|
|
156
|
+
"domain": domain,
|
|
157
|
+
"summary": self._normalize_summary(summary, fallback_summary or f"Contenido {kind} en {self._relative(path)}."),
|
|
158
|
+
"owner": self._owner_for(path),
|
|
159
|
+
"source_refs": [self._relative(path)],
|
|
160
|
+
"tags": [kind, section, domain],
|
|
161
|
+
}
|
|
162
|
+
return self._entity(self._relative(path), payload)
|
|
163
|
+
|
|
164
|
+
def _entity_from_json(self, path: Path, kind: str, section: str, domain: str) -> Dict[str, Any]:
|
|
165
|
+
payload_json = self._load_json_file(path)
|
|
166
|
+
title = str(payload_json.get("name") or payload_json.get("title") or path.stem)
|
|
167
|
+
summary = str(payload_json.get("description") or f"Artefacto JSON de tipo {kind} en {self._relative(path)}.")
|
|
168
|
+
payload = {
|
|
169
|
+
"title": title,
|
|
170
|
+
"slug": self._slug_for(kind, path),
|
|
171
|
+
"kind": kind,
|
|
172
|
+
"section": section,
|
|
173
|
+
"domain": domain,
|
|
174
|
+
"summary": self._normalize_summary(summary, f"Artefacto JSON de tipo {kind} en {self._relative(path)}."),
|
|
175
|
+
"owner": self._owner_for(path),
|
|
176
|
+
"source_refs": [self._relative(path)],
|
|
177
|
+
"tags": [kind, section, domain, "json"],
|
|
178
|
+
}
|
|
179
|
+
return self._entity(self._relative(path), payload)
|
|
180
|
+
|
|
181
|
+
def _entity(self, entity_id: str, payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
182
|
+
relations = list(payload.get("relations", [])) if isinstance(payload.get("relations", []), list) else []
|
|
183
|
+
checksum_payload = {
|
|
184
|
+
"payload": payload,
|
|
185
|
+
"relations": relations,
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
"id": entity_id,
|
|
189
|
+
"type": payload.get("kind", "report"),
|
|
190
|
+
"checksum": self._checksum(checksum_payload),
|
|
191
|
+
"raw_data": payload,
|
|
192
|
+
"relations": relations,
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
def _enrich_relations(self, entities: List[Dict[str, Any]]) -> None:
|
|
196
|
+
if not entities:
|
|
197
|
+
return
|
|
198
|
+
|
|
199
|
+
entities_by_id = {
|
|
200
|
+
str(entity.get("id", "")): entity
|
|
201
|
+
for entity in entities
|
|
202
|
+
if isinstance(entity, dict) and str(entity.get("id", "")).strip()
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
for entity in entities:
|
|
206
|
+
if not isinstance(entity, dict):
|
|
207
|
+
continue
|
|
208
|
+
raw_data = entity.get("raw_data", {}) if isinstance(entity.get("raw_data", {}), dict) else {}
|
|
209
|
+
kind = str(raw_data.get("kind", "")).strip()
|
|
210
|
+
source_refs = raw_data.get("source_refs", []) if isinstance(raw_data.get("source_refs", []), list) else []
|
|
211
|
+
source_ref = str(source_refs[0]) if source_refs else ""
|
|
212
|
+
title = str(raw_data.get("title", "")).strip().lower()
|
|
213
|
+
|
|
214
|
+
if kind == "agent":
|
|
215
|
+
self._relate_agent(entity, entities_by_id, title)
|
|
216
|
+
elif kind == "skill":
|
|
217
|
+
self._relate_skill(entity, entities_by_id, source_ref)
|
|
218
|
+
elif kind == "policy":
|
|
219
|
+
self._relate_policy(entity, entities_by_id, source_ref)
|
|
220
|
+
elif kind == "spec":
|
|
221
|
+
self._relate_spec(entity, entities_by_id, source_ref)
|
|
222
|
+
elif kind == "report":
|
|
223
|
+
self._relate_report(entity, entities_by_id, source_ref)
|
|
224
|
+
elif kind == "project":
|
|
225
|
+
self._relate_project(entity, entities_by_id, title)
|
|
226
|
+
|
|
227
|
+
def _relate_agent(self, entity: Dict[str, Any], entities_by_id: Dict[str, Dict[str, Any]], title: str) -> None:
|
|
228
|
+
skill_map = {
|
|
229
|
+
"backend": ".github/skills/backend-coding/SKILL.md",
|
|
230
|
+
"frontend-agent": ".github/skills/frontend-coding/SKILL.md",
|
|
231
|
+
"dba": ".github/skills/database-analysis/SKILL.md",
|
|
232
|
+
"iot": ".github/skills/iot-architecture/SKILL.md",
|
|
233
|
+
"legacy": ".github/skills/legacy-migration/SKILL.md",
|
|
234
|
+
"rag-local": ".github/skills/rag-knowledge/SKILL.md",
|
|
235
|
+
"rag-azure": ".github/skills/azure-rag-enterprise/SKILL.md",
|
|
236
|
+
"community-manager": ".github/skills/community-content/SKILL.md",
|
|
237
|
+
"ux-ui": ".github/skills/ux-ui-governance/SKILL.md",
|
|
238
|
+
"wiki": ".github/skills/wiki-tools.json",
|
|
239
|
+
}
|
|
240
|
+
for needle, target_id in skill_map.items():
|
|
241
|
+
if needle in title and target_id in entities_by_id:
|
|
242
|
+
self._add_relation(entity, target_id, "uses_skill")
|
|
243
|
+
|
|
244
|
+
shared_targets = [
|
|
245
|
+
".github/skills/token-saver/SKILL.md",
|
|
246
|
+
".github/skills/caveman-mode/SKILL.md",
|
|
247
|
+
"AGENTS.md",
|
|
248
|
+
"ARCHITECTURE.md",
|
|
249
|
+
]
|
|
250
|
+
for target_id in shared_targets:
|
|
251
|
+
if target_id in entities_by_id:
|
|
252
|
+
relation_type = "follows" if target_id.endswith(".md") else "uses_skill"
|
|
253
|
+
self._add_relation(entity, target_id, relation_type)
|
|
254
|
+
|
|
255
|
+
def _relate_skill(self, entity: Dict[str, Any], entities_by_id: Dict[str, Dict[str, Any]], source_ref: str) -> None:
|
|
256
|
+
if source_ref == ".github/skills/token-saver/SKILL.md":
|
|
257
|
+
for target_id in ["specs/optimization.spec.md", "observability/metrics.md"]:
|
|
258
|
+
if target_id in entities_by_id:
|
|
259
|
+
self._add_relation(entity, target_id, "supports")
|
|
260
|
+
if source_ref == ".github/skills/caveman-mode/SKILL.md":
|
|
261
|
+
for target_id in ["specs/optimization.spec.md", "observability/metrics.md"]:
|
|
262
|
+
if target_id in entities_by_id:
|
|
263
|
+
self._add_relation(entity, target_id, "supports")
|
|
264
|
+
if source_ref == ".github/skills/wiki-tools.json":
|
|
265
|
+
for target_id in ["README_WIKI.md", "autodocs/README.md"]:
|
|
266
|
+
if target_id in entities_by_id:
|
|
267
|
+
self._add_relation(entity, target_id, "documents")
|
|
268
|
+
|
|
269
|
+
def _relate_policy(self, entity: Dict[str, Any], entities_by_id: Dict[str, Dict[str, Any]], source_ref: str) -> None:
|
|
270
|
+
policy_to_spec = {
|
|
271
|
+
"policies/security-policy.md": "specs/security.spec.md",
|
|
272
|
+
"policies/context-policy.md": "specs/routing.spec.md",
|
|
273
|
+
"policies/repo-intake-policy.md": "specs/repo-intake.spec.md",
|
|
274
|
+
"policies/cost-policy.md": "specs/optimization.spec.md",
|
|
275
|
+
}
|
|
276
|
+
target_id = policy_to_spec.get(source_ref)
|
|
277
|
+
if target_id and target_id in entities_by_id:
|
|
278
|
+
self._add_relation(entity, target_id, "governs")
|
|
279
|
+
|
|
280
|
+
def _relate_spec(self, entity: Dict[str, Any], entities_by_id: Dict[str, Dict[str, Any]], source_ref: str) -> None:
|
|
281
|
+
if source_ref == "specs/routing.spec.md":
|
|
282
|
+
for target_id in ["AGENTS.md", "orchestrator/router.md", "orchestrator/corporate-routing.md"]:
|
|
283
|
+
if target_id in entities_by_id:
|
|
284
|
+
self._add_relation(entity, target_id, "defines")
|
|
285
|
+
if source_ref == "specs/observability.spec.md":
|
|
286
|
+
for target_id in ["observability/metrics.md", "observability/routing-evaluator.md"]:
|
|
287
|
+
if target_id in entities_by_id:
|
|
288
|
+
self._add_relation(entity, target_id, "defines")
|
|
289
|
+
|
|
290
|
+
def _relate_report(self, entity: Dict[str, Any], entities_by_id: Dict[str, Dict[str, Any]], source_ref: str) -> None:
|
|
291
|
+
if source_ref == "ARCHITECTURE.md":
|
|
292
|
+
for target_id in ["AGENTS.md", "orchestrator/router.md"]:
|
|
293
|
+
if target_id in entities_by_id:
|
|
294
|
+
self._add_relation(entity, target_id, "explains")
|
|
295
|
+
if source_ref == "autodocs/analysis_mcpee/OPENWIKI_INTERNAL_BLUEPRINT.md":
|
|
296
|
+
for target_id in ["autodocs/README.md", "README_WIKI.md"]:
|
|
297
|
+
if target_id in entities_by_id:
|
|
298
|
+
self._add_relation(entity, target_id, "drives")
|
|
299
|
+
if source_ref == "observability/metrics.md":
|
|
300
|
+
target_id = "specs/observability.spec.md"
|
|
301
|
+
if target_id in entities_by_id:
|
|
302
|
+
self._add_relation(entity, target_id, "implements")
|
|
303
|
+
|
|
304
|
+
def _relate_project(self, entity: Dict[str, Any], entities_by_id: Dict[str, Dict[str, Any]], title: str) -> None:
|
|
305
|
+
if title == "techriders":
|
|
306
|
+
for target_id in ["specs/architecture.spec.md", "specs/observability.spec.md"]:
|
|
307
|
+
if target_id in entities_by_id:
|
|
308
|
+
self._add_relation(entity, target_id, "consumes")
|
|
309
|
+
|
|
310
|
+
def _add_relation(self, entity: Dict[str, Any], target_id: str, relation_type: str) -> None:
|
|
311
|
+
relations = entity.get("relations", [])
|
|
312
|
+
if not isinstance(relations, list):
|
|
313
|
+
relations = []
|
|
314
|
+
entity["relations"] = relations
|
|
315
|
+
|
|
316
|
+
for relation in relations:
|
|
317
|
+
if not isinstance(relation, dict):
|
|
318
|
+
continue
|
|
319
|
+
if str(relation.get("target", "")) == target_id and str(relation.get("type", "")) == relation_type:
|
|
320
|
+
return
|
|
321
|
+
|
|
322
|
+
relations.append({"target": target_id, "type": relation_type})
|
|
323
|
+
|
|
324
|
+
def _extract_title(self, content: str) -> str:
|
|
325
|
+
for line in content.splitlines():
|
|
326
|
+
stripped = line.strip()
|
|
327
|
+
if stripped.startswith("#"):
|
|
328
|
+
return stripped.lstrip("#").strip()
|
|
329
|
+
return ""
|
|
330
|
+
|
|
331
|
+
def _extract_summary(self, content: str) -> str:
|
|
332
|
+
lines = [line.strip() for line in content.splitlines()]
|
|
333
|
+
in_fence = False
|
|
334
|
+
for index, line in enumerate(lines):
|
|
335
|
+
if line.startswith("```"):
|
|
336
|
+
in_fence = not in_fence
|
|
337
|
+
continue
|
|
338
|
+
if in_fence:
|
|
339
|
+
continue
|
|
340
|
+
if not line or line.startswith("#"):
|
|
341
|
+
continue
|
|
342
|
+
if line.startswith("<!--"):
|
|
343
|
+
continue
|
|
344
|
+
if line.startswith("-") or line.startswith("1."):
|
|
345
|
+
continue
|
|
346
|
+
if line.startswith("|") or line.endswith(":"):
|
|
347
|
+
continue
|
|
348
|
+
next_line = lines[index + 1] if index + 1 < len(lines) else ""
|
|
349
|
+
if next_line.startswith("```") or next_line.startswith("|") or next_line.startswith("<!--"):
|
|
350
|
+
next_line = ""
|
|
351
|
+
if next_line and not next_line.startswith("#"):
|
|
352
|
+
return f"{line} {next_line}".strip()
|
|
353
|
+
return line
|
|
354
|
+
return ""
|
|
355
|
+
|
|
356
|
+
def _normalize_summary(self, summary: str, fallback: str) -> str:
|
|
357
|
+
normalized = summary.strip()
|
|
358
|
+
if len(normalized) < 24:
|
|
359
|
+
return fallback
|
|
360
|
+
return normalized
|
|
361
|
+
|
|
362
|
+
def _slug_for(self, kind: str, path: Path) -> str:
|
|
363
|
+
relative = self._relative(path)
|
|
364
|
+
stem = path.name
|
|
365
|
+
if path.name.lower() == "skill.md" and path.parent.name:
|
|
366
|
+
stem = path.parent.name
|
|
367
|
+
tokens = [kind, stem]
|
|
368
|
+
if kind == "report" and "analysis_mcpee" in relative:
|
|
369
|
+
tokens.insert(1, "autodocs")
|
|
370
|
+
return self._slugify("-".join(tokens))
|
|
371
|
+
|
|
372
|
+
def _slugify(self, value: str) -> str:
|
|
373
|
+
normalized = []
|
|
374
|
+
for char in value.lower():
|
|
375
|
+
if char.isalnum():
|
|
376
|
+
normalized.append(char)
|
|
377
|
+
else:
|
|
378
|
+
normalized.append("-")
|
|
379
|
+
slug = "".join(normalized)
|
|
380
|
+
while "--" in slug:
|
|
381
|
+
slug = slug.replace("--", "-")
|
|
382
|
+
return slug.strip("-") or "untitled"
|
|
383
|
+
|
|
384
|
+
def _relative(self, path: Path) -> str:
|
|
385
|
+
return path.relative_to(self.repo_root).as_posix()
|
|
386
|
+
|
|
387
|
+
def _is_tracked(self, path: Path) -> bool:
|
|
388
|
+
rel = self._relative(path)
|
|
389
|
+
if not rel:
|
|
390
|
+
return False
|
|
391
|
+
try:
|
|
392
|
+
result = subprocess.run(
|
|
393
|
+
["git", "ls-files", "--error-unmatch", rel],
|
|
394
|
+
cwd=self.repo_root,
|
|
395
|
+
stdout=subprocess.DEVNULL,
|
|
396
|
+
stderr=subprocess.DEVNULL,
|
|
397
|
+
check=False,
|
|
398
|
+
)
|
|
399
|
+
return result.returncode == 0
|
|
400
|
+
except OSError:
|
|
401
|
+
return False
|
|
402
|
+
|
|
403
|
+
def _owner_for(self, path: Path) -> str:
|
|
404
|
+
relative = self._relative(path)
|
|
405
|
+
parts = [segment for segment in relative.split("/") if segment]
|
|
406
|
+
if len(parts) <= 1:
|
|
407
|
+
return "repo"
|
|
408
|
+
return parts[-2]
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import sys
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any, Dict, List, cast
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
8
|
+
SEARCH_INDEX_PATH = REPO_ROOT / "autodocs" / "generated" / "search-index.json"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
SearchEntry = Dict[str, Any]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _load_index() -> List[SearchEntry]:
|
|
15
|
+
if not SEARCH_INDEX_PATH.exists():
|
|
16
|
+
return []
|
|
17
|
+
with SEARCH_INDEX_PATH.open("r", encoding="utf-8") as handle:
|
|
18
|
+
payload = json.load(handle)
|
|
19
|
+
if isinstance(payload, list):
|
|
20
|
+
entries: List[SearchEntry] = []
|
|
21
|
+
for item in cast(List[Any], payload):
|
|
22
|
+
if isinstance(item, dict):
|
|
23
|
+
entries.append(cast(SearchEntry, item))
|
|
24
|
+
return entries
|
|
25
|
+
return []
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _matches(entry: SearchEntry, query: str) -> bool:
|
|
29
|
+
haystack = " ".join(
|
|
30
|
+
[
|
|
31
|
+
str(entry.get("title", "")),
|
|
32
|
+
str(entry.get("summary", "")),
|
|
33
|
+
str(entry.get("kind", "")),
|
|
34
|
+
str(entry.get("domain", "")),
|
|
35
|
+
" ".join(str(tag) for tag in entry.get("tags", [])),
|
|
36
|
+
]
|
|
37
|
+
).lower()
|
|
38
|
+
return query.lower() in haystack
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def main() -> int:
|
|
42
|
+
query = " ".join(sys.argv[1:]).strip()
|
|
43
|
+
if not query:
|
|
44
|
+
print("Usage: py -3 -m scripts.wiki.query_autodocs <query>")
|
|
45
|
+
return 1
|
|
46
|
+
|
|
47
|
+
results = [entry for entry in _load_index() if _matches(entry, query)]
|
|
48
|
+
if not results:
|
|
49
|
+
print("No matches")
|
|
50
|
+
return 0
|
|
51
|
+
|
|
52
|
+
for entry in results:
|
|
53
|
+
print(f"- {entry.get('title', '')} [{entry.get('kind', '')}] -> {entry.get('path', '')}")
|
|
54
|
+
print(f" {entry.get('summary', '')}")
|
|
55
|
+
|
|
56
|
+
return 0
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if __name__ == "__main__":
|
|
60
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import hashlib
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any, Dict, List
|
|
5
|
+
|
|
6
|
+
from scripts.wiki.normalizer import section_catalog
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class WikiValidator:
|
|
10
|
+
def __init__(self, schema_path: Path) -> None:
|
|
11
|
+
self.schema_path = schema_path
|
|
12
|
+
self.allowed_sections = {section["id"] for section in section_catalog()}
|
|
13
|
+
self.allowed_kinds = {
|
|
14
|
+
"agent",
|
|
15
|
+
"skill",
|
|
16
|
+
"prompt",
|
|
17
|
+
"policy",
|
|
18
|
+
"project",
|
|
19
|
+
"spec",
|
|
20
|
+
"report",
|
|
21
|
+
"capability",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def validate(self, wiki_nodes: Dict[str, Dict[str, Any]]) -> Dict[str, Any]:
|
|
25
|
+
errors: List[Dict[str, Any]] = []
|
|
26
|
+
warnings: List[Dict[str, Any]] = []
|
|
27
|
+
info: List[Dict[str, Any]] = []
|
|
28
|
+
slug_registry: Dict[str, str] = {}
|
|
29
|
+
|
|
30
|
+
if not self.schema_path.exists():
|
|
31
|
+
warnings.append(self._issue("schema", "schema_missing", "Schema file not found", "warning"))
|
|
32
|
+
|
|
33
|
+
for node_key, node in wiki_nodes.items():
|
|
34
|
+
self._validate_required(node_key, node, errors)
|
|
35
|
+
self._validate_kind(node_key, node, errors)
|
|
36
|
+
self._validate_section(node_key, node, errors)
|
|
37
|
+
self._validate_slug(node_key, node, slug_registry, errors)
|
|
38
|
+
self._validate_sources(node_key, node, warnings)
|
|
39
|
+
self._validate_summary(node_key, node, warnings)
|
|
40
|
+
self._validate_relations(node_key, node, wiki_nodes, errors)
|
|
41
|
+
|
|
42
|
+
quality_score = self._quality_score(total=len(wiki_nodes), errors=len(errors), warnings=len(warnings))
|
|
43
|
+
info.append(self._issue("summary", "quality_score", f"quality_score={quality_score}", "info"))
|
|
44
|
+
|
|
45
|
+
signature = hashlib.sha256(
|
|
46
|
+
json.dumps(wiki_nodes, sort_keys=True, ensure_ascii=True, separators=(",", ":")).encode("utf-8")
|
|
47
|
+
).hexdigest()
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
"generated_at": f"sha256:{signature}",
|
|
51
|
+
"schema_path": "autodocs/schema/wiki-node.schema.json",
|
|
52
|
+
"summary": {
|
|
53
|
+
"node_count": len(wiki_nodes),
|
|
54
|
+
"error_count": len(errors),
|
|
55
|
+
"warning_count": len(warnings),
|
|
56
|
+
"info_count": len(info),
|
|
57
|
+
"quality_score": quality_score,
|
|
58
|
+
},
|
|
59
|
+
"errors": errors,
|
|
60
|
+
"warnings": warnings,
|
|
61
|
+
"info": info,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
def write_reports(self, json_path: Path, markdown_path: Path, report: Dict[str, Any]) -> None:
|
|
65
|
+
json_path.parent.mkdir(parents=True, exist_ok=True)
|
|
66
|
+
with json_path.open("w", encoding="utf-8") as handle:
|
|
67
|
+
json.dump(report, handle, indent=2, ensure_ascii=True)
|
|
68
|
+
|
|
69
|
+
markdown = self._render_markdown_report(report)
|
|
70
|
+
with markdown_path.open("w", encoding="utf-8") as handle:
|
|
71
|
+
handle.write(markdown)
|
|
72
|
+
|
|
73
|
+
def _validate_required(self, node_key: str, node: Dict[str, Any], errors: List[Dict[str, Any]]) -> None:
|
|
74
|
+
required = ["title", "slug", "kind", "summary", "source_refs", "navigation"]
|
|
75
|
+
for field in required:
|
|
76
|
+
value = node.get(field)
|
|
77
|
+
if value in (None, "", [], {}):
|
|
78
|
+
errors.append(self._issue(node_key, "required", f"Missing required field: {field}", "error"))
|
|
79
|
+
|
|
80
|
+
def _validate_kind(self, node_key: str, node: Dict[str, Any], errors: List[Dict[str, Any]]) -> None:
|
|
81
|
+
kind = str(node.get("kind", "")).strip()
|
|
82
|
+
if kind and kind not in self.allowed_kinds:
|
|
83
|
+
errors.append(self._issue(node_key, "kind", f"Unsupported kind: {kind}", "error"))
|
|
84
|
+
|
|
85
|
+
def _validate_section(self, node_key: str, node: Dict[str, Any], errors: List[Dict[str, Any]]) -> None:
|
|
86
|
+
navigation = node.get("navigation", {}) if isinstance(node.get("navigation", {}), dict) else {}
|
|
87
|
+
section = str(navigation.get("section", "")).strip()
|
|
88
|
+
if section and section not in self.allowed_sections:
|
|
89
|
+
errors.append(self._issue(node_key, "section", f"Unsupported section: {section}", "error"))
|
|
90
|
+
|
|
91
|
+
def _validate_slug(
|
|
92
|
+
self,
|
|
93
|
+
node_key: str,
|
|
94
|
+
node: Dict[str, Any],
|
|
95
|
+
slug_registry: Dict[str, str],
|
|
96
|
+
errors: List[Dict[str, Any]],
|
|
97
|
+
) -> None:
|
|
98
|
+
slug = str(node.get("slug", "")).strip()
|
|
99
|
+
if not slug:
|
|
100
|
+
return
|
|
101
|
+
owner = slug_registry.get(slug)
|
|
102
|
+
if owner and owner != node_key:
|
|
103
|
+
errors.append(self._issue(node_key, "slug_duplicate", f"Duplicate slug: {slug}", "error"))
|
|
104
|
+
return
|
|
105
|
+
slug_registry[slug] = node_key
|
|
106
|
+
|
|
107
|
+
def _validate_sources(self, node_key: str, node: Dict[str, Any], warnings: List[Dict[str, Any]]) -> None:
|
|
108
|
+
source_refs = node.get("source_refs", [])
|
|
109
|
+
if not isinstance(source_refs, list) or not source_refs:
|
|
110
|
+
warnings.append(self._issue(node_key, "sources", "Node has no source refs", "warning"))
|
|
111
|
+
|
|
112
|
+
def _validate_summary(self, node_key: str, node: Dict[str, Any], warnings: List[Dict[str, Any]]) -> None:
|
|
113
|
+
summary = str(node.get("summary", "")).strip()
|
|
114
|
+
if len(summary) < 24:
|
|
115
|
+
warnings.append(self._issue(node_key, "summary", "Summary is too short", "warning"))
|
|
116
|
+
|
|
117
|
+
def _validate_relations(
|
|
118
|
+
self,
|
|
119
|
+
node_key: str,
|
|
120
|
+
node: Dict[str, Any],
|
|
121
|
+
wiki_nodes: Dict[str, Dict[str, Any]],
|
|
122
|
+
errors: List[Dict[str, Any]],
|
|
123
|
+
) -> None:
|
|
124
|
+
relations = node.get("relations", [])
|
|
125
|
+
if not isinstance(relations, list):
|
|
126
|
+
errors.append(self._issue(node_key, "relations", "Relations must be a list", "error"))
|
|
127
|
+
return
|
|
128
|
+
|
|
129
|
+
for relation in relations:
|
|
130
|
+
if not isinstance(relation, dict):
|
|
131
|
+
errors.append(self._issue(node_key, "relations", "Relation must be an object", "error"))
|
|
132
|
+
continue
|
|
133
|
+
target = str(relation.get("target", "")).strip()
|
|
134
|
+
if target and target not in wiki_nodes:
|
|
135
|
+
errors.append(self._issue(node_key, "relation_target", f"Relation target not found: {target}", "error"))
|
|
136
|
+
|
|
137
|
+
def _quality_score(self, total: int, errors: int, warnings: int) -> int:
|
|
138
|
+
if total <= 0:
|
|
139
|
+
return 100
|
|
140
|
+
penalty = errors * 20 + warnings * 5
|
|
141
|
+
score = max(0, 100 - penalty)
|
|
142
|
+
return score
|
|
143
|
+
|
|
144
|
+
def _issue(self, node: str, code: str, message: str, severity: str) -> Dict[str, str]:
|
|
145
|
+
return {
|
|
146
|
+
"node": node,
|
|
147
|
+
"code": code,
|
|
148
|
+
"severity": severity,
|
|
149
|
+
"message": message,
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
def _render_markdown_report(self, report: Dict[str, Any]) -> str:
|
|
153
|
+
summary = report.get("summary", {}) if isinstance(report.get("summary", {}), dict) else {}
|
|
154
|
+
lines = [
|
|
155
|
+
"# AutoDocs Validation Report",
|
|
156
|
+
"",
|
|
157
|
+
f"- generated_at: {report.get('generated_at', '')}",
|
|
158
|
+
f"- schema_path: {report.get('schema_path', '')}",
|
|
159
|
+
f"- node_count: {summary.get('node_count', 0)}",
|
|
160
|
+
f"- error_count: {summary.get('error_count', 0)}",
|
|
161
|
+
f"- warning_count: {summary.get('warning_count', 0)}",
|
|
162
|
+
f"- quality_score: {summary.get('quality_score', 0)}",
|
|
163
|
+
"",
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
lines.extend(self._render_issue_block("Errors", report.get("errors", [])))
|
|
167
|
+
lines.extend(self._render_issue_block("Warnings", report.get("warnings", [])))
|
|
168
|
+
lines.extend(self._render_issue_block("Info", report.get("info", [])))
|
|
169
|
+
return "\n".join(lines)
|
|
170
|
+
|
|
171
|
+
def _render_issue_block(self, title: str, issues: Any) -> List[str]:
|
|
172
|
+
lines = [f"## {title}", ""]
|
|
173
|
+
if not isinstance(issues, list) or not issues:
|
|
174
|
+
lines.append("- none")
|
|
175
|
+
lines.append("")
|
|
176
|
+
return lines
|
|
177
|
+
|
|
178
|
+
for issue in issues:
|
|
179
|
+
if not isinstance(issue, dict):
|
|
180
|
+
continue
|
|
181
|
+
lines.append(f"- [{issue.get('severity', '')}] {issue.get('node', '')}: {issue.get('message', '')}")
|
|
182
|
+
lines.append("")
|
|
183
|
+
return lines
|