xtrm-tools 0.5.24 → 0.5.26
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/.claude-plugin/marketplace.json +19 -0
- package/.claude-plugin/plugin.json +9 -0
- package/README.md +9 -3
- package/cli/dist/index.cjs +182 -219
- package/cli/dist/index.cjs.map +1 -1
- package/cli/package.json +1 -1
- package/config/hooks.json +8 -0
- package/hooks/beads-claim-sync.mjs +2 -4
- package/hooks/beads-commit-gate.mjs +2 -2
- package/hooks/beads-edit-gate.mjs +3 -3
- package/hooks/beads-memory-gate.mjs +2 -2
- package/hooks/beads-stop-gate.mjs +2 -2
- package/hooks/xtrm-logger.mjs +84 -91
- package/hooks/xtrm-session-logger.mjs +27 -0
- package/hooks/xtrm-tool-logger.mjs +53 -0
- package/package.json +5 -1
- package/plugins/xtrm-tools/.claude-plugin/plugin.json +9 -0
- package/plugins/xtrm-tools/.mcp.json +18 -0
- package/plugins/xtrm-tools/hooks/README.md +61 -0
- package/plugins/xtrm-tools/hooks/beads-claim-sync.mjs +223 -0
- package/plugins/xtrm-tools/hooks/beads-commit-gate.mjs +70 -0
- package/plugins/xtrm-tools/hooks/beads-compact-restore.mjs +69 -0
- package/plugins/xtrm-tools/hooks/beads-compact-save.mjs +51 -0
- package/plugins/xtrm-tools/hooks/beads-edit-gate.mjs +85 -0
- package/plugins/xtrm-tools/hooks/beads-gate-core.mjs +236 -0
- package/plugins/xtrm-tools/hooks/beads-gate-messages.mjs +68 -0
- package/plugins/xtrm-tools/hooks/beads-gate-utils.mjs +194 -0
- package/plugins/xtrm-tools/hooks/beads-memory-gate.mjs +81 -0
- package/plugins/xtrm-tools/hooks/beads-stop-gate.mjs +53 -0
- package/plugins/xtrm-tools/hooks/gitnexus/gitnexus-hook.cjs +222 -0
- package/plugins/xtrm-tools/hooks/hooks.json +115 -0
- package/plugins/xtrm-tools/hooks/quality-check-env.mjs +79 -0
- package/plugins/xtrm-tools/hooks/quality-check.cjs +1286 -0
- package/plugins/xtrm-tools/hooks/quality-check.py +345 -0
- package/plugins/xtrm-tools/hooks/statusline.mjs +145 -0
- package/plugins/xtrm-tools/hooks/using-xtrm-reminder.mjs +35 -0
- package/plugins/xtrm-tools/hooks/worktree-boundary.mjs +33 -0
- package/plugins/xtrm-tools/hooks/xtrm-logger.mjs +123 -0
- package/plugins/xtrm-tools/hooks/xtrm-session-logger.mjs +27 -0
- package/plugins/xtrm-tools/hooks/xtrm-tool-logger.mjs +53 -0
- package/plugins/xtrm-tools/skills/README.txt +31 -0
- package/plugins/xtrm-tools/skills/clean-code/SKILL.md +201 -0
- package/plugins/xtrm-tools/skills/creating-service-skills/SKILL.md +433 -0
- package/plugins/xtrm-tools/skills/creating-service-skills/references/script_quality_standards.md +425 -0
- package/plugins/xtrm-tools/skills/creating-service-skills/references/service_skill_system_guide.md +278 -0
- package/plugins/xtrm-tools/skills/creating-service-skills/scripts/bootstrap.py +326 -0
- package/plugins/xtrm-tools/skills/creating-service-skills/scripts/deep_dive.py +304 -0
- package/plugins/xtrm-tools/skills/creating-service-skills/scripts/scaffolder.py +482 -0
- package/plugins/xtrm-tools/skills/delegating/SKILL.md +196 -0
- package/plugins/xtrm-tools/skills/delegating/config.yaml +210 -0
- package/plugins/xtrm-tools/skills/delegating/references/orchestration-protocols.md +41 -0
- package/plugins/xtrm-tools/skills/docker-expert/SKILL.md +409 -0
- package/plugins/xtrm-tools/skills/documenting/CHANGELOG.md +23 -0
- package/plugins/xtrm-tools/skills/documenting/README.md +148 -0
- package/plugins/xtrm-tools/skills/documenting/SKILL.md +113 -0
- package/plugins/xtrm-tools/skills/documenting/examples/example_pattern.md +70 -0
- package/plugins/xtrm-tools/skills/documenting/examples/example_reference.md +70 -0
- package/plugins/xtrm-tools/skills/documenting/examples/example_ssot_analytics.md +64 -0
- package/plugins/xtrm-tools/skills/documenting/examples/example_workflow.md +141 -0
- package/plugins/xtrm-tools/skills/documenting/references/changelog-format.md +97 -0
- package/plugins/xtrm-tools/skills/documenting/references/metadata-schema.md +136 -0
- package/plugins/xtrm-tools/skills/documenting/references/taxonomy.md +81 -0
- package/plugins/xtrm-tools/skills/documenting/references/versioning-rules.md +78 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/bump_version.sh +60 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/changelog/__init__.py +0 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/changelog/add_entry.py +216 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/changelog/bump_release.py +117 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/changelog/init_changelog.py +54 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/changelog/validate_changelog.py +128 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/drift_detector.py +266 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/generate_template.py +311 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/list_by_category.sh +84 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/orchestrator.py +255 -0
- package/plugins/xtrm-tools/skills/documenting/scripts/validate_metadata.py +242 -0
- package/plugins/xtrm-tools/skills/documenting/templates/CHANGELOG.md.template +13 -0
- package/plugins/xtrm-tools/skills/documenting/tests/integration_test.sh +70 -0
- package/plugins/xtrm-tools/skills/documenting/tests/test_changelog.py +201 -0
- package/plugins/xtrm-tools/skills/documenting/tests/test_drift_detector.py +80 -0
- package/plugins/xtrm-tools/skills/documenting/tests/test_orchestrator.py +52 -0
- package/plugins/xtrm-tools/skills/documenting/tests/test_validate_metadata.py +64 -0
- package/plugins/xtrm-tools/skills/find-skills/SKILL.md +133 -0
- package/plugins/xtrm-tools/skills/gitnexus-debugging/SKILL.md +85 -0
- package/plugins/xtrm-tools/skills/gitnexus-exploring/SKILL.md +75 -0
- package/plugins/xtrm-tools/skills/gitnexus-impact-analysis/SKILL.md +94 -0
- package/plugins/xtrm-tools/skills/gitnexus-refactoring/SKILL.md +113 -0
- package/plugins/xtrm-tools/skills/hook-development/SKILL.md +797 -0
- package/plugins/xtrm-tools/skills/hook-development/examples/load-context.sh +55 -0
- package/plugins/xtrm-tools/skills/hook-development/examples/quality-check.js +1168 -0
- package/plugins/xtrm-tools/skills/hook-development/examples/validate-bash.sh +43 -0
- package/plugins/xtrm-tools/skills/hook-development/examples/validate-write.sh +38 -0
- package/plugins/xtrm-tools/skills/hook-development/references/advanced.md +527 -0
- package/plugins/xtrm-tools/skills/hook-development/references/migration.md +369 -0
- package/plugins/xtrm-tools/skills/hook-development/references/patterns.md +412 -0
- package/plugins/xtrm-tools/skills/hook-development/scripts/README.md +164 -0
- package/plugins/xtrm-tools/skills/hook-development/scripts/hook-linter.sh +153 -0
- package/plugins/xtrm-tools/skills/hook-development/scripts/test-hook.sh +252 -0
- package/plugins/xtrm-tools/skills/hook-development/scripts/validate-hook-schema.sh +159 -0
- package/plugins/xtrm-tools/skills/obsidian-cli/SKILL.md +106 -0
- package/plugins/xtrm-tools/skills/orchestrating-agents/SKILL.md +135 -0
- package/plugins/xtrm-tools/skills/orchestrating-agents/config.yaml +45 -0
- package/plugins/xtrm-tools/skills/orchestrating-agents/references/agent-context-integration.md +37 -0
- package/plugins/xtrm-tools/skills/orchestrating-agents/references/examples.md +45 -0
- package/plugins/xtrm-tools/skills/orchestrating-agents/references/handover-protocol.md +31 -0
- package/plugins/xtrm-tools/skills/orchestrating-agents/references/workflows.md +42 -0
- package/plugins/xtrm-tools/skills/orchestrating-agents/scripts/detect_neighbors.py +23 -0
- package/plugins/xtrm-tools/skills/prompt-improving/README.md +162 -0
- package/plugins/xtrm-tools/skills/prompt-improving/SKILL.md +74 -0
- package/plugins/xtrm-tools/skills/prompt-improving/references/analysis_commands.md +24 -0
- package/plugins/xtrm-tools/skills/prompt-improving/references/chain_of_thought.md +24 -0
- package/plugins/xtrm-tools/skills/prompt-improving/references/mcp_definitions.md +20 -0
- package/plugins/xtrm-tools/skills/prompt-improving/references/multishot.md +23 -0
- package/plugins/xtrm-tools/skills/prompt-improving/references/xml_core.md +60 -0
- package/plugins/xtrm-tools/skills/python-testing/SKILL.md +815 -0
- package/plugins/xtrm-tools/skills/scoping-service-skills/SKILL.md +231 -0
- package/plugins/xtrm-tools/skills/scoping-service-skills/scripts/scope.py +74 -0
- package/plugins/xtrm-tools/skills/senior-backend/SKILL.md +209 -0
- package/plugins/xtrm-tools/skills/senior-backend/references/api_design_patterns.md +103 -0
- package/plugins/xtrm-tools/skills/senior-backend/references/backend_security_practices.md +103 -0
- package/plugins/xtrm-tools/skills/senior-backend/references/database_optimization_guide.md +103 -0
- package/plugins/xtrm-tools/skills/senior-backend/scripts/api_load_tester.py +114 -0
- package/plugins/xtrm-tools/skills/senior-backend/scripts/api_scaffolder.py +114 -0
- package/plugins/xtrm-tools/skills/senior-backend/scripts/database_migration_tool.py +114 -0
- package/plugins/xtrm-tools/skills/senior-data-scientist/SKILL.md +226 -0
- package/plugins/xtrm-tools/skills/senior-data-scientist/references/experiment_design_frameworks.md +80 -0
- package/plugins/xtrm-tools/skills/senior-data-scientist/references/feature_engineering_patterns.md +80 -0
- package/plugins/xtrm-tools/skills/senior-data-scientist/references/statistical_methods_advanced.md +80 -0
- package/plugins/xtrm-tools/skills/senior-data-scientist/scripts/experiment_designer.py +100 -0
- package/plugins/xtrm-tools/skills/senior-data-scientist/scripts/feature_engineering_pipeline.py +100 -0
- package/plugins/xtrm-tools/skills/senior-data-scientist/scripts/model_evaluation_suite.py +100 -0
- package/plugins/xtrm-tools/skills/senior-devops/SKILL.md +209 -0
- package/plugins/xtrm-tools/skills/senior-devops/references/cicd_pipeline_guide.md +103 -0
- package/plugins/xtrm-tools/skills/senior-devops/references/deployment_strategies.md +103 -0
- package/plugins/xtrm-tools/skills/senior-devops/references/infrastructure_as_code.md +103 -0
- package/plugins/xtrm-tools/skills/senior-devops/scripts/deployment_manager.py +114 -0
- package/plugins/xtrm-tools/skills/senior-devops/scripts/pipeline_generator.py +114 -0
- package/plugins/xtrm-tools/skills/senior-devops/scripts/terraform_scaffolder.py +114 -0
- package/plugins/xtrm-tools/skills/senior-security/SKILL.md +209 -0
- package/plugins/xtrm-tools/skills/senior-security/references/cryptography_implementation.md +103 -0
- package/plugins/xtrm-tools/skills/senior-security/references/penetration_testing_guide.md +103 -0
- package/plugins/xtrm-tools/skills/senior-security/references/security_architecture_patterns.md +103 -0
- package/plugins/xtrm-tools/skills/senior-security/scripts/pentest_automator.py +114 -0
- package/plugins/xtrm-tools/skills/senior-security/scripts/security_auditor.py +114 -0
- package/plugins/xtrm-tools/skills/senior-security/scripts/threat_modeler.py +114 -0
- package/plugins/xtrm-tools/skills/skill-creator/LICENSE.txt +202 -0
- package/plugins/xtrm-tools/skills/skill-creator/SKILL.md +479 -0
- package/plugins/xtrm-tools/skills/skill-creator/agents/analyzer.md +274 -0
- package/plugins/xtrm-tools/skills/skill-creator/agents/comparator.md +202 -0
- package/plugins/xtrm-tools/skills/skill-creator/agents/grader.md +223 -0
- package/plugins/xtrm-tools/skills/skill-creator/assets/eval_review.html +146 -0
- package/plugins/xtrm-tools/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/plugins/xtrm-tools/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/plugins/xtrm-tools/skills/skill-creator/references/schemas.md +430 -0
- package/plugins/xtrm-tools/skills/skill-creator/scripts/__init__.py +0 -0
- package/plugins/xtrm-tools/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/plugins/xtrm-tools/skills/skill-creator/scripts/generate_report.py +326 -0
- package/plugins/xtrm-tools/skills/skill-creator/scripts/improve_description.py +248 -0
- package/plugins/xtrm-tools/skills/skill-creator/scripts/package_skill.py +136 -0
- package/plugins/xtrm-tools/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/plugins/xtrm-tools/skills/skill-creator/scripts/run_eval.py +310 -0
- package/plugins/xtrm-tools/skills/skill-creator/scripts/run_loop.py +332 -0
- package/plugins/xtrm-tools/skills/skill-creator/scripts/utils.py +47 -0
- package/plugins/xtrm-tools/skills/sync-docs/SKILL.md +155 -0
- package/plugins/xtrm-tools/skills/sync-docs/evals/evals.json +89 -0
- package/plugins/xtrm-tools/skills/sync-docs/references/doc-structure.md +99 -0
- package/plugins/xtrm-tools/skills/sync-docs/references/schema.md +103 -0
- package/plugins/xtrm-tools/skills/sync-docs/scripts/changelog/add_entry.py +216 -0
- package/plugins/xtrm-tools/skills/sync-docs/scripts/context_gatherer.py +240 -0
- package/plugins/xtrm-tools/skills/sync-docs/scripts/doc_structure_analyzer.py +495 -0
- package/plugins/xtrm-tools/skills/sync-docs/scripts/drift_detector.py +563 -0
- package/plugins/xtrm-tools/skills/sync-docs/scripts/validate_doc.py +365 -0
- package/plugins/xtrm-tools/skills/sync-docs/scripts/validate_metadata.py +185 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/benchmark.json +293 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/benchmark.md +13 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-doc-audit/eval_metadata.json +27 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-doc-audit/with_skill/outputs/result.md +210 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-doc-audit/with_skill/run-1/grading.json +28 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-doc-audit/with_skill/run-1/timing.json +1 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-doc-audit/without_skill/outputs/result.md +101 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-doc-audit/without_skill/run-1/grading.json +28 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-doc-audit/without_skill/run-1/timing.json +5 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-doc-audit/without_skill/timing.json +5 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-fix-mode/eval_metadata.json +27 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-fix-mode/with_skill/outputs/result.md +198 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-fix-mode/with_skill/run-1/grading.json +28 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-fix-mode/with_skill/run-1/timing.json +1 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-fix-mode/without_skill/outputs/result.md +94 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-fix-mode/without_skill/run-1/grading.json +28 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-fix-mode/without_skill/run-1/timing.json +1 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/eval_metadata.json +27 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/with_skill/outputs/result.md +237 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/with_skill/run-1/grading.json +28 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/with_skill/run-1/timing.json +1 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/without_skill/outputs/result.md +134 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/without_skill/run-1/grading.json +28 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/without_skill/run-1/timing.json +1 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/benchmark.json +297 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/benchmark.md +13 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-doc-audit/eval_metadata.json +27 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-doc-audit/with_skill/outputs/result.md +137 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-doc-audit/with_skill/run-1/grading.json +92 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-doc-audit/with_skill/run-1/timing.json +1 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-doc-audit/without_skill/outputs/result.md +134 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-doc-audit/without_skill/run-1/grading.json +86 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-doc-audit/without_skill/run-1/timing.json +1 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-fix-mode/eval_metadata.json +27 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-fix-mode/with_skill/outputs/result.md +193 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-fix-mode/with_skill/run-1/grading.json +72 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-fix-mode/with_skill/run-1/timing.json +1 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-fix-mode/without_skill/outputs/result.md +211 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-fix-mode/without_skill/run-1/grading.json +91 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-fix-mode/without_skill/run-1/timing.json +5 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/eval_metadata.json +27 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/with_skill/outputs/result.md +182 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/with_skill/run-1/grading.json +95 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/with_skill/run-1/timing.json +1 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/without_skill/outputs/result.md +222 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/without_skill/run-1/grading.json +88 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/without_skill/run-1/timing.json +5 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/benchmark.json +298 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/benchmark.md +13 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-doc-audit/eval_metadata.json +27 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-doc-audit/with_skill/outputs/result.md +125 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-doc-audit/with_skill/run-1/grading.json +97 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-doc-audit/with_skill/run-1/timing.json +5 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-doc-audit/without_skill/outputs/result.md +144 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-doc-audit/without_skill/run-1/grading.json +78 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-doc-audit/without_skill/run-1/timing.json +5 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-fix-mode/eval_metadata.json +27 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-fix-mode/with_skill/outputs/result.md +104 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-fix-mode/with_skill/run-1/grading.json +91 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-fix-mode/with_skill/run-1/timing.json +5 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-fix-mode/without_skill/outputs/result.md +79 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-fix-mode/without_skill/run-1/grading.json +82 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-fix-mode/without_skill/run-1/timing.json +5 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/eval_metadata.json +27 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase1_context.json +302 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase2_drift.txt +33 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase3_analysis.json +114 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase4_fix.txt +118 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase5_validate.txt +38 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/result.md +158 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/run-1/grading.json +95 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/run-1/timing.json +5 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/without_skill/outputs/result.md +71 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/without_skill/run-1/grading.json +90 -0
- package/plugins/xtrm-tools/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/without_skill/run-1/timing.json +5 -0
- package/plugins/xtrm-tools/skills/test-planning/SKILL.md +208 -0
- package/plugins/xtrm-tools/skills/test-planning/evals/evals.json +23 -0
- package/plugins/xtrm-tools/skills/updating-service-skills/SKILL.md +136 -0
- package/plugins/xtrm-tools/skills/updating-service-skills/scripts/drift_detector.py +222 -0
- package/plugins/xtrm-tools/skills/using-TDD/SKILL.md +410 -0
- package/plugins/xtrm-tools/skills/using-quality-gates/SKILL.md +254 -0
- package/plugins/xtrm-tools/skills/using-serena-lsp/README.md +8 -0
- package/plugins/xtrm-tools/skills/using-serena-lsp/REFERENCE.md +194 -0
- package/plugins/xtrm-tools/skills/using-serena-lsp/SKILL.md +82 -0
- package/plugins/xtrm-tools/skills/using-service-skills/SKILL.md +108 -0
- package/plugins/xtrm-tools/skills/using-service-skills/scripts/cataloger.py +74 -0
- package/plugins/xtrm-tools/skills/using-service-skills/scripts/skill_activator.py +152 -0
- package/plugins/xtrm-tools/skills/using-service-skills/scripts/test_skill_activator.py +58 -0
- package/plugins/xtrm-tools/skills/using-xtrm/SKILL.md +124 -0
- package/plugins/xtrm-tools/skills/xt-end/SKILL.md +128 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Validate and generate schema-compliant docs/ files.
|
|
4
|
+
|
|
5
|
+
Schema for docs/ files:
|
|
6
|
+
Required: title, scope, category, version, updated
|
|
7
|
+
Optional: description, source_of_truth_for (glob list), domain (tag list)
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
validate_doc.py <file_or_dir> # validate one file or all *.md in dir
|
|
11
|
+
validate_doc.py --generate <path> # generate scaffold + required flags below
|
|
12
|
+
--title="..."
|
|
13
|
+
--scope="..."
|
|
14
|
+
--category="reference|guide|architecture|api"
|
|
15
|
+
--source-for="glob1,glob2" # optional
|
|
16
|
+
--description="..." # optional
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import sys
|
|
20
|
+
import re
|
|
21
|
+
import json
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from datetime import date
|
|
24
|
+
|
|
25
|
+
# ── Schema ────────────────────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
REQUIRED_FIELDS = ["title", "scope", "category", "version", "updated"]
|
|
28
|
+
VALID_CATEGORIES = ["reference", "guide", "architecture", "api", "plan", "overview"]
|
|
29
|
+
|
|
30
|
+
CATEGORY_DESCRIPTIONS = {
|
|
31
|
+
"reference": "Look-up table, cheat sheet, or technical specification",
|
|
32
|
+
"guide": "How-to documentation with step-by-step instructions",
|
|
33
|
+
"architecture": "System design, component relationships, high-level overview",
|
|
34
|
+
"api": "API contracts, interfaces, or data schemas",
|
|
35
|
+
"plan": "Implementation plan or roadmap",
|
|
36
|
+
"overview": "Summary introduction to a subsystem",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# ── Frontmatter helpers ───────────────────────────────────────────────────────
|
|
41
|
+
|
|
42
|
+
def extract_frontmatter(content: str) -> dict | None:
|
|
43
|
+
"""Parse simple YAML frontmatter without external dependencies.
|
|
44
|
+
|
|
45
|
+
Handles scalar values, quoted strings, and list fields (- item syntax).
|
|
46
|
+
"""
|
|
47
|
+
m = re.match(r"^---\n(.*?)\n---\n", content, re.DOTALL)
|
|
48
|
+
if not m:
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
result: dict[str, object] = {}
|
|
52
|
+
current_key: str | None = None
|
|
53
|
+
current_list: list[str] | None = None
|
|
54
|
+
|
|
55
|
+
for line in m.group(1).splitlines():
|
|
56
|
+
# List item under current key
|
|
57
|
+
if current_list is not None and re.match(r"^\s+-\s+", line):
|
|
58
|
+
current_list.append(re.sub(r"^\s+-\s+", "", line).strip().strip('"\''))
|
|
59
|
+
continue
|
|
60
|
+
|
|
61
|
+
# New key: value line
|
|
62
|
+
kv = re.match(r'^([a-zA-Z_][a-zA-Z0-9_]*)\s*:\s*(.*)', line)
|
|
63
|
+
if kv:
|
|
64
|
+
# Flush previous list
|
|
65
|
+
if current_key is not None and current_list is not None:
|
|
66
|
+
result[current_key] = current_list
|
|
67
|
+
|
|
68
|
+
current_key = kv.group(1)
|
|
69
|
+
raw_val = kv.group(2).strip()
|
|
70
|
+
|
|
71
|
+
if raw_val == "" or raw_val == ">-":
|
|
72
|
+
# Value on following lines (list or multiline) — start list
|
|
73
|
+
current_list = []
|
|
74
|
+
elif raw_val.startswith("["):
|
|
75
|
+
# Inline list: [a, b, c]
|
|
76
|
+
current_list = None
|
|
77
|
+
inner = raw_val.strip("[]")
|
|
78
|
+
result[current_key] = [v.strip().strip('"\'') for v in inner.split(",") if v.strip()]
|
|
79
|
+
else:
|
|
80
|
+
current_list = None
|
|
81
|
+
result[current_key] = raw_val.strip('"\'')
|
|
82
|
+
else:
|
|
83
|
+
# Continuation line for multiline scalar — ignore for our purposes
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
# Flush trailing list
|
|
87
|
+
if current_key is not None and current_list is not None:
|
|
88
|
+
result[current_key] = current_list
|
|
89
|
+
|
|
90
|
+
return result
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def extract_headings(content: str) -> list[tuple[str, str]]:
|
|
94
|
+
"""Return (heading, first_sentence) for every ## section."""
|
|
95
|
+
results = []
|
|
96
|
+
lines = content.splitlines()
|
|
97
|
+
i = 0
|
|
98
|
+
while i < len(lines):
|
|
99
|
+
line = lines[i]
|
|
100
|
+
if line.startswith("## ") and not line.startswith("### "):
|
|
101
|
+
heading = line[3:].strip()
|
|
102
|
+
summary = ""
|
|
103
|
+
j = i + 1
|
|
104
|
+
in_code = False
|
|
105
|
+
while j < len(lines):
|
|
106
|
+
ln = lines[j].strip()
|
|
107
|
+
if ln.startswith("```"):
|
|
108
|
+
in_code = not in_code
|
|
109
|
+
j += 1
|
|
110
|
+
continue
|
|
111
|
+
if not in_code and ln and not ln.startswith("#"):
|
|
112
|
+
summary = ln.split(".")[0].strip()[:120]
|
|
113
|
+
break
|
|
114
|
+
j += 1
|
|
115
|
+
results.append((heading, summary))
|
|
116
|
+
i += 1
|
|
117
|
+
return results
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def make_anchor(heading: str) -> str:
|
|
121
|
+
"""Generate a GitHub-compatible anchor from a heading string."""
|
|
122
|
+
anchor = heading.lower()
|
|
123
|
+
anchor = re.sub(r"\s+", "-", anchor) # spaces → hyphens
|
|
124
|
+
anchor = re.sub(r"[^a-z0-9\-]", "", anchor) # strip non-alphanumeric (except -)
|
|
125
|
+
anchor = re.sub(r"-+", "-", anchor) # collapse runs
|
|
126
|
+
return anchor.strip("-")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def generate_index_table(headings: list[tuple[str, str]]) -> str:
|
|
130
|
+
rows = ["| Section | Summary |", "|---|---|"]
|
|
131
|
+
for heading, summary in headings:
|
|
132
|
+
rows.append(f"| [{heading}](#{make_anchor(heading)}) | {summary or '_no summary_'} |")
|
|
133
|
+
return "\n".join(rows) + "\n"
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def inject_index(content: str, table: str) -> str:
|
|
137
|
+
header = "<!-- INDEX: auto-generated by validate_doc.py — do not edit manually -->\n"
|
|
138
|
+
footer = "<!-- END INDEX -->"
|
|
139
|
+
block = f"{header}{table}{footer}"
|
|
140
|
+
|
|
141
|
+
existing = re.search(r"<!-- INDEX:.*?-->.*?<!-- END INDEX -->", content, re.DOTALL)
|
|
142
|
+
if existing:
|
|
143
|
+
return content[: existing.start()] + block + content[existing.end() :]
|
|
144
|
+
|
|
145
|
+
fm_match = re.match(r"^(---\n.*?\n---\n)(.*)", content, re.DOTALL)
|
|
146
|
+
if fm_match:
|
|
147
|
+
return fm_match.group(1) + "\n" + block + "\n" + fm_match.group(2)
|
|
148
|
+
|
|
149
|
+
return block + "\n" + content
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# ── Validation ────────────────────────────────────────────────────────────────
|
|
153
|
+
|
|
154
|
+
def validate_file(path: Path) -> tuple[bool, list[str], list[str]]:
|
|
155
|
+
"""Returns (passed, errors, warnings)."""
|
|
156
|
+
errors: list[str] = []
|
|
157
|
+
warnings: list[str] = []
|
|
158
|
+
|
|
159
|
+
if not path.exists():
|
|
160
|
+
return False, [f"File not found: {path}"], []
|
|
161
|
+
|
|
162
|
+
content = path.read_text(encoding="utf-8")
|
|
163
|
+
fm = extract_frontmatter(content)
|
|
164
|
+
|
|
165
|
+
if fm is None:
|
|
166
|
+
errors.append("Missing or invalid YAML frontmatter (wrap in --- markers)")
|
|
167
|
+
return False, errors, warnings
|
|
168
|
+
|
|
169
|
+
# Required fields
|
|
170
|
+
for field in REQUIRED_FIELDS:
|
|
171
|
+
if field not in fm:
|
|
172
|
+
errors.append(f"Missing required field: {field}")
|
|
173
|
+
|
|
174
|
+
# version format
|
|
175
|
+
if "version" in fm:
|
|
176
|
+
if not re.match(r"^\d+\.\d+\.\d+$", str(fm["version"])):
|
|
177
|
+
errors.append(f"version must be semver (x.y.z), got: {fm['version']}")
|
|
178
|
+
|
|
179
|
+
# updated format
|
|
180
|
+
if "updated" in fm:
|
|
181
|
+
if not re.match(r"^\d{4}-\d{2}-\d{2}", str(fm["updated"])):
|
|
182
|
+
warnings.append(f"updated should be ISO date (YYYY-MM-DD), got: {fm['updated']}")
|
|
183
|
+
|
|
184
|
+
# category valid
|
|
185
|
+
if "category" in fm and fm["category"] not in VALID_CATEGORIES:
|
|
186
|
+
errors.append(
|
|
187
|
+
f"category '{fm['category']}' not valid. Choose from: {', '.join(VALID_CATEGORIES)}"
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# domain is list
|
|
191
|
+
if "domain" in fm and not isinstance(fm["domain"], list):
|
|
192
|
+
errors.append("domain must be a list, e.g. [hooks, claude]")
|
|
193
|
+
|
|
194
|
+
# source_of_truth_for and tracks are lists of globs
|
|
195
|
+
if "source_of_truth_for" in fm and not isinstance(fm["source_of_truth_for"], list):
|
|
196
|
+
errors.append("source_of_truth_for must be a list of glob patterns")
|
|
197
|
+
if "tracks" in fm and not isinstance(fm["tracks"], list):
|
|
198
|
+
errors.append("tracks must be a list of glob patterns")
|
|
199
|
+
|
|
200
|
+
# Regenerate INDEX if valid
|
|
201
|
+
if not errors:
|
|
202
|
+
headings = extract_headings(content)
|
|
203
|
+
if headings:
|
|
204
|
+
table = generate_index_table(headings)
|
|
205
|
+
new_content = inject_index(content, table)
|
|
206
|
+
if new_content != content:
|
|
207
|
+
path.write_text(new_content, encoding="utf-8")
|
|
208
|
+
warnings.append("INDEX regenerated")
|
|
209
|
+
|
|
210
|
+
return len(errors) == 0, errors, warnings
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def validate_directory(docs_dir: Path) -> dict:
|
|
214
|
+
results = {}
|
|
215
|
+
for md_file in sorted(docs_dir.glob("*.md")):
|
|
216
|
+
passed, errors, warnings = validate_file(md_file)
|
|
217
|
+
results[str(md_file.relative_to(docs_dir.parent))] = {
|
|
218
|
+
"passed": passed,
|
|
219
|
+
"errors": errors,
|
|
220
|
+
"warnings": warnings,
|
|
221
|
+
}
|
|
222
|
+
return results
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def print_file_result(path: str, passed: bool, errors: list[str], warnings: list[str]) -> None:
|
|
226
|
+
status = "PASS" if passed else "FAIL"
|
|
227
|
+
mark = "" if passed else ""
|
|
228
|
+
print(f"\n{mark} {path} [{status}]")
|
|
229
|
+
for e in errors:
|
|
230
|
+
print(f" ERROR: {e}")
|
|
231
|
+
for w in warnings:
|
|
232
|
+
print(f" WARN: {w}")
|
|
233
|
+
if passed and not warnings:
|
|
234
|
+
print(" All checks passed.")
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
# ── Generator ─────────────────────────────────────────────────────────────────
|
|
238
|
+
|
|
239
|
+
SCAFFOLD_TEMPLATE = """\
|
|
240
|
+
---
|
|
241
|
+
title: {title}
|
|
242
|
+
scope: {scope}
|
|
243
|
+
category: {category}
|
|
244
|
+
version: 1.0.0
|
|
245
|
+
updated: {today}
|
|
246
|
+
{source_field}{tracks_field}{description_field}domain: []
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
<!-- INDEX: auto-generated by validate_doc.py — do not edit manually -->
|
|
250
|
+
<!-- END INDEX -->
|
|
251
|
+
|
|
252
|
+
# {title}
|
|
253
|
+
|
|
254
|
+
> {category_desc}
|
|
255
|
+
|
|
256
|
+
## Overview
|
|
257
|
+
|
|
258
|
+
_Describe what this document covers._
|
|
259
|
+
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def generate_scaffold(output_path: Path, title: str, scope: str, category: str,
|
|
264
|
+
source_for: list[str], description: str) -> None:
|
|
265
|
+
source_field = ""
|
|
266
|
+
tracks_field = ""
|
|
267
|
+
if source_for:
|
|
268
|
+
items = "\n".join(f' - "{g}"' for g in source_for)
|
|
269
|
+
source_field = f"source_of_truth_for:\n{items}\n"
|
|
270
|
+
# tracks: mirrors source_of_truth_for so drift_detector.py picks up changes
|
|
271
|
+
tracks_field = f"tracks:\n{items}\n"
|
|
272
|
+
|
|
273
|
+
desc_field = f'description: "{description}"\n' if description else ""
|
|
274
|
+
category_desc = CATEGORY_DESCRIPTIONS.get(category, category)
|
|
275
|
+
|
|
276
|
+
content = SCAFFOLD_TEMPLATE.format(
|
|
277
|
+
title=title,
|
|
278
|
+
scope=scope,
|
|
279
|
+
category=category,
|
|
280
|
+
today=date.today().isoformat(),
|
|
281
|
+
source_field=source_field,
|
|
282
|
+
tracks_field=tracks_field,
|
|
283
|
+
description_field=desc_field,
|
|
284
|
+
category_desc=category_desc,
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
288
|
+
output_path.write_text(content, encoding="utf-8")
|
|
289
|
+
print(f"Generated: {output_path}")
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
# ── Entry point ───────────────────────────────────────────────────────────────
|
|
293
|
+
|
|
294
|
+
def main() -> None:
|
|
295
|
+
args = sys.argv[1:]
|
|
296
|
+
|
|
297
|
+
if not args:
|
|
298
|
+
print("Usage:")
|
|
299
|
+
print(" validate_doc.py <file_or_dir>")
|
|
300
|
+
print(" validate_doc.py --generate <path> --title=... --scope=... --category=...")
|
|
301
|
+
sys.exit(1)
|
|
302
|
+
|
|
303
|
+
# Generate mode
|
|
304
|
+
if "--generate" in args:
|
|
305
|
+
idx = args.index("--generate")
|
|
306
|
+
if idx + 1 >= len(args):
|
|
307
|
+
print("ERROR: --generate requires a path argument")
|
|
308
|
+
sys.exit(1)
|
|
309
|
+
output_path = Path(args[idx + 1])
|
|
310
|
+
|
|
311
|
+
kw: dict[str, str] = {}
|
|
312
|
+
source_for: list[str] = []
|
|
313
|
+
for arg in args:
|
|
314
|
+
if arg.startswith("--title="):
|
|
315
|
+
kw["title"] = arg.split("=", 1)[1]
|
|
316
|
+
elif arg.startswith("--scope="):
|
|
317
|
+
kw["scope"] = arg.split("=", 1)[1]
|
|
318
|
+
elif arg.startswith("--category="):
|
|
319
|
+
kw["category"] = arg.split("=", 1)[1]
|
|
320
|
+
elif arg.startswith("--source-for="):
|
|
321
|
+
source_for = [g.strip() for g in arg.split("=", 1)[1].split(",")]
|
|
322
|
+
elif arg.startswith("--description="):
|
|
323
|
+
kw["description"] = arg.split("=", 1)[1]
|
|
324
|
+
|
|
325
|
+
for req in ["title", "scope", "category"]:
|
|
326
|
+
if req not in kw:
|
|
327
|
+
print(f"ERROR: --{req} is required for --generate")
|
|
328
|
+
sys.exit(1)
|
|
329
|
+
|
|
330
|
+
generate_scaffold(
|
|
331
|
+
output_path,
|
|
332
|
+
title=kw["title"],
|
|
333
|
+
scope=kw["scope"],
|
|
334
|
+
category=kw["category"],
|
|
335
|
+
source_for=source_for,
|
|
336
|
+
description=kw.get("description", ""),
|
|
337
|
+
)
|
|
338
|
+
sys.exit(0)
|
|
339
|
+
|
|
340
|
+
# Validate mode
|
|
341
|
+
target = Path(args[0])
|
|
342
|
+
all_passed = True
|
|
343
|
+
|
|
344
|
+
if target.is_dir():
|
|
345
|
+
results = validate_directory(target)
|
|
346
|
+
for path_str, res in results.items():
|
|
347
|
+
print_file_result(path_str, res["passed"], res["errors"], res["warnings"])
|
|
348
|
+
if not res["passed"]:
|
|
349
|
+
all_passed = False
|
|
350
|
+
if results:
|
|
351
|
+
total = len(results)
|
|
352
|
+
passed = sum(1 for r in results.values() if r["passed"])
|
|
353
|
+
print(f"\nResult: {passed}/{total} files passed")
|
|
354
|
+
else:
|
|
355
|
+
print(f"No .md files found in {target}")
|
|
356
|
+
else:
|
|
357
|
+
passed, errors, warnings = validate_file(target)
|
|
358
|
+
print_file_result(str(target), passed, errors, warnings)
|
|
359
|
+
all_passed = passed
|
|
360
|
+
|
|
361
|
+
sys.exit(0 if all_passed else 1)
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
if __name__ == "__main__":
|
|
365
|
+
main()
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Validate docs/ markdown metadata compliance.
|
|
4
|
+
|
|
5
|
+
Checks frontmatter schema for docs/*.md files and regenerates INDEX tables.
|
|
6
|
+
Runs as a local sync-docs validator (no external skill dependencies).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import sys
|
|
10
|
+
import re
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
import yaml
|
|
15
|
+
except ImportError:
|
|
16
|
+
yaml = None
|
|
17
|
+
|
|
18
|
+
REQUIRED_FIELDS = ["title", "scope", "category", "version", "updated"]
|
|
19
|
+
VALID_CATEGORIES = {"reference", "guide", "architecture", "api", "plan", "overview"}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def extract_headings(content: str) -> list[tuple[str, str]]:
|
|
23
|
+
results = []
|
|
24
|
+
lines = content.splitlines()
|
|
25
|
+
i = 0
|
|
26
|
+
while i < len(lines):
|
|
27
|
+
line = lines[i]
|
|
28
|
+
if line.startswith("## ") and not line.startswith("### "):
|
|
29
|
+
heading = line[3:].strip()
|
|
30
|
+
summary = ""
|
|
31
|
+
j = i + 1
|
|
32
|
+
in_code = False
|
|
33
|
+
while j < len(lines):
|
|
34
|
+
text = lines[j].strip()
|
|
35
|
+
if text.startswith("```"):
|
|
36
|
+
in_code = not in_code
|
|
37
|
+
j += 1
|
|
38
|
+
continue
|
|
39
|
+
if not in_code and text and not text.startswith("#") and not text.startswith("|") and not text.startswith("-"):
|
|
40
|
+
summary = text.split(".")[0].strip()[:120]
|
|
41
|
+
break
|
|
42
|
+
j += 1
|
|
43
|
+
results.append((heading, summary))
|
|
44
|
+
i += 1
|
|
45
|
+
return results
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def generate_index_table(headings: list[tuple[str, str]]) -> str:
|
|
49
|
+
rows = ["| Section | Summary |", "|---|---|"]
|
|
50
|
+
for heading, summary in headings:
|
|
51
|
+
anchor = heading.lower()
|
|
52
|
+
for ch in "/()":
|
|
53
|
+
anchor = anchor.replace(ch, "")
|
|
54
|
+
anchor = re.sub(r"[\s_]+", "-", anchor)
|
|
55
|
+
anchor = re.sub(r"-+", "-", anchor).strip("-")
|
|
56
|
+
rows.append(f"| [{heading}](#{anchor}) | {summary or '_no summary_'} |")
|
|
57
|
+
return "\n".join(rows) + "\n"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def inject_index(content: str, table: str) -> str:
|
|
61
|
+
header = "<!-- INDEX: auto-generated by validate_metadata.py — do not edit manually -->\n"
|
|
62
|
+
footer = "<!-- END INDEX -->"
|
|
63
|
+
block = f"{header}{table}{footer}"
|
|
64
|
+
|
|
65
|
+
existing = re.search(r"<!-- INDEX:.*?-->.*?<!-- END INDEX -->", content, re.DOTALL)
|
|
66
|
+
if existing:
|
|
67
|
+
return content[: existing.start()] + block + content[existing.end() :]
|
|
68
|
+
|
|
69
|
+
fm_match = re.match(r"^(---\n.*?\n---\n)(.*)", content, re.DOTALL)
|
|
70
|
+
if fm_match:
|
|
71
|
+
return fm_match.group(1) + "\n" + block + "\n" + fm_match.group(2)
|
|
72
|
+
|
|
73
|
+
return block + "\n" + content
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def extract_frontmatter(content: str) -> dict:
|
|
77
|
+
match = re.match(r"^---\n(.*?)\n---\n", content, re.DOTALL)
|
|
78
|
+
if not match:
|
|
79
|
+
return {}
|
|
80
|
+
|
|
81
|
+
raw = match.group(1)
|
|
82
|
+
if yaml is not None:
|
|
83
|
+
try:
|
|
84
|
+
return yaml.safe_load(raw) or {}
|
|
85
|
+
except Exception:
|
|
86
|
+
return {}
|
|
87
|
+
|
|
88
|
+
data = {}
|
|
89
|
+
for line in raw.splitlines():
|
|
90
|
+
if ":" in line:
|
|
91
|
+
key, value = line.split(":", 1)
|
|
92
|
+
data[key.strip()] = value.strip().strip('"')
|
|
93
|
+
return data
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def validate_semver(value: str) -> bool:
|
|
97
|
+
return bool(re.match(r"^\d+\.\d+\.\d+$", str(value)))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def validate_date(value: str) -> bool:
|
|
101
|
+
return bool(re.match(r"^\d{4}-\d{2}-\d{2}$", str(value)))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def validate_metadata_file(path: Path) -> bool:
|
|
105
|
+
if not path.exists():
|
|
106
|
+
print(f"ERROR: File not found: {path}")
|
|
107
|
+
return False
|
|
108
|
+
|
|
109
|
+
content = path.read_text(encoding="utf-8")
|
|
110
|
+
fm = extract_frontmatter(content)
|
|
111
|
+
|
|
112
|
+
errors = []
|
|
113
|
+
warnings = []
|
|
114
|
+
|
|
115
|
+
if not fm:
|
|
116
|
+
errors.append("Missing or invalid YAML frontmatter")
|
|
117
|
+
else:
|
|
118
|
+
missing = [k for k in REQUIRED_FIELDS if k not in fm]
|
|
119
|
+
if missing:
|
|
120
|
+
errors.append(f"Missing required fields: {', '.join(missing)}")
|
|
121
|
+
|
|
122
|
+
if "category" in fm and fm["category"] not in VALID_CATEGORIES:
|
|
123
|
+
errors.append(
|
|
124
|
+
f"Invalid category '{fm['category']}'. Valid: {', '.join(sorted(VALID_CATEGORIES))}"
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
if "version" in fm and not validate_semver(str(fm["version"])):
|
|
128
|
+
errors.append(f"Invalid version format: {fm['version']} (expected x.y.z)")
|
|
129
|
+
|
|
130
|
+
if "updated" in fm and not validate_date(str(fm["updated"])):
|
|
131
|
+
errors.append(f"Invalid updated format: {fm['updated']} (expected YYYY-MM-DD)")
|
|
132
|
+
|
|
133
|
+
if "source_of_truth_for" in fm and not isinstance(fm["source_of_truth_for"], list):
|
|
134
|
+
warnings.append("source_of_truth_for should be a list")
|
|
135
|
+
|
|
136
|
+
print(f"Validating: {path}")
|
|
137
|
+
if errors:
|
|
138
|
+
print("\n❌ ERRORS:")
|
|
139
|
+
for error in errors:
|
|
140
|
+
print(f" - {error}")
|
|
141
|
+
if warnings:
|
|
142
|
+
print("\n⚠️ WARNINGS:")
|
|
143
|
+
for warning in warnings:
|
|
144
|
+
print(f" - {warning}")
|
|
145
|
+
if not errors and not warnings:
|
|
146
|
+
print("\n✅ VALID: All checks passed!")
|
|
147
|
+
|
|
148
|
+
headings = extract_headings(content)
|
|
149
|
+
if headings:
|
|
150
|
+
table = generate_index_table(headings)
|
|
151
|
+
updated_content = inject_index(content, table)
|
|
152
|
+
if updated_content != content:
|
|
153
|
+
path.write_text(updated_content, encoding="utf-8")
|
|
154
|
+
print(" ✏️ INDEX regenerated.")
|
|
155
|
+
|
|
156
|
+
return not errors
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def iter_targets(target: Path) -> list[Path]:
|
|
160
|
+
if target.is_dir():
|
|
161
|
+
return sorted(target.rglob("*.md"))
|
|
162
|
+
return [target]
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def main() -> None:
|
|
166
|
+
if len(sys.argv) < 2:
|
|
167
|
+
print("Usage: validate_metadata.py <docs-file-or-directory>")
|
|
168
|
+
sys.exit(1)
|
|
169
|
+
|
|
170
|
+
target = Path(sys.argv[1])
|
|
171
|
+
paths = iter_targets(target)
|
|
172
|
+
if not paths:
|
|
173
|
+
print(f"No markdown files found at: {target}")
|
|
174
|
+
sys.exit(1)
|
|
175
|
+
|
|
176
|
+
all_ok = True
|
|
177
|
+
for path in paths:
|
|
178
|
+
if not validate_metadata_file(path):
|
|
179
|
+
all_ok = False
|
|
180
|
+
|
|
181
|
+
sys.exit(0 if all_ok else 1)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
if __name__ == "__main__":
|
|
185
|
+
main()
|