xtrm-tools 0.5.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 +504 -0
- package/README.md +201 -0
- package/cli/dist/index.cjs +57378 -0
- package/cli/dist/index.cjs.map +1 -0
- package/cli/dist/index.d.cts +2 -0
- package/cli/package.json +47 -0
- package/config/.env.example +40 -0
- package/config/hooks.json +72 -0
- package/config/instructions/agents-top.md +30 -0
- package/config/instructions/claude-top.md +30 -0
- package/config/mcp_servers.json +57 -0
- package/config/mcp_servers_optional.json +53 -0
- package/config/pi/auth.json.template +14 -0
- package/config/pi/extensions/auto-session-name/index.ts +29 -0
- package/config/pi/extensions/auto-session-name/package.json +16 -0
- package/config/pi/extensions/auto-update/index.ts +71 -0
- package/config/pi/extensions/auto-update/package.json +16 -0
- package/config/pi/extensions/beads/index.ts +166 -0
- package/config/pi/extensions/beads/package.json +16 -0
- package/config/pi/extensions/bg-process/index.ts +230 -0
- package/config/pi/extensions/bg-process/package.json +16 -0
- package/config/pi/extensions/compact-header/index.ts +69 -0
- package/config/pi/extensions/compact-header/package.json +16 -0
- package/config/pi/extensions/core/adapter.ts +52 -0
- package/config/pi/extensions/core/guard-rules.ts +102 -0
- package/config/pi/extensions/core/lib.ts +3 -0
- package/config/pi/extensions/core/logger.ts +45 -0
- package/config/pi/extensions/core/runner.ts +71 -0
- package/config/pi/extensions/core/session-state.ts +59 -0
- package/config/pi/extensions/custom-footer/index.ts +160 -0
- package/config/pi/extensions/custom-footer/package.json +16 -0
- package/config/pi/extensions/custom-provider-qwen-cli/index.ts +363 -0
- package/config/pi/extensions/custom-provider-qwen-cli/package.json +1 -0
- package/config/pi/extensions/git-checkpoint/index.ts +53 -0
- package/config/pi/extensions/git-checkpoint/package.json +16 -0
- package/config/pi/extensions/minimal-mode/index.ts +201 -0
- package/config/pi/extensions/minimal-mode/package.json +16 -0
- package/config/pi/extensions/plan-mode/README.md +65 -0
- package/config/pi/extensions/plan-mode/index.ts +417 -0
- package/config/pi/extensions/plan-mode/package.json +12 -0
- package/config/pi/extensions/plan-mode/utils.ts +324 -0
- package/config/pi/extensions/quality-gates/index.ts +67 -0
- package/config/pi/extensions/quality-gates/package.json +16 -0
- package/config/pi/extensions/service-skills/index.ts +108 -0
- package/config/pi/extensions/service-skills/package.json +16 -0
- package/config/pi/extensions/session-flow/index.ts +131 -0
- package/config/pi/extensions/session-flow/package.json +16 -0
- package/config/pi/extensions/todo/index.ts +299 -0
- package/config/pi/extensions/todo/package.json +16 -0
- package/config/pi/extensions/xtrm-loader/index.ts +89 -0
- package/config/pi/extensions/xtrm-loader/package.json +16 -0
- package/config/pi/install-schema.json +44 -0
- package/config/pi/models.json.template +76 -0
- package/config/pi/pi-worktrees-settings.json +6 -0
- package/config/pi/settings.json.template +16 -0
- package/config/settings.json +70 -0
- package/hooks/README.md +75 -0
- package/hooks/agent_context.py +105 -0
- package/hooks/beads-claim-sync.mjs +166 -0
- package/hooks/beads-commit-gate.mjs +55 -0
- package/hooks/beads-compact-restore.mjs +69 -0
- package/hooks/beads-compact-save.mjs +51 -0
- package/hooks/beads-edit-gate.mjs +45 -0
- package/hooks/beads-gate-core.mjs +215 -0
- package/hooks/beads-gate-messages.mjs +87 -0
- package/hooks/beads-gate-utils.mjs +185 -0
- package/hooks/beads-memory-gate.mjs +61 -0
- package/hooks/beads-stop-gate.mjs +32 -0
- package/hooks/branch-state.mjs +39 -0
- package/hooks/gitnexus/gitnexus-hook.cjs +222 -0
- package/hooks/guard-rules.mjs +118 -0
- package/hooks/hooks.json +116 -0
- package/hooks/main-guard-post-push.mjs +71 -0
- package/hooks/main-guard.mjs +119 -0
- package/hooks/quality-check.cjs +1286 -0
- package/hooks/quality-check.py +345 -0
- package/hooks/serena-workflow-reminder.py +74 -0
- package/package.json +77 -0
- package/project-skills/quality-gates/.claude/hooks/hook-config.json +66 -0
- package/project-skills/quality-gates/.claude/hooks/quality-check.cjs +1286 -0
- package/project-skills/quality-gates/.claude/hooks/quality-check.py +334 -0
- package/project-skills/quality-gates/.claude/settings.json +3 -0
- package/project-skills/quality-gates/.claude/skills/using-quality-gates/SKILL.md +254 -0
- package/project-skills/quality-gates/README.md +109 -0
- package/project-skills/quality-gates/evals/evals.json +181 -0
- package/project-skills/quality-gates/workspace/iteration-1/FINAL-EVAL-SUMMARY.md +75 -0
- package/project-skills/quality-gates/workspace/iteration-1/edge-case-auto-fix-verification/with_skill/outputs/response.md +59 -0
- package/project-skills/quality-gates/workspace/iteration-1/edge-case-mixed-language-project/with_skill/outputs/response.md +60 -0
- package/project-skills/quality-gates/workspace/iteration-1/eval-summary.md +105 -0
- package/project-skills/quality-gates/workspace/iteration-1/partial-install-python-only/with_skill/outputs/response.md +93 -0
- package/project-skills/quality-gates/workspace/iteration-1/python-refactor-request/with_skill/outputs/response.md +104 -0
- package/project-skills/quality-gates/workspace/iteration-1/quality-gate-error-fix/with_skill/outputs/response.md +74 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-general-chat/with_skill/outputs/response.md +18 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-math-question/with_skill/outputs/response.md +18 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-unrelated-coding/with_skill/outputs/response.md +56 -0
- package/project-skills/quality-gates/workspace/iteration-1/tdd-guard-blocking-confusion/with_skill/outputs/response.md +67 -0
- package/project-skills/quality-gates/workspace/iteration-1/typescript-feature-with-tests/with_skill/outputs/response.md +97 -0
- package/project-skills/service-skills-set/.claude/git-hooks/doc_reminder.py +67 -0
- package/project-skills/service-skills-set/.claude/git-hooks/skill_staleness.py +194 -0
- package/project-skills/service-skills-set/.claude/service-registry.json +4 -0
- package/project-skills/service-skills-set/.claude/settings.json +37 -0
- package/project-skills/service-skills-set/.claude/skills/creating-service-skills/SKILL.md +433 -0
- package/project-skills/service-skills-set/.claude/skills/creating-service-skills/references/script_quality_standards.md +425 -0
- package/project-skills/service-skills-set/.claude/skills/creating-service-skills/references/service_skill_system_guide.md +278 -0
- package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/bootstrap.py +308 -0
- package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/deep_dive.py +304 -0
- package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/scaffolder.py +482 -0
- package/project-skills/service-skills-set/.claude/skills/scoping-service-skills/SKILL.md +231 -0
- package/project-skills/service-skills-set/.claude/skills/scoping-service-skills/scripts/scope.py +74 -0
- package/project-skills/service-skills-set/.claude/skills/updating-service-skills/SKILL.md +136 -0
- package/project-skills/service-skills-set/.claude/skills/updating-service-skills/scripts/drift_detector.py +222 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/SKILL.md +108 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/cataloger.py +74 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/skill_activator.py +152 -0
- package/project-skills/service-skills-set/README.md +93 -0
- package/project-skills/service-skills-set/install-service-skills.py +193 -0
- package/project-skills/service-skills-set/service-skills-readme.md +236 -0
- package/skills/README.txt +31 -0
- package/skills/clean-code/SKILL.md +201 -0
- package/skills/creating-service-skills/SKILL.md +433 -0
- package/skills/creating-service-skills/references/script_quality_standards.md +425 -0
- package/skills/creating-service-skills/references/service_skill_system_guide.md +278 -0
- package/skills/creating-service-skills/scripts/bootstrap.py +326 -0
- package/skills/creating-service-skills/scripts/deep_dive.py +304 -0
- package/skills/creating-service-skills/scripts/scaffolder.py +482 -0
- package/skills/delegating/SKILL.md +196 -0
- package/skills/delegating/config.yaml +210 -0
- package/skills/delegating/references/orchestration-protocols.md +41 -0
- package/skills/docker-expert/SKILL.md +409 -0
- package/skills/documenting/CHANGELOG.md +23 -0
- package/skills/documenting/README.md +148 -0
- package/skills/documenting/SKILL.md +113 -0
- package/skills/documenting/examples/example_pattern.md +70 -0
- package/skills/documenting/examples/example_reference.md +70 -0
- package/skills/documenting/examples/example_ssot_analytics.md +64 -0
- package/skills/documenting/examples/example_workflow.md +141 -0
- package/skills/documenting/references/changelog-format.md +97 -0
- package/skills/documenting/references/metadata-schema.md +136 -0
- package/skills/documenting/references/taxonomy.md +81 -0
- package/skills/documenting/references/versioning-rules.md +78 -0
- package/skills/documenting/scripts/bump_version.sh +60 -0
- package/skills/documenting/scripts/changelog/__init__.py +0 -0
- package/skills/documenting/scripts/changelog/add_entry.py +216 -0
- package/skills/documenting/scripts/changelog/bump_release.py +117 -0
- package/skills/documenting/scripts/changelog/init_changelog.py +54 -0
- package/skills/documenting/scripts/changelog/validate_changelog.py +128 -0
- package/skills/documenting/scripts/drift_detector.py +266 -0
- package/skills/documenting/scripts/generate_template.py +311 -0
- package/skills/documenting/scripts/list_by_category.sh +84 -0
- package/skills/documenting/scripts/orchestrator.py +255 -0
- package/skills/documenting/scripts/validate_metadata.py +242 -0
- package/skills/documenting/templates/CHANGELOG.md.template +13 -0
- package/skills/find-skills/SKILL.md +133 -0
- package/skills/gitnexus-debugging/SKILL.md +85 -0
- package/skills/gitnexus-exploring/SKILL.md +75 -0
- package/skills/gitnexus-impact-analysis/SKILL.md +94 -0
- package/skills/gitnexus-refactoring/SKILL.md +113 -0
- package/skills/hook-development/SKILL.md +797 -0
- package/skills/hook-development/examples/load-context.sh +55 -0
- package/skills/hook-development/examples/quality-check.js +1168 -0
- package/skills/hook-development/examples/validate-bash.sh +43 -0
- package/skills/hook-development/examples/validate-write.sh +38 -0
- package/skills/hook-development/references/advanced.md +527 -0
- package/skills/hook-development/references/migration.md +369 -0
- package/skills/hook-development/references/patterns.md +412 -0
- package/skills/hook-development/scripts/README.md +164 -0
- package/skills/hook-development/scripts/hook-linter.sh +153 -0
- package/skills/hook-development/scripts/test-hook.sh +252 -0
- package/skills/hook-development/scripts/validate-hook-schema.sh +159 -0
- package/skills/obsidian-cli/SKILL.md +106 -0
- package/skills/orchestrating-agents/SKILL.md +135 -0
- package/skills/orchestrating-agents/config.yaml +45 -0
- package/skills/orchestrating-agents/references/agent-context-integration.md +37 -0
- package/skills/orchestrating-agents/references/examples.md +45 -0
- package/skills/orchestrating-agents/references/handover-protocol.md +31 -0
- package/skills/orchestrating-agents/references/workflows.md +42 -0
- package/skills/orchestrating-agents/scripts/detect_neighbors.py +23 -0
- package/skills/prompt-improving/README.md +162 -0
- package/skills/prompt-improving/SKILL.md +74 -0
- package/skills/prompt-improving/references/analysis_commands.md +24 -0
- package/skills/prompt-improving/references/chain_of_thought.md +24 -0
- package/skills/prompt-improving/references/mcp_definitions.md +20 -0
- package/skills/prompt-improving/references/multishot.md +23 -0
- package/skills/prompt-improving/references/xml_core.md +60 -0
- package/skills/python-testing/SKILL.md +815 -0
- package/skills/scoping-service-skills/SKILL.md +231 -0
- package/skills/scoping-service-skills/scripts/scope.py +74 -0
- package/skills/senior-backend/SKILL.md +209 -0
- package/skills/senior-backend/references/api_design_patterns.md +103 -0
- package/skills/senior-backend/references/backend_security_practices.md +103 -0
- package/skills/senior-backend/references/database_optimization_guide.md +103 -0
- package/skills/senior-backend/scripts/api_load_tester.py +114 -0
- package/skills/senior-backend/scripts/api_scaffolder.py +114 -0
- package/skills/senior-backend/scripts/database_migration_tool.py +114 -0
- package/skills/senior-data-scientist/SKILL.md +226 -0
- package/skills/senior-data-scientist/references/experiment_design_frameworks.md +80 -0
- package/skills/senior-data-scientist/references/feature_engineering_patterns.md +80 -0
- package/skills/senior-data-scientist/references/statistical_methods_advanced.md +80 -0
- package/skills/senior-data-scientist/scripts/experiment_designer.py +100 -0
- package/skills/senior-data-scientist/scripts/feature_engineering_pipeline.py +100 -0
- package/skills/senior-data-scientist/scripts/model_evaluation_suite.py +100 -0
- package/skills/senior-devops/SKILL.md +209 -0
- package/skills/senior-devops/references/cicd_pipeline_guide.md +103 -0
- package/skills/senior-devops/references/deployment_strategies.md +103 -0
- package/skills/senior-devops/references/infrastructure_as_code.md +103 -0
- package/skills/senior-devops/scripts/deployment_manager.py +114 -0
- package/skills/senior-devops/scripts/pipeline_generator.py +114 -0
- package/skills/senior-devops/scripts/terraform_scaffolder.py +114 -0
- package/skills/senior-security/SKILL.md +209 -0
- package/skills/senior-security/references/cryptography_implementation.md +103 -0
- package/skills/senior-security/references/penetration_testing_guide.md +103 -0
- package/skills/senior-security/references/security_architecture_patterns.md +103 -0
- package/skills/senior-security/scripts/pentest_automator.py +114 -0
- package/skills/senior-security/scripts/security_auditor.py +114 -0
- package/skills/senior-security/scripts/threat_modeler.py +114 -0
- package/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skill-creator/SKILL.md +479 -0
- package/skills/skill-creator/agents/analyzer.md +274 -0
- package/skills/skill-creator/agents/comparator.md +202 -0
- package/skills/skill-creator/agents/grader.md +223 -0
- package/skills/skill-creator/assets/eval_review.html +146 -0
- package/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/skills/skill-creator/references/schemas.md +430 -0
- package/skills/skill-creator/scripts/__init__.py +0 -0
- package/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/skills/skill-creator/scripts/generate_report.py +326 -0
- package/skills/skill-creator/scripts/improve_description.py +248 -0
- package/skills/skill-creator/scripts/package_skill.py +136 -0
- package/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/skills/skill-creator/scripts/run_eval.py +310 -0
- package/skills/skill-creator/scripts/run_loop.py +332 -0
- package/skills/skill-creator/scripts/utils.py +47 -0
- package/skills/sync-docs/SKILL.md +132 -0
- package/skills/sync-docs/evals/evals.json +89 -0
- package/skills/sync-docs/references/doc-structure.md +99 -0
- package/skills/sync-docs/references/schema.md +103 -0
- package/skills/sync-docs/scripts/changelog/add_entry.py +216 -0
- package/skills/sync-docs/scripts/context_gatherer.py +240 -0
- package/skills/sync-docs/scripts/doc_structure_analyzer.py +495 -0
- package/skills/sync-docs/scripts/drift_detector.py +327 -0
- package/skills/sync-docs/scripts/validate_doc.py +365 -0
- package/skills/sync-docs/scripts/validate_metadata.py +185 -0
- package/skills/sync-docs-workspace/iteration-1/benchmark.json +293 -0
- package/skills/sync-docs-workspace/iteration-1/benchmark.md +13 -0
- package/skills/sync-docs-workspace/iteration-1/eval-doc-audit/eval_metadata.json +27 -0
- package/skills/sync-docs-workspace/iteration-1/eval-doc-audit/with_skill/outputs/result.md +210 -0
- package/skills/sync-docs-workspace/iteration-1/eval-doc-audit/with_skill/run-1/grading.json +28 -0
- package/skills/sync-docs-workspace/iteration-1/eval-doc-audit/with_skill/run-1/timing.json +1 -0
- package/skills/sync-docs-workspace/iteration-1/eval-doc-audit/without_skill/outputs/result.md +101 -0
- package/skills/sync-docs-workspace/iteration-1/eval-doc-audit/without_skill/run-1/grading.json +28 -0
- package/skills/sync-docs-workspace/iteration-1/eval-doc-audit/without_skill/run-1/timing.json +5 -0
- package/skills/sync-docs-workspace/iteration-1/eval-doc-audit/without_skill/timing.json +5 -0
- package/skills/sync-docs-workspace/iteration-1/eval-fix-mode/eval_metadata.json +27 -0
- package/skills/sync-docs-workspace/iteration-1/eval-fix-mode/with_skill/outputs/result.md +198 -0
- package/skills/sync-docs-workspace/iteration-1/eval-fix-mode/with_skill/run-1/grading.json +28 -0
- package/skills/sync-docs-workspace/iteration-1/eval-fix-mode/with_skill/run-1/timing.json +1 -0
- package/skills/sync-docs-workspace/iteration-1/eval-fix-mode/without_skill/outputs/result.md +94 -0
- package/skills/sync-docs-workspace/iteration-1/eval-fix-mode/without_skill/run-1/grading.json +28 -0
- package/skills/sync-docs-workspace/iteration-1/eval-fix-mode/without_skill/run-1/timing.json +1 -0
- package/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/eval_metadata.json +27 -0
- package/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/with_skill/outputs/result.md +237 -0
- package/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/with_skill/run-1/grading.json +28 -0
- package/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/with_skill/run-1/timing.json +1 -0
- package/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/without_skill/outputs/result.md +134 -0
- package/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/without_skill/run-1/grading.json +28 -0
- package/skills/sync-docs-workspace/iteration-1/eval-sprint-closeout/without_skill/run-1/timing.json +1 -0
- package/skills/sync-docs-workspace/iteration-2/benchmark.json +297 -0
- package/skills/sync-docs-workspace/iteration-2/benchmark.md +13 -0
- package/skills/sync-docs-workspace/iteration-2/eval-doc-audit/eval_metadata.json +27 -0
- package/skills/sync-docs-workspace/iteration-2/eval-doc-audit/with_skill/outputs/result.md +137 -0
- package/skills/sync-docs-workspace/iteration-2/eval-doc-audit/with_skill/run-1/grading.json +92 -0
- package/skills/sync-docs-workspace/iteration-2/eval-doc-audit/with_skill/run-1/timing.json +1 -0
- package/skills/sync-docs-workspace/iteration-2/eval-doc-audit/without_skill/outputs/result.md +134 -0
- package/skills/sync-docs-workspace/iteration-2/eval-doc-audit/without_skill/run-1/grading.json +86 -0
- package/skills/sync-docs-workspace/iteration-2/eval-doc-audit/without_skill/run-1/timing.json +1 -0
- package/skills/sync-docs-workspace/iteration-2/eval-fix-mode/eval_metadata.json +27 -0
- package/skills/sync-docs-workspace/iteration-2/eval-fix-mode/with_skill/outputs/result.md +193 -0
- package/skills/sync-docs-workspace/iteration-2/eval-fix-mode/with_skill/run-1/grading.json +72 -0
- package/skills/sync-docs-workspace/iteration-2/eval-fix-mode/with_skill/run-1/timing.json +1 -0
- package/skills/sync-docs-workspace/iteration-2/eval-fix-mode/without_skill/outputs/result.md +211 -0
- package/skills/sync-docs-workspace/iteration-2/eval-fix-mode/without_skill/run-1/grading.json +91 -0
- package/skills/sync-docs-workspace/iteration-2/eval-fix-mode/without_skill/run-1/timing.json +5 -0
- package/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/eval_metadata.json +27 -0
- package/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/with_skill/outputs/result.md +182 -0
- package/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/with_skill/run-1/grading.json +95 -0
- package/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/with_skill/run-1/timing.json +1 -0
- package/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/without_skill/outputs/result.md +222 -0
- package/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/without_skill/run-1/grading.json +88 -0
- package/skills/sync-docs-workspace/iteration-2/eval-sprint-closeout/without_skill/run-1/timing.json +5 -0
- package/skills/sync-docs-workspace/iteration-3/benchmark.json +298 -0
- package/skills/sync-docs-workspace/iteration-3/benchmark.md +13 -0
- package/skills/sync-docs-workspace/iteration-3/eval-doc-audit/eval_metadata.json +27 -0
- package/skills/sync-docs-workspace/iteration-3/eval-doc-audit/with_skill/outputs/result.md +125 -0
- package/skills/sync-docs-workspace/iteration-3/eval-doc-audit/with_skill/run-1/grading.json +97 -0
- package/skills/sync-docs-workspace/iteration-3/eval-doc-audit/with_skill/run-1/timing.json +5 -0
- package/skills/sync-docs-workspace/iteration-3/eval-doc-audit/without_skill/outputs/result.md +144 -0
- package/skills/sync-docs-workspace/iteration-3/eval-doc-audit/without_skill/run-1/grading.json +78 -0
- package/skills/sync-docs-workspace/iteration-3/eval-doc-audit/without_skill/run-1/timing.json +5 -0
- package/skills/sync-docs-workspace/iteration-3/eval-fix-mode/eval_metadata.json +27 -0
- package/skills/sync-docs-workspace/iteration-3/eval-fix-mode/with_skill/outputs/result.md +104 -0
- package/skills/sync-docs-workspace/iteration-3/eval-fix-mode/with_skill/run-1/grading.json +91 -0
- package/skills/sync-docs-workspace/iteration-3/eval-fix-mode/with_skill/run-1/timing.json +5 -0
- package/skills/sync-docs-workspace/iteration-3/eval-fix-mode/without_skill/outputs/result.md +79 -0
- package/skills/sync-docs-workspace/iteration-3/eval-fix-mode/without_skill/run-1/grading.json +82 -0
- package/skills/sync-docs-workspace/iteration-3/eval-fix-mode/without_skill/run-1/timing.json +5 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/eval_metadata.json +27 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase1_context.json +302 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase2_drift.txt +33 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase3_analysis.json +114 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase4_fix.txt +118 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/phase5_validate.txt +38 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/outputs/result.md +158 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/run-1/grading.json +95 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/with_skill/run-1/timing.json +5 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/without_skill/outputs/result.md +71 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/without_skill/run-1/grading.json +90 -0
- package/skills/sync-docs-workspace/iteration-3/eval-sprint-closeout/without_skill/run-1/timing.json +5 -0
- package/skills/test-planning/SKILL.md +208 -0
- package/skills/test-planning/evals/evals.json +23 -0
- package/skills/updating-service-skills/SKILL.md +136 -0
- package/skills/updating-service-skills/scripts/drift_detector.py +222 -0
- package/skills/using-TDD/SKILL.md +410 -0
- package/skills/using-quality-gates/SKILL.md +254 -0
- package/skills/using-serena-lsp/README.md +8 -0
- package/skills/using-serena-lsp/REFERENCE.md +194 -0
- package/skills/using-serena-lsp/SKILL.md +82 -0
- package/skills/using-service-skills/SKILL.md +108 -0
- package/skills/using-service-skills/scripts/cataloger.py +74 -0
- package/skills/using-service-skills/scripts/skill_activator.py +152 -0
- package/skills/using-service-skills/scripts/test_skill_activator.py +58 -0
- package/skills/using-xtrm/SKILL.md +245 -0
- package/skills/xt-end/SKILL.md +128 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* oh-pi Background Process Extension
|
|
3
|
+
*
|
|
4
|
+
* 任何 bash 命令超时未完成时,自动送到后台执行。
|
|
5
|
+
* 进程完成后自动通过 sendMessage 通知 LLM,无需轮询。
|
|
6
|
+
* 提供 bg_status 工具让 LLM 查看/停止后台进程。
|
|
7
|
+
*/
|
|
8
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
9
|
+
import { Type } from "@sinclair/typebox";
|
|
10
|
+
import { StringEnum } from "@mariozechner/pi-ai";
|
|
11
|
+
import { spawn, execSync } from "node:child_process";
|
|
12
|
+
import { writeFileSync, readFileSync, appendFileSync, existsSync } from "node:fs";
|
|
13
|
+
|
|
14
|
+
/** 超时阈值(毫秒),超过此时间自动后台化 */
|
|
15
|
+
const BG_TIMEOUT_MS = 10_000;
|
|
16
|
+
|
|
17
|
+
interface BgProcess {
|
|
18
|
+
pid: number;
|
|
19
|
+
command: string;
|
|
20
|
+
logFile: string;
|
|
21
|
+
startedAt: number;
|
|
22
|
+
finished: boolean;
|
|
23
|
+
exitCode: number | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function (pi: ExtensionAPI) {
|
|
27
|
+
const bgProcesses = new Map<number, BgProcess>();
|
|
28
|
+
|
|
29
|
+
// 覆盖内置 bash 工具
|
|
30
|
+
pi.registerTool({
|
|
31
|
+
name: "bash",
|
|
32
|
+
label: "Bash",
|
|
33
|
+
description: `Execute a bash command. Output is truncated to 2000 lines or 50KB. If a command runs longer than ${BG_TIMEOUT_MS / 1000}s, it is automatically backgrounded and you get the PID + log file path. Use the bg_status tool to check on backgrounded processes.`,
|
|
34
|
+
parameters: Type.Object({
|
|
35
|
+
command: Type.String({ description: "Bash command to execute" }),
|
|
36
|
+
timeout: Type.Optional(Type.Number({ description: "Timeout in seconds (optional)" })),
|
|
37
|
+
}),
|
|
38
|
+
async execute(toolCallId, params, signal) {
|
|
39
|
+
const { command } = params;
|
|
40
|
+
const userTimeout = params.timeout ? params.timeout * 1000 : undefined;
|
|
41
|
+
const effectiveTimeout = userTimeout ?? BG_TIMEOUT_MS;
|
|
42
|
+
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
let stdout = "";
|
|
45
|
+
let stderr = "";
|
|
46
|
+
let settled = false;
|
|
47
|
+
let backgrounded = false;
|
|
48
|
+
|
|
49
|
+
const child = spawn("bash", ["-c", command], {
|
|
50
|
+
cwd: process.cwd(),
|
|
51
|
+
env: { ...process.env },
|
|
52
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
child.stdout?.on("data", (d: Buffer) => {
|
|
56
|
+
const chunk = d.toString();
|
|
57
|
+
stdout += chunk;
|
|
58
|
+
// 后台化后追加写入日志
|
|
59
|
+
if (backgrounded) {
|
|
60
|
+
try { appendFileSync(bgProcesses.get(child.pid!)?.logFile ?? "", chunk); } catch {}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
child.stderr?.on("data", (d: Buffer) => {
|
|
64
|
+
const chunk = d.toString();
|
|
65
|
+
stderr += chunk;
|
|
66
|
+
if (backgrounded) {
|
|
67
|
+
try { appendFileSync(bgProcesses.get(child.pid!)?.logFile ?? "", chunk); } catch {}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// 超时处理:保持管道,标记为后台
|
|
72
|
+
const timer = setTimeout(() => {
|
|
73
|
+
if (settled) return;
|
|
74
|
+
settled = true;
|
|
75
|
+
backgrounded = true;
|
|
76
|
+
|
|
77
|
+
child.unref();
|
|
78
|
+
|
|
79
|
+
const logFile = `/tmp/oh-pi-bg-${Date.now()}.log`;
|
|
80
|
+
const pid = child.pid!;
|
|
81
|
+
|
|
82
|
+
// 把已有输出写入日志
|
|
83
|
+
writeFileSync(logFile, stdout + stderr);
|
|
84
|
+
|
|
85
|
+
const proc: BgProcess = { pid, command, logFile, startedAt: Date.now(), finished: false, exitCode: null };
|
|
86
|
+
bgProcesses.set(pid, proc);
|
|
87
|
+
|
|
88
|
+
// 监听完成事件,自动通知 LLM
|
|
89
|
+
child.on("close", (code) => {
|
|
90
|
+
proc.finished = true;
|
|
91
|
+
proc.exitCode = code;
|
|
92
|
+
const tail = (stdout + stderr).slice(-3000);
|
|
93
|
+
const truncated = (stdout + stderr).length > 3000 ? "[...truncated]\n" + tail : tail;
|
|
94
|
+
// 最终输出写入日志
|
|
95
|
+
try { writeFileSync(logFile, stdout + stderr); } catch {}
|
|
96
|
+
|
|
97
|
+
pi.sendMessage({
|
|
98
|
+
content: `[BG_PROCESS_DONE] PID ${pid} finished (exit ${code ?? "?"})\nCommand: ${command}\n\nOutput (last 3000 chars):\n${truncated}`,
|
|
99
|
+
display: true,
|
|
100
|
+
triggerTurn: true,
|
|
101
|
+
deliverAs: "followUp",
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const preview = (stdout + stderr).slice(0, 500);
|
|
106
|
+
const text = `Command still running after ${effectiveTimeout / 1000}s, moved to background.\nPID: ${pid}\nLog: ${logFile}\nStop: kill ${pid}\n\nOutput so far:\n${preview}\n\n⏳ You will be notified automatically when it finishes. No need to poll.`;
|
|
107
|
+
|
|
108
|
+
resolve({
|
|
109
|
+
content: [{ type: "text", text }],
|
|
110
|
+
details: {},
|
|
111
|
+
});
|
|
112
|
+
}, effectiveTimeout);
|
|
113
|
+
|
|
114
|
+
// 正常结束(超时前)
|
|
115
|
+
child.on("close", (code) => {
|
|
116
|
+
if (settled) return;
|
|
117
|
+
settled = true;
|
|
118
|
+
clearTimeout(timer);
|
|
119
|
+
|
|
120
|
+
const output = (stdout + stderr).trim();
|
|
121
|
+
const exitInfo = code !== 0 ? `\n[Exit code: ${code}]` : "";
|
|
122
|
+
|
|
123
|
+
resolve({
|
|
124
|
+
content: [{ type: "text", text: output + exitInfo }],
|
|
125
|
+
details: {},
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
child.on("error", (err) => {
|
|
130
|
+
if (settled) return;
|
|
131
|
+
settled = true;
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
|
|
134
|
+
resolve({
|
|
135
|
+
content: [{ type: "text", text: `Error: ${err.message}` }],
|
|
136
|
+
details: {},
|
|
137
|
+
isError: true,
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// 处理 abort signal
|
|
142
|
+
if (signal) {
|
|
143
|
+
signal.addEventListener("abort", () => {
|
|
144
|
+
if (settled) return;
|
|
145
|
+
settled = true;
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
try { child.kill(); } catch {}
|
|
148
|
+
resolve({
|
|
149
|
+
content: [{ type: "text", text: "Command cancelled." }],
|
|
150
|
+
details: {},
|
|
151
|
+
});
|
|
152
|
+
}, { once: true });
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// bg_status 工具:查看/管理后台进程
|
|
159
|
+
pi.registerTool({
|
|
160
|
+
name: "bg_status",
|
|
161
|
+
label: "Background Process Status",
|
|
162
|
+
description: "Check status, view output, or stop background processes that were auto-backgrounded.",
|
|
163
|
+
parameters: Type.Object({
|
|
164
|
+
action: StringEnum(["list", "log", "stop"] as const, { description: "list=show all, log=view output, stop=kill process" }),
|
|
165
|
+
pid: Type.Optional(Type.Number({ description: "PID of the process (required for log/stop)" })),
|
|
166
|
+
}),
|
|
167
|
+
async execute(toolCallId, params) {
|
|
168
|
+
const { action, pid } = params;
|
|
169
|
+
|
|
170
|
+
if (action === "list") {
|
|
171
|
+
if (bgProcesses.size === 0) {
|
|
172
|
+
return { content: [{ type: "text", text: "No background processes." }], details: {} };
|
|
173
|
+
}
|
|
174
|
+
const lines = [...bgProcesses.values()].map((p) => {
|
|
175
|
+
const status = p.finished ? `⚪ stopped (exit ${p.exitCode ?? "?"})` : (isAlive(p.pid) ? "🟢 running" : "⚪ stopped");
|
|
176
|
+
return `PID: ${p.pid} | ${status} | Log: ${p.logFile}\n Cmd: ${p.command}`;
|
|
177
|
+
});
|
|
178
|
+
return { content: [{ type: "text", text: lines.join("\n\n") }], details: {} };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (!pid) {
|
|
182
|
+
return { content: [{ type: "text", text: "Error: pid is required for log/stop" }], details: {}, isError: true };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const proc = bgProcesses.get(pid);
|
|
186
|
+
|
|
187
|
+
if (action === "log") {
|
|
188
|
+
const logFile = proc?.logFile;
|
|
189
|
+
if (logFile && existsSync(logFile)) {
|
|
190
|
+
try {
|
|
191
|
+
const content = readFileSync(logFile, "utf-8");
|
|
192
|
+
const tail = content.slice(-5000);
|
|
193
|
+
const truncated = content.length > 5000 ? `[...truncated, showing last 5000 chars]\n${tail}` : tail;
|
|
194
|
+
return { content: [{ type: "text", text: truncated || "(empty)" }], details: {} };
|
|
195
|
+
} catch (e: any) {
|
|
196
|
+
return { content: [{ type: "text", text: `Error reading log: ${e.message}` }], details: {}, isError: true };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return { content: [{ type: "text", text: "No log available for this PID." }], details: {} };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (action === "stop") {
|
|
203
|
+
try {
|
|
204
|
+
process.kill(pid, "SIGTERM");
|
|
205
|
+
bgProcesses.delete(pid);
|
|
206
|
+
return { content: [{ type: "text", text: `Process ${pid} terminated.` }], details: {} };
|
|
207
|
+
} catch {
|
|
208
|
+
bgProcesses.delete(pid);
|
|
209
|
+
return { content: [{ type: "text", text: `Process ${pid} not found (already stopped?).` }], details: {} };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return { content: [{ type: "text", text: `Unknown action: ${action}` }], details: {}, isError: true };
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// 清理:退出时杀掉所有后台进程
|
|
218
|
+
pi.on("session_shutdown", async () => {
|
|
219
|
+
for (const [pid, proc] of bgProcesses) {
|
|
220
|
+
if (!proc.finished) {
|
|
221
|
+
try { process.kill(pid, "SIGTERM"); } catch {}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
bgProcesses.clear();
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function isAlive(pid: number): boolean {
|
|
229
|
+
try { process.kill(pid, 0); return true; } catch { return false; }
|
|
230
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xtrm/pi-bg-process",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "xtrm Pi extension: bg-process",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.ts"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"pi",
|
|
11
|
+
"extension",
|
|
12
|
+
"xtrm"
|
|
13
|
+
],
|
|
14
|
+
"author": "xtrm",
|
|
15
|
+
"license": "MIT"
|
|
16
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* oh-pi Compact Header — table-style startup info with dynamic column widths
|
|
3
|
+
*/
|
|
4
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
5
|
+
import { VERSION } from "@mariozechner/pi-coding-agent";
|
|
6
|
+
import { truncateToWidth, visibleWidth } from "@mariozechner/pi-tui";
|
|
7
|
+
|
|
8
|
+
export default function (pi: ExtensionAPI) {
|
|
9
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
10
|
+
if (!ctx.hasUI) return;
|
|
11
|
+
|
|
12
|
+
ctx.ui.setHeader((_tui, theme) => ({
|
|
13
|
+
render(width: number): string[] {
|
|
14
|
+
const d = (s: string) => theme.fg("dim", s);
|
|
15
|
+
const a = (s: string) => theme.fg("accent", s);
|
|
16
|
+
|
|
17
|
+
const cmds = pi.getCommands();
|
|
18
|
+
const prompts = cmds.filter(c => c.source === "prompt").map(c => `/${c.name}`).join(" ");
|
|
19
|
+
const skills = cmds.filter(c => c.source === "skill").map(c => c.name).join(" ");
|
|
20
|
+
const model = ctx.model ? `${ctx.model.id}` : "no model";
|
|
21
|
+
const thinking = pi.getThinkingLevel();
|
|
22
|
+
const provider = ctx.model?.provider ?? "";
|
|
23
|
+
|
|
24
|
+
const pad = (s: string, w: number) => s + " ".repeat(Math.max(0, w - visibleWidth(s)));
|
|
25
|
+
const t = (s: string) => truncateToWidth(s, width);
|
|
26
|
+
const sep = d(" │ ");
|
|
27
|
+
|
|
28
|
+
// Right two columns are fixed width
|
|
29
|
+
const rCol = [
|
|
30
|
+
[d("esc"), a("interrupt"), d("S-tab"), a("thinking")],
|
|
31
|
+
[d("^C"), a("clear/exit"), d("^O"), a("expand")],
|
|
32
|
+
[d("^P"), a("model"), d("^G"), a("editor")],
|
|
33
|
+
[d("/"), a("commands"), d("^V"), a("paste")],
|
|
34
|
+
[d("!"), a("bash"), d(""), a("")],
|
|
35
|
+
];
|
|
36
|
+
const k1w = 6, v1w = 13, k2w = 6, v2w = 9;
|
|
37
|
+
const rightW = k1w + v1w + 3 + k2w + v2w + 3; // 3 for each sep
|
|
38
|
+
|
|
39
|
+
// Left column gets remaining space
|
|
40
|
+
const leftW = Math.max(20, width - rightW);
|
|
41
|
+
const lk = 9; // label width
|
|
42
|
+
|
|
43
|
+
const lCol = [
|
|
44
|
+
[d("version"), a(`v${VERSION} ${provider}`)],
|
|
45
|
+
[d("model"), a(model)],
|
|
46
|
+
[d("think"), a(thinking)],
|
|
47
|
+
[d(""), d("")],
|
|
48
|
+
[d(""), d("")],
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const lines: string[] = [""];
|
|
52
|
+
for (let i = 0; i < 5; i++) {
|
|
53
|
+
const [lk0, lv0] = lCol[i];
|
|
54
|
+
const [rk0, rv0, rk1, rv1] = rCol[i];
|
|
55
|
+
const left = truncateToWidth(pad(lk0, lk) + lv0, leftW);
|
|
56
|
+
const right = pad(rk0, k1w) + pad(rv0, v1w) + sep + pad(rk1, k2w) + rv1;
|
|
57
|
+
lines.push(t(pad(left, leftW) + sep + right));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (prompts) lines.push(t(`${pad(d("prompts"), lk)}${a(prompts)}`));
|
|
61
|
+
if (skills) lines.push(t(`${pad(d("skills"), lk)}${a(skills)}`));
|
|
62
|
+
lines.push(d("─".repeat(width)));
|
|
63
|
+
|
|
64
|
+
return lines;
|
|
65
|
+
},
|
|
66
|
+
invalidate() {},
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xtrm/pi-compact-header",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "xtrm Pi extension: compact-header",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.ts"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"pi",
|
|
11
|
+
"extension",
|
|
12
|
+
"xtrm"
|
|
13
|
+
],
|
|
14
|
+
"author": "xtrm",
|
|
15
|
+
"license": "MIT"
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as nodePath from "node:path";
|
|
3
|
+
|
|
4
|
+
import type { ExtensionAPI, ToolCallEvent } from "@mariozechner/pi-coding-agent";
|
|
5
|
+
import { PI_MUTATING_FILE_TOOLS } from "./guard-rules";
|
|
6
|
+
|
|
7
|
+
export class EventAdapter {
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the tool event is a mutating file operation (write, edit, etc).
|
|
10
|
+
*/
|
|
11
|
+
static isMutatingFileTool(event: ToolCallEvent<any, any>): boolean {
|
|
12
|
+
return PI_MUTATING_FILE_TOOLS.includes(event.toolName);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Extracts the target path from a tool input, resolving against the current working directory.
|
|
17
|
+
*/
|
|
18
|
+
static extractPathFromToolInput(event: ToolCallEvent<any, any>, cwd: string): string | null {
|
|
19
|
+
const input = event.input;
|
|
20
|
+
if (!input) return null;
|
|
21
|
+
|
|
22
|
+
const pathRaw = input.path || input.file || input.filePath;
|
|
23
|
+
if (typeof pathRaw === "string") {
|
|
24
|
+
return pathRaw; // Usually Pi passes absolute paths anyway or paths relative to root
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Safely formats a block reason string to ensure UI readiness.
|
|
32
|
+
*/
|
|
33
|
+
static formatBlockReason(prefix: string, details: string): string {
|
|
34
|
+
return `${prefix}: ${details}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns true if the given directory is a beads project (has a .beads directory).
|
|
38
|
+
*/
|
|
39
|
+
static isBeadsProject(cwd: string): boolean {
|
|
40
|
+
return fs.existsSync(nodePath.join(cwd, ".beads"));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Parses the summary line from `bd list` output.
|
|
45
|
+
* Returns { open, inProgress } or null if the line is absent.
|
|
46
|
+
*/
|
|
47
|
+
static parseBdCounts(output: string): { open: number; inProgress: number } | null {
|
|
48
|
+
const m = output.match(/Total:\s*\d+\s+issues?\s*\((\d+)\s+open,\s*(\d+)\s+in progress\)/);
|
|
49
|
+
if (!m) return null;
|
|
50
|
+
return { open: parseInt(m[1], 10), inProgress: parseInt(m[2], 10) };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Canonical guard-rule constants for Pi extensions.
|
|
2
|
+
// Mirrors hooks/guard-rules.mjs with Pi-specific tool naming where needed.
|
|
3
|
+
|
|
4
|
+
export const PI_MUTATING_FILE_TOOLS = [
|
|
5
|
+
"write",
|
|
6
|
+
"edit",
|
|
7
|
+
"replace_content",
|
|
8
|
+
"replace_lines",
|
|
9
|
+
"delete_lines",
|
|
10
|
+
"insert_at_line",
|
|
11
|
+
"create_text_file",
|
|
12
|
+
"rename_symbol",
|
|
13
|
+
"replace_symbol_body",
|
|
14
|
+
"insert_after_symbol",
|
|
15
|
+
"insert_before_symbol",
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
export const SAFE_BASH_PREFIXES = [
|
|
19
|
+
// Git read-only
|
|
20
|
+
"git status",
|
|
21
|
+
"git log",
|
|
22
|
+
"git diff",
|
|
23
|
+
"git show",
|
|
24
|
+
"git blame",
|
|
25
|
+
"git branch",
|
|
26
|
+
"git fetch",
|
|
27
|
+
"git remote",
|
|
28
|
+
"git config",
|
|
29
|
+
"git pull",
|
|
30
|
+
"git stash",
|
|
31
|
+
"git worktree",
|
|
32
|
+
"git checkout -b",
|
|
33
|
+
"git switch -c",
|
|
34
|
+
// Tools
|
|
35
|
+
"gh",
|
|
36
|
+
"bd",
|
|
37
|
+
"npx gitnexus",
|
|
38
|
+
"xtrm finish",
|
|
39
|
+
// Read-only filesystem
|
|
40
|
+
"cat",
|
|
41
|
+
"ls",
|
|
42
|
+
"head",
|
|
43
|
+
"tail",
|
|
44
|
+
"pwd",
|
|
45
|
+
"which",
|
|
46
|
+
"type",
|
|
47
|
+
"env",
|
|
48
|
+
"printenv",
|
|
49
|
+
"find",
|
|
50
|
+
"grep",
|
|
51
|
+
"rg",
|
|
52
|
+
"fd",
|
|
53
|
+
"wc",
|
|
54
|
+
"sort",
|
|
55
|
+
"uniq",
|
|
56
|
+
"cut",
|
|
57
|
+
"awk",
|
|
58
|
+
"jq",
|
|
59
|
+
"yq",
|
|
60
|
+
"bat",
|
|
61
|
+
"less",
|
|
62
|
+
"more",
|
|
63
|
+
"file",
|
|
64
|
+
"stat",
|
|
65
|
+
"du",
|
|
66
|
+
"tree",
|
|
67
|
+
// Allowed writes (specific paths)
|
|
68
|
+
"touch .beads/",
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
export const DANGEROUS_BASH_PATTERNS = [
|
|
72
|
+
"sed\\s+-i",
|
|
73
|
+
"echo\\s+[^\\n]*>",
|
|
74
|
+
"printf\\s+[^\\n]*>",
|
|
75
|
+
"cat\\s+[^\\n]*>",
|
|
76
|
+
"tee\\b",
|
|
77
|
+
"(?:^|\\s)(?:vim|nano|vi)\\b",
|
|
78
|
+
"(?:^|\\s)mv\\b",
|
|
79
|
+
"(?:^|\\s)cp\\b",
|
|
80
|
+
"(?:^|\\s)rm\\b",
|
|
81
|
+
"(?:^|\\s)mkdir\\b",
|
|
82
|
+
"(?:^|\\s)touch\\b",
|
|
83
|
+
"(?:^|\\s)chmod\\b",
|
|
84
|
+
"(?:^|\\s)chown\\b",
|
|
85
|
+
">>",
|
|
86
|
+
"(?:^|\\s)git\\s+add\\b",
|
|
87
|
+
"(?:^|\\s)git\\s+commit\\b",
|
|
88
|
+
"(?:^|\\s)git\\s+merge\\b",
|
|
89
|
+
"(?:^|\\s)git\\s+push\\b",
|
|
90
|
+
"(?:^|\\s)git\\s+reset\\b",
|
|
91
|
+
"(?:^|\\s)git\\s+checkout\\b",
|
|
92
|
+
"(?:^|\\s)git\\s+rebase\\b",
|
|
93
|
+
"(?:^|\\s)git\\s+stash\\b",
|
|
94
|
+
"(?:^|\\s)npm\\s+install\\b",
|
|
95
|
+
"(?:^|\\s)bun\\s+install\\b",
|
|
96
|
+
"(?:^|\\s)bun\\s+add\\b",
|
|
97
|
+
"(?:^|\\s)node\\s+(?:-e|--eval)\\b",
|
|
98
|
+
"(?:^|\\s)bun\\s+(?:-e|--eval)\\b",
|
|
99
|
+
"(?:^|\\s)python\\s+-c\\b",
|
|
100
|
+
"(?:^|\\s)perl\\s+-e\\b",
|
|
101
|
+
"(?:^|\\s)ruby\\s+-e\\b",
|
|
102
|
+
];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
2
|
+
|
|
3
|
+
export interface LoggerOptions {
|
|
4
|
+
namespace: string;
|
|
5
|
+
level?: LogLevel;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class Logger {
|
|
9
|
+
private namespace: string;
|
|
10
|
+
private level: LogLevel;
|
|
11
|
+
|
|
12
|
+
constructor(options: LoggerOptions) {
|
|
13
|
+
this.namespace = options.namespace;
|
|
14
|
+
this.level = options.level || "info";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private shouldLog(level: LogLevel): boolean {
|
|
18
|
+
const levels: LogLevel[] = ["debug", "info", "warn", "error"];
|
|
19
|
+
return levels.indexOf(level) >= levels.indexOf(this.level);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
debug(message: string, ...args: any[]) {
|
|
23
|
+
if (this.shouldLog("debug")) {
|
|
24
|
+
console.debug(`[${this.namespace}] DEBUG: ${message}`, ...args);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
info(message: string, ...args: any[]) {
|
|
29
|
+
if (this.shouldLog("info")) {
|
|
30
|
+
console.info(`[${this.namespace}] INFO: ${message}`, ...args);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
warn(message: string, ...args: any[]) {
|
|
35
|
+
if (this.shouldLog("warn")) {
|
|
36
|
+
console.warn(`[${this.namespace}] WARN: ${message}`, ...args);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
error(message: string, ...args: any[]) {
|
|
41
|
+
if (this.shouldLog("error")) {
|
|
42
|
+
console.error(`[${this.namespace}] ERROR: ${message}`, ...args);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { execFile, spawnSync } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
|
|
4
|
+
const execFileAsync = promisify(execFile);
|
|
5
|
+
|
|
6
|
+
export interface RunOptions {
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
env?: Record<string, string>;
|
|
10
|
+
input?: string; // Standard input
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface RunResult {
|
|
14
|
+
code: number;
|
|
15
|
+
stdout: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class SubprocessRunner {
|
|
20
|
+
/**
|
|
21
|
+
* Run a command deterministically with a timeout and optional stdin.
|
|
22
|
+
*/
|
|
23
|
+
static async run(
|
|
24
|
+
command: string,
|
|
25
|
+
args: string[],
|
|
26
|
+
options: RunOptions = {}
|
|
27
|
+
): Promise<RunResult> {
|
|
28
|
+
const timeout = options.timeoutMs ?? 10000;
|
|
29
|
+
const cwd = options.cwd ?? process.cwd();
|
|
30
|
+
const env = { ...process.env, ...options.env };
|
|
31
|
+
|
|
32
|
+
if (options.input !== undefined) {
|
|
33
|
+
// Use spawnSync for stdin support if input is provided
|
|
34
|
+
const result = spawnSync(command, args, {
|
|
35
|
+
cwd,
|
|
36
|
+
env,
|
|
37
|
+
input: options.input,
|
|
38
|
+
encoding: "utf8",
|
|
39
|
+
timeout,
|
|
40
|
+
maxBuffer: 1024 * 1024 * 10,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
code: result.status ?? 1,
|
|
45
|
+
stdout: (result.stdout ?? "").trim(),
|
|
46
|
+
stderr: (result.stderr ?? "").trim(),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const result = await execFileAsync(command, args, {
|
|
52
|
+
timeout,
|
|
53
|
+
cwd,
|
|
54
|
+
env,
|
|
55
|
+
maxBuffer: 1024 * 1024 * 10,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
code: 0,
|
|
60
|
+
stdout: result.stdout.trim(),
|
|
61
|
+
stderr: result.stderr.trim(),
|
|
62
|
+
};
|
|
63
|
+
} catch (error: any) {
|
|
64
|
+
return {
|
|
65
|
+
code: error.code ?? 1,
|
|
66
|
+
stdout: (error.stdout ?? "").trim(),
|
|
67
|
+
stderr: (error.stderr ?? error.message ?? "").trim(),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
|
|
4
|
+
export type SessionPhase =
|
|
5
|
+
| 'claimed'
|
|
6
|
+
| 'phase1-done'
|
|
7
|
+
| 'waiting-merge'
|
|
8
|
+
| 'conflicting'
|
|
9
|
+
| 'pending-cleanup'
|
|
10
|
+
| 'merged'
|
|
11
|
+
| 'cleanup-done';
|
|
12
|
+
|
|
13
|
+
export interface SessionState {
|
|
14
|
+
issueId: string;
|
|
15
|
+
branch: string;
|
|
16
|
+
worktreePath: string;
|
|
17
|
+
prNumber: number | null;
|
|
18
|
+
prUrl: string | null;
|
|
19
|
+
phase: SessionPhase;
|
|
20
|
+
conflictFiles: string[];
|
|
21
|
+
startedAt: string;
|
|
22
|
+
lastChecked: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const SESSION_STATE_FILE = '.xtrm-session-state.json';
|
|
26
|
+
|
|
27
|
+
export function findSessionStateFile(startCwd: string): string | null {
|
|
28
|
+
let current = path.resolve(startCwd || process.cwd());
|
|
29
|
+
for (;;) {
|
|
30
|
+
const candidate = path.join(current, SESSION_STATE_FILE);
|
|
31
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
32
|
+
const parent = path.dirname(current);
|
|
33
|
+
if (parent === current) return null;
|
|
34
|
+
current = parent;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function readSessionState(startCwd: string): SessionState | null {
|
|
39
|
+
const filePath = findSessionStateFile(startCwd);
|
|
40
|
+
if (!filePath) return null;
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
43
|
+
if (!parsed || typeof parsed !== 'object') return null;
|
|
44
|
+
if (!parsed.issueId || !parsed.branch || !parsed.worktreePath || !parsed.phase) return null;
|
|
45
|
+
return {
|
|
46
|
+
issueId: String(parsed.issueId),
|
|
47
|
+
branch: String(parsed.branch),
|
|
48
|
+
worktreePath: String(parsed.worktreePath),
|
|
49
|
+
prNumber: parsed.prNumber ?? null,
|
|
50
|
+
prUrl: parsed.prUrl ?? null,
|
|
51
|
+
phase: parsed.phase,
|
|
52
|
+
conflictFiles: Array.isArray(parsed.conflictFiles) ? parsed.conflictFiles.map(String) : [],
|
|
53
|
+
startedAt: String(parsed.startedAt || ''),
|
|
54
|
+
lastChecked: String(parsed.lastChecked || ''),
|
|
55
|
+
} as SessionState;
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|