@r1z4x/tezgah 1.0.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/CHANGELOG.md +738 -0
- package/LICENSE +21 -0
- package/MANIFEST +753 -0
- package/README.de.md +169 -0
- package/README.es.md +168 -0
- package/README.fr.md +166 -0
- package/README.md +161 -0
- package/README.tr.md +163 -0
- package/agents/tezgah-reviewer.md +70 -0
- package/bin/codegen +337 -0
- package/bin/consult +797 -0
- package/bin/tezgah-adhd +50 -0
- package/bin/tezgah-agents +45 -0
- package/bin/tezgah-capture +66 -0
- package/bin/tezgah-context +96 -0
- package/bin/tezgah-decisions +213 -0
- package/bin/tezgah-design +953 -0
- package/bin/tezgah-docs +1199 -0
- package/bin/tezgah-doctor +497 -0
- package/bin/tezgah-dsh +37 -0
- package/bin/tezgah-dsh.cmd +70 -0
- package/bin/tezgah-gate +75 -0
- package/bin/tezgah-import-ai-research +439 -0
- package/bin/tezgah-index +32 -0
- package/bin/tezgah-lessons +148 -0
- package/bin/tezgah-mcp +322 -0
- package/bin/tezgah-migrate +324 -0
- package/bin/tezgah-pony +50 -0
- package/bin/tezgah-research +772 -0
- package/bin/tezgah-rollback +93 -0
- package/bin/tezgah-route +124 -0
- package/bin/tezgah-setup +5798 -0
- package/bin/tezgah-status +383 -0
- package/bin/tezgah-task +607 -0
- package/bin/tezgah-taste +423 -0
- package/bin/tezgah-triage +485 -0
- package/bin/tezgah.js +36 -0
- package/commands/adhd.md +21 -0
- package/commands/ponytail.md +21 -0
- package/docs/README.md +112 -0
- package/docs/architecture.md +226 -0
- package/docs/citations-baseline.json +59 -0
- package/docs/clarity-baseline.json +116 -0
- package/docs/contract.md +416 -0
- package/docs/environment.md +141 -0
- package/docs/evidence.md +831 -0
- package/docs/feature-audit.md +139 -0
- package/docs/gate.md +407 -0
- package/docs/glossary.md +201 -0
- package/docs/hosts.md +400 -0
- package/docs/index.json +471 -0
- package/docs/judge.md +193 -0
- package/docs/layers.md +189 -0
- package/docs/models.md +160 -0
- package/docs/operations.md +666 -0
- package/docs/research.md +809 -0
- package/docs/results/paired-outcome-2026-10.jsonl +254 -0
- package/docs/results/paired-outcome-2026-10.md +204 -0
- package/docs/skills.md +236 -0
- package/docs/status-line.md +315 -0
- package/docs/testing.md +287 -0
- package/docs/vision.md +117 -0
- package/hooks/hooks.json +33 -0
- package/hooks/projects-auto-init.py +98 -0
- package/hooks/projects-posttooluse.py +149 -0
- package/hooks/projects-pretooluse.py +40 -0
- package/hooks/projects-stop.py +60 -0
- package/hooks/tezgah_agents.py +817 -0
- package/hooks/tezgah_apps.py +266 -0
- package/hooks/tezgah_attest.py +255 -0
- package/hooks/tezgah_clarity.py +171 -0
- package/hooks/tezgah_components.py +140 -0
- package/hooks/tezgah_context.py +2953 -0
- package/hooks/tezgah_embed.py +765 -0
- package/hooks/tezgah_gate.py +2736 -0
- package/hooks/tezgah_guard.py +177 -0
- package/hooks/tezgah_index.py +124 -0
- package/hooks/tezgah_integrity.py +5141 -0
- package/hooks/tezgah_judge.py +487 -0
- package/hooks/tezgah_lang.py +230 -0
- package/hooks/tezgah_lessons.py +210 -0
- package/hooks/tezgah_models.py +855 -0
- package/hooks/tezgah_paths.py +1132 -0
- package/hooks/tezgah_policy.py +1039 -0
- package/hooks/tezgah_rank.py +77 -0
- package/hooks/tezgah_replay.py +1109 -0
- package/hooks/tezgah_research.py +5176 -0
- package/hooks/tezgah_shapes.py +305 -0
- package/hooks/tezgah_skill_pick.py +227 -0
- package/hooks/tezgah_snapshot.py +490 -0
- package/hooks/tezgah_stopspec.py +320 -0
- package/hooks/tezgah_task.py +458 -0
- package/hooks/tezgah_taste.py +201 -0
- package/hooks/tezgah_untrusted.py +112 -0
- package/hooks/tezgah_update.py +430 -0
- package/hosts/codex/hook.py +268 -0
- package/hosts/codex/hooks.json +26 -0
- package/hosts/cursor/hook.py +461 -0
- package/hosts/cursor/hooks.json +44 -0
- package/hosts/dsh/hooks.json +21 -0
- package/hosts/dsh/statusline/lib/client.js +138 -0
- package/hosts/dsh/statusline/lib/index.js +104 -0
- package/hosts/dsh/statusline/package.json +28 -0
- package/hosts/omp/hook.py +277 -0
- package/hosts/omp/tezgah-hook.ts.in +701 -0
- package/hosts/opencode/plugins/tezgah.js +2742 -0
- package/hosts/opencode/tui/tezgah-tui.tsx +151 -0
- package/output-styles/tezgah.md +142 -0
- package/package.json +32 -0
- package/packaging/build.sh +342 -0
- package/packaging/install.ps1 +166 -0
- package/packaging/install.sh +56 -0
- package/packaging/upgrade.sh +142 -0
- package/skills/ai-research/0-autoresearch-skill/SKILL.md +411 -0
- package/skills/ai-research/0-autoresearch-skill/references/agent-continuity.md +95 -0
- package/skills/ai-research/0-autoresearch-skill/references/progress-reporting.md +166 -0
- package/skills/ai-research/0-autoresearch-skill/references/skill-routing.md +219 -0
- package/skills/ai-research/0-autoresearch-skill/templates/findings.md +44 -0
- package/skills/ai-research/0-autoresearch-skill/templates/research-log.md +41 -0
- package/skills/ai-research/01-model-architecture/litgpt/SKILL.md +469 -0
- package/skills/ai-research/01-model-architecture/litgpt/references/custom-models.md +569 -0
- package/skills/ai-research/01-model-architecture/litgpt/references/distributed-training.md +452 -0
- package/skills/ai-research/01-model-architecture/litgpt/references/supported-models.md +337 -0
- package/skills/ai-research/01-model-architecture/litgpt/references/training-recipes.md +620 -0
- package/skills/ai-research/01-model-architecture/mamba/SKILL.md +260 -0
- package/skills/ai-research/01-model-architecture/mamba/references/architecture-details.md +207 -0
- package/skills/ai-research/01-model-architecture/mamba/references/benchmarks.md +256 -0
- package/skills/ai-research/01-model-architecture/mamba/references/training-guide.md +389 -0
- package/skills/ai-research/01-model-architecture/nanogpt/SKILL.md +290 -0
- package/skills/ai-research/01-model-architecture/nanogpt/references/architecture.md +383 -0
- package/skills/ai-research/01-model-architecture/nanogpt/references/data.md +477 -0
- package/skills/ai-research/01-model-architecture/nanogpt/references/training.md +565 -0
- package/skills/ai-research/01-model-architecture/rwkv/SKILL.md +260 -0
- package/skills/ai-research/01-model-architecture/rwkv/references/architecture-details.md +345 -0
- package/skills/ai-research/01-model-architecture/rwkv/references/rwkv7.md +387 -0
- package/skills/ai-research/01-model-architecture/rwkv/references/state-management.md +370 -0
- package/skills/ai-research/01-model-architecture/torchtitan/SKILL.md +358 -0
- package/skills/ai-research/01-model-architecture/torchtitan/references/checkpoint.md +182 -0
- package/skills/ai-research/01-model-architecture/torchtitan/references/custom-models.md +259 -0
- package/skills/ai-research/01-model-architecture/torchtitan/references/float8.md +134 -0
- package/skills/ai-research/01-model-architecture/torchtitan/references/fsdp.md +127 -0
- package/skills/ai-research/02-tokenization/huggingface-tokenizers/SKILL.md +516 -0
- package/skills/ai-research/02-tokenization/huggingface-tokenizers/references/algorithms.md +654 -0
- package/skills/ai-research/02-tokenization/huggingface-tokenizers/references/integration.md +638 -0
- package/skills/ai-research/02-tokenization/huggingface-tokenizers/references/pipeline.md +724 -0
- package/skills/ai-research/02-tokenization/huggingface-tokenizers/references/training.md +566 -0
- package/skills/ai-research/02-tokenization/sentencepiece/SKILL.md +235 -0
- package/skills/ai-research/02-tokenization/sentencepiece/references/algorithms.md +201 -0
- package/skills/ai-research/02-tokenization/sentencepiece/references/training.md +305 -0
- package/skills/ai-research/03-fine-tuning/axolotl/SKILL.md +158 -0
- package/skills/ai-research/03-fine-tuning/axolotl/references/api.md +5549 -0
- package/skills/ai-research/03-fine-tuning/axolotl/references/dataset-formats.md +1030 -0
- package/skills/ai-research/03-fine-tuning/axolotl/references/index.md +16 -0
- package/skills/ai-research/03-fine-tuning/axolotl/references/other.md +3564 -0
- package/skills/ai-research/03-fine-tuning/llama-factory/SKILL.md +80 -0
- package/skills/ai-research/03-fine-tuning/llama-factory/references/_images.md +24 -0
- package/skills/ai-research/03-fine-tuning/llama-factory/references/advanced.md +1056 -0
- package/skills/ai-research/03-fine-tuning/llama-factory/references/getting_started.md +350 -0
- package/skills/ai-research/03-fine-tuning/llama-factory/references/index.md +20 -0
- package/skills/ai-research/03-fine-tuning/llama-factory/references/other.md +32 -0
- package/skills/ai-research/03-fine-tuning/peft/SKILL.md +431 -0
- package/skills/ai-research/03-fine-tuning/peft/references/advanced-usage.md +515 -0
- package/skills/ai-research/03-fine-tuning/peft/references/troubleshooting.md +481 -0
- package/skills/ai-research/03-fine-tuning/unsloth/SKILL.md +80 -0
- package/skills/ai-research/03-fine-tuning/unsloth/references/index.md +8 -0
- package/skills/ai-research/03-fine-tuning/unsloth/references/llms.md +83 -0
- package/skills/ai-research/04-mechanistic-interpretability/nnsight/SKILL.md +436 -0
- package/skills/ai-research/04-mechanistic-interpretability/nnsight/references/README.md +79 -0
- package/skills/ai-research/04-mechanistic-interpretability/nnsight/references/api.md +345 -0
- package/skills/ai-research/04-mechanistic-interpretability/nnsight/references/tutorials.md +301 -0
- package/skills/ai-research/04-mechanistic-interpretability/pyvene/SKILL.md +473 -0
- package/skills/ai-research/04-mechanistic-interpretability/pyvene/references/README.md +74 -0
- package/skills/ai-research/04-mechanistic-interpretability/pyvene/references/api.md +384 -0
- package/skills/ai-research/04-mechanistic-interpretability/pyvene/references/tutorials.md +377 -0
- package/skills/ai-research/04-mechanistic-interpretability/saelens/SKILL.md +386 -0
- package/skills/ai-research/04-mechanistic-interpretability/saelens/references/README.md +71 -0
- package/skills/ai-research/04-mechanistic-interpretability/saelens/references/api.md +334 -0
- package/skills/ai-research/04-mechanistic-interpretability/saelens/references/tutorials.md +319 -0
- package/skills/ai-research/04-mechanistic-interpretability/transformer-lens/SKILL.md +346 -0
- package/skills/ai-research/04-mechanistic-interpretability/transformer-lens/references/README.md +55 -0
- package/skills/ai-research/04-mechanistic-interpretability/transformer-lens/references/api.md +363 -0
- package/skills/ai-research/04-mechanistic-interpretability/transformer-lens/references/tutorials.md +340 -0
- package/skills/ai-research/05-data-processing/nemo-curator/SKILL.md +383 -0
- package/skills/ai-research/05-data-processing/nemo-curator/references/deduplication.md +88 -0
- package/skills/ai-research/05-data-processing/nemo-curator/references/filtering.md +103 -0
- package/skills/ai-research/05-data-processing/ray-data/SKILL.md +326 -0
- package/skills/ai-research/05-data-processing/ray-data/references/integration.md +83 -0
- package/skills/ai-research/05-data-processing/ray-data/references/transformations.md +84 -0
- package/skills/ai-research/06-post-training/grpo-rl-training/README.md +98 -0
- package/skills/ai-research/06-post-training/grpo-rl-training/SKILL.md +572 -0
- package/skills/ai-research/06-post-training/miles/SKILL.md +315 -0
- package/skills/ai-research/06-post-training/miles/references/api-reference.md +142 -0
- package/skills/ai-research/06-post-training/miles/references/troubleshooting.md +353 -0
- package/skills/ai-research/06-post-training/openrlhf/SKILL.md +249 -0
- package/skills/ai-research/06-post-training/openrlhf/references/algorithm-comparison.md +405 -0
- package/skills/ai-research/06-post-training/openrlhf/references/custom-rewards.md +531 -0
- package/skills/ai-research/06-post-training/openrlhf/references/hybrid-engine.md +288 -0
- package/skills/ai-research/06-post-training/openrlhf/references/multi-node-training.md +455 -0
- package/skills/ai-research/06-post-training/simpo/SKILL.md +219 -0
- package/skills/ai-research/06-post-training/simpo/references/datasets.md +479 -0
- package/skills/ai-research/06-post-training/simpo/references/hyperparameters.md +453 -0
- package/skills/ai-research/06-post-training/simpo/references/loss-functions.md +351 -0
- package/skills/ai-research/06-post-training/slime/SKILL.md +464 -0
- package/skills/ai-research/06-post-training/slime/references/api-reference.md +393 -0
- package/skills/ai-research/06-post-training/slime/references/troubleshooting.md +387 -0
- package/skills/ai-research/06-post-training/torchforge/SKILL.md +433 -0
- package/skills/ai-research/06-post-training/torchforge/references/api-reference.md +328 -0
- package/skills/ai-research/06-post-training/torchforge/references/troubleshooting.md +410 -0
- package/skills/ai-research/06-post-training/trl-fine-tuning/SKILL.md +455 -0
- package/skills/ai-research/06-post-training/trl-fine-tuning/references/dpo-variants.md +228 -0
- package/skills/ai-research/06-post-training/trl-fine-tuning/references/online-rl.md +83 -0
- package/skills/ai-research/06-post-training/trl-fine-tuning/references/reward-modeling.md +123 -0
- package/skills/ai-research/06-post-training/trl-fine-tuning/references/sft-training.md +169 -0
- package/skills/ai-research/06-post-training/verl/SKILL.md +391 -0
- package/skills/ai-research/06-post-training/verl/references/api-reference.md +302 -0
- package/skills/ai-research/06-post-training/verl/references/troubleshooting.md +392 -0
- package/skills/ai-research/07-safety-alignment/constitutional-ai/SKILL.md +290 -0
- package/skills/ai-research/07-safety-alignment/llamaguard/SKILL.md +337 -0
- package/skills/ai-research/07-safety-alignment/nemo-guardrails/SKILL.md +297 -0
- package/skills/ai-research/07-safety-alignment/prompt-guard/SKILL.md +312 -0
- package/skills/ai-research/08-distributed-training/accelerate/SKILL.md +332 -0
- package/skills/ai-research/08-distributed-training/accelerate/references/custom-plugins.md +454 -0
- package/skills/ai-research/08-distributed-training/accelerate/references/megatron-integration.md +490 -0
- package/skills/ai-research/08-distributed-training/accelerate/references/performance.md +526 -0
- package/skills/ai-research/08-distributed-training/deepspeed/SKILL.md +141 -0
- package/skills/ai-research/08-distributed-training/deepspeed/references/08.md +18 -0
- package/skills/ai-research/08-distributed-training/deepspeed/references/09.md +174 -0
- package/skills/ai-research/08-distributed-training/deepspeed/references/2020.md +379 -0
- package/skills/ai-research/08-distributed-training/deepspeed/references/2023.md +280 -0
- package/skills/ai-research/08-distributed-training/deepspeed/references/assets.md +180 -0
- package/skills/ai-research/08-distributed-training/deepspeed/references/index.md +36 -0
- package/skills/ai-research/08-distributed-training/deepspeed/references/mii.md +119 -0
- package/skills/ai-research/08-distributed-training/deepspeed/references/other.md +1192 -0
- package/skills/ai-research/08-distributed-training/megatron-core/SKILL.md +366 -0
- package/skills/ai-research/08-distributed-training/megatron-core/references/benchmarks.md +250 -0
- package/skills/ai-research/08-distributed-training/megatron-core/references/parallelism-guide.md +405 -0
- package/skills/ai-research/08-distributed-training/megatron-core/references/production-examples.md +474 -0
- package/skills/ai-research/08-distributed-training/megatron-core/references/training-recipes.md +548 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/SKILL.md +231 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_dcp_async_recipe.md +14 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_dcp_overview.md +19 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_dcp_recipe.md +18 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_ddp_notes.md +10 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_device_mesh_tutorial.md +22 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_examples_fsdp2.md +15 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_fsdp1_api.md +9 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_fsdp2_tutorial.md +45 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_fully_shard_api.md +49 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/pytorch_tp_tutorial.md +22 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/ray_train_fsdp2_example.md +13 -0
- package/skills/ai-research/08-distributed-training/pytorch-fsdp2/references/torchtitan_fsdp_notes.md +14 -0
- package/skills/ai-research/08-distributed-training/pytorch-lightning/SKILL.md +346 -0
- package/skills/ai-research/08-distributed-training/pytorch-lightning/references/callbacks.md +437 -0
- package/skills/ai-research/08-distributed-training/pytorch-lightning/references/distributed.md +491 -0
- package/skills/ai-research/08-distributed-training/pytorch-lightning/references/hyperparameter-tuning.md +557 -0
- package/skills/ai-research/08-distributed-training/ray-train/SKILL.md +406 -0
- package/skills/ai-research/08-distributed-training/ray-train/references/multi-node.md +629 -0
- package/skills/ai-research/09-infrastructure/lambda-labs/SKILL.md +545 -0
- package/skills/ai-research/09-infrastructure/lambda-labs/references/advanced-usage.md +612 -0
- package/skills/ai-research/09-infrastructure/lambda-labs/references/troubleshooting.md +531 -0
- package/skills/ai-research/09-infrastructure/modal/SKILL.md +341 -0
- package/skills/ai-research/09-infrastructure/modal/references/advanced-usage.md +504 -0
- package/skills/ai-research/09-infrastructure/modal/references/troubleshooting.md +495 -0
- package/skills/ai-research/09-infrastructure/skypilot/SKILL.md +509 -0
- package/skills/ai-research/09-infrastructure/skypilot/references/advanced-usage.md +492 -0
- package/skills/ai-research/09-infrastructure/skypilot/references/troubleshooting.md +571 -0
- package/skills/ai-research/10-optimization/awq/SKILL.md +310 -0
- package/skills/ai-research/10-optimization/awq/references/advanced-usage.md +325 -0
- package/skills/ai-research/10-optimization/awq/references/troubleshooting.md +345 -0
- package/skills/ai-research/10-optimization/bitsandbytes/SKILL.md +411 -0
- package/skills/ai-research/10-optimization/bitsandbytes/references/memory-optimization.md +522 -0
- package/skills/ai-research/10-optimization/bitsandbytes/references/qlora-training.md +522 -0
- package/skills/ai-research/10-optimization/bitsandbytes/references/quantization-formats.md +448 -0
- package/skills/ai-research/10-optimization/flash-attention/SKILL.md +367 -0
- package/skills/ai-research/10-optimization/flash-attention/references/benchmarks.md +216 -0
- package/skills/ai-research/10-optimization/flash-attention/references/transformers-integration.md +294 -0
- package/skills/ai-research/10-optimization/gguf/SKILL.md +427 -0
- package/skills/ai-research/10-optimization/gguf/references/advanced-usage.md +505 -0
- package/skills/ai-research/10-optimization/gguf/references/troubleshooting.md +443 -0
- package/skills/ai-research/10-optimization/gptq/SKILL.md +450 -0
- package/skills/ai-research/10-optimization/gptq/references/calibration.md +338 -0
- package/skills/ai-research/10-optimization/gptq/references/integration.md +130 -0
- package/skills/ai-research/10-optimization/gptq/references/troubleshooting.md +96 -0
- package/skills/ai-research/10-optimization/hqq/SKILL.md +445 -0
- package/skills/ai-research/10-optimization/hqq/references/advanced-usage.md +529 -0
- package/skills/ai-research/10-optimization/hqq/references/troubleshooting.md +504 -0
- package/skills/ai-research/10-optimization/ml-training-recipes/SKILL.md +319 -0
- package/skills/ai-research/10-optimization/ml-training-recipes/references/architecture.md +320 -0
- package/skills/ai-research/10-optimization/ml-training-recipes/references/biomedical.md +498 -0
- package/skills/ai-research/10-optimization/ml-training-recipes/references/domain-specific.md +626 -0
- package/skills/ai-research/10-optimization/ml-training-recipes/references/experiment-loop.md +129 -0
- package/skills/ai-research/10-optimization/ml-training-recipes/references/optimizers.md +330 -0
- package/skills/ai-research/10-optimization/ml-training-recipes/references/scaling-and-selection.md +428 -0
- package/skills/ai-research/11-evaluation/bigcode-evaluation-harness/SKILL.md +405 -0
- package/skills/ai-research/11-evaluation/bigcode-evaluation-harness/references/benchmarks.md +394 -0
- package/skills/ai-research/11-evaluation/bigcode-evaluation-harness/references/custom-tasks.md +425 -0
- package/skills/ai-research/11-evaluation/bigcode-evaluation-harness/references/issues.md +395 -0
- package/skills/ai-research/11-evaluation/lm-evaluation-harness/SKILL.md +490 -0
- package/skills/ai-research/11-evaluation/lm-evaluation-harness/references/api-evaluation.md +491 -0
- package/skills/ai-research/11-evaluation/lm-evaluation-harness/references/benchmark-guide.md +489 -0
- package/skills/ai-research/11-evaluation/lm-evaluation-harness/references/custom-tasks.md +603 -0
- package/skills/ai-research/11-evaluation/lm-evaluation-harness/references/distributed-eval.md +520 -0
- package/skills/ai-research/11-evaluation/nemo-evaluator/SKILL.md +494 -0
- package/skills/ai-research/11-evaluation/nemo-evaluator/references/adapter-system.md +341 -0
- package/skills/ai-research/11-evaluation/nemo-evaluator/references/configuration.md +448 -0
- package/skills/ai-research/11-evaluation/nemo-evaluator/references/custom-benchmarks.md +316 -0
- package/skills/ai-research/11-evaluation/nemo-evaluator/references/execution-backends.md +362 -0
- package/skills/ai-research/12-inference-serving/llama-cpp/SKILL.md +258 -0
- package/skills/ai-research/12-inference-serving/llama-cpp/references/optimization.md +90 -0
- package/skills/ai-research/12-inference-serving/llama-cpp/references/quantization.md +214 -0
- package/skills/ai-research/12-inference-serving/llama-cpp/references/server.md +126 -0
- package/skills/ai-research/12-inference-serving/sglang/SKILL.md +442 -0
- package/skills/ai-research/12-inference-serving/sglang/references/deployment.md +491 -0
- package/skills/ai-research/12-inference-serving/sglang/references/radix-attention.md +414 -0
- package/skills/ai-research/12-inference-serving/sglang/references/structured-generation.md +542 -0
- package/skills/ai-research/12-inference-serving/tensorrt-llm/SKILL.md +187 -0
- package/skills/ai-research/12-inference-serving/tensorrt-llm/references/multi-gpu.md +299 -0
- package/skills/ai-research/12-inference-serving/tensorrt-llm/references/optimization.md +243 -0
- package/skills/ai-research/12-inference-serving/tensorrt-llm/references/serving.md +471 -0
- package/skills/ai-research/12-inference-serving/vllm/SKILL.md +364 -0
- package/skills/ai-research/12-inference-serving/vllm/references/optimization.md +227 -0
- package/skills/ai-research/12-inference-serving/vllm/references/quantization.md +285 -0
- package/skills/ai-research/12-inference-serving/vllm/references/server-deployment.md +256 -0
- package/skills/ai-research/12-inference-serving/vllm/references/troubleshooting.md +448 -0
- package/skills/ai-research/13-mlops/mlflow/SKILL.md +704 -0
- package/skills/ai-research/13-mlops/mlflow/references/deployment.md +745 -0
- package/skills/ai-research/13-mlops/mlflow/references/model-registry.md +771 -0
- package/skills/ai-research/13-mlops/mlflow/references/tracking.md +681 -0
- package/skills/ai-research/13-mlops/swanlab/SKILL.md +406 -0
- package/skills/ai-research/13-mlops/swanlab/references/integrations.md +305 -0
- package/skills/ai-research/13-mlops/swanlab/references/visualization.md +234 -0
- package/skills/ai-research/13-mlops/tensorboard/SKILL.md +629 -0
- package/skills/ai-research/13-mlops/tensorboard/references/integrations.md +639 -0
- package/skills/ai-research/13-mlops/tensorboard/references/profiling.md +546 -0
- package/skills/ai-research/13-mlops/tensorboard/references/visualization.md +621 -0
- package/skills/ai-research/13-mlops/weights-and-biases/SKILL.md +590 -0
- package/skills/ai-research/13-mlops/weights-and-biases/references/artifacts.md +585 -0
- package/skills/ai-research/13-mlops/weights-and-biases/references/integrations.md +701 -0
- package/skills/ai-research/13-mlops/weights-and-biases/references/sweeps.md +848 -0
- package/skills/ai-research/14-agents/a-evolve/SKILL.md +383 -0
- package/skills/ai-research/14-agents/a-evolve/references/README.md +831 -0
- package/skills/ai-research/14-agents/a-evolve/references/api.md +594 -0
- package/skills/ai-research/14-agents/a-evolve/references/architecture.md +417 -0
- package/skills/ai-research/14-agents/a-evolve/references/design-patterns.md +462 -0
- package/skills/ai-research/14-agents/a-evolve/references/examples.md +352 -0
- package/skills/ai-research/14-agents/a-evolve/references/issues.md +591 -0
- package/skills/ai-research/14-agents/a-evolve/references/releases.md +112 -0
- package/skills/ai-research/14-agents/a-evolve/references/tutorials.md +819 -0
- package/skills/ai-research/14-agents/autogpt/SKILL.md +403 -0
- package/skills/ai-research/14-agents/autogpt/references/advanced-usage.md +536 -0
- package/skills/ai-research/14-agents/autogpt/references/troubleshooting.md +421 -0
- package/skills/ai-research/14-agents/crewai/SKILL.md +498 -0
- package/skills/ai-research/14-agents/crewai/references/flows.md +439 -0
- package/skills/ai-research/14-agents/crewai/references/tools.md +430 -0
- package/skills/ai-research/14-agents/crewai/references/troubleshooting.md +481 -0
- package/skills/ai-research/14-agents/langchain/SKILL.md +480 -0
- package/skills/ai-research/14-agents/langchain/references/agents.md +500 -0
- package/skills/ai-research/14-agents/langchain/references/integration.md +563 -0
- package/skills/ai-research/14-agents/langchain/references/rag.md +601 -0
- package/skills/ai-research/14-agents/llamaindex/SKILL.md +569 -0
- package/skills/ai-research/14-agents/llamaindex/references/agents.md +84 -0
- package/skills/ai-research/14-agents/llamaindex/references/data_connectors.md +109 -0
- package/skills/ai-research/14-agents/llamaindex/references/query_engines.md +407 -0
- package/skills/ai-research/15-rag/chroma/SKILL.md +406 -0
- package/skills/ai-research/15-rag/chroma/references/integration.md +39 -0
- package/skills/ai-research/15-rag/faiss/SKILL.md +221 -0
- package/skills/ai-research/15-rag/faiss/references/index_types.md +281 -0
- package/skills/ai-research/15-rag/pinecone/SKILL.md +358 -0
- package/skills/ai-research/15-rag/pinecone/references/deployment.md +182 -0
- package/skills/ai-research/15-rag/qdrant/SKILL.md +493 -0
- package/skills/ai-research/15-rag/qdrant/references/advanced-usage.md +649 -0
- package/skills/ai-research/15-rag/qdrant/references/troubleshooting.md +632 -0
- package/skills/ai-research/15-rag/sentence-transformers/SKILL.md +255 -0
- package/skills/ai-research/15-rag/sentence-transformers/references/models.md +124 -0
- package/skills/ai-research/16-prompt-engineering/dspy/SKILL.md +590 -0
- package/skills/ai-research/16-prompt-engineering/dspy/references/examples.md +664 -0
- package/skills/ai-research/16-prompt-engineering/dspy/references/modules.md +476 -0
- package/skills/ai-research/16-prompt-engineering/dspy/references/optimizers.md +567 -0
- package/skills/ai-research/16-prompt-engineering/guidance/SKILL.md +572 -0
- package/skills/ai-research/16-prompt-engineering/guidance/references/backends.md +555 -0
- package/skills/ai-research/16-prompt-engineering/guidance/references/constraints.md +675 -0
- package/skills/ai-research/16-prompt-engineering/guidance/references/examples.md +768 -0
- package/skills/ai-research/16-prompt-engineering/instructor/SKILL.md +740 -0
- package/skills/ai-research/16-prompt-engineering/instructor/references/examples.md +108 -0
- package/skills/ai-research/16-prompt-engineering/instructor/references/providers.md +71 -0
- package/skills/ai-research/16-prompt-engineering/instructor/references/validation.md +607 -0
- package/skills/ai-research/16-prompt-engineering/outlines/SKILL.md +652 -0
- package/skills/ai-research/16-prompt-engineering/outlines/references/backends.md +616 -0
- package/skills/ai-research/16-prompt-engineering/outlines/references/examples.md +774 -0
- package/skills/ai-research/16-prompt-engineering/outlines/references/json_generation.md +653 -0
- package/skills/ai-research/17-observability/langsmith/SKILL.md +422 -0
- package/skills/ai-research/17-observability/langsmith/references/advanced-usage.md +549 -0
- package/skills/ai-research/17-observability/langsmith/references/troubleshooting.md +538 -0
- package/skills/ai-research/17-observability/phoenix/SKILL.md +475 -0
- package/skills/ai-research/17-observability/phoenix/references/advanced-usage.md +620 -0
- package/skills/ai-research/17-observability/phoenix/references/troubleshooting.md +539 -0
- package/skills/ai-research/18-multimodal/audiocraft/SKILL.md +564 -0
- package/skills/ai-research/18-multimodal/audiocraft/references/advanced-usage.md +667 -0
- package/skills/ai-research/18-multimodal/audiocraft/references/troubleshooting.md +505 -0
- package/skills/ai-research/18-multimodal/blip-2/SKILL.md +564 -0
- package/skills/ai-research/18-multimodal/blip-2/references/advanced-usage.md +681 -0
- package/skills/ai-research/18-multimodal/blip-2/references/troubleshooting.md +527 -0
- package/skills/ai-research/18-multimodal/clip/SKILL.md +253 -0
- package/skills/ai-research/18-multimodal/clip/references/applications.md +208 -0
- package/skills/ai-research/18-multimodal/cosmos-policy/SKILL.md +402 -0
- package/skills/ai-research/18-multimodal/cosmos-policy/references/libero-commands.md +175 -0
- package/skills/ai-research/18-multimodal/cosmos-policy/references/robocasa-commands.md +147 -0
- package/skills/ai-research/18-multimodal/llava/SKILL.md +304 -0
- package/skills/ai-research/18-multimodal/llava/references/training.md +198 -0
- package/skills/ai-research/18-multimodal/openpi/SKILL.md +480 -0
- package/skills/ai-research/18-multimodal/openpi/references/checkpoints-and-env-map.md +86 -0
- package/skills/ai-research/18-multimodal/openpi/references/config-recipes.md +50 -0
- package/skills/ai-research/18-multimodal/openpi/references/pytorch-gotchas.md +49 -0
- package/skills/ai-research/18-multimodal/openpi/references/remote-client-pattern.md +48 -0
- package/skills/ai-research/18-multimodal/openpi/references/training-debugging.md +46 -0
- package/skills/ai-research/18-multimodal/openvla-oft/SKILL.md +441 -0
- package/skills/ai-research/18-multimodal/openvla-oft/references/aloha-workflow.md +141 -0
- package/skills/ai-research/18-multimodal/openvla-oft/references/config-troubleshooting.md +97 -0
- package/skills/ai-research/18-multimodal/openvla-oft/references/libero-workflow.md +115 -0
- package/skills/ai-research/18-multimodal/openvla-oft/references/paper-and-checkpoints.md +84 -0
- package/skills/ai-research/18-multimodal/segment-anything/SKILL.md +500 -0
- package/skills/ai-research/18-multimodal/segment-anything/references/advanced-usage.md +590 -0
- package/skills/ai-research/18-multimodal/segment-anything/references/troubleshooting.md +485 -0
- package/skills/ai-research/18-multimodal/stable-diffusion/SKILL.md +519 -0
- package/skills/ai-research/18-multimodal/stable-diffusion/references/advanced-usage.md +717 -0
- package/skills/ai-research/18-multimodal/stable-diffusion/references/troubleshooting.md +556 -0
- package/skills/ai-research/18-multimodal/whisper/SKILL.md +317 -0
- package/skills/ai-research/18-multimodal/whisper/references/languages.md +190 -0
- package/skills/ai-research/19-emerging-techniques/knowledge-distillation/SKILL.md +458 -0
- package/skills/ai-research/19-emerging-techniques/knowledge-distillation/references/minillm.md +335 -0
- package/skills/ai-research/19-emerging-techniques/long-context/SKILL.md +536 -0
- package/skills/ai-research/19-emerging-techniques/long-context/references/extension_methods.md +469 -0
- package/skills/ai-research/19-emerging-techniques/long-context/references/fine_tuning.md +612 -0
- package/skills/ai-research/19-emerging-techniques/long-context/references/rope.md +403 -0
- package/skills/ai-research/19-emerging-techniques/model-merging/SKILL.md +497 -0
- package/skills/ai-research/19-emerging-techniques/model-merging/references/coefficient-tuning.md +415 -0
- package/skills/ai-research/19-emerging-techniques/model-merging/references/evaluation.md +463 -0
- package/skills/ai-research/19-emerging-techniques/model-merging/references/examples.md +429 -0
- package/skills/ai-research/19-emerging-techniques/model-merging/references/methods.md +353 -0
- package/skills/ai-research/19-emerging-techniques/model-pruning/SKILL.md +495 -0
- package/skills/ai-research/19-emerging-techniques/model-pruning/references/wanda.md +348 -0
- package/skills/ai-research/19-emerging-techniques/moe-training/SKILL.md +526 -0
- package/skills/ai-research/19-emerging-techniques/moe-training/references/architectures.md +433 -0
- package/skills/ai-research/19-emerging-techniques/moe-training/references/inference.md +349 -0
- package/skills/ai-research/19-emerging-techniques/moe-training/references/training.md +426 -0
- package/skills/ai-research/19-emerging-techniques/speculative-decoding/SKILL.md +467 -0
- package/skills/ai-research/19-emerging-techniques/speculative-decoding/references/lookahead.md +310 -0
- package/skills/ai-research/19-emerging-techniques/speculative-decoding/references/medusa.md +351 -0
- package/skills/ai-research/20-ml-paper-writing/academic-plotting/SKILL.md +479 -0
- package/skills/ai-research/20-ml-paper-writing/academic-plotting/references/data-visualization.md +509 -0
- package/skills/ai-research/20-ml-paper-writing/academic-plotting/references/diagram-generation.md +395 -0
- package/skills/ai-research/20-ml-paper-writing/academic-plotting/references/style-guide.md +305 -0
- package/skills/ai-research/20-ml-paper-writing/ml-paper-writing/SKILL.md +982 -0
- package/skills/ai-research/20-ml-paper-writing/ml-paper-writing/references/checklists.md +348 -0
- package/skills/ai-research/20-ml-paper-writing/ml-paper-writing/references/citation-workflow.md +563 -0
- package/skills/ai-research/20-ml-paper-writing/ml-paper-writing/references/reviewer-guidelines.md +349 -0
- package/skills/ai-research/20-ml-paper-writing/ml-paper-writing/references/sources.md +165 -0
- package/skills/ai-research/20-ml-paper-writing/ml-paper-writing/references/writing-guide.md +477 -0
- package/skills/ai-research/20-ml-paper-writing/presenting-conference-talks/SKILL.md +298 -0
- package/skills/ai-research/20-ml-paper-writing/presenting-conference-talks/references/slide-templates.md +505 -0
- package/skills/ai-research/20-ml-paper-writing/systems-paper-writing/SKILL.md +270 -0
- package/skills/ai-research/20-ml-paper-writing/systems-paper-writing/references/checklist.md +279 -0
- package/skills/ai-research/20-ml-paper-writing/systems-paper-writing/references/reviewer-guidelines.md +116 -0
- package/skills/ai-research/20-ml-paper-writing/systems-paper-writing/references/section-blueprints.md +400 -0
- package/skills/ai-research/20-ml-paper-writing/systems-paper-writing/references/systems-conferences.md +261 -0
- package/skills/ai-research/20-ml-paper-writing/systems-paper-writing/references/writing-patterns.md +231 -0
- package/skills/ai-research/21-research-ideation/brainstorming-research-ideas/SKILL.md +384 -0
- package/skills/ai-research/21-research-ideation/creative-thinking-for-research/SKILL.md +366 -0
- package/skills/ai-research/22-agent-native-research-artifact/compiler/SKILL.md +245 -0
- package/skills/ai-research/22-agent-native-research-artifact/compiler/references/ara-schema.md +439 -0
- package/skills/ai-research/22-agent-native-research-artifact/compiler/references/exploration-tree-spec.md +125 -0
- package/skills/ai-research/22-agent-native-research-artifact/compiler/references/validation-checklist.md +149 -0
- package/skills/ai-research/22-agent-native-research-artifact/research-manager/SKILL.md +324 -0
- package/skills/ai-research/22-agent-native-research-artifact/research-manager/references/event-taxonomy.md +124 -0
- package/skills/ai-research/22-agent-native-research-artifact/research-manager/references/provenance-tags.md +190 -0
- package/skills/ai-research/22-agent-native-research-artifact/research-manager/references/session-protocol.md +162 -0
- package/skills/ai-research/22-agent-native-research-artifact/rigor-reviewer/SKILL.md +322 -0
- package/skills/ai-research/22-agent-native-research-artifact/rigor-reviewer/references/review-dimensions.md +182 -0
- package/skills/ai-research/SKILL.md +101 -0
- package/skills/ai-research/SOURCE +38 -0
- package/skills/ai-research/index/1-frame.md +18 -0
- package/skills/ai-research/index/2-data.md +21 -0
- package/skills/ai-research/index/3-train.md +48 -0
- package/skills/ai-research/index/4-measure.md +25 -0
- package/skills/ai-research/index/5-run.md +23 -0
- package/skills/ai-research/index/6-write.md +35 -0
- package/skills/ai-research/library.json +3456 -0
- package/skills/analyze-app/EVALS.md +82 -0
- package/skills/analyze-app/SKILL.md +188 -0
- package/skills/design-contract/EVALS.md +80 -0
- package/skills/design-contract/SKILL.md +171 -0
- package/skills/design-library/EVALS.md +85 -0
- package/skills/design-library/INDEX.md +59 -0
- package/skills/design-library/SKILL.md +58 -0
- package/skills/design-library/SOURCE +131 -0
- package/skills/design-library/adaptive-interfaces/skills/colour-independence/SKILL.md +90 -0
- package/skills/design-library/adaptive-interfaces/skills/flexible-typography/SKILL.md +83 -0
- package/skills/design-library/adaptive-interfaces/skills/information-density/SKILL.md +87 -0
- package/skills/design-library/adaptive-interfaces/skills/preference-audit/SKILL.md +70 -0
- package/skills/design-library/adaptive-interfaces/skills/responsive-accessibility/SKILL.md +86 -0
- package/skills/design-library/adaptive-interfaces/skills/responsive-review/SKILL.md +76 -0
- package/skills/design-library/adaptive-interfaces/skills/simplified-views/SKILL.md +97 -0
- package/skills/design-library/adaptive-interfaces/skills/specify/SKILL.md +63 -0
- package/skills/design-library/adaptive-interfaces/skills/user-preference-respect/SKILL.md +100 -0
- package/skills/design-library/cognitive-accessibility/skills/adaptive-personalisation/SKILL.md +61 -0
- package/skills/design-library/cognitive-accessibility/skills/assess-load/SKILL.md +48 -0
- package/skills/design-library/cognitive-accessibility/skills/cognitive-load-assessment/SKILL.md +60 -0
- package/skills/design-library/cognitive-accessibility/skills/contextual-help-design/SKILL.md +61 -0
- package/skills/design-library/cognitive-accessibility/skills/error-prevention-recovery/SKILL.md +71 -0
- package/skills/design-library/cognitive-accessibility/skills/focus-attention-design/SKILL.md +67 -0
- package/skills/design-library/cognitive-accessibility/skills/memory-load-reduction/SKILL.md +60 -0
- package/skills/design-library/cognitive-accessibility/skills/plain-language-design/SKILL.md +78 -0
- package/skills/design-library/cognitive-accessibility/skills/review/SKILL.md +56 -0
- package/skills/design-library/cognitive-accessibility/skills/simplify/SKILL.md +39 -0
- package/skills/design-library/cognitive-accessibility/skills/wayfinding-navigation/SKILL.md +64 -0
- package/skills/design-library/design-research/skills/behavioural-analytics/SKILL.md +33 -0
- package/skills/design-library/design-research/skills/qual-quant-triangulation/SKILL.md +33 -0
- package/skills/design-library/inclusive-interaction/skills/audit/SKILL.md +50 -0
- package/skills/design-library/inclusive-interaction/skills/design-flow/SKILL.md +58 -0
- package/skills/design-library/inclusive-interaction/skills/feedback-and-status/SKILL.md +76 -0
- package/skills/design-library/inclusive-interaction/skills/gesture-alternatives/SKILL.md +70 -0
- package/skills/design-library/inclusive-interaction/skills/keyboard-navigation/SKILL.md +99 -0
- package/skills/design-library/inclusive-interaction/skills/keyboard-review/SKILL.md +54 -0
- package/skills/design-library/inclusive-interaction/skills/motion-sensitivity/SKILL.md +79 -0
- package/skills/design-library/inclusive-interaction/skills/multi-modal-input/SKILL.md +70 -0
- package/skills/design-library/inclusive-interaction/skills/touch-target-design/SKILL.md +71 -0
- package/skills/design-library/inclusive-interaction/skills/voice-interaction/SKILL.md +68 -0
- package/skills/design-library/visual-critique/skills/critique-affordance/SKILL.md +45 -0
- package/skills/design-library/visual-critique/skills/critique-brand-consistency/SKILL.md +42 -0
- package/skills/design-library/visual-critique/skills/critique-color/SKILL.md +44 -0
- package/skills/design-library/visual-critique/skills/critique-composition/SKILL.md +46 -0
- package/skills/design-library/visual-critique/skills/critique-information-density/SKILL.md +45 -0
- package/skills/design-library/visual-critique/skills/critique-typography/SKILL.md +45 -0
- package/skills/design-library/visual-critique/skills/critique-visual-hierarchy/SKILL.md +40 -0
- package/skills/feature-audit/EVALS.md +83 -0
- package/skills/feature-audit/SKILL.md +326 -0
- package/skills/harness/EVALS.md +81 -0
- package/skills/harness/SKILL.md +88 -0
- package/skills/i-have-adhd/EVALS.md +80 -0
- package/skills/i-have-adhd/SKILL.md +183 -0
- package/skills/no-ai-slop/EVALS.md +89 -0
- package/skills/no-ai-slop/SKILL.md +209 -0
- package/skills/no-ai-slop/eval.md +52 -0
- package/skills/plan-add/EVALS.md +79 -0
- package/skills/plan-add/SKILL.md +179 -0
- package/skills/plan-add/render_table.py +72 -0
- package/skills/plan-status/EVALS.md +78 -0
- package/skills/plan-status/SKILL.md +52 -0
- package/skills/plan-sync/EVALS.md +80 -0
- package/skills/plan-sync/SKILL.md +69 -0
- package/skills/pm-frameworks/SKILL.md +33 -0
- package/skills/pm-frameworks/SOURCE +39 -0
- package/skills/pm-frameworks/intended-vs-implemented/SKILL.md +42 -0
- package/skills/pm-frameworks/opportunity-solution-tree/SKILL.md +64 -0
- package/skills/ponytail/EVALS.md +80 -0
- package/skills/ponytail/SKILL.md +124 -0
- package/skills/product-analysis/EVALS.md +103 -0
- package/skills/product-analysis/SKILL.md +361 -0
- package/skills/research/EVALS.md +104 -0
- package/skills/research/SKILL.md +570 -0
- package/skills/rl-env/SKILL.md +53 -0
- package/skills/rl-env/SOURCE +41 -0
- package/skills/rl-env/generate-nemo-gym-env/SKILL.md +169 -0
- package/skills/rl-env/generate-nemo-gym-env/references/architecture.md +114 -0
- package/skills/rl-env/generate-openenv-env/SKILL.md +183 -0
- package/skills/rl-env/generate-openenv-env/references/architecture.md +82 -0
- package/skills/rl-env/generate-ors-env/SKILL.md +209 -0
- package/skills/rl-env/generate-ors-env/references/architecture.md +113 -0
- package/skills/rl-env/generate-verifiers-env/SKILL.md +188 -0
- package/skills/rl-env/generate-verifiers-env/references/architecture.md +119 -0
- package/skills/rl-env/rl-env-from-description/SKILL.md +124 -0
- package/skills/rl-env/rl-env-from-description/references/interview.md +75 -0
- package/skills/rl-env/rl-env-from-description/references/nemo_gym.md +41 -0
- package/skills/rl-env/rl-env-from-description/references/openenv.md +35 -0
- package/skills/rl-env/rl-env-from-description/references/ors.md +50 -0
- package/skills/rl-env/rl-env-from-description/references/verifiers.md +39 -0
- package/skills/tezgah-contract/EVALS.md +78 -0
- package/skills/tezgah-contract/SKILL.md +792 -0
- package/statusline.py +129 -0
- package/workflows/graph-impact.js +153 -0
- package/workflows/graph-map.js +158 -0
- package/workflows/graph-review.js +170 -0
package/bin/tezgah-mcp
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""tezgah-mcp - tezgah's own MCP surface, one stdio server for every host.
|
|
3
|
+
|
|
4
|
+
A host draws a collapsed tool-call card for its own tools and for MCP tools, and
|
|
5
|
+
nothing else: tezgah's actions ran as `bash` calls, so the whole command line and
|
|
6
|
+
its output landed in the transcript. This server is the same work behind a tool
|
|
7
|
+
call - `initialize`, `tools/list`, `tools/call` over newline-delimited JSON-RPC
|
|
8
|
+
2.0, the framing `bin/tezgah-setup --mcp-schemas` probes with, so the server and
|
|
9
|
+
the probe agree by construction.
|
|
10
|
+
|
|
11
|
+
Five tools, one leg of tezgah's CLI each: the server never re-implements a rule,
|
|
12
|
+
it runs the installed command and returns its output as text - one summary line,
|
|
13
|
+
then the log line by line, so the collapsed card and its expanded body are the
|
|
14
|
+
same data. A tool that fails is the tool's own exit status (`isError`), not a
|
|
15
|
+
hidden error: what the command said is the answer.
|
|
16
|
+
|
|
17
|
+
A malformed line is answered with a JSON-RPC parse error and the loop keeps
|
|
18
|
+
reading, because a host writing one bad frame must not end the session.
|
|
19
|
+
"""
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import subprocess
|
|
23
|
+
import sys
|
|
24
|
+
|
|
25
|
+
HERE = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
|
26
|
+
sys.path.insert(0, os.path.join(HERE, "hooks"))
|
|
27
|
+
import tezgah_paths as tp # noqa: E402
|
|
28
|
+
|
|
29
|
+
PROTOCOL_VERSION = "2024-11-05"
|
|
30
|
+
SERVER_VERSION = "1"
|
|
31
|
+
# A delegate that never returns would hang the host's tool call: the ceiling is
|
|
32
|
+
# per tool, because `consult` waits on remote models and the rest do not.
|
|
33
|
+
TIMEOUT = 120
|
|
34
|
+
CONSULT_TIMEOUT = 600
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def tool_status(args):
|
|
38
|
+
"""`tezgah-status`: no argument, an optional directory to report on, after
|
|
39
|
+
`--` so a caller's string can never be read as a flag (audit L-7)."""
|
|
40
|
+
path = args.get("path")
|
|
41
|
+
return [tp.tool("tezgah-status")] + (["--", path] if path else []), None, None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def refuse_status(args):
|
|
45
|
+
"""The refusal for a `path` that is not an existing directory, or one that
|
|
46
|
+
starts with a dash: `--` already keeps it a positional, and this refuses the
|
|
47
|
+
value outright so the report never runs on a string that is not a place."""
|
|
48
|
+
path = args.get("path")
|
|
49
|
+
if path and (path.startswith("-") or not os.path.isdir(path)):
|
|
50
|
+
return "property 'path' must be an existing directory"
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def tool_gate_check(args):
|
|
55
|
+
"""`tezgah-gate check`: the call a host would gate, as its stdin JSON."""
|
|
56
|
+
call = {"tool": "Bash", "input": {"command": args["command"]},
|
|
57
|
+
"cwd": args.get("path") or os.getcwd()}
|
|
58
|
+
return [tp.tool("tezgah-gate"), "check"], json.dumps(call), None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def tool_features(args):
|
|
62
|
+
"""`tezgah-setup --features`: the feature table and this run's selection."""
|
|
63
|
+
return [tp.tool("tezgah-setup"), "--features"], None, None
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def tool_consult(args):
|
|
67
|
+
"""`consult`: the question the external models answer, then the referee;
|
|
68
|
+
with `use`, the members the user picked are recorded first (`--use`)."""
|
|
69
|
+
use = args.get("use")
|
|
70
|
+
return [tp.tool("consult"), args["question"]] + (["--use", use] if use else []), None, None
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def tool_research_check(args):
|
|
74
|
+
"""`tezgah-research check`: the line's citations, in the repo asked about;
|
|
75
|
+
with `slug`, that one line, after `--` so it can never be read as a flag."""
|
|
76
|
+
path, slug = args.get("path"), args.get("slug")
|
|
77
|
+
return ([tp.tool("tezgah-research"), "check"] + (["--", slug] if slug else []),
|
|
78
|
+
None, path or None)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def refuse_research_check(args):
|
|
82
|
+
"""The refusal for a `slug` that is not a research line name (`valid_slug`:
|
|
83
|
+
lowercase letters, digits and dashes, never a leading dash)."""
|
|
84
|
+
slug = args.get("slug")
|
|
85
|
+
if slug is None:
|
|
86
|
+
return None
|
|
87
|
+
import tezgah_research as tr # deferred: only this tool reads it
|
|
88
|
+
return None if tr.valid_slug(slug) else (
|
|
89
|
+
"property 'slug' must be a research line name (lowercase letters, digits, "
|
|
90
|
+
"dashes)")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# The surface. `properties` is both the schema and the list `arguments` is
|
|
94
|
+
# validated against, so a property the tool does not read cannot be declared
|
|
95
|
+
# here and a property declared here cannot arrive unread. `delegate` is the
|
|
96
|
+
# tezgah command the tool answers from, and it is what the summary line names.
|
|
97
|
+
SPECS = (
|
|
98
|
+
{"name": "tezgah_status",
|
|
99
|
+
"description": "Which tezgah contracts are armed in a directory, which "
|
|
100
|
+
"were used this session, and which are off. Answers from "
|
|
101
|
+
"`tezgah-status` - one segment per line, with its marks.",
|
|
102
|
+
"delegate": "tezgah-status",
|
|
103
|
+
"run": tool_status,
|
|
104
|
+
"refuse": refuse_status,
|
|
105
|
+
"properties": {
|
|
106
|
+
"path": ("string", "Directory to report on; defaults to the server's "
|
|
107
|
+
"own working directory.")}},
|
|
108
|
+
{"name": "tezgah_gate_check",
|
|
109
|
+
"description": "Ask the gate what it would decide about one shell "
|
|
110
|
+
"command, without running it: the refusal reason, or "
|
|
111
|
+
"nothing when the call passes. Answers from "
|
|
112
|
+
"`tezgah-gate check`.",
|
|
113
|
+
"delegate": "tezgah-gate check",
|
|
114
|
+
"run": tool_gate_check,
|
|
115
|
+
"properties": {
|
|
116
|
+
"command": ("string", "The shell command a host is about to run."),
|
|
117
|
+
"path": ("string", "The directory the command would run in; its "
|
|
118
|
+
"scope is what the gate judges.")},
|
|
119
|
+
"required": ("command",)},
|
|
120
|
+
{"name": "tezgah_features",
|
|
121
|
+
"description": "Every tezgah feature id with its default, its selection "
|
|
122
|
+
"and whether its dependency is installed. Answers from "
|
|
123
|
+
"`tezgah-setup --features`.",
|
|
124
|
+
"delegate": "tezgah-setup --features",
|
|
125
|
+
"run": tool_features,
|
|
126
|
+
"properties": {}},
|
|
127
|
+
{"name": "tezgah_consult",
|
|
128
|
+
"description": "A second opinion on one question: independent answers "
|
|
129
|
+
"from external models, then one referee. Answers from "
|
|
130
|
+
"`consult`; needs an agent CLI or a provider key. Exit 4/5 "
|
|
131
|
+
"lists the members to offer the user; pass the choice as "
|
|
132
|
+
"`use`.",
|
|
133
|
+
"delegate": "consult",
|
|
134
|
+
"run": tool_consult,
|
|
135
|
+
"timeout": CONSULT_TIMEOUT,
|
|
136
|
+
"properties": {
|
|
137
|
+
"question": ("string", "The question, stated so a model can answer "
|
|
138
|
+
"it without the session's context."),
|
|
139
|
+
"use": ("string", "Members the user chose, comma-separated (e.g. "
|
|
140
|
+
"`cli:codex,openrouter`): recorded as consult's "
|
|
141
|
+
"choice before the question is asked.")},
|
|
142
|
+
"required": ("question",)},
|
|
143
|
+
{"name": "tezgah_research_check",
|
|
144
|
+
"description": "Check a repository's research lines - their predictions, "
|
|
145
|
+
"citations and receipts - from their own manifest. Answers "
|
|
146
|
+
"from `tezgah-research check`.",
|
|
147
|
+
"delegate": "tezgah-research check",
|
|
148
|
+
"run": tool_research_check,
|
|
149
|
+
"refuse": refuse_research_check,
|
|
150
|
+
"properties": {
|
|
151
|
+
"path": ("string", "The repository to check; defaults to the "
|
|
152
|
+
"server's own working directory."),
|
|
153
|
+
"slug": ("string", "One research line to check in full; when "
|
|
154
|
+
"omitted, the open lines in full and each line "
|
|
155
|
+
"under done/ by its order seal only.")}},
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def schema(spec):
|
|
160
|
+
"""The tool's `inputSchema`, built only from the properties it declares."""
|
|
161
|
+
return {
|
|
162
|
+
"type": "object",
|
|
163
|
+
"properties": {name: {"type": ptype, "description": desc}
|
|
164
|
+
for name, (ptype, desc) in spec["properties"].items()},
|
|
165
|
+
"required": list(spec.get("required", ())),
|
|
166
|
+
"additionalProperties": False,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def declared(spec):
|
|
171
|
+
"""The tool's JSON-RPC descriptor."""
|
|
172
|
+
return {"name": spec["name"], "description": spec["description"],
|
|
173
|
+
"inputSchema": schema(spec)}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def spec_for(name):
|
|
177
|
+
return next((s for s in SPECS if s["name"] == name), None)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def arguments_for(spec, raw):
|
|
181
|
+
"""(validated arguments, refusal) for one call.
|
|
182
|
+
|
|
183
|
+
Every declared property is a string here, and the set of keys is closed in
|
|
184
|
+
both directions: a required property must arrive non-empty, a property the
|
|
185
|
+
schema does not declare is refused rather than ignored, because a host
|
|
186
|
+
sending one is a host whose call would otherwise be answered about
|
|
187
|
+
something other than what it asked."""
|
|
188
|
+
args = {}
|
|
189
|
+
for name in spec["properties"]:
|
|
190
|
+
value = raw.get(name)
|
|
191
|
+
needed = name in spec.get("required", ())
|
|
192
|
+
if value is None or (needed and not str(value).strip()):
|
|
193
|
+
if needed:
|
|
194
|
+
return None, "missing required property %r" % name
|
|
195
|
+
continue
|
|
196
|
+
if not isinstance(value, str):
|
|
197
|
+
return None, "property %r must be a string" % name
|
|
198
|
+
args[name] = value
|
|
199
|
+
unknown = sorted(set(raw) - set(spec["properties"]))
|
|
200
|
+
if unknown:
|
|
201
|
+
return None, "unknown property %s" % ", ".join(repr(u) for u in unknown)
|
|
202
|
+
return args, None
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def run(argv, stdin_text, cwd, timeout):
|
|
206
|
+
"""One delegate run: (exit status, the log's lines).
|
|
207
|
+
|
|
208
|
+
stdout then stderr: a command that fails explains itself on stderr, and the
|
|
209
|
+
card is the only place a host shows it. stdin is /dev/null unless the tool
|
|
210
|
+
feeds the command something - an inherited pipe would let a delegate read
|
|
211
|
+
the host's own JSON-RPC stream, which is the session, not its input."""
|
|
212
|
+
kwargs = {"capture_output": True, "text": True, "timeout": timeout,
|
|
213
|
+
"cwd": cwd}
|
|
214
|
+
if stdin_text is None:
|
|
215
|
+
kwargs["stdin"] = subprocess.DEVNULL
|
|
216
|
+
else:
|
|
217
|
+
kwargs["input"] = stdin_text
|
|
218
|
+
try:
|
|
219
|
+
proc = subprocess.run(argv, **kwargs)
|
|
220
|
+
except OSError as exc:
|
|
221
|
+
return None, ["%s did not start: %s" % (argv[0], exc)]
|
|
222
|
+
except subprocess.TimeoutExpired:
|
|
223
|
+
return None, ["%s did not finish within %ss" % (argv[0], timeout)]
|
|
224
|
+
return proc.returncode, proc.stdout.splitlines() + proc.stderr.splitlines()
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def summary(spec, status, lines):
|
|
228
|
+
"""The one line a host collapses to, before the log."""
|
|
229
|
+
return "%s: %s %s, %d line(s)" % (
|
|
230
|
+
spec["name"], spec["delegate"],
|
|
231
|
+
"exited %d" % status if status is not None else "did not run",
|
|
232
|
+
len(lines))
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def call(spec, args):
|
|
236
|
+
"""The `tools/call` result: the summary line, then the log line by line."""
|
|
237
|
+
argv, stdin_text, cwd = spec["run"](args)
|
|
238
|
+
status, lines = run(argv, stdin_text, cwd,
|
|
239
|
+
spec.get("timeout", TIMEOUT))
|
|
240
|
+
text = "\n".join([summary(spec, status, lines)] + lines)
|
|
241
|
+
result = {"content": [{"type": "text", "text": text}]}
|
|
242
|
+
if status != 0:
|
|
243
|
+
result["isError"] = True
|
|
244
|
+
return result
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def ok(msg_id, result):
|
|
248
|
+
return {"jsonrpc": "2.0", "id": msg_id, "result": result}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def error(msg_id, code, message):
|
|
252
|
+
return {"jsonrpc": "2.0", "id": msg_id,
|
|
253
|
+
"error": {"code": code, "message": message}}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def dispatch(msg):
|
|
257
|
+
"""The reply for one message, or None when it wants none.
|
|
258
|
+
|
|
259
|
+
A notification (no id) is not answered; neither is a client's reply to a
|
|
260
|
+
request of ours. Every failure is a JSON-RPC error rather than an exception,
|
|
261
|
+
because the loop has to survive the frame that caused it."""
|
|
262
|
+
method = msg.get("method")
|
|
263
|
+
if not isinstance(method, str) or msg.get("id") is None:
|
|
264
|
+
return None
|
|
265
|
+
msg_id = msg["id"]
|
|
266
|
+
params = msg.get("params")
|
|
267
|
+
params = params if isinstance(params, dict) else {}
|
|
268
|
+
if method == "initialize":
|
|
269
|
+
return ok(msg_id, {
|
|
270
|
+
"protocolVersion": params.get("protocolVersion") or PROTOCOL_VERSION,
|
|
271
|
+
"capabilities": {"tools": {}},
|
|
272
|
+
"serverInfo": {"name": "tezgah", "version": SERVER_VERSION}})
|
|
273
|
+
if method == "tools/list":
|
|
274
|
+
return ok(msg_id, {"tools": [declared(s) for s in SPECS]})
|
|
275
|
+
if method == "tools/call":
|
|
276
|
+
spec = spec_for(params.get("name"))
|
|
277
|
+
if spec is None:
|
|
278
|
+
return error(msg_id, -32602, "unknown tool %r (have: %s)"
|
|
279
|
+
% (params.get("name"),
|
|
280
|
+
", ".join(s["name"] for s in SPECS)))
|
|
281
|
+
raw = params.get("arguments")
|
|
282
|
+
raw = raw if isinstance(raw, dict) else {}
|
|
283
|
+
args, refusal = arguments_for(spec, raw)
|
|
284
|
+
if not refusal and spec.get("refuse"):
|
|
285
|
+
refusal = spec["refuse"](args)
|
|
286
|
+
if refusal:
|
|
287
|
+
return error(msg_id, -32602, refusal)
|
|
288
|
+
return ok(msg_id, call(spec, args))
|
|
289
|
+
if method == "ping":
|
|
290
|
+
return ok(msg_id, {})
|
|
291
|
+
return error(msg_id, -32601, "method not found: %s" % method)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def serve(stdin, stdout):
|
|
295
|
+
"""Read one JSON object per line, answer each, exit 0 at EOF."""
|
|
296
|
+
for line in stdin:
|
|
297
|
+
if not line.strip():
|
|
298
|
+
continue
|
|
299
|
+
try:
|
|
300
|
+
msg = json.loads(line)
|
|
301
|
+
if not isinstance(msg, dict):
|
|
302
|
+
raise ValueError("not a JSON object")
|
|
303
|
+
except ValueError as exc:
|
|
304
|
+
reply = error(None, -32700, "parse error: %s" % exc)
|
|
305
|
+
else:
|
|
306
|
+
reply = dispatch(msg)
|
|
307
|
+
if reply is None:
|
|
308
|
+
continue
|
|
309
|
+
stdout.write(json.dumps(reply) + "\n")
|
|
310
|
+
stdout.flush()
|
|
311
|
+
return 0
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def main():
|
|
315
|
+
try:
|
|
316
|
+
return serve(sys.stdin, sys.stdout)
|
|
317
|
+
except BrokenPipeError:
|
|
318
|
+
return 0
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
if __name__ == "__main__":
|
|
322
|
+
sys.exit(main())
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""tezgah-migrate [--apply] [--repo PATH ...] - move legacy tezgah state into <repo>/.tezgah.
|
|
3
|
+
|
|
4
|
+
Without --repo it looks at every git repository directly under each configured
|
|
5
|
+
root (a directory with its own `.git` directory; the tezgah checkout itself is
|
|
6
|
+
skipped). Without --apply it only prints what it would do. With --apply it first
|
|
7
|
+
writes a backup tarball of every path it touches to
|
|
8
|
+
~/.config/tezgah/backups/<repo>-<UTC stamp>.tar.gz, then:
|
|
9
|
+
|
|
10
|
+
1. untracks a `.tezgah/` the project repo tracks (`git rm -r --cached`; the
|
|
11
|
+
files stay on disk);
|
|
12
|
+
2. moves a root `plans/` in tezgah plan format into `.tezgah/plans/`;
|
|
13
|
+
3. moves a root `analysis/` into `.tezgah/analysis/`;
|
|
14
|
+
4. moves a root `research/` into `.tezgah/analysis/imported-research/`;
|
|
15
|
+
5. writes `.tezgah/analysis/project-knowledge.md`, an index of the
|
|
16
|
+
project-owned knowledge that stays where it is (CLAUDE.md, AGENTS.md,
|
|
17
|
+
docs/research/, .claude/agents ...);
|
|
18
|
+
6. ensures the workspace (`/.tezgah/` and `/.codegraph/` in .gitignore, a
|
|
19
|
+
private git repository at `.tezgah/.git`) and commits the imported content
|
|
20
|
+
there.
|
|
21
|
+
|
|
22
|
+
A file whose name already exists at the destination with other content is
|
|
23
|
+
reported and left where it is. Nothing is committed in the project repository and
|
|
24
|
+
nothing is pushed: the result is an uncommitted change for the user to review.
|
|
25
|
+
A re-run after a clean apply finds nothing to do.
|
|
26
|
+
|
|
27
|
+
Exit codes: 0 ok, 1 an apply step failed, 2 misuse.
|
|
28
|
+
"""
|
|
29
|
+
import datetime
|
|
30
|
+
import os
|
|
31
|
+
import subprocess
|
|
32
|
+
import sys
|
|
33
|
+
import tarfile
|
|
34
|
+
|
|
35
|
+
HERE = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
|
36
|
+
sys.path.insert(0, os.path.join(HERE, "hooks"))
|
|
37
|
+
import tezgah_paths as tp # noqa: E402
|
|
38
|
+
from tezgah_paths import ensure_workspace, ws_git # noqa: E402
|
|
39
|
+
|
|
40
|
+
IGNORES = tp.WORKSPACE_IGNORES
|
|
41
|
+
KNOWLEDGE = ("CLAUDE.md", "AGENTS.md", "GEMINI.md", "docs/research", ".claude/agents",
|
|
42
|
+
".claude/skills", ".claude/commands", ".agents", "skills")
|
|
43
|
+
RULE_FILES = ("CLAUDE.md", "AGENTS.md", "GEMINI.md")
|
|
44
|
+
INDEX = os.path.join(".tezgah", "analysis", "project-knowledge.md")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def read(path):
|
|
48
|
+
try:
|
|
49
|
+
with open(path, encoding="utf-8") as fh:
|
|
50
|
+
return fh.read()
|
|
51
|
+
except (OSError, UnicodeDecodeError):
|
|
52
|
+
return ""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def git(repo, *args):
|
|
56
|
+
return subprocess.run(["git", "-C", repo] + list(args), capture_output=True, text=True)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def in_work_tree(repo):
|
|
60
|
+
return git(repo, "rev-parse", "--is-inside-work-tree").stdout.strip() == "true"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def missing_ignores(repo):
|
|
64
|
+
lines = {line.strip() for line in read(os.path.join(repo, ".gitignore")).splitlines()}
|
|
65
|
+
return [want for want in IGNORES
|
|
66
|
+
if not lines & {want, want.strip("/"), want.rstrip("/"), want.lstrip("/")}]
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def tracked(repo, path):
|
|
70
|
+
out = git(repo, "ls-files", "-z", "--", path).stdout
|
|
71
|
+
return [p for p in out.split("\0") if p]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def files_under(root):
|
|
75
|
+
"""Every file (and symlink) below `root`, relative to it, sorted."""
|
|
76
|
+
found = []
|
|
77
|
+
for base, dirs, files in os.walk(root):
|
|
78
|
+
dirs[:] = [d for d in dirs if d != ".git" or base != root]
|
|
79
|
+
for name in files + [d for d in dirs if os.path.islink(os.path.join(base, d))]:
|
|
80
|
+
found.append(os.path.relpath(os.path.join(base, name), root))
|
|
81
|
+
return sorted(found)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def same(a, b):
|
|
85
|
+
try:
|
|
86
|
+
with open(a, "rb") as fa, open(b, "rb") as fb:
|
|
87
|
+
return fa.read() == fb.read()
|
|
88
|
+
except OSError:
|
|
89
|
+
return False
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def is_plan_tree(path):
|
|
93
|
+
return (os.path.isdir(os.path.join(path, "open")) or os.path.isdir(os.path.join(path, "done"))
|
|
94
|
+
or "<!-- status:start -->" in read(os.path.join(path, "README.md")))
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def first_heading(path):
|
|
98
|
+
"""The first markdown heading of a file, or of a directory's README.md (else
|
|
99
|
+
its first .md file); '-' when there is none."""
|
|
100
|
+
if os.path.isdir(path):
|
|
101
|
+
mds = [f for f in files_under(path) if f.endswith(".md")]
|
|
102
|
+
if not mds:
|
|
103
|
+
return "-"
|
|
104
|
+
path = os.path.join(path, "README.md" if "README.md" in mds else mds[0])
|
|
105
|
+
lines = read(path).splitlines()
|
|
106
|
+
if lines and lines[0].strip() == "---":
|
|
107
|
+
end = next((i for i, line in enumerate(lines[1:], 1) if line.strip() == "---"), 0)
|
|
108
|
+
lines = lines[end + 1:]
|
|
109
|
+
for line in lines:
|
|
110
|
+
if line.startswith("#"):
|
|
111
|
+
return line.lstrip("#").strip() or "-"
|
|
112
|
+
return "-"
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def knowledge_index(repo):
|
|
116
|
+
"""The index text, or '' when the repo has no project-owned knowledge."""
|
|
117
|
+
paths = [p for p in KNOWLEDGE if os.path.lexists(os.path.join(repo, p))]
|
|
118
|
+
paths += sorted(p for p in tracked(repo, ".")
|
|
119
|
+
if "/" in p and os.path.basename(p) in RULE_FILES and p not in paths)
|
|
120
|
+
if not paths:
|
|
121
|
+
return ""
|
|
122
|
+
rows = ["# Project knowledge", "",
|
|
123
|
+
"Project-owned knowledge that stays where it is. tezgah-migrate wrote this",
|
|
124
|
+
"index so a session finds it; the project's git owns the files.", "",
|
|
125
|
+
"| path | files | first heading |", "|---|---|---|"]
|
|
126
|
+
for p in paths:
|
|
127
|
+
full = os.path.join(repo, p)
|
|
128
|
+
count = len(files_under(full)) if os.path.isdir(full) else 1
|
|
129
|
+
rows.append("| `%s` | %d | %s |" % (p, count, first_heading(full).replace("|", "\\|")))
|
|
130
|
+
return "\n".join(rows) + "\n"
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class Plan:
|
|
134
|
+
"""What one repo needs: printable steps, the paths a backup must hold, and
|
|
135
|
+
the callables that perform the steps."""
|
|
136
|
+
|
|
137
|
+
def __init__(self, repo):
|
|
138
|
+
self.repo = repo
|
|
139
|
+
self.steps = [] # (text, callable)
|
|
140
|
+
self.skipped = [] # text
|
|
141
|
+
self.backup = set() # repo-relative paths
|
|
142
|
+
self.imported = False
|
|
143
|
+
|
|
144
|
+
def add(self, text, fn, *backup):
|
|
145
|
+
self.steps.append((text, fn))
|
|
146
|
+
self.backup.update(backup)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def plan_move(plan, src, dest):
|
|
150
|
+
"""Move every file of root `src` under `dest`; a differing name collision is
|
|
151
|
+
skipped and stays in place, an identical one only drops the source."""
|
|
152
|
+
repo = plan.repo
|
|
153
|
+
root = os.path.join(repo, src)
|
|
154
|
+
if not os.path.isdir(root) or os.path.islink(root):
|
|
155
|
+
return
|
|
156
|
+
known = set(tracked(repo, src))
|
|
157
|
+
moves = []
|
|
158
|
+
for rel in files_under(root):
|
|
159
|
+
target = os.path.join(repo, dest, rel)
|
|
160
|
+
if os.path.lexists(target) and not same(os.path.join(root, rel), target):
|
|
161
|
+
plan.skipped.append("%s/%s: %s/%s exists with other content" % (src, rel, dest, rel))
|
|
162
|
+
continue
|
|
163
|
+
moves.append(rel)
|
|
164
|
+
if not moves:
|
|
165
|
+
return
|
|
166
|
+
untrack = [p for p in (os.path.join(src, rel) for rel in moves) if p in known]
|
|
167
|
+
|
|
168
|
+
def run():
|
|
169
|
+
for rel in moves:
|
|
170
|
+
source, target = os.path.join(root, rel), os.path.join(repo, dest, rel)
|
|
171
|
+
if os.path.lexists(target):
|
|
172
|
+
os.remove(source) # identical copy already there; the backup holds it
|
|
173
|
+
else:
|
|
174
|
+
os.makedirs(os.path.dirname(target), exist_ok=True)
|
|
175
|
+
os.rename(source, target)
|
|
176
|
+
if untrack:
|
|
177
|
+
out = git(repo, "rm", "-q", "--cached", "--", *untrack)
|
|
178
|
+
if out.returncode:
|
|
179
|
+
raise RuntimeError(out.stderr.strip())
|
|
180
|
+
for base, _dirs, _files in sorted(os.walk(root), reverse=True):
|
|
181
|
+
if not os.listdir(base):
|
|
182
|
+
os.rmdir(base)
|
|
183
|
+
|
|
184
|
+
plan.add("move %s/ -> %s/ (%d files, %d tracked)" % (src, dest, len(moves), len(untrack)),
|
|
185
|
+
run, src)
|
|
186
|
+
plan.imported = True
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def make_plan(repo):
|
|
190
|
+
plan = Plan(repo)
|
|
191
|
+
ws = os.path.join(repo, ".tezgah")
|
|
192
|
+
ours = tracked(repo, ".tezgah")
|
|
193
|
+
if ours:
|
|
194
|
+
def untrack():
|
|
195
|
+
out = git(repo, "rm", "-r", "-q", "--cached", ".tezgah")
|
|
196
|
+
if out.returncode:
|
|
197
|
+
raise RuntimeError(out.stderr.strip())
|
|
198
|
+
plan.add("untrack .tezgah/ (%d tracked files; they stay on disk)" % len(ours),
|
|
199
|
+
untrack, ".tezgah")
|
|
200
|
+
if os.path.isdir(os.path.join(repo, "plans")):
|
|
201
|
+
if is_plan_tree(os.path.join(repo, "plans")):
|
|
202
|
+
plan_move(plan, "plans", ".tezgah/plans")
|
|
203
|
+
else:
|
|
204
|
+
plan.skipped.append("plans/: not in tezgah plan format, left alone")
|
|
205
|
+
plan_move(plan, "analysis", ".tezgah/analysis")
|
|
206
|
+
plan_move(plan, "research", ".tezgah/analysis/imported-research")
|
|
207
|
+
|
|
208
|
+
text = knowledge_index(repo)
|
|
209
|
+
if text and read(os.path.join(repo, INDEX)) != text:
|
|
210
|
+
def index():
|
|
211
|
+
os.makedirs(os.path.dirname(os.path.join(repo, INDEX)), exist_ok=True)
|
|
212
|
+
with open(os.path.join(repo, INDEX), "w", encoding="utf-8") as fh:
|
|
213
|
+
fh.write(text)
|
|
214
|
+
plan.add("index project knowledge (%d paths) -> %s" % (text.count("\n| `"), INDEX),
|
|
215
|
+
index, INDEX)
|
|
216
|
+
plan.imported = True
|
|
217
|
+
|
|
218
|
+
missing = missing_ignores(repo) if in_work_tree(repo) else []
|
|
219
|
+
fresh = not os.path.isdir(os.path.join(ws, ".git"))
|
|
220
|
+
if missing or fresh:
|
|
221
|
+
def ensure():
|
|
222
|
+
if ensure_workspace(repo) is None:
|
|
223
|
+
raise RuntimeError("ensure_workspace failed")
|
|
224
|
+
parts = (["add %s to .gitignore" % " ".join(missing)] if missing else []) + \
|
|
225
|
+
(["git init .tezgah"] if fresh else [])
|
|
226
|
+
plan.add("ensure workspace: %s" % "; ".join(parts), ensure, ".gitignore", ".tezgah")
|
|
227
|
+
if fresh or plan.imported or ws_git(repo, "rev-parse", "-q", "--verify", "HEAD").returncode:
|
|
228
|
+
head = git(repo, "rev-parse", "--short", "HEAD").stdout.strip() or "none"
|
|
229
|
+
message = "import from project history %s" % head
|
|
230
|
+
|
|
231
|
+
def commit():
|
|
232
|
+
# without its own .git, `git -C .tezgah` would reach the project repo
|
|
233
|
+
if not os.path.isdir(os.path.join(ws, ".git")):
|
|
234
|
+
raise RuntimeError("%s/.git is missing" % ws)
|
|
235
|
+
ws_git(repo, "add", "-A")
|
|
236
|
+
out = ws_git(repo, "commit", "-q", "--allow-empty", "-m", message)
|
|
237
|
+
if out.returncode:
|
|
238
|
+
raise RuntimeError((out.stderr or out.stdout or "").strip())
|
|
239
|
+
plan.add("commit .tezgah content in its private repo: %r" % message, commit)
|
|
240
|
+
return plan
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def write_backup(plan):
|
|
244
|
+
repo = plan.repo
|
|
245
|
+
stamp = datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%dT%H%M%S")
|
|
246
|
+
folder = os.path.join(tp.CONFIG_DIR, "backups")
|
|
247
|
+
os.makedirs(folder, exist_ok=True)
|
|
248
|
+
path = os.path.join(folder, "%s-%s.tar.gz" % (os.path.basename(repo), stamp))
|
|
249
|
+
with tarfile.open(path, "w:gz") as tar:
|
|
250
|
+
for rel in sorted(plan.backup):
|
|
251
|
+
if os.path.lexists(os.path.join(repo, rel)):
|
|
252
|
+
tar.add(os.path.join(repo, rel), arcname=rel)
|
|
253
|
+
return path
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def migrate(repo, apply):
|
|
257
|
+
plan = make_plan(repo)
|
|
258
|
+
print("%s (%s)" % (os.path.basename(repo), repo))
|
|
259
|
+
for text, _fn in plan.steps:
|
|
260
|
+
print(" %s %s" % ("do" if apply else "would", text))
|
|
261
|
+
for text in plan.skipped:
|
|
262
|
+
print(" skip %s" % text)
|
|
263
|
+
backup, failed = "none", False
|
|
264
|
+
if plan.steps and apply:
|
|
265
|
+
backup = write_backup(plan)
|
|
266
|
+
for text, fn in plan.steps:
|
|
267
|
+
try:
|
|
268
|
+
fn()
|
|
269
|
+
except (OSError, RuntimeError) as exc:
|
|
270
|
+
print(" FAIL %s: %s" % (text, exc))
|
|
271
|
+
failed = True
|
|
272
|
+
break
|
|
273
|
+
elif plan.steps:
|
|
274
|
+
backup = "would write %s" % os.path.join(tp.CONFIG_DIR, "backups",
|
|
275
|
+
os.path.basename(repo) + "-<stamp>.tar.gz")
|
|
276
|
+
print("= %s: %d %s, %d skipped, backup %s" % (
|
|
277
|
+
os.path.basename(repo), len(plan.steps), "done" if apply and not failed else
|
|
278
|
+
"failed" if failed else "planned", len(plan.skipped), backup))
|
|
279
|
+
return not failed
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def discover():
|
|
283
|
+
repos = []
|
|
284
|
+
for root in tp.roots():
|
|
285
|
+
try:
|
|
286
|
+
names = sorted(os.listdir(root))
|
|
287
|
+
except OSError:
|
|
288
|
+
continue
|
|
289
|
+
for name in names:
|
|
290
|
+
path = os.path.realpath(os.path.join(root, name))
|
|
291
|
+
if not os.path.isdir(os.path.join(path, ".git")):
|
|
292
|
+
continue
|
|
293
|
+
if path == tp.PLUGIN_ROOT or os.path.isfile(os.path.join(path, "hooks", "tezgah_policy.py")):
|
|
294
|
+
continue
|
|
295
|
+
repos.append(path)
|
|
296
|
+
return repos
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def main(argv):
|
|
300
|
+
apply, repos, i = False, [], 0
|
|
301
|
+
while i < len(argv):
|
|
302
|
+
if argv[i] == "--apply":
|
|
303
|
+
apply = True
|
|
304
|
+
elif argv[i] == "--repo" and i + 1 < len(argv):
|
|
305
|
+
repos.append(os.path.realpath(argv[i + 1]))
|
|
306
|
+
i += 1
|
|
307
|
+
else:
|
|
308
|
+
print(__doc__, file=sys.stderr)
|
|
309
|
+
return 2
|
|
310
|
+
i += 1
|
|
311
|
+
for repo in repos:
|
|
312
|
+
if not os.path.isdir(os.path.join(repo, ".git")):
|
|
313
|
+
print("tezgah-migrate: %s is not a git repository root" % repo, file=sys.stderr)
|
|
314
|
+
return 2
|
|
315
|
+
ok = True
|
|
316
|
+
for repo in repos or discover():
|
|
317
|
+
ok = migrate(repo, apply) and ok
|
|
318
|
+
if not apply:
|
|
319
|
+
print("dry run: nothing changed; re-run with --apply to perform it")
|
|
320
|
+
return 0 if ok else 1
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
if __name__ == "__main__":
|
|
324
|
+
sys.exit(main(sys.argv[1:]))
|