@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
|
@@ -0,0 +1,701 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
3
|
+
import { basename, delimiter, dirname, join } from "node:path";
|
|
4
|
+
|
|
5
|
+
// tezgah-setup substitutes the absolute path of hosts/omp/hook.py, the python
|
|
6
|
+
// half that owns the contract, the gate and the evidence ledger. This file is
|
|
7
|
+
// only the bridge: omp's extension events in, the host's own envelopes back.
|
|
8
|
+
const HOOK = "@HOOK@";
|
|
9
|
+
|
|
10
|
+
// The interpreter the hook runs under, resolved the way tezgah's own
|
|
11
|
+
// `hooks/tezgah_paths.python_cmd()` resolves it: the tezgah override first, then
|
|
12
|
+
// the names the platforms ship. A bridge that names one interpreter is dead on a
|
|
13
|
+
// host that ships another - which is what the whole Windows half of the plan is
|
|
14
|
+
// about - so the resolution is done once, here. Memoised after the first ask: the
|
|
15
|
+
// probe reads PATH, and a session that never reaches the hook must not pay for it.
|
|
16
|
+
let pythonMemo: string | undefined;
|
|
17
|
+
|
|
18
|
+
function pythonBin(): string {
|
|
19
|
+
if (pythonMemo) return pythonMemo;
|
|
20
|
+
// The order is the order they answer in: `py` is the Windows launcher, and
|
|
21
|
+
// TEZGAH_PYTHON (the name the manifests and every other adapter resolve
|
|
22
|
+
// through) overrides the list entirely.
|
|
23
|
+
const names = ["python3", "python", "py"];
|
|
24
|
+
if (process.env.TEZGAH_PYTHON) {
|
|
25
|
+
return (pythonMemo = process.env.TEZGAH_PYTHON);
|
|
26
|
+
}
|
|
27
|
+
// A bare name is resolved by the OS at spawn time only through its own rules,
|
|
28
|
+
// and node does not read a shell's hash, so the lookup is done here: PATH with
|
|
29
|
+
// the platform's separator, and `.exe` beside each name on Windows.
|
|
30
|
+
const dirs = String(process.env.PATH || "").split(delimiter);
|
|
31
|
+
const win = process.platform === "win32";
|
|
32
|
+
const found = names.find((name) => dirs.some((dir) => {
|
|
33
|
+
try {
|
|
34
|
+
return existsSync(join(dir, name))
|
|
35
|
+
|| (win && existsSync(join(dir, name + ".exe")));
|
|
36
|
+
} catch { return false; }
|
|
37
|
+
}));
|
|
38
|
+
// Nothing resolved: the first documented name, so the failure the catch below
|
|
39
|
+
// reports names an interpreter instead of an empty command.
|
|
40
|
+
return (pythonMemo = found || names[0]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// The status line refreshes on the events omp already emits - session start,
|
|
44
|
+
// session switch, turn end, and the tool results that move a used mark - so the
|
|
45
|
+
// hook polls nothing. The one timer is the motion below: it runs only while the
|
|
46
|
+
// agent works, redraws the line it already holds (no python per frame), goes
|
|
47
|
+
// through omp's own isolated `ctx.setInterval`, and stops at the agent's
|
|
48
|
+
// terminal end, a session switch and shutdown.
|
|
49
|
+
|
|
50
|
+
// Motion: while the agent runs, the widget leads with a spinner, the tool that
|
|
51
|
+
// is running and the seconds it has run - the way omp's own footer shows work.
|
|
52
|
+
// The frames are braille, one cell each, and the prefix is dropped the moment
|
|
53
|
+
// the agent stops, so an idle line never looks busy.
|
|
54
|
+
const FRAMES = ["\u280b", "\u2819", "\u2839", "\u2838", "\u283c", "\u2834",
|
|
55
|
+
"\u2826", "\u2827", "\u2807", "\u280f"];
|
|
56
|
+
const FRAME_MS = 100;
|
|
57
|
+
|
|
58
|
+
// NO_COLOR / TEZGAH_STATUS_COLOR=0 are the same opt-outs the python renderer
|
|
59
|
+
// reads; TEZGAH_STATUS_ANIMATE=0 keeps the colors and drops the motion.
|
|
60
|
+
function colorOn(): boolean {
|
|
61
|
+
return process.env.NO_COLOR === undefined && process.env.TEZGAH_STATUS_COLOR !== "0";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function motionOn(): boolean {
|
|
65
|
+
return process.env.TEZGAH_STATUS_ANIMATE !== "0";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// The busy prefix for one frame: spinner, then the running tool (or "thinking"
|
|
69
|
+
// between tools) and the whole run's seconds, then a dim bar before the marks.
|
|
70
|
+
// `bare` keeps the spinner alone, for a width that has no room for the rest.
|
|
71
|
+
// Only a line without the logo (NO_COLOR) takes the spinner: a colored line's
|
|
72
|
+
// motion is the logo itself (logoFrame), and its activity text is `activity`.
|
|
73
|
+
export function busyPrefix(frame: number, tool: string, secs: number,
|
|
74
|
+
color: boolean, bare = false): string {
|
|
75
|
+
const spin = FRAMES[((frame % FRAMES.length) + FRAMES.length) % FRAMES.length];
|
|
76
|
+
if (bare) return color ? "\u001b[1;35m" + spin + "\u001b[0m " : spin + " ";
|
|
77
|
+
const what = (tool || "thinking") + " " + Math.max(0, Math.floor(secs)) + "s";
|
|
78
|
+
if (!color) return spin + " " + what + " | ";
|
|
79
|
+
return "\u001b[1;35m" + spin + "\u001b[0m \u001b[35m" + what +
|
|
80
|
+
"\u001b[0m \u001b[2m\u2502\u001b[0m ";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// The running tool and the run's seconds, set beside the animated logo.
|
|
84
|
+
export function activity(tool: string, secs: number): string {
|
|
85
|
+
return "\u001b[35m" + (tool || "thinking") + " " + Math.max(0, Math.floor(secs)) +
|
|
86
|
+
"s\u001b[0m \u001b[2m\u2502\u001b[0m ";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// The logo the python renderer puts at the head of a colored line: three upper
|
|
90
|
+
// half blocks, the middle one's background being the support (hooks/
|
|
91
|
+
// tezgah_context.logo_head). Matched by shape, whatever palette drew it.
|
|
92
|
+
const HEAD_LOGO = /^\u001b\[38;2;\d+;\d+;\d+m\u2580\u001b\[48;2;\d+;\d+;\d+m\u2580\u001b\[49m\u2580\u001b\[0m/;
|
|
93
|
+
// The logo's own colors (assets/logo/tezgah-logo.svg) for each background: the
|
|
94
|
+
// worktop's top face and the teal support on a dark terminal, their darker faces
|
|
95
|
+
// on a light one, where the bright pair would wash out; `shine` is the sheen.
|
|
96
|
+
const LOGO_COLORS = {
|
|
97
|
+
dark: { top: "255;197;92", leg: "23;161;140", shine: "255;238;196", legShine: "96;226;204" },
|
|
98
|
+
light: { top: "184;118;28", leg: "14;124;107", shine: "242;167;59", legShine: "23;161;140" },
|
|
99
|
+
};
|
|
100
|
+
const VERSION_DARK = "\u001b[2m\u001b[38;2;255;197;92m";
|
|
101
|
+
const VERSION_LIGHT = "\u001b[38;2;184;118;28m";
|
|
102
|
+
|
|
103
|
+
// One frame of the T. `frame` null is the still logo; a number sweeps a sheen
|
|
104
|
+
// across the worktop left to right, then down the support, two frames a step.
|
|
105
|
+
export function logoFrame(frame: number | null, light: boolean): string {
|
|
106
|
+
const c = light ? LOGO_COLORS.light : LOGO_COLORS.dark;
|
|
107
|
+
const at = frame === null ? -1 : Math.floor(frame / 2) % 6;
|
|
108
|
+
const tops = [0, 1, 2].map((i) => (at === i ? c.shine : c.top));
|
|
109
|
+
const fg = (i: number) => (i && tops[i] === tops[i - 1] ? "" : "\u001b[38;2;" + tops[i] + "m");
|
|
110
|
+
const leg = "\u001b[48;2;" + (at === 3 ? c.legShine : c.leg) + "m";
|
|
111
|
+
// a color is written only where it changes, so the still frame is exactly
|
|
112
|
+
// the logo the python renderer drew (logo_head)
|
|
113
|
+
return fg(0) + "\u2580" + fg(1) + leg + "\u2580\u001b[49m" + fg(2) + "\u2580\u001b[0m";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// The line with its head redrawn for this frame and this background: the logo
|
|
117
|
+
// replaced by `logoFrame`, the version recolored on a light terminal. A line
|
|
118
|
+
// without the logo (plain, or an old hook) is returned as it came.
|
|
119
|
+
export function restyle(line: string, frame: number | null, light: boolean): string {
|
|
120
|
+
const m = HEAD_LOGO.exec(line);
|
|
121
|
+
if (!m) return line;
|
|
122
|
+
let rest = line.slice(m[0].length);
|
|
123
|
+
if (light) rest = rest.split(VERSION_DARK).join(VERSION_LIGHT);
|
|
124
|
+
return logoFrame(frame, light) + rest;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Cells a rendered line takes: the python renderer draws only one-cell glyphs,
|
|
128
|
+
// so stripping the escapes is the whole measure (hooks/tezgah_context.cells).
|
|
129
|
+
const ANSI = /\u001b\[[0-9;?]*[A-Za-z]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g;
|
|
130
|
+
|
|
131
|
+
export function cellsOf(text: string): number {
|
|
132
|
+
return Array.from(text.replace(ANSI, "")).length;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Cut a colored line to `max` cells, escapes kept whole, with an ellipsis and a
|
|
136
|
+
// reset at the cut - the last resort when not even the narrowest tier fits.
|
|
137
|
+
export function cut(text: string, max: number): string {
|
|
138
|
+
if (max <= 0) return "";
|
|
139
|
+
if (cellsOf(text) <= max) return text;
|
|
140
|
+
let out = "";
|
|
141
|
+
let used = 0;
|
|
142
|
+
let i = 0;
|
|
143
|
+
while (i < text.length && used < max - 1) {
|
|
144
|
+
ANSI.lastIndex = i;
|
|
145
|
+
const m = ANSI.exec(text);
|
|
146
|
+
if (m && m.index === i) {
|
|
147
|
+
out += m[0];
|
|
148
|
+
i += m[0].length;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const ch = String.fromCodePoint(text.codePointAt(i) as number);
|
|
152
|
+
out += ch;
|
|
153
|
+
i += ch.length;
|
|
154
|
+
used += 1;
|
|
155
|
+
}
|
|
156
|
+
return out + "\u2026\u001b[0m";
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// The widest tier ([line, cells], widest first) that fits `room`, else the
|
|
160
|
+
// narrowest cut to it: a narrow terminal gets a shorter line, never a wrapped
|
|
161
|
+
// one - the wrap was the second row the line used to spill onto.
|
|
162
|
+
export function fit(tiers: Array<[string, number]>, room: number): string {
|
|
163
|
+
for (const [line, width] of tiers) {
|
|
164
|
+
if (width <= room) return line;
|
|
165
|
+
}
|
|
166
|
+
const last = tiers[tiers.length - 1];
|
|
167
|
+
return last ? cut(last[0], room) : "";
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// omp sanitizes what `setStatus` stores (ANSI/VT sequences stripped), so the
|
|
171
|
+
// per-mark colors the hook returns survive only through the widget path, which
|
|
172
|
+
// renders the string as it is. The status key stays as the fallback for a build
|
|
173
|
+
// without setWidget: the text is then uncolored, never wrong. `sized` is the
|
|
174
|
+
// width-aware body: the widget is a component whose render(width) asks it for
|
|
175
|
+
// the one line that fits, so the host's own width decides and nothing wraps.
|
|
176
|
+
// The factory also receives omp's theme, whose `isLight` says which background
|
|
177
|
+
// the logo has to stand out against.
|
|
178
|
+
function draw(ctx: any, line: string,
|
|
179
|
+
sized?: (width: number, light: boolean) => string): void {
|
|
180
|
+
// The widget is drawn by the host, not by the hook, so it is the one surface
|
|
181
|
+
// a broken hook cannot take away - and talking to a host UI is where a build
|
|
182
|
+
// can refuse. Nothing here may throw: the line is cosmetic, and the caller's
|
|
183
|
+
// message (the session brief, the failure notice) still has to go out.
|
|
184
|
+
try {
|
|
185
|
+
if (!line || !ctx?.ui) return;
|
|
186
|
+
if (typeof ctx.ui.setWidget !== "function") {
|
|
187
|
+
ctx.ui.setStatus("tezgah", line);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (sized) {
|
|
191
|
+
try {
|
|
192
|
+
// one column of padding, the way omp pads its string widgets
|
|
193
|
+
ctx.ui.setWidget("tezgah", (_ui: any, theme: any) => ({
|
|
194
|
+
render: (width: number) => [" " + sized(Math.max(0, width - 1),
|
|
195
|
+
theme?.isLight === true)],
|
|
196
|
+
invalidate: () => {},
|
|
197
|
+
}), { placement: "belowEditor" });
|
|
198
|
+
return;
|
|
199
|
+
} catch { /* a build without component widgets takes the string below */ }
|
|
200
|
+
}
|
|
201
|
+
ctx.ui.setWidget("tezgah", [line], { placement: "belowEditor" });
|
|
202
|
+
} catch { /* a host that refuses the widget keeps the message instead */ }
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Tools whose result can move the status line's used marks, carry the evidence
|
|
206
|
+
// the Stop rule reads, or arrive from outside the user and the workspace.
|
|
207
|
+
// read/grep/glob are absent on purpose: a read-heavy turn would otherwise spawn
|
|
208
|
+
// python per call for nothing. The three web tools are here because their result
|
|
209
|
+
// is exactly the one the untrusted-content label exists for.
|
|
210
|
+
const WATCHED = ["bash", "shell", "command", "edit", "write", "multiedit",
|
|
211
|
+
"notebookedit", "apply_patch", "edit_file", "write_file", "search_replace",
|
|
212
|
+
"task", "agent", "spawn_agent", "web_search", "web_fetch", "browser"];
|
|
213
|
+
|
|
214
|
+
// A read of a tezgah skill file is the one read whose result moves a status
|
|
215
|
+
// mark, and matching it here keeps the rule that made reads unwatched: ordinary
|
|
216
|
+
// reads never reach python. Mirror of hooks/tezgah_context.skill_read_kind,
|
|
217
|
+
// which names the kind python records - the mark `SKILL_MARKS` draws for the two
|
|
218
|
+
// skills the always-on core tells a session to read, and `skill:<name>` for any
|
|
219
|
+
// other shipped skill, the kind the fitness report folds
|
|
220
|
+
// (`tezgah-status --skill-fitness`) and no status mark is spelled with.
|
|
221
|
+
const SKILL_MARKS: Record<string, string> =
|
|
222
|
+
{ ponytail: "pony", "i-have-adhd": "adhd" };
|
|
223
|
+
const READ_TOOLS = ["read", "read_file", "readfile", "view_file"];
|
|
224
|
+
|
|
225
|
+
// The skills this checkout ships, the catalogue hooks/tezgah_context
|
|
226
|
+
// .shipped_skills() reads: a directory under the checkout's `skills/` with a
|
|
227
|
+
// SKILL.md in it. The template's @HOOK@ is <checkout>/hosts/omp/hook.py, so the
|
|
228
|
+
// checkout is two directories above the hook. Read once and only for a
|
|
229
|
+
// skill-shaped read; a checkout this cannot read leaves an empty catalogue, and
|
|
230
|
+
// the two marks above are still matched by name whatever it holds.
|
|
231
|
+
let skillsMemo: string[] | undefined;
|
|
232
|
+
function shippedSkills(): string[] {
|
|
233
|
+
if (skillsMemo) return skillsMemo;
|
|
234
|
+
const dir = join(dirname(dirname(dirname(HOOK))), "skills");
|
|
235
|
+
try {
|
|
236
|
+
skillsMemo = readdirSync(dir).filter(
|
|
237
|
+
(name) => existsSync(join(dir, name, "SKILL.md")));
|
|
238
|
+
} catch {
|
|
239
|
+
skillsMemo = [];
|
|
240
|
+
}
|
|
241
|
+
return skillsMemo;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// The skill name a read path names, or "": `<...>/skills/<name>/SKILL.md`, and
|
|
245
|
+
// the internal URL omp's read tool also takes, `skill://<name>`, which is the
|
|
246
|
+
// same SKILL.md with or without its tail
|
|
247
|
+
// (hooks/tezgah_context._skill_read_name).
|
|
248
|
+
function skillName(path: string): string {
|
|
249
|
+
const m = /(?:^|\/)skills\/([^/]+)\/SKILL\.md$/.exec(path);
|
|
250
|
+
if (m) return m[1];
|
|
251
|
+
const url = /^skill:\/\/([^/]+)/.exec(path);
|
|
252
|
+
return url ? url[1] : "";
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function skillRead(tool: string, args: any): boolean {
|
|
256
|
+
if (!READ_TOOLS.includes(tool.toLowerCase())) return false;
|
|
257
|
+
const raw = args?.filePath ?? args?.file_path ?? args?.path ?? "";
|
|
258
|
+
const name = skillName(String(raw).replace(/\\/g, "/"));
|
|
259
|
+
if (!name) return false;
|
|
260
|
+
return Object.prototype.hasOwnProperty.call(SKILL_MARKS, name)
|
|
261
|
+
|| shippedSkills().includes(name);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// The gate is only consulted for the tools the shared rule knows: the refusal
|
|
265
|
+
// of the grep-only explorer (task/agent), the anti-shortcut and attribution
|
|
266
|
+
// checks (bash), and the test-skip check (the edit/write names). An MCP tool is
|
|
267
|
+
// consulted when its name carries an effect verb (MCP_EFFECT, see `tool_call`).
|
|
268
|
+
const GATED = ["grep", "bash", "shell", "command", "task", "agent", "edit",
|
|
269
|
+
"write", "multiedit", "notebookedit", "apply_patch", "edit_file", "write_file",
|
|
270
|
+
"search_replace", "powershell", "pwsh"];
|
|
271
|
+
|
|
272
|
+
// The effect verbs of tezgah_integrity.MCP_VERBS, as one pattern: a read-only
|
|
273
|
+
// MCP call (a code-graph query) reaches no content rule, so it pays no spawn.
|
|
274
|
+
// tests/test_setup.py holds this pattern, hooks/hooks.json and
|
|
275
|
+
// hosts/dsh/hooks.json equal to the verb classes.
|
|
276
|
+
const MCP_EFFECT = /^mcp__(?:.*[^A-Za-z0-9])?(?:append|cancel|clear|click|close|comment|commit|copy|create|delete|deploy|drag|edit|email|evaluate|exec|execute|fill|insert|install|kill|launch|merge|message|mkdir|move|navigate|notify|patch|pause|post|press|print|publish|push|put|release|remove|rename|replace|reply|resume|review|run|save|send|set|share|skip|start|stop|submit|swipe|tag|tap|terminate|type|uninstall|update|upload|write)(?:[^A-Za-z0-9].*)?$/;
|
|
277
|
+
|
|
278
|
+
// The provenance label omp puts in front of a result that came from outside the
|
|
279
|
+
// user and the workspace. The handler's return value replaces the tool result
|
|
280
|
+
// (extensionRunner.emitToolResult reads `content`/`details`/`isError` off it and
|
|
281
|
+
// the tool call hands that back as the result), so the line is read with the
|
|
282
|
+
// content it applies to, in the same turn - not as a side message. An unknown
|
|
283
|
+
// content shape is left alone rather than replaced by a label alone, which would
|
|
284
|
+
// throw the result away.
|
|
285
|
+
function labelled(content: any, label: string): any {
|
|
286
|
+
const part = { type: "text", text: label };
|
|
287
|
+
if (Array.isArray(content)) return [part, ...content];
|
|
288
|
+
if (typeof content === "string") {
|
|
289
|
+
return [part, { type: "text", text: content }];
|
|
290
|
+
}
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// A check's own output saying it ran nothing: the same literal as
|
|
295
|
+
// hooks/tezgah_integrity.py `EMPTY_RUN` (tests/test_omp_extension.py pins the
|
|
296
|
+
// two equal), read here because the bridge sends the hook a size and never the
|
|
297
|
+
// body. Read on the result's last EMPTY_RUN_TAIL characters, like the core.
|
|
298
|
+
const EMPTY_RUN = /^[=\s]*(?:collected 0 items|no tests ran|ran 0 tests|no tests found)\b/im;
|
|
299
|
+
const EMPTY_RUN_TAIL = 4096;
|
|
300
|
+
function emptyRun(content: any): boolean {
|
|
301
|
+
const text = typeof content === "string" ? content
|
|
302
|
+
: Array.isArray(content)
|
|
303
|
+
? content.map((p: any) => (typeof p?.text === "string" ? p.text : "")).join("\n")
|
|
304
|
+
: "";
|
|
305
|
+
return EMPTY_RUN.test(text.slice(-EMPTY_RUN_TAIL));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// The hook's failure is the one state the bridge can see and the hook cannot
|
|
309
|
+
// report: no interpreter to start it with, the checkout moved, the hook crashed
|
|
310
|
+
// or ran past the timeout. It is remembered here so the next event can say so.
|
|
311
|
+
let hookError = "";
|
|
312
|
+
// the session already told about the failure in flight, so a broken hook costs
|
|
313
|
+
// one message per episode rather than one per event
|
|
314
|
+
let toldSession: string | undefined;
|
|
315
|
+
|
|
316
|
+
const FAIL = "\u001b[31mhook\u2717\u001b[0m tezgah hook failed";
|
|
317
|
+
|
|
318
|
+
// The reason names the hook's own last stderr line (a traceback ends on the
|
|
319
|
+
// exception, e.g. the ImportError), and falls back to node's message for a
|
|
320
|
+
// failure with no stderr: no interpreter, a timeout.
|
|
321
|
+
function why(err: any): string {
|
|
322
|
+
const lines = String(err?.stderr ?? "").split("\n")
|
|
323
|
+
.map((line) => line.trim()).filter(Boolean);
|
|
324
|
+
const text = lines.length ? lines[lines.length - 1]
|
|
325
|
+
: String(err?.message ?? err ?? "").split("\n")[0];
|
|
326
|
+
return text.slice(0, 160) || "no answer";
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function ask(payload: Record<string, unknown>): any {
|
|
330
|
+
try {
|
|
331
|
+
// stderr is piped, not inherited: an inherited stream writes the hook's
|
|
332
|
+
// traceback straight into omp's TUI, over the screen, on every redraw. It
|
|
333
|
+
// is read back by why() instead.
|
|
334
|
+
const out = execFileSync(pythonBin(), [HOOK], {
|
|
335
|
+
input: JSON.stringify(payload),
|
|
336
|
+
encoding: "utf8",
|
|
337
|
+
timeout: 10000,
|
|
338
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
339
|
+
});
|
|
340
|
+
hookError = "";
|
|
341
|
+
toldSession = undefined;
|
|
342
|
+
return out.trim() ? JSON.parse(out) : {};
|
|
343
|
+
} catch (err) {
|
|
344
|
+
// A missing python or a crash in the hook leaves the host exactly as it
|
|
345
|
+
// was: tezgah never turns its own failure into a blocked tool call. The
|
|
346
|
+
// failure is kept instead of thrown, and surfaces on the widget below.
|
|
347
|
+
hookError = why(err);
|
|
348
|
+
return {};
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// The failure mark: draw() already cannot throw, so a broken hook costs the
|
|
353
|
+
// marks and nothing else.
|
|
354
|
+
function markBroken(ctx: any): void {
|
|
355
|
+
draw(ctx, FAIL);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// The one line that says what happened and how to check it, delivered once per
|
|
359
|
+
// failing session on the events that can carry a message.
|
|
360
|
+
function failureNotice(ctx: any, session: string | undefined): string | undefined {
|
|
361
|
+
if (!hookError) return undefined;
|
|
362
|
+
markBroken(ctx);
|
|
363
|
+
if (toldSession === String(session)) return undefined;
|
|
364
|
+
toldSession = String(session);
|
|
365
|
+
return "tezgah: its omp hook failed, so the gate, the evidence ledger and the " +
|
|
366
|
+
"status line are off this session. Reason: " + hookError + ". Tell the user " +
|
|
367
|
+
"in one line and carry on with their task; do not debug, reinstall or " +
|
|
368
|
+
"reconfigure tezgah mid-session (the user can check it with `" +
|
|
369
|
+
pythonBin() + " " + HOOK + "` or `tezgah-setup --report`).";
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function cwdOf(ctx: any): string {
|
|
373
|
+
return String(ctx?.cwd ?? process.cwd());
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function sessionOf(ctx: any): string | undefined {
|
|
377
|
+
try {
|
|
378
|
+
return ctx?.sessionManager?.getSessionId?.() ?? undefined;
|
|
379
|
+
} catch {
|
|
380
|
+
return undefined;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// A task subagent runs in its own session with the same extensions, so it gets
|
|
385
|
+
// session_start too. It must get the subagent brief, not the parent's payload:
|
|
386
|
+
// the parent's runs the indexer, regenerates the agents and tells the model to
|
|
387
|
+
// run plan-status, which a fan-out of subagents would each do again. omp writes
|
|
388
|
+
// the child's transcript inside the parent's session directory
|
|
389
|
+
// (`<parent>.jsonl` -> `<parent>/<AgentId>.jsonl`) with `parentSession` naming
|
|
390
|
+
// the parent in its header. A fork also carries `parentSession`, but its file
|
|
391
|
+
// sits beside the parent, not inside it, so it stays a main session.
|
|
392
|
+
function isSubagent(ctx: any): boolean {
|
|
393
|
+
try {
|
|
394
|
+
const sm = ctx?.sessionManager;
|
|
395
|
+
const file = String(sm?.getSessionFile?.() ?? "").replace(/\\/g, "/");
|
|
396
|
+
const parent = String(sm?.getHeader?.()?.parentSession ?? "")
|
|
397
|
+
.replace(/\\/g, "/");
|
|
398
|
+
if (!file || !parent) return false;
|
|
399
|
+
const root = parent.endsWith(".jsonl") ? parent.slice(0, -6) : parent;
|
|
400
|
+
return file.startsWith(root + "/");
|
|
401
|
+
} catch {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export default function tezgahOmp(pi: any): void {
|
|
407
|
+
// The idx glyph the last probed answer carried. omp redraws the line after
|
|
408
|
+
// every watched tool and the stamp probe behind that mark is the line's only
|
|
409
|
+
// subprocess, so the per-tool redraw sends the glyph back rather than forking
|
|
410
|
+
// git for a mark that cannot have moved within one turn. turn_end and the
|
|
411
|
+
// session switch still ask for the probe, so the mark is fresh at every turn
|
|
412
|
+
// boundary - where it is read.
|
|
413
|
+
let idxGlyph: string | undefined;
|
|
414
|
+
// The motion's state: the last line the hook drew, whether the agent is
|
|
415
|
+
// running, the tool in flight and when the run began. A frame repaints from
|
|
416
|
+
// these alone, so it forks nothing.
|
|
417
|
+
let line = "";
|
|
418
|
+
let tiers: Array<[string, number]> = [];
|
|
419
|
+
let busy = false;
|
|
420
|
+
let tool = "";
|
|
421
|
+
let since = 0;
|
|
422
|
+
let frame = 0;
|
|
423
|
+
let timer: any;
|
|
424
|
+
let timerCtx: any;
|
|
425
|
+
// One frame at the width the host hands the widget. A colored line leads with
|
|
426
|
+
// the logo, so the motion is the logo itself (restyle): the T's sheen sweeps
|
|
427
|
+
// while the agent runs, and the tool and its seconds sit right after it -
|
|
428
|
+
// dropped when they would leave the marks under 24 cells. A plain line keeps
|
|
429
|
+
// the braille spinner in front. The widest tier that fits takes the rest.
|
|
430
|
+
const sized = (width: number, light = false): string => {
|
|
431
|
+
const moving = busy && timer !== undefined;
|
|
432
|
+
const secs = (Date.now() - since) / 1000;
|
|
433
|
+
const logo = HEAD_LOGO.test(line);
|
|
434
|
+
let pre = !moving ? "" : logo ? activity(tool, secs)
|
|
435
|
+
: busyPrefix(frame, tool, secs, colorOn());
|
|
436
|
+
if (moving && width - cellsOf(pre) < 24) {
|
|
437
|
+
pre = logo ? "" : busyPrefix(frame, tool, 0, colorOn(), true);
|
|
438
|
+
}
|
|
439
|
+
const room = width - cellsOf(pre);
|
|
440
|
+
const draw = (cells: number): string => restyle(
|
|
441
|
+
tiers.length ? fit(tiers, cells) : cut(line, cells), moving ? frame : null, light);
|
|
442
|
+
const body = draw(room);
|
|
443
|
+
if (!logo) return pre + body;
|
|
444
|
+
// the logo, then the activity, then the rest of the tier
|
|
445
|
+
const head = logoFrame(moving ? frame : null, light);
|
|
446
|
+
if (!pre || !body.startsWith(head)) return body;
|
|
447
|
+
const join = (text: string): string =>
|
|
448
|
+
head + " " + pre + text.slice(head.length).replace(/^ /, "");
|
|
449
|
+
const out = join(body);
|
|
450
|
+
if (cellsOf(out) <= width) return out;
|
|
451
|
+
// The glue adds one cell when the tier does not already carry the separating
|
|
452
|
+
// space (the version-dropped tier starts with a dim " \u00b7 " chip instead),
|
|
453
|
+
// which showed up as a line one cell over its budget and omp truncating it.
|
|
454
|
+
// Redrawing one cell narrower keeps the promise `fit` makes and costs a second
|
|
455
|
+
// fit only in the case that used to overflow.
|
|
456
|
+
return join(draw(room - 1));
|
|
457
|
+
};
|
|
458
|
+
const paint = (ctx: any): void => {
|
|
459
|
+
if (hookError) return markBroken(ctx);
|
|
460
|
+
if (!line) return;
|
|
461
|
+
draw(ctx, line, sized);
|
|
462
|
+
};
|
|
463
|
+
const stopMotion = (): void => {
|
|
464
|
+
if (timer !== undefined) {
|
|
465
|
+
try {
|
|
466
|
+
if (typeof timerCtx?.clearTimer === "function") timerCtx.clearTimer(timer);
|
|
467
|
+
else clearInterval(timer);
|
|
468
|
+
} catch { /* a timer the host already cleared is gone either way */ }
|
|
469
|
+
}
|
|
470
|
+
timer = undefined;
|
|
471
|
+
timerCtx = undefined;
|
|
472
|
+
};
|
|
473
|
+
// Only the widget renders a frame as it is; the setStatus fallback strips
|
|
474
|
+
// ANSI and would redraw the host's own status bar ten times a second, so a
|
|
475
|
+
// build without the widget keeps the still line.
|
|
476
|
+
const startMotion = (ctx: any): void => {
|
|
477
|
+
if (timer !== undefined || !motionOn()) return;
|
|
478
|
+
if (typeof ctx?.ui?.setWidget !== "function") return;
|
|
479
|
+
const tick = (): void => {
|
|
480
|
+
try {
|
|
481
|
+
frame += 1;
|
|
482
|
+
paint(ctx);
|
|
483
|
+
} catch { /* a frame is cosmetic; the next one tries again */ }
|
|
484
|
+
};
|
|
485
|
+
try {
|
|
486
|
+
timerCtx = ctx;
|
|
487
|
+
timer = typeof ctx.setInterval === "function"
|
|
488
|
+
? ctx.setInterval(tick, FRAME_MS)
|
|
489
|
+
: setInterval(tick, FRAME_MS);
|
|
490
|
+
timer?.unref?.();
|
|
491
|
+
} catch {
|
|
492
|
+
timer = undefined;
|
|
493
|
+
timerCtx = undefined;
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
const show = (ctx: any, res: any): void => {
|
|
497
|
+
if (res.idx) idxGlyph = res.idx;
|
|
498
|
+
if (res.status) {
|
|
499
|
+
line = res.status;
|
|
500
|
+
tiers = Array.isArray(res.tiers) ? res.tiers : [];
|
|
501
|
+
paint(ctx);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
// A failed hook answers nothing, so the last good line would keep claiming a
|
|
505
|
+
// gate that is not running: the widget is repainted with the failure instead.
|
|
506
|
+
const refresh = (ctx: any): void => {
|
|
507
|
+
const res = ask({ event: "status", cwd: cwdOf(ctx), session_id: sessionOf(ctx) });
|
|
508
|
+
if (hookError) return markBroken(ctx);
|
|
509
|
+
show(ctx, res);
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
pi.on("agent_start", async (_event: any, ctx: any) => {
|
|
513
|
+
busy = true;
|
|
514
|
+
tool = "";
|
|
515
|
+
since = Date.now();
|
|
516
|
+
startMotion(ctx);
|
|
517
|
+
paint(ctx);
|
|
518
|
+
});
|
|
519
|
+
pi.on("tool_execution_start", async (event: any, ctx: any) => {
|
|
520
|
+
tool = String(event?.toolName ?? event?.name ?? "");
|
|
521
|
+
if (busy) paint(ctx);
|
|
522
|
+
});
|
|
523
|
+
pi.on("tool_execution_end", async (_event: any, ctx: any) => {
|
|
524
|
+
tool = "";
|
|
525
|
+
if (busy) paint(ctx);
|
|
526
|
+
});
|
|
527
|
+
// `isTerminal: false` means omp will resume the run (retry, compaction, a
|
|
528
|
+
// queued delivery), so the spinner keeps going; an absent field is terminal.
|
|
529
|
+
pi.on("agent_end", async (event: any, ctx: any) => {
|
|
530
|
+
if (event?.isTerminal === false) return;
|
|
531
|
+
busy = false;
|
|
532
|
+
tool = "";
|
|
533
|
+
stopMotion();
|
|
534
|
+
paint(ctx);
|
|
535
|
+
});
|
|
536
|
+
pi.on("session_shutdown", async () => {
|
|
537
|
+
busy = false;
|
|
538
|
+
stopMotion();
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
pi.on("session_start", async (_event: any, ctx: any) => {
|
|
542
|
+
const session = sessionOf(ctx);
|
|
543
|
+
const subagent = isSubagent(ctx);
|
|
544
|
+
// The judgement seam's own CLIs (tezgah-triage, tezgah-docs) record their
|
|
545
|
+
// row under TEZGAH_SESSION, and omp's shells inherit this process's env - so
|
|
546
|
+
// the main session exports its id once. A subagent shares the process and
|
|
547
|
+
// must not repoint its parent's shells at itself.
|
|
548
|
+
if (session && !subagent) process.env.TEZGAH_SESSION = String(session);
|
|
549
|
+
// A subagent's parent is the id the main session exported - the session a
|
|
550
|
+
// `tezgah-route` row was written under - and its agent is the file name omp
|
|
551
|
+
// gave the child (`<parent>/<AgentId>.jsonl`). The route report joins on them.
|
|
552
|
+
const link = subagent && process.env.TEZGAH_SESSION
|
|
553
|
+
? { parent: process.env.TEZGAH_SESSION,
|
|
554
|
+
agent: basename(String(ctx?.sessionManager?.getSessionFile?.() ?? ""), ".jsonl") }
|
|
555
|
+
: {};
|
|
556
|
+
const res = ask({ event: "session_start", cwd: cwdOf(ctx),
|
|
557
|
+
session_id: session, subagent, ...link });
|
|
558
|
+
if (hookError) {
|
|
559
|
+
const notice = failureNotice(ctx, session);
|
|
560
|
+
if (notice) {
|
|
561
|
+
try {
|
|
562
|
+
pi.sendMessage({ customType: "tezgah-hook-error", content: notice,
|
|
563
|
+
display: true, attribution: "agent" },
|
|
564
|
+
{ deliverAs: "nextTurn" });
|
|
565
|
+
} catch { /* the notice is best effort, the mark is already drawn */ }
|
|
566
|
+
}
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
if (res.status) show(ctx, res);
|
|
570
|
+
if (res.context) {
|
|
571
|
+
// omp's always-on RULES.md carries the contract itself; what rides here
|
|
572
|
+
// is this repo's state, so the model knows the index, the open plans and
|
|
573
|
+
// the lessons without the contract being paid twice.
|
|
574
|
+
pi.sendMessage({ customType: "tezgah-session", content: res.context,
|
|
575
|
+
display: false, attribution: "agent" },
|
|
576
|
+
{ deliverAs: "nextTurn" });
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
// omp emits session_compact once the summary has replaced the history, with
|
|
581
|
+
// the compaction entry (its `summary` is the text the model is given next).
|
|
582
|
+
// Unsubscribed, the live state - resume, plans, lessons, graph line - was lost
|
|
583
|
+
// at the first compaction (audit L-3, INT-06). The answer is the same
|
|
584
|
+
// `post_compact` block Claude and Codex build, sent on the channel
|
|
585
|
+
// session_start uses; the summary rides as `compact_summary` so the hook
|
|
586
|
+
// records the compaction row. A subagent is skipped: the post-compact block
|
|
587
|
+
// runs the indexer, which only the parent session may start.
|
|
588
|
+
pi.on("session_compact", async (event: any, ctx: any) => {
|
|
589
|
+
if (isSubagent(ctx)) return;
|
|
590
|
+
const summary = event?.compactionEntry?.summary;
|
|
591
|
+
const res = ask({ event: "post_compact", cwd: cwdOf(ctx), session_id: sessionOf(ctx),
|
|
592
|
+
compact_summary: typeof summary === "string" ? summary : undefined });
|
|
593
|
+
if (hookError || !res.context) return;
|
|
594
|
+
pi.sendMessage({ customType: "tezgah-session", content: res.context,
|
|
595
|
+
display: false, attribution: "agent" },
|
|
596
|
+
{ deliverAs: "nextTurn" });
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
// The notice as the message-capable events hand it back: before_agent_start
|
|
600
|
+
// returns it, session_start sends it.
|
|
601
|
+
const noticeMessage = (ctx: any, session: string | undefined): any => {
|
|
602
|
+
const notice = failureNotice(ctx, session);
|
|
603
|
+
return notice ? { message: { customType: "tezgah-hook-error", content: notice,
|
|
604
|
+
display: true, attribution: "agent" } } : undefined;
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
pi.on("session_switch", async (_event: any, ctx: any) => {
|
|
608
|
+
busy = false;
|
|
609
|
+
stopMotion();
|
|
610
|
+
refresh(ctx);
|
|
611
|
+
});
|
|
612
|
+
pi.on("turn_end", async (_event: any, ctx: any) => refresh(ctx));
|
|
613
|
+
|
|
614
|
+
pi.on("before_agent_start", async (event: any, ctx: any) => {
|
|
615
|
+
const session = sessionOf(ctx);
|
|
616
|
+
if (hookError) return noticeMessage(ctx, session);
|
|
617
|
+
// omp also fires this for a queued batch that carries no user text (the
|
|
618
|
+
// continuation it starts after the Stop rule blocks a turn, for one). The
|
|
619
|
+
// reminder is armed by a prompt, so a text-less batch must not pay for it
|
|
620
|
+
// again.
|
|
621
|
+
const prompt = String(event?.prompt ?? "").trim();
|
|
622
|
+
if (!prompt) return undefined;
|
|
623
|
+
const res = ask({ event: "user_prompt", cwd: cwdOf(ctx), prompt,
|
|
624
|
+
session_id: session });
|
|
625
|
+
if (hookError) return noticeMessage(ctx, session);
|
|
626
|
+
if (!res.context) return undefined;
|
|
627
|
+
// A hidden message, not a system-prompt rewrite: omp keeps per-request
|
|
628
|
+
// bytes out of the system prompt so an open-weight provider keeps its
|
|
629
|
+
// prefix cache, and the turn's reminder is exactly such a byte.
|
|
630
|
+
return { message: { customType: "tezgah-reminder", content: res.context,
|
|
631
|
+
display: false, attribution: "agent" } };
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
pi.on("tool_call", async (event: any, ctx: any) => {
|
|
635
|
+
const tool = String(event?.toolName ?? event?.name ?? "");
|
|
636
|
+
// An MCP tool is named per server (`mcp__<server>_<tool>`), so no exact
|
|
637
|
+
// list can hold it: an effect verb in the name reaches the gate, whose
|
|
638
|
+
// content rules read its payload (tezgah_integrity.mcp_class).
|
|
639
|
+
if (!GATED.includes(tool.toLowerCase()) && !MCP_EFFECT.test(tool)) {
|
|
640
|
+
return undefined;
|
|
641
|
+
}
|
|
642
|
+
const res = ask({ event: "pre_tool_use", cwd: cwdOf(ctx), tool,
|
|
643
|
+
input: event?.input ?? event?.args ?? {},
|
|
644
|
+
session_id: sessionOf(ctx) });
|
|
645
|
+
if (hookError) {
|
|
646
|
+
markBroken(ctx);
|
|
647
|
+
return undefined; // a hook that cannot answer cannot refuse either
|
|
648
|
+
}
|
|
649
|
+
if (res.deny) return { block: true, reason: res.deny };
|
|
650
|
+
return undefined;
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
pi.on("tool_result", async (event: any, ctx: any) => {
|
|
654
|
+
const tool = String(event?.toolName ?? "");
|
|
655
|
+
const args = event?.input ?? {};
|
|
656
|
+
if (!WATCHED.includes(tool.toLowerCase()) && !tool.startsWith("mcp__")
|
|
657
|
+
&& !skillRead(tool, args)) {
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
// Tri-state: an unread outcome must never be written as a passed check,
|
|
661
|
+
// because the Stop rule below reads this ledger as evidence.
|
|
662
|
+
const failed = typeof event?.isError === "boolean" ? event.isError : null;
|
|
663
|
+
// The evidence row asks one question about the result - is it non-zero - so
|
|
664
|
+
// the bridge sends a size and never the body: `ask()` serializes its payload
|
|
665
|
+
// onto the hook's stdin, which is exactly the copy the writer's rule bans. A
|
|
666
|
+
// string is its own length, a part list is its count, and anything else is
|
|
667
|
+
// left unstated rather than guessed - an absent field is not a field of 0.
|
|
668
|
+
// The one thing read from the body is the empty-run flag (`emptyRun`), and
|
|
669
|
+
// only the flag crosses: the body still never does.
|
|
670
|
+
const content = event?.content;
|
|
671
|
+
const resultLen = typeof content === "string" ? content.length
|
|
672
|
+
: Array.isArray(content) ? content.length : undefined;
|
|
673
|
+
const res = ask({ event: "post_tool_use", cwd: cwdOf(ctx), tool,
|
|
674
|
+
input: event?.input ?? {}, failed, idx: idxGlyph,
|
|
675
|
+
session_id: sessionOf(ctx), result_len: resultLen,
|
|
676
|
+
empty_run: emptyRun(content) || undefined });
|
|
677
|
+
if (hookError) return markBroken(ctx);
|
|
678
|
+
show(ctx, res);
|
|
679
|
+
// A result that came from outside the user and the workspace is labelled in
|
|
680
|
+
// place; every other result is left exactly as the host produced it.
|
|
681
|
+
if (res.label) {
|
|
682
|
+
const content = labelled(event?.content, res.label);
|
|
683
|
+
if (content) return { content };
|
|
684
|
+
}
|
|
685
|
+
return undefined;
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
pi.on("session_stop", async (event: any, ctx: any) => {
|
|
689
|
+
const res = ask({ event: "stop", cwd: cwdOf(ctx), session_id: sessionOf(ctx),
|
|
690
|
+
last_assistant_message: event?.last_assistant_message,
|
|
691
|
+
stop_hook_active: event?.stop_hook_active === true });
|
|
692
|
+
if (hookError) {
|
|
693
|
+
markBroken(ctx);
|
|
694
|
+
return undefined; // an unanswerable Stop rule must not block the turn
|
|
695
|
+
}
|
|
696
|
+
if (res.decision === "block" && res.reason) {
|
|
697
|
+
return { decision: "block", reason: res.reason };
|
|
698
|
+
}
|
|
699
|
+
return undefined;
|
|
700
|
+
});
|
|
701
|
+
}
|