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,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XTRM Custom Footer Extension
|
|
3
|
+
*
|
|
4
|
+
* Displays: XTRM brand, Model, Context%, CWD, Git branch, Beads chip
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
8
|
+
import { truncateToWidth } from "@mariozechner/pi-tui";
|
|
9
|
+
|
|
10
|
+
import { SubprocessRunner, EventAdapter } from "../core/lib";
|
|
11
|
+
|
|
12
|
+
export default function (pi: ExtensionAPI) {
|
|
13
|
+
interface BeadState {
|
|
14
|
+
claimId: string | null;
|
|
15
|
+
shortId: string | null;
|
|
16
|
+
status: string | null;
|
|
17
|
+
openCount: number;
|
|
18
|
+
lastFetch: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const STATUS_ICONS: Record<string, string> = {
|
|
22
|
+
open: "○",
|
|
23
|
+
in_progress: "◐",
|
|
24
|
+
blocked: "●",
|
|
25
|
+
closed: "✓",
|
|
26
|
+
};
|
|
27
|
+
// Chip background colours (raw ANSI — theme has no bg() API)
|
|
28
|
+
const CHIP_BG_NEUTRAL = "\x1b[48;5;238m"; // dark gray
|
|
29
|
+
const CHIP_BG_ACTIVE = "\x1b[48;5;39m"; // blue
|
|
30
|
+
const CHIP_BG_BLOCKED = "\x1b[48;5;88m"; // red
|
|
31
|
+
const CHIP_FG = "\x1b[38;5;15m"; // white
|
|
32
|
+
const CHIP_RESET = "\x1b[0m";
|
|
33
|
+
const chip = (text: string, bg = CHIP_BG_NEUTRAL): string =>
|
|
34
|
+
`${bg}${CHIP_FG} ${text} ${CHIP_RESET}`;
|
|
35
|
+
|
|
36
|
+
const STATUS_BG: Record<string, string> = {
|
|
37
|
+
open: CHIP_BG_NEUTRAL,
|
|
38
|
+
in_progress: CHIP_BG_ACTIVE,
|
|
39
|
+
blocked: CHIP_BG_BLOCKED,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
let capturedCtx: any = null;
|
|
43
|
+
let sessionId: string = "";
|
|
44
|
+
let beadState: BeadState = { claimId: null, shortId: null, status: null, openCount: 0, lastFetch: 0 };
|
|
45
|
+
let refreshing = false;
|
|
46
|
+
let requestRender: (() => void) | null = null;
|
|
47
|
+
const CACHE_TTL = 5000;
|
|
48
|
+
|
|
49
|
+
const getCwd = () => capturedCtx?.cwd || process.cwd();
|
|
50
|
+
const getShortId = (id: string) => id.split("-").pop() ?? id;
|
|
51
|
+
|
|
52
|
+
const refreshBeadState = async () => {
|
|
53
|
+
if (refreshing || Date.now() - beadState.lastFetch < CACHE_TTL) return;
|
|
54
|
+
const cwd = getCwd();
|
|
55
|
+
if (!EventAdapter.isBeadsProject(cwd)) return;
|
|
56
|
+
if (!sessionId) return;
|
|
57
|
+
refreshing = true;
|
|
58
|
+
try {
|
|
59
|
+
const claimResult = await SubprocessRunner.run("bd", ["kv", "get", `claimed:${sessionId}`], { cwd });
|
|
60
|
+
const claimId = claimResult.code === 0 ? claimResult.stdout.trim() || null : null;
|
|
61
|
+
|
|
62
|
+
let status: string | null = null;
|
|
63
|
+
if (claimId) {
|
|
64
|
+
const showResult = await SubprocessRunner.run("bd", ["show", claimId, "--json"], { cwd });
|
|
65
|
+
if (showResult.code === 0) {
|
|
66
|
+
try { status = JSON.parse(showResult.stdout)[0]?.status ?? null; } catch {}
|
|
67
|
+
}
|
|
68
|
+
if (status === "closed") {
|
|
69
|
+
await SubprocessRunner.run("bd", ["kv", "clear", `claimed:${sessionId}`], { cwd });
|
|
70
|
+
beadState = { claimId: null, shortId: null, status: null, openCount: beadState.openCount, lastFetch: Date.now() };
|
|
71
|
+
requestRender?.();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let openCount = 0;
|
|
77
|
+
const listResult = await SubprocessRunner.run("bd", ["list"], { cwd });
|
|
78
|
+
if (listResult.code === 0) {
|
|
79
|
+
const m = listResult.stdout.match(/\((\d+)\s+open/);
|
|
80
|
+
if (m) openCount = parseInt(m[1], 10);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
beadState = { claimId, shortId: claimId ? getShortId(claimId) : null, status, openCount, lastFetch: Date.now() };
|
|
84
|
+
requestRender?.();
|
|
85
|
+
} catch {}
|
|
86
|
+
finally { refreshing = false; }
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const buildBeadChip = (): string => {
|
|
90
|
+
const { claimId, shortId, status, openCount } = beadState;
|
|
91
|
+
if (claimId && shortId && status) {
|
|
92
|
+
const icon = STATUS_ICONS[status] ?? "?";
|
|
93
|
+
const bg = STATUS_BG[status] ?? CHIP_BG_NEUTRAL;
|
|
94
|
+
return chip(`bd:${shortId}${icon}`, bg);
|
|
95
|
+
}
|
|
96
|
+
if (openCount > 0) {
|
|
97
|
+
return chip(`bd:${openCount}${STATUS_ICONS.open}`);
|
|
98
|
+
}
|
|
99
|
+
return "";
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
103
|
+
capturedCtx = ctx;
|
|
104
|
+
// Get session ID from sessionManager/context (prefer UUID, consistent with hooks)
|
|
105
|
+
sessionId = ctx.sessionManager?.getSessionId?.() ?? ctx.sessionId ?? ctx.session_id ?? process.pid.toString();
|
|
106
|
+
|
|
107
|
+
ctx.ui.setFooter((tui, theme, footerData) => {
|
|
108
|
+
requestRender = () => tui.requestRender();
|
|
109
|
+
const unsub = footerData.onBranchChange(() => tui.requestRender());
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
dispose() { unsub(); requestRender = null; },
|
|
113
|
+
invalidate() {},
|
|
114
|
+
render(width: number): string[] {
|
|
115
|
+
refreshBeadState().catch(() => {});
|
|
116
|
+
|
|
117
|
+
const BOLD = "\x1b[1m", BOLD_OFF = "\x1b[22m";
|
|
118
|
+
const brand = `${BOLD}${theme.fg("accent", "XTRM")}${BOLD_OFF}`;
|
|
119
|
+
|
|
120
|
+
const usage = ctx.getContextUsage();
|
|
121
|
+
const pct = usage?.percent ?? 0;
|
|
122
|
+
const pctColor = pct > 75 ? "error" : pct > 50 ? "warning" : "success";
|
|
123
|
+
const usageStr = theme.fg(pctColor, `${pct.toFixed(0)}%`);
|
|
124
|
+
|
|
125
|
+
const parts = process.cwd().split("/");
|
|
126
|
+
const short = parts.length > 2 ? parts.slice(-2).join("/") : process.cwd();
|
|
127
|
+
const cwdStr = theme.fg("muted", `⌂ ${short}`);
|
|
128
|
+
|
|
129
|
+
const branch = footerData.getGitBranch();
|
|
130
|
+
const branchStr = branch ? theme.fg("accent", `⎇ ${branch}`) : "";
|
|
131
|
+
|
|
132
|
+
const modelId = ctx.model?.id || "no-model";
|
|
133
|
+
const modelChip = chip(modelId);
|
|
134
|
+
|
|
135
|
+
const sep = " ";
|
|
136
|
+
|
|
137
|
+
const brandModel = `${brand} ${modelChip}`;
|
|
138
|
+
const beadChip = buildBeadChip();
|
|
139
|
+
const leftParts = [brandModel, usageStr];
|
|
140
|
+
if (beadChip) leftParts.push(beadChip);
|
|
141
|
+
leftParts.push(cwdStr);
|
|
142
|
+
if (branchStr) leftParts.push(branchStr);
|
|
143
|
+
|
|
144
|
+
const left = leftParts.join(sep);
|
|
145
|
+
return [truncateToWidth(left, width)];
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Bust the bead cache immediately after any bd write
|
|
152
|
+
pi.on("tool_result", async (event: any) => {
|
|
153
|
+
const cmd = event?.input?.command;
|
|
154
|
+
if (cmd && /\bbd\s+(close|update|create|claim)\b/.test(cmd)) {
|
|
155
|
+
beadState.lastFetch = 0;
|
|
156
|
+
setTimeout(() => refreshBeadState().catch(() => {}), 200);
|
|
157
|
+
}
|
|
158
|
+
return undefined;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xtrm/pi-custom-footer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "xtrm Pi extension: custom-footer",
|
|
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,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qwen CLI Provider Extension
|
|
3
|
+
*
|
|
4
|
+
* Provides access to Qwen models via OAuth authentication with chat.qwen.ai.
|
|
5
|
+
* Uses device code flow with PKCE for secure browser-based authentication.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* pi -e ./packages/coding-agent/examples/extensions/custom-provider-qwen-cli
|
|
9
|
+
* # Then /login qwen-cli, or set QWEN_CLI_API_KEY=...
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "@mariozechner/pi-ai";
|
|
13
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
14
|
+
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// Constants
|
|
17
|
+
// =============================================================================
|
|
18
|
+
|
|
19
|
+
const QWEN_DEVICE_CODE_ENDPOINT = "https://chat.qwen.ai/api/v1/oauth2/device/code";
|
|
20
|
+
const QWEN_TOKEN_ENDPOINT = "https://chat.qwen.ai/api/v1/oauth2/token";
|
|
21
|
+
const QWEN_CLIENT_ID = "f0304373b74a44d2b584a3fb70ca9e56";
|
|
22
|
+
const QWEN_SCOPE = "openid profile email model.completion";
|
|
23
|
+
const QWEN_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
24
|
+
const QWEN_DEFAULT_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1";
|
|
25
|
+
const QWEN_POLL_INTERVAL_MS = 2000;
|
|
26
|
+
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// PKCE Helpers
|
|
29
|
+
// =============================================================================
|
|
30
|
+
|
|
31
|
+
async function generatePKCE(): Promise<{ verifier: string; challenge: string }> {
|
|
32
|
+
const array = new Uint8Array(32);
|
|
33
|
+
crypto.getRandomValues(array);
|
|
34
|
+
const verifier = btoa(String.fromCharCode(...array))
|
|
35
|
+
.replace(/\+/g, "-")
|
|
36
|
+
.replace(/\//g, "_")
|
|
37
|
+
.replace(/=+$/, "");
|
|
38
|
+
|
|
39
|
+
const encoder = new TextEncoder();
|
|
40
|
+
const data = encoder.encode(verifier);
|
|
41
|
+
const hash = await crypto.subtle.digest("SHA-256", data);
|
|
42
|
+
const challenge = btoa(String.fromCharCode(...new Uint8Array(hash)))
|
|
43
|
+
.replace(/\+/g, "-")
|
|
44
|
+
.replace(/\//g, "_")
|
|
45
|
+
.replace(/=+$/, "");
|
|
46
|
+
|
|
47
|
+
return { verifier, challenge };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// =============================================================================
|
|
51
|
+
// OAuth Implementation
|
|
52
|
+
// =============================================================================
|
|
53
|
+
|
|
54
|
+
interface DeviceCodeResponse {
|
|
55
|
+
device_code: string;
|
|
56
|
+
user_code: string;
|
|
57
|
+
verification_uri: string;
|
|
58
|
+
verification_uri_complete?: string;
|
|
59
|
+
expires_in: number;
|
|
60
|
+
interval?: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface TokenResponse {
|
|
64
|
+
access_token: string;
|
|
65
|
+
refresh_token?: string;
|
|
66
|
+
token_type: string;
|
|
67
|
+
expires_in: number;
|
|
68
|
+
resource_url?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function abortableSleep(ms: number, signal?: AbortSignal): Promise<void> {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
if (signal?.aborted) {
|
|
74
|
+
reject(new Error("Login cancelled"));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const timeout = setTimeout(resolve, ms);
|
|
78
|
+
signal?.addEventListener(
|
|
79
|
+
"abort",
|
|
80
|
+
() => {
|
|
81
|
+
clearTimeout(timeout);
|
|
82
|
+
reject(new Error("Login cancelled"));
|
|
83
|
+
},
|
|
84
|
+
{ once: true },
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function startDeviceFlow(): Promise<{ deviceCode: DeviceCodeResponse; verifier: string }> {
|
|
90
|
+
const { verifier, challenge } = await generatePKCE();
|
|
91
|
+
|
|
92
|
+
const body = new URLSearchParams({
|
|
93
|
+
client_id: QWEN_CLIENT_ID,
|
|
94
|
+
scope: QWEN_SCOPE,
|
|
95
|
+
code_challenge: challenge,
|
|
96
|
+
code_challenge_method: "S256",
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const headers: Record<string, string> = {
|
|
100
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
101
|
+
Accept: "application/json",
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const requestId = globalThis.crypto?.randomUUID?.();
|
|
105
|
+
if (requestId) headers["x-request-id"] = requestId;
|
|
106
|
+
|
|
107
|
+
const response = await fetch(QWEN_DEVICE_CODE_ENDPOINT, {
|
|
108
|
+
method: "POST",
|
|
109
|
+
headers,
|
|
110
|
+
body: body.toString(),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
const text = await response.text();
|
|
115
|
+
throw new Error(`Device code request failed: ${response.status} ${text}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const data = (await response.json()) as DeviceCodeResponse;
|
|
119
|
+
if (!data.device_code || !data.user_code || !data.verification_uri) {
|
|
120
|
+
throw new Error("Invalid device code response: missing required fields");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return { deviceCode: data, verifier };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function pollForToken(
|
|
127
|
+
deviceCode: string,
|
|
128
|
+
verifier: string,
|
|
129
|
+
intervalSeconds: number | undefined,
|
|
130
|
+
expiresIn: number,
|
|
131
|
+
signal?: AbortSignal,
|
|
132
|
+
): Promise<TokenResponse> {
|
|
133
|
+
const deadline = Date.now() + expiresIn * 1000;
|
|
134
|
+
const resolvedIntervalSeconds =
|
|
135
|
+
typeof intervalSeconds === "number" &&
|
|
136
|
+
Number.isFinite(intervalSeconds) &&
|
|
137
|
+
intervalSeconds > 0
|
|
138
|
+
? intervalSeconds
|
|
139
|
+
: QWEN_POLL_INTERVAL_MS / 1000;
|
|
140
|
+
let intervalMs = Math.max(1000, Math.floor(resolvedIntervalSeconds * 1000));
|
|
141
|
+
|
|
142
|
+
const handleTokenError = async (
|
|
143
|
+
error: string,
|
|
144
|
+
description?: string,
|
|
145
|
+
): Promise<boolean> => {
|
|
146
|
+
switch (error) {
|
|
147
|
+
case "authorization_pending":
|
|
148
|
+
await abortableSleep(intervalMs, signal);
|
|
149
|
+
return true;
|
|
150
|
+
case "slow_down":
|
|
151
|
+
intervalMs = Math.min(intervalMs + 5000, 10000);
|
|
152
|
+
await abortableSleep(intervalMs, signal);
|
|
153
|
+
return true;
|
|
154
|
+
case "expired_token":
|
|
155
|
+
throw new Error("Device code expired. Please restart authentication.");
|
|
156
|
+
case "access_denied":
|
|
157
|
+
throw new Error("Authorization denied by user.");
|
|
158
|
+
default:
|
|
159
|
+
throw new Error(`Token request failed: ${error} - ${description || ""}`);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
while (Date.now() < deadline) {
|
|
164
|
+
if (signal?.aborted) {
|
|
165
|
+
throw new Error("Login cancelled");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const body = new URLSearchParams({
|
|
169
|
+
grant_type: QWEN_GRANT_TYPE,
|
|
170
|
+
client_id: QWEN_CLIENT_ID,
|
|
171
|
+
device_code: deviceCode,
|
|
172
|
+
code_verifier: verifier,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const response = await fetch(QWEN_TOKEN_ENDPOINT, {
|
|
176
|
+
method: "POST",
|
|
177
|
+
headers: {
|
|
178
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
179
|
+
Accept: "application/json",
|
|
180
|
+
},
|
|
181
|
+
body: body.toString(),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const responseText = await response.text();
|
|
185
|
+
let data:
|
|
186
|
+
| (TokenResponse & { error?: string; error_description?: string })
|
|
187
|
+
| null = null;
|
|
188
|
+
|
|
189
|
+
if (responseText) {
|
|
190
|
+
try {
|
|
191
|
+
data = JSON.parse(responseText) as TokenResponse & {
|
|
192
|
+
error?: string;
|
|
193
|
+
error_description?: string;
|
|
194
|
+
};
|
|
195
|
+
} catch {
|
|
196
|
+
data = null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const error = data?.error;
|
|
201
|
+
const errorDescription = data?.error_description;
|
|
202
|
+
|
|
203
|
+
if (!response.ok) {
|
|
204
|
+
if (error && (await handleTokenError(error, errorDescription))) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
throw new Error(
|
|
208
|
+
`Token request failed: ${response.status} ${response.statusText}. Response: ${responseText}`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (data?.access_token) {
|
|
213
|
+
return data;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (error && (await handleTokenError(error, errorDescription))) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
throw new Error("Token request failed: missing access token in response");
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
throw new Error("Authentication timed out. Please try again.");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function loginQwen(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {
|
|
227
|
+
const { deviceCode, verifier } = await startDeviceFlow();
|
|
228
|
+
|
|
229
|
+
// Show verification URL and user code to user
|
|
230
|
+
const authUrl =
|
|
231
|
+
deviceCode.verification_uri_complete || deviceCode.verification_uri;
|
|
232
|
+
const instructions = deviceCode.verification_uri_complete
|
|
233
|
+
? undefined // Code is already embedded in the URL
|
|
234
|
+
: `Enter code: ${deviceCode.user_code}`;
|
|
235
|
+
|
|
236
|
+
callbacks.onAuth({ url: authUrl, instructions });
|
|
237
|
+
|
|
238
|
+
// Poll for token
|
|
239
|
+
const tokenResponse = await pollForToken(
|
|
240
|
+
deviceCode.device_code,
|
|
241
|
+
verifier,
|
|
242
|
+
deviceCode.interval,
|
|
243
|
+
deviceCode.expires_in,
|
|
244
|
+
callbacks.signal,
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
// Calculate expiry with 5-minute buffer
|
|
248
|
+
const expiresAt = Date.now() + tokenResponse.expires_in * 1000 - 5 * 60 * 1000;
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
refresh: tokenResponse.refresh_token || "",
|
|
252
|
+
access: tokenResponse.access_token,
|
|
253
|
+
expires: expiresAt,
|
|
254
|
+
// Store resource_url for API base URL if provided
|
|
255
|
+
enterpriseUrl: tokenResponse.resource_url,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async function refreshQwenToken(credentials: OAuthCredentials): Promise<OAuthCredentials> {
|
|
260
|
+
const body = new URLSearchParams({
|
|
261
|
+
grant_type: "refresh_token",
|
|
262
|
+
refresh_token: credentials.refresh,
|
|
263
|
+
client_id: QWEN_CLIENT_ID,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
const response = await fetch(QWEN_TOKEN_ENDPOINT, {
|
|
267
|
+
method: "POST",
|
|
268
|
+
headers: {
|
|
269
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
270
|
+
Accept: "application/json",
|
|
271
|
+
},
|
|
272
|
+
body: body.toString(),
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
if (!response.ok) {
|
|
276
|
+
const text = await response.text();
|
|
277
|
+
throw new Error(`Token refresh failed: ${response.status} ${text}`);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const data = (await response.json()) as TokenResponse;
|
|
281
|
+
if (!data.access_token) {
|
|
282
|
+
throw new Error("Token refresh failed: no access token in response");
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const expiresAt = Date.now() + data.expires_in * 1000 - 5 * 60 * 1000;
|
|
286
|
+
|
|
287
|
+
return {
|
|
288
|
+
refresh: data.refresh_token || credentials.refresh,
|
|
289
|
+
access: data.access_token,
|
|
290
|
+
expires: expiresAt,
|
|
291
|
+
enterpriseUrl: data.resource_url ?? credentials.enterpriseUrl,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function getQwenBaseUrl(resourceUrl?: string): string {
|
|
296
|
+
if (!resourceUrl) {
|
|
297
|
+
return QWEN_DEFAULT_BASE_URL;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
let url = resourceUrl.startsWith("http") ? resourceUrl : `https://${resourceUrl}`;
|
|
301
|
+
if (!url.endsWith("/v1")) {
|
|
302
|
+
url = `${url}/v1`;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return url;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// =============================================================================
|
|
309
|
+
// Extension Entry Point
|
|
310
|
+
// =============================================================================
|
|
311
|
+
|
|
312
|
+
export default function (pi: ExtensionAPI) {
|
|
313
|
+
pi.registerProvider("qwen-cli", {
|
|
314
|
+
baseUrl: QWEN_DEFAULT_BASE_URL,
|
|
315
|
+
apiKey: "QWEN_CLI_API_KEY",
|
|
316
|
+
api: "openai-completions",
|
|
317
|
+
models: [
|
|
318
|
+
{
|
|
319
|
+
id: "qwen3-coder-plus",
|
|
320
|
+
name: "Qwen3 Coder Plus",
|
|
321
|
+
reasoning: false,
|
|
322
|
+
input: ["text"],
|
|
323
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
324
|
+
contextWindow: 1000000,
|
|
325
|
+
maxTokens: 65536,
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
id: "qwen3-coder-flash",
|
|
329
|
+
name: "Qwen3 Coder Flash",
|
|
330
|
+
reasoning: false,
|
|
331
|
+
input: ["text"],
|
|
332
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
333
|
+
contextWindow: 1000000,
|
|
334
|
+
maxTokens: 65536,
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
id: "vision-model",
|
|
338
|
+
name: "Qwen3 VL Plus",
|
|
339
|
+
reasoning: true,
|
|
340
|
+
input: ["text", "image"],
|
|
341
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
342
|
+
contextWindow: 262144,
|
|
343
|
+
maxTokens: 32768,
|
|
344
|
+
compat: {
|
|
345
|
+
supportsDeveloperRole: false,
|
|
346
|
+
thinkingFormat: "qwen",
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
oauth: {
|
|
351
|
+
name: "Qwen CLI",
|
|
352
|
+
login: loginQwen,
|
|
353
|
+
refreshToken: refreshQwenToken,
|
|
354
|
+
getApiKey: (cred) => cred.access,
|
|
355
|
+
modifyModels: (models, cred) => {
|
|
356
|
+
const baseUrl = getQwenBaseUrl(cred.enterpriseUrl as string | undefined);
|
|
357
|
+
return models.map((m) =>
|
|
358
|
+
m.provider === "qwen-cli" ? { ...m, baseUrl } : m,
|
|
359
|
+
);
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "name": "pi-extension-custom-provider-qwen-cli", "private": true, "version": "1.7.1", "type": "module", "scripts": { "clean": "echo 'nothing to clean'", "build": "echo 'nothing to build'", "check": "echo 'nothing to check'" }, "pi": { "extensions": [ "./index.ts" ] } }
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Checkpoint Extension
|
|
3
|
+
*
|
|
4
|
+
* Creates git stash checkpoints at each turn so /fork can restore code state.
|
|
5
|
+
* When forking, offers to restore code to that point in history.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
9
|
+
|
|
10
|
+
export default function (pi: ExtensionAPI) {
|
|
11
|
+
const checkpoints = new Map<string, string>();
|
|
12
|
+
let currentEntryId: string | undefined;
|
|
13
|
+
|
|
14
|
+
// Track the current entry ID when user messages are saved
|
|
15
|
+
pi.on("tool_result", async (_event, ctx) => {
|
|
16
|
+
const leaf = ctx.sessionManager.getLeafEntry();
|
|
17
|
+
if (leaf) currentEntryId = leaf.id;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
pi.on("turn_start", async () => {
|
|
21
|
+
// Create a git stash entry before LLM makes changes
|
|
22
|
+
const { stdout } = await pi.exec("git", ["stash", "create"]);
|
|
23
|
+
const ref = stdout.trim();
|
|
24
|
+
if (ref && currentEntryId) {
|
|
25
|
+
checkpoints.set(currentEntryId, ref);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
pi.on("session_before_fork", async (event, ctx) => {
|
|
30
|
+
const ref = checkpoints.get(event.entryId);
|
|
31
|
+
if (!ref) return;
|
|
32
|
+
|
|
33
|
+
if (!ctx.hasUI) {
|
|
34
|
+
// In non-interactive mode, don't restore automatically
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const choice = await ctx.ui.select("Restore code state?", [
|
|
39
|
+
"Yes, restore code to that point",
|
|
40
|
+
"No, keep current code",
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
if (choice?.startsWith("Yes")) {
|
|
44
|
+
await pi.exec("git", ["stash", "apply", ref]);
|
|
45
|
+
ctx.ui.notify("Code restored to checkpoint", "info");
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
pi.on("agent_end", async () => {
|
|
50
|
+
// Clear checkpoints after agent completes
|
|
51
|
+
checkpoints.clear();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xtrm/pi-git-checkpoint",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "xtrm Pi extension: git-checkpoint",
|
|
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
|
+
}
|