agentic-flow-kit 1.8.7 → 2.1.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/LICENSE +2 -2
- package/README.md +172 -138
- package/bin/flow-kit.mjs +7 -2
- package/locales/en/installer.json +110 -0
- package/locales/en/overrides/.agents/commands/deploy.md +52 -0
- package/locales/en/overrides/.agents/commands/maintain.md +76 -0
- package/locales/en/overrides/.agents/commands/new-task.md +89 -0
- package/locales/en/overrides/.agents/commands/pipeline-run.md +56 -0
- package/locales/en/overrides/.agents/commands/pr-review.md +30 -0
- package/locales/en/overrides/.agents/commands/review.md +93 -0
- package/locales/en/overrides/.agents/commands/stages.md +256 -0
- package/locales/en/overrides/.agents/notes/pr-review-cost-discipline.md +48 -0
- package/locales/en/overrides/.agents/notes/process-order-rule.md +21 -0
- package/locales/en/overrides/.agents/notes/runtime-env.local.example.md +21 -0
- package/locales/en/overrides/.agents/pipelines/_TEMPLATE.md +75 -0
- package/locales/en/overrides/.agents/pipelines/pipeline-closing.md +28 -0
- package/locales/en/overrides/.agents/roles/implementer.md +28 -0
- package/locales/en/overrides/.agents/roles/independent-reviewer.md +39 -0
- package/locales/en/overrides/.agents/roles/pr-adjudicator.md +27 -0
- package/locales/en/overrides/.agents/roles/pr-finder.md +51 -0
- package/locales/en/overrides/.agents/roles/pr-verifier.md +44 -0
- package/locales/en/overrides/.agents/roles/ui-verifier.md +22 -0
- package/locales/en/overrides/.agents/roles/wiki-compiler.md +47 -0
- package/locales/en/overrides/.agents/skills/arena/SKILL.md +50 -0
- package/locales/en/overrides/.agents/skills/autonomous-run/SKILL.md +45 -0
- package/locales/en/overrides/.agents/skills/blast-radius/SKILL.md +53 -0
- package/locales/en/overrides/.agents/skills/csharp-quality-gates/SKILL.md +109 -0
- package/locales/en/overrides/.agents/skills/dev-tour/SKILL.md +98 -0
- package/locales/en/overrides/.agents/skills/dream/SKILL.md +63 -0
- package/locales/en/overrides/.agents/skills/eval/SKILL.md +42 -0
- package/locales/en/overrides/.agents/skills/interrogate/SKILL.md +49 -0
- package/locales/en/overrides/.agents/skills/number-vetting/SKILL.md +35 -0
- package/locales/en/overrides/.agents/skills/page-refactor/SKILL.md +192 -0
- package/locales/en/overrides/.agents/skills/papercut-fix/SKILL.md +92 -0
- package/locales/en/overrides/.agents/skills/pause-safely/SKILL.md +31 -0
- package/locales/en/overrides/.agents/skills/perf/SKILL.md +42 -0
- package/locales/en/overrides/.agents/skills/review-method/SKILL.md +92 -0
- package/locales/en/overrides/.agents/skills/session-resume/SKILL.md +69 -0
- package/locales/en/overrides/.agents/skills/shipyard-workflow-closeout/SKILL.md +109 -0
- package/locales/en/overrides/.agents/skills/show-me-your-work/SKILL.md +57 -0
- package/locales/en/overrides/.agents/skills/tfs-pr/SKILL.md +95 -0
- package/locales/en/overrides/.agents/skills/verify-ui/SKILL.md +116 -0
- package/locales/en/overrides/.agents/skills/visual-parity/SKILL.md +35 -0
- package/locales/en/overrides/.agents/skills/why/SKILL.md +56 -0
- package/locales/en/overrides/.agents/skills/wiki/SKILL.md +53 -0
- package/locales/en/overrides/.claude/agents/implementer.md +9 -0
- package/locales/en/overrides/.claude/agents/independent-reviewer.md +10 -0
- package/locales/en/overrides/.claude/agents/pr-adjudicator.md +10 -0
- package/locales/en/overrides/.claude/agents/pr-finder.md +10 -0
- package/locales/en/overrides/.claude/agents/pr-verifier.md +10 -0
- package/locales/en/overrides/.claude/agents/ui-verifier.md +10 -0
- package/locales/en/overrides/.claude/agents/wiki-compiler.md +10 -0
- package/locales/en/overrides/.claude/commands/wf-deploy.md +8 -0
- package/locales/en/overrides/.claude/commands/wf-maintain.md +8 -0
- package/locales/en/overrides/.claude/commands/wf-new-task.md +8 -0
- package/locales/en/overrides/.claude/commands/wf-pipeline-run.md +8 -0
- package/locales/en/overrides/.claude/commands/wf-pr-review.md +8 -0
- package/locales/en/overrides/.claude/commands/wf-review.md +8 -0
- package/locales/en/overrides/.claude/commands/wf-stages.md +8 -0
- package/locales/en/overrides/.cline/agents/implementer.yml +13 -0
- package/locales/en/overrides/.cline/agents/independent-reviewer.yml +11 -0
- package/locales/en/overrides/.cline/agents/pr-adjudicator.yml +11 -0
- package/locales/en/overrides/.cline/agents/pr-finder.yml +11 -0
- package/locales/en/overrides/.cline/agents/pr-verifier.yml +11 -0
- package/locales/en/overrides/.cline/agents/ui-verifier.yml +8 -0
- package/locales/en/overrides/.cline/agents/wiki-compiler.yml +14 -0
- package/locales/en/overrides/.cline/workflows/wf-deploy.md +8 -0
- package/locales/en/overrides/.cline/workflows/wf-maintain.md +8 -0
- package/locales/en/overrides/.cline/workflows/wf-new-task.md +8 -0
- package/locales/en/overrides/.cline/workflows/wf-pipeline-run.md +8 -0
- package/locales/en/overrides/.cline/workflows/wf-pr-review.md +8 -0
- package/locales/en/overrides/.cline/workflows/wf-review.md +8 -0
- package/locales/en/overrides/.cline/workflows/wf-stages.md +8 -0
- package/locales/en/overrides/.codebuddy/CODEBUDDY.md +7 -0
- package/locales/en/overrides/.codebuddy/agents/implementer.md +9 -0
- package/locales/en/overrides/.codebuddy/agents/independent-reviewer.md +10 -0
- package/locales/en/overrides/.codebuddy/agents/pr-adjudicator.md +10 -0
- package/locales/en/overrides/.codebuddy/agents/pr-finder.md +10 -0
- package/locales/en/overrides/.codebuddy/agents/pr-verifier.md +10 -0
- package/locales/en/overrides/.codebuddy/agents/ui-verifier.md +11 -0
- package/locales/en/overrides/.codebuddy/agents/wiki-compiler.md +10 -0
- package/locales/en/overrides/.codebuddy/commands/wf-deploy.md +8 -0
- package/locales/en/overrides/.codebuddy/commands/wf-maintain.md +8 -0
- package/locales/en/overrides/.codebuddy/commands/wf-new-task.md +8 -0
- package/locales/en/overrides/.codebuddy/commands/wf-pipeline-run.md +8 -0
- package/locales/en/overrides/.codebuddy/commands/wf-pr-review.md +8 -0
- package/locales/en/overrides/.codebuddy/commands/wf-review.md +8 -0
- package/locales/en/overrides/.codebuddy/commands/wf-stages.md +8 -0
- package/locales/en/overrides/.codebuddy/rules/backend-scope.md +5 -0
- package/locales/en/overrides/.codebuddy/rules/frontend-scope.md +5 -0
- package/locales/en/overrides/.codebuddy/skills/tfs-pr/SKILL.md +6 -0
- package/locales/en/overrides/.commandcode/agents/implementer.md +10 -0
- package/locales/en/overrides/.commandcode/agents/independent-reviewer.md +9 -0
- package/locales/en/overrides/.commandcode/agents/pr-adjudicator.md +9 -0
- package/locales/en/overrides/.commandcode/agents/pr-finder.md +9 -0
- package/locales/en/overrides/.commandcode/agents/pr-verifier.md +9 -0
- package/locales/en/overrides/.commandcode/agents/ui-verifier.md +10 -0
- package/locales/en/overrides/.commandcode/agents/wiki-compiler.md +10 -0
- package/locales/en/overrides/.commandcode/commands/wf-deploy.md +7 -0
- package/locales/en/overrides/.commandcode/commands/wf-maintain.md +7 -0
- package/locales/en/overrides/.commandcode/commands/wf-new-task.md +7 -0
- package/locales/en/overrides/.commandcode/commands/wf-pipeline-run.md +7 -0
- package/locales/en/overrides/.commandcode/commands/wf-pr-review.md +7 -0
- package/locales/en/overrides/.commandcode/commands/wf-review.md +7 -0
- package/locales/en/overrides/.commandcode/commands/wf-stages.md +7 -0
- package/locales/en/overrides/.opencode/agents/implementer.md +51 -0
- package/locales/en/overrides/.opencode/agents/independent-reviewer.md +18 -0
- package/locales/en/overrides/.opencode/agents/pr-adjudicator.md +18 -0
- package/locales/en/overrides/.opencode/agents/pr-finder.md +18 -0
- package/locales/en/overrides/.opencode/agents/pr-verifier.md +18 -0
- package/locales/en/overrides/.opencode/agents/ui-verifier.md +45 -0
- package/locales/en/overrides/.opencode/agents/wiki-compiler.md +51 -0
- package/locales/en/overrides/.opencode/commands/wf-deploy.md +7 -0
- package/locales/en/overrides/.opencode/commands/wf-maintain.md +7 -0
- package/locales/en/overrides/.opencode/commands/wf-new-task.md +7 -0
- package/locales/en/overrides/.opencode/commands/wf-pipeline-run.md +7 -0
- package/locales/en/overrides/.opencode/commands/wf-pr-review.md +7 -0
- package/locales/en/overrides/.opencode/commands/wf-review.md +7 -0
- package/locales/en/overrides/.opencode/commands/wf-stages.md +7 -0
- package/locales/en/overrides/.pi/agents/implementer.md +11 -0
- package/locales/en/overrides/.pi/agents/independent-reviewer.md +12 -0
- package/locales/en/overrides/.pi/agents/pr-adjudicator.md +12 -0
- package/locales/en/overrides/.pi/agents/pr-finder.md +11 -0
- package/locales/en/overrides/.pi/agents/pr-verifier.md +11 -0
- package/locales/en/overrides/.pi/agents/ui-verifier.md +11 -0
- package/locales/en/overrides/.pi/agents/wiki-compiler.md +11 -0
- package/locales/en/overrides/.qoder/agents/implementer.md +9 -0
- package/locales/en/overrides/.qoder/agents/independent-reviewer.md +10 -0
- package/locales/en/overrides/.qoder/agents/pr-adjudicator.md +10 -0
- package/locales/en/overrides/.qoder/agents/pr-finder.md +10 -0
- package/locales/en/overrides/.qoder/agents/pr-verifier.md +10 -0
- package/locales/en/overrides/.qoder/agents/ui-verifier.md +10 -0
- package/locales/en/overrides/.qoder/agents/wiki-compiler.md +10 -0
- package/locales/en/overrides/.qoder/commands/wf-deploy.md +8 -0
- package/locales/en/overrides/.qoder/commands/wf-maintain.md +8 -0
- package/locales/en/overrides/.qoder/commands/wf-new-task.md +8 -0
- package/locales/en/overrides/.qoder/commands/wf-pipeline-run.md +8 -0
- package/locales/en/overrides/.qoder/commands/wf-pr-review.md +8 -0
- package/locales/en/overrides/.qoder/commands/wf-review.md +8 -0
- package/locales/en/overrides/.qoder/commands/wf-stages.md +8 -0
- package/locales/en/overrides/.qwen/agents/implementer.md +10 -0
- package/locales/en/overrides/.qwen/agents/independent-reviewer.md +10 -0
- package/locales/en/overrides/.qwen/agents/pr-adjudicator.md +10 -0
- package/locales/en/overrides/.qwen/agents/pr-finder.md +10 -0
- package/locales/en/overrides/.qwen/agents/pr-verifier.md +10 -0
- package/locales/en/overrides/.qwen/agents/ui-verifier.md +10 -0
- package/locales/en/overrides/.qwen/agents/wiki-compiler.md +13 -0
- package/locales/en/overrides/.qwen/commands/wf-deploy.md +7 -0
- package/locales/en/overrides/.qwen/commands/wf-maintain.md +7 -0
- package/locales/en/overrides/.qwen/commands/wf-new-task.md +7 -0
- package/locales/en/overrides/.qwen/commands/wf-pipeline-run.md +7 -0
- package/locales/en/overrides/.qwen/commands/wf-pr-review.md +7 -0
- package/locales/en/overrides/.qwen/commands/wf-review.md +7 -0
- package/locales/en/overrides/.qwen/commands/wf-stages.md +7 -0
- package/locales/en/overrides/.trae/agents/implementer.md +9 -0
- package/locales/en/overrides/.trae/agents/independent-reviewer.md +10 -0
- package/locales/en/overrides/.trae/agents/pr-adjudicator.md +10 -0
- package/locales/en/overrides/.trae/agents/pr-finder.md +10 -0
- package/locales/en/overrides/.trae/agents/pr-verifier.md +10 -0
- package/locales/en/overrides/.trae/agents/ui-verifier.md +10 -0
- package/locales/en/overrides/.trae/agents/wiki-compiler.md +10 -0
- package/locales/en/overrides/.trae/commands/wf-deploy.md +8 -0
- package/locales/en/overrides/.trae/commands/wf-maintain.md +8 -0
- package/locales/en/overrides/.trae/commands/wf-new-task.md +8 -0
- package/locales/en/overrides/.trae/commands/wf-pipeline-run.md +8 -0
- package/locales/en/overrides/.trae/commands/wf-pr-review.md +8 -0
- package/locales/en/overrides/.trae/commands/wf-review.md +8 -0
- package/locales/en/overrides/.trae/commands/wf-stages.md +8 -0
- package/locales/en/overrides/.trae/rules/backend-scope.md +5 -0
- package/locales/en/overrides/.trae/rules/frontend-scope.md +5 -0
- package/locales/en/overrides/.zcode/agents/implementer.md +8 -0
- package/locales/en/overrides/.zcode/agents/independent-reviewer.md +8 -0
- package/locales/en/overrides/.zcode/agents/ui-verifier.md +8 -0
- package/locales/en/overrides/.zcode/agents/wiki-compiler.md +8 -0
- package/locales/en/overrides/AGENTS.md +52 -0
- package/locales/en/overrides/CLAUDE.md +20 -0
- package/locales/en/overrides/wiki/INDEX.md +33 -0
- package/locales/en/overrides/wiki/drafts-archive/README.md +6 -0
- package/locales/en/overrides/wiki//346/225/260/346/215/256/347/273/264/346/212/244/README.md +22 -0
- package/locales/en/overrides/wiki//347/237/245/350/257/206/346/262/211/346/267/200/346/200/273/350/247/210.html +230 -0
- package/locales/en/overrides/workflow/INDEX.md +13 -0
- package/locales/en/overrides/workflow/README.md +69 -0
- package/locales/en/overrides/workflow/archive/README.md +3 -0
- package/locales/en/overrides/workflow/delegations.md +4 -0
- package/locales/en/overrides/workflow/effective-policy.md +4 -0
- package/locales/en/overrides/workflow/gate-cost.md +4 -0
- package/locales/en/overrides/workflow/incidents/_TEMPLATE.md +49 -0
- package/locales/en/overrides/workflow/intents/_TEMPLATE.md +43 -0
- package/locales/en/overrides/workflow/metrics.md +4 -0
- package/locales/en/overrides/workflow/papercuts.md +3 -0
- package/locales/en/overrides/workflow/plans/_TEMPLATE.md +47 -0
- package/locales/en/overrides/workflow/regression-checklist.md +3 -0
- package/locales/en/overrides/workflow/specs/_TEMPLATE.md +86 -0
- package/locales/en/overrides/workflow/verify-evidence.md +4 -0
- package/locales/zh-CN/installer.json +110 -0
- package/package.json +23 -36
- package/schemas/install-manifest.schema.json +26 -0
- package/schemas/project-profile.schema.json +28 -0
- package/src/cli/args.mjs +43 -0
- package/src/cli/main.mjs +79 -0
- package/src/commands/add-host.mjs +29 -0
- package/src/commands/doctor.mjs +126 -0
- package/src/commands/install.mjs +296 -0
- package/src/commands/upgrade.mjs +30 -0
- package/src/git/config.mjs +61 -0
- package/src/hosts/registry.mjs +170 -0
- package/src/i18n.mjs +35 -0
- package/src/install/apply.mjs +138 -0
- package/src/install/frontmatter.mjs +84 -0
- package/src/install/manifest.mjs +40 -0
- package/src/install/plan.mjs +241 -0
- package/src/models/known.mjs +13 -0
- package/src/models/probe.mjs +163 -0
- package/src/models/resolve.mjs +312 -0
- package/src/render/tokens.mjs +105 -0
- package/src/tui/ansi.mjs +55 -0
- package/src/tui/flows.mjs +306 -0
- package/src/tui/prompts.mjs +139 -0
- package/src/tui/screen.mjs +217 -0
- package/src/tui/widgets.mjs +111 -0
- package/src/tui/wizard.mjs +68 -0
- package/templates/engine/.agents/board/dev-tour.html +1940 -0
- package/templates/engine/.agents/board/index.html +835 -0
- package/templates/engine/.agents/commands/deploy.md +52 -0
- package/templates/engine/.agents/commands/maintain.md +76 -0
- package/templates/engine/.agents/commands/new-task.md +89 -0
- package/templates/engine/.agents/commands/pipeline-run.md +60 -0
- package/templates/engine/.agents/commands/pr-review.md +30 -0
- package/templates/engine/.agents/commands/review.md +93 -0
- package/templates/engine/.agents/commands/stages.md +257 -0
- package/templates/engine/.agents/config/agent-eval.json +17 -0
- package/templates/engine/.agents/config/commit-msg-rules.json +7 -0
- package/templates/engine/.agents/config/engine.json +11 -0
- package/templates/engine/.agents/config/gate-budgets.json +5 -0
- package/templates/engine/.agents/config/mechanism-registry.md +63 -0
- package/templates/engine/.agents/config/memory-tiers.json +13 -0
- package/templates/engine/.agents/config/model-roles.json +26 -0
- package/templates/engine/.agents/config/model-roles.local.example.json +7 -0
- package/templates/engine/.agents/config/pipeline.json +36 -0
- package/templates/engine/.agents/config/pr-review.json +67 -0
- package/templates/engine/.agents/config/principles.md +32 -0
- package/templates/engine/.agents/config/steering.json +28 -0
- package/templates/engine/.agents/config/workflow-enums.txt +25 -0
- package/templates/engine/.agents/evals/README.md +49 -0
- package/templates/engine/.agents/evals/tasks.tsv +6 -0
- package/templates/engine/.agents/hooks/check-architecture.mjs +168 -0
- package/templates/engine/.agents/hooks/check-audit-fields.mjs +56 -0
- package/templates/engine/.agents/hooks/check-commit-plan-ref.mjs +84 -0
- package/templates/engine/.agents/hooks/check-confirm-order.mjs +281 -0
- package/templates/engine/.agents/hooks/check-delete-guard.mjs +63 -0
- package/templates/engine/.agents/hooks/check-notify-guard.mjs +55 -0
- package/templates/engine/.agents/hooks/commit-check.cjs +208 -0
- package/templates/engine/.agents/hooks/gates.json +33 -0
- package/templates/engine/.agents/hooks/local-pre-commit.mjs +27 -0
- package/templates/engine/.agents/hooks/pre-shell-check.cjs +361 -0
- package/templates/engine/.agents/hooks/pre-write-check.cjs +247 -0
- package/templates/engine/.agents/notes/gate-diet.md +75 -0
- package/templates/engine/.agents/notes/injected-memory.md +14 -0
- package/templates/engine/.agents/notes/pr-review-cost-discipline.md +48 -0
- package/templates/engine/.agents/notes/process-order-rule.md +21 -0
- package/templates/engine/.agents/notes/runtime-env.local.example.md +21 -0
- package/templates/engine/.agents/notes/steering-tiers.md +28 -0
- package/templates/engine/.agents/pipelines/_TEMPLATE.md +75 -0
- package/templates/engine/.agents/pipelines/pipeline-closing.md +28 -0
- package/templates/engine/.agents/pipelines//347/244/272/344/276/213-/345/271/266/350/241/214/345/256/236/347/216/260/350/257/204/345/256/241.md +16 -0
- package/templates/engine/.agents/roles/implementer.md +28 -0
- package/templates/engine/.agents/roles/independent-reviewer.md +39 -0
- package/templates/engine/.agents/roles/pr-adjudicator.md +27 -0
- package/templates/engine/.agents/roles/pr-finder.md +51 -0
- package/templates/engine/.agents/roles/pr-verifier.md +44 -0
- package/templates/engine/.agents/roles/ui-verifier.md +22 -0
- package/templates/engine/.agents/roles/wiki-compiler.md +47 -0
- package/templates/engine/.agents/scripts/agent-eval.mjs +268 -0
- package/templates/engine/.agents/scripts/agg-delegations.mjs +439 -0
- package/templates/engine/.agents/scripts/agg-judgments.mjs +301 -0
- package/templates/engine/.agents/scripts/agg-kb-usage.mjs +196 -0
- package/templates/engine/.agents/scripts/append-compensation.mjs +109 -0
- package/templates/engine/.agents/scripts/archive-sweep.mjs +229 -0
- package/templates/engine/.agents/scripts/auto-tour.mjs +77 -0
- package/templates/engine/.agents/scripts/board-port.mjs +17 -0
- package/templates/engine/.agents/scripts/check-doc-body-drift.mjs +102 -0
- package/templates/engine/.agents/scripts/check-engine-artifacts.mjs +54 -0
- package/templates/engine/.agents/scripts/check-hook-wiring.mjs +75 -0
- package/templates/engine/.agents/scripts/check-lane-surface.mjs +393 -0
- package/templates/engine/.agents/scripts/check-ledger-doc-presence.mjs +71 -0
- package/templates/engine/.agents/scripts/check-ledger-invariant.mjs +873 -0
- package/templates/engine/.agents/scripts/check-local-gate-config.mjs +95 -0
- package/templates/engine/.agents/scripts/check-local-gates.mjs +248 -0
- package/templates/engine/.agents/scripts/check-loop-kit.mjs +550 -0
- package/templates/engine/.agents/scripts/check-loop-rev-semantics.mjs +59 -0
- package/templates/engine/.agents/scripts/check-loop-sections/s01-pairing.mjs +116 -0
- package/templates/engine/.agents/scripts/check-loop-sections/s03x-regr-evidence.mjs +38 -0
- package/templates/engine/.agents/scripts/check-loop-sections/s08-acceptance.mjs +130 -0
- package/templates/engine/.agents/scripts/check-loop-sections/s15-fingerprint.mjs +152 -0
- package/templates/engine/.agents/scripts/check-loop-sections/s23-convergence-audit.mjs +182 -0
- package/templates/engine/.agents/scripts/check-loop-sections/s29-regr-enforcer.mjs +69 -0
- package/templates/engine/.agents/scripts/check-loop.mjs +131 -0
- package/templates/engine/.agents/scripts/check-pipeline-state.mjs +85 -0
- package/templates/engine/.agents/scripts/check-regression-consistency.mjs +252 -0
- package/templates/engine/.agents/scripts/check-schema-residue.mjs +144 -0
- package/templates/engine/.agents/scripts/check-scope-range.mjs +156 -0
- package/templates/engine/.agents/scripts/check-scope.mjs +121 -0
- package/templates/engine/.agents/scripts/check-scripts-syntax.mjs +138 -0
- package/templates/engine/.agents/scripts/check-secrets-lite.mjs +239 -0
- package/templates/engine/.agents/scripts/check-secrets.mjs +104 -0
- package/templates/engine/.agents/scripts/check-test-impact-map.mjs +107 -0
- package/templates/engine/.agents/scripts/ci-assert-frontend-deps.mjs +42 -0
- package/templates/engine/.agents/scripts/ci-commit-hygiene.mjs +86 -0
- package/templates/engine/.agents/scripts/ci-install-gitleaks.mjs +75 -0
- package/templates/engine/.agents/scripts/ci-push-before.mjs +49 -0
- package/templates/engine/.agents/scripts/claims.mjs +166 -0
- package/templates/engine/.agents/scripts/closeout.mjs +127 -0
- package/templates/engine/.agents/scripts/compact-ledgers.mjs +70 -0
- package/templates/engine/.agents/scripts/confirm-doc.mjs +737 -0
- package/templates/engine/.agents/scripts/delegation-presence.mjs +38 -0
- package/templates/engine/.agents/scripts/dev-tour-model.mjs +1398 -0
- package/templates/engine/.agents/scripts/dream-run.mjs +358 -0
- package/templates/engine/.agents/scripts/ensure-board.mjs +187 -0
- package/templates/engine/.agents/scripts/failure-attribution.mjs +11 -0
- package/templates/engine/.agents/scripts/fill-intent.mjs +60 -0
- package/templates/engine/.agents/scripts/fill-plan.mjs +105 -0
- package/templates/engine/.agents/scripts/fill-spec.mjs +72 -0
- package/templates/engine/.agents/scripts/fix-task.mjs +77 -0
- package/templates/engine/.agents/scripts/gen-dev-tour.mjs +191 -0
- package/templates/engine/.agents/scripts/gen-effective-policy.mjs +113 -0
- package/templates/engine/.agents/scripts/gen-engine-map.mjs +292 -0
- package/templates/engine/.agents/scripts/gen-narrative-claims.mjs +275 -0
- package/templates/engine/.agents/scripts/gen-verify-evidence.mjs +115 -0
- package/templates/engine/.agents/scripts/gen-wiki-board.mjs +221 -0
- package/templates/engine/.agents/scripts/gen-workflow-index.mjs +201 -0
- package/templates/engine/.agents/scripts/gen-workflow-metrics.mjs +692 -0
- package/templates/engine/.agents/scripts/git-merge-jsonl.mjs +62 -0
- package/templates/engine/.agents/scripts/judgment-ledger.mjs +68 -0
- package/templates/engine/.agents/scripts/kb-cache-evict.mjs +50 -0
- package/templates/engine/.agents/scripts/kb-search.mjs +423 -0
- package/templates/engine/.agents/scripts/lane-surface-audit.mjs +145 -0
- package/templates/engine/.agents/scripts/ledger-loader.mjs +77 -0
- package/templates/engine/.agents/scripts/ledger-shards.mjs +346 -0
- package/templates/engine/.agents/scripts/memory-tier.mjs +196 -0
- package/templates/engine/.agents/scripts/memory-wiki.mjs +296 -0
- package/templates/engine/.agents/scripts/metrics-core.mjs +131 -0
- package/templates/engine/.agents/scripts/outcome-metrics.mjs +195 -0
- package/templates/engine/.agents/scripts/path-lease.mjs +177 -0
- package/templates/engine/.agents/scripts/pipeline-run.mjs +964 -0
- package/templates/engine/.agents/scripts/policy.mjs +250 -0
- package/templates/engine/.agents/scripts/pr-create.mjs +54 -0
- package/templates/engine/.agents/scripts/pr-review.mjs +1551 -0
- package/templates/engine/.agents/scripts/quote-grounding.mjs +233 -0
- package/templates/engine/.agents/scripts/regen-ledgers.mjs +59 -0
- package/templates/engine/.agents/scripts/rewrite-file.mjs +135 -0
- package/templates/engine/.agents/scripts/rule-budget.mjs +246 -0
- package/templates/engine/.agents/scripts/session-log.mjs +157 -0
- package/templates/engine/.agents/scripts/stage-gates.mjs +812 -0
- package/templates/engine/.agents/scripts/steering.mjs +75 -0
- package/templates/engine/.agents/scripts/test-impact-lib.mjs +451 -0
- package/templates/engine/.agents/scripts/test-impact.mjs +105 -0
- package/templates/engine/.agents/scripts/trust-mode.mjs +130 -0
- package/templates/engine/.agents/scripts/verify-scope.mjs +163 -0
- package/templates/engine/.agents/scripts/verify-wiki-consistency.mjs +264 -0
- package/templates/engine/.agents/scripts/verify.mjs +858 -0
- package/templates/engine/.agents/scripts/warn-format.mjs +57 -0
- package/templates/engine/.agents/scripts/wf-journal.mjs +230 -0
- package/templates/engine/.agents/scripts/workflow-board-server.mjs +696 -0
- package/templates/engine/.agents/scripts/workflow-enums.mjs +70 -0
- package/templates/engine/.agents/scripts/workflows-check.mjs +260 -0
- package/templates/engine/.agents/settings.json +33 -0
- package/templates/engine/.agents/skills/arena/SKILL.md +54 -0
- package/templates/engine/.agents/skills/autonomous-run/SKILL.md +45 -0
- package/templates/engine/.agents/skills/blast-radius/SKILL.md +53 -0
- package/templates/engine/.agents/skills/csharp-quality-gates/SKILL.md +109 -0
- package/templates/engine/.agents/skills/csharp-quality-gates/scripts/quality-gates.mjs +430 -0
- package/templates/engine/.agents/skills/dev-tour/SKILL.md +98 -0
- package/templates/engine/.agents/skills/dream/SKILL.md +82 -0
- package/templates/engine/.agents/skills/eval/SKILL.md +58 -0
- package/templates/engine/.agents/skills/eval/scripts/eval-score.mjs +59 -0
- package/templates/engine/.agents/skills/interrogate/SKILL.md +49 -0
- package/templates/engine/.agents/skills/interrogate/scripts/interrogate-plan.mjs +72 -0
- package/templates/engine/.agents/skills/model-upgrade/SKILL.md +41 -0
- package/templates/engine/.agents/skills/number-vetting/SKILL.md +35 -0
- package/templates/engine/.agents/skills/page-refactor/SKILL.md +192 -0
- package/templates/engine/.agents/skills/page-refactor/references/templates.md +989 -0
- package/templates/engine/.agents/skills/papercut-fix/SKILL.md +92 -0
- package/templates/engine/.agents/skills/papercut-fix/references/response-template.md +81 -0
- package/templates/engine/.agents/skills/pause-safely/SKILL.md +31 -0
- package/templates/engine/.agents/skills/perf/SKILL.md +42 -0
- package/templates/engine/.agents/skills/review-method/SKILL.md +92 -0
- package/templates/engine/.agents/skills/review-method/golden-set.md +61 -0
- package/templates/engine/.agents/skills/session-resume/SKILL.md +76 -0
- package/templates/engine/.agents/skills/session-resume/scripts/worktree-audit.mjs +110 -0
- package/templates/engine/.agents/skills/shipyard-workflow-closeout/SKILL.md +109 -0
- package/templates/engine/.agents/skills/show-me-your-work/SKILL.md +71 -0
- package/templates/engine/.agents/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
- package/templates/engine/.agents/skills/show-me-your-work/scripts/decision-log.mjs +24 -0
- package/templates/engine/.agents/skills/tfs-pr/SKILL.md +95 -0
- package/templates/engine/.agents/skills/tfs-pr/scripts/tfs-pr.mjs +947 -0
- package/templates/engine/.agents/skills/verify-ui/SKILL.md +116 -0
- package/templates/engine/.agents/skills/verify-ui/features/.gitkeep +0 -0
- package/templates/engine/.agents/skills/verify-ui/scripts/gen-verify-feature.mjs +114 -0
- package/templates/engine/.agents/skills/visual-parity/SKILL.md +35 -0
- package/templates/engine/.agents/skills/why/SKILL.md +56 -0
- package/templates/engine/.agents/skills/why/scripts/why-evidence.mjs +74 -0
- package/templates/engine/.agents/skills/wiki/SKILL.md +56 -0
- package/templates/engine/.agents/tests/auto-tour.test.mjs +82 -0
- package/templates/engine/.agents/tests/dev-tour-model.test.mjs +452 -0
- package/templates/engine/.agents/tests/fill-plan-lite.test.mjs +46 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-bare-mid-path.md +14 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-bare-mid-path.model.json +179 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-fake-path-guard.md +21 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-fake-path-guard.model.json +194 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-h3-batches.md +20 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-h3-batches.model.json +207 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-issues.md +24 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-issues.model.json +225 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-l1-single-file.md +15 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-l1-single-file.model.json +160 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-layer-word-unique.md +29 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-layer-word-unique.model.json +266 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-layers-fallback.md +17 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-layers-fallback.model.json +207 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-numbered-steps.md +39 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-numbered-steps.model.json +359 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-path-guess.md +16 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-path-guess.model.json +131 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-table-rows.md +29 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-table-rows.model.json +190 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-task-checkboxes.md +39 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-task-checkboxes.model.json +362 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-union-label.md +24 -0
- package/templates/engine/.agents/tests/fixtures/dev-tour/plan-union-label.model.json +224 -0
- package/templates/engine/.agents/tests/tools/gen-synthetic-plan.mjs +108 -0
- package/templates/git/.gitattributes +23 -0
- package/templates/git/.githooks/commit-msg +72 -0
- package/templates/git/.githooks/package.json +3 -0
- package/templates/git/.githooks/post-commit +62 -0
- package/templates/git/.githooks/pre-commit +197 -0
- package/templates/git/.githooks/pre-merge-commit +28 -0
- package/templates/git/.githooks/pre-push +201 -0
- package/templates/git/.github/workflows/ci.yml +32 -0
- package/templates/git/.gitignore.engine +11 -0
- package/templates/git/azure-pipelines.yml +46 -0
- package/templates/host-meta/SKILLS.md +3 -0
- package/templates/host-meta/claude/skill-pointer.md +6 -0
- package/templates/host-meta/cline/skill-index.md +6 -0
- package/templates/host-meta/codebuddy/skill-pointer.md +6 -0
- package/templates/host-meta/commandcode/skill-index.md +5 -0
- package/templates/host-meta/opencode/skill-pointer.md +6 -0
- package/templates/host-meta/qoder/skill-index.md +5 -0
- package/templates/host-meta/qwen/skill-index.md +5 -0
- package/templates/host-meta/trae/skill-index.md +6 -0
- package/templates/hosts/claude/CLAUDE.md +55 -0
- package/templates/hosts/claude/agents/implementer.md +7 -0
- package/templates/hosts/claude/agents/independent-reviewer.md +8 -0
- package/templates/hosts/claude/agents/pr-adjudicator.md +8 -0
- package/templates/hosts/claude/agents/pr-finder.md +8 -0
- package/templates/hosts/claude/agents/pr-verifier.md +8 -0
- package/templates/hosts/claude/agents/ui-verifier.md +8 -0
- package/templates/hosts/claude/agents/wiki-compiler.md +8 -0
- package/templates/hosts/claude/commands/wf-deploy.md +10 -0
- package/templates/hosts/claude/commands/wf-maintain.md +10 -0
- package/templates/hosts/claude/commands/wf-new-task.md +10 -0
- package/templates/hosts/claude/commands/wf-pipeline-run.md +10 -0
- package/templates/hosts/claude/commands/wf-pr-review.md +10 -0
- package/templates/hosts/claude/commands/wf-review.md +10 -0
- package/templates/hosts/claude/commands/wf-stages.md +10 -0
- package/templates/hosts/claude/settings.hardened.json +94 -0
- package/templates/hosts/claude/settings.json +55 -0
- package/templates/hosts/cline/agents/implementer.yml +15 -0
- package/templates/hosts/cline/agents/independent-reviewer.yml +20 -0
- package/templates/hosts/cline/agents/pr-adjudicator.yml +18 -0
- package/templates/hosts/cline/agents/pr-finder.yml +19 -0
- package/templates/hosts/cline/agents/pr-verifier.yml +18 -0
- package/templates/hosts/cline/agents/ui-verifier.yml +17 -0
- package/templates/hosts/cline/agents/wiki-compiler.yml +20 -0
- package/templates/hosts/cline/hooks/PreToolUse.cjs +260 -0
- package/templates/hosts/cline/workflows/wf-deploy.md +8 -0
- package/templates/hosts/cline/workflows/wf-maintain.md +8 -0
- package/templates/hosts/cline/workflows/wf-new-task.md +8 -0
- package/templates/hosts/cline/workflows/wf-pipeline-run.md +8 -0
- package/templates/hosts/cline/workflows/wf-pr-review.md +8 -0
- package/templates/hosts/cline/workflows/wf-review.md +8 -0
- package/templates/hosts/cline/workflows/wf-stages.md +8 -0
- package/templates/hosts/codebuddy/CODEBUDDY.md +7 -0
- package/templates/hosts/codebuddy/agents/implementer.md +9 -0
- package/templates/hosts/codebuddy/agents/independent-reviewer.md +10 -0
- package/templates/hosts/codebuddy/agents/pr-adjudicator.md +10 -0
- package/templates/hosts/codebuddy/agents/pr-finder.md +10 -0
- package/templates/hosts/codebuddy/agents/pr-verifier.md +10 -0
- package/templates/hosts/codebuddy/agents/ui-verifier.md +11 -0
- package/templates/hosts/codebuddy/agents/wiki-compiler.md +10 -0
- package/templates/hosts/codebuddy/commands/wf-deploy.md +10 -0
- package/templates/hosts/codebuddy/commands/wf-maintain.md +10 -0
- package/templates/hosts/codebuddy/commands/wf-new-task.md +10 -0
- package/templates/hosts/codebuddy/commands/wf-pipeline-run.md +10 -0
- package/templates/hosts/codebuddy/commands/wf-pr-review.md +10 -0
- package/templates/hosts/codebuddy/commands/wf-review.md +10 -0
- package/templates/hosts/codebuddy/commands/wf-stages.md +10 -0
- package/templates/hosts/codebuddy/rules/backend-scope.md +5 -0
- package/templates/hosts/codebuddy/rules/frontend-scope.md +5 -0
- package/templates/hosts/codebuddy/settings.json +31 -0
- package/templates/hosts/codebuddy/skills/tfs-pr/SKILL.md +6 -0
- package/templates/hosts/commandcode/agents/implementer.md +10 -0
- package/templates/hosts/commandcode/agents/independent-reviewer.md +9 -0
- package/templates/hosts/commandcode/agents/pr-adjudicator.md +9 -0
- package/templates/hosts/commandcode/agents/pr-finder.md +9 -0
- package/templates/hosts/commandcode/agents/pr-verifier.md +9 -0
- package/templates/hosts/commandcode/agents/ui-verifier.md +11 -0
- package/templates/hosts/commandcode/agents/wiki-compiler.md +10 -0
- package/templates/hosts/commandcode/commands/wf-deploy.md +9 -0
- package/templates/hosts/commandcode/commands/wf-maintain.md +9 -0
- package/templates/hosts/commandcode/commands/wf-new-task.md +9 -0
- package/templates/hosts/commandcode/commands/wf-pipeline-run.md +9 -0
- package/templates/hosts/commandcode/commands/wf-pr-review.md +9 -0
- package/templates/hosts/commandcode/commands/wf-review.md +9 -0
- package/templates/hosts/commandcode/commands/wf-stages.md +9 -0
- package/templates/hosts/commandcode/settings.json +57 -0
- package/templates/hosts/opencode/agents/implementer.md +51 -0
- package/templates/hosts/opencode/agents/independent-reviewer.md +18 -0
- package/templates/hosts/opencode/agents/pr-adjudicator.md +18 -0
- package/templates/hosts/opencode/agents/pr-finder.md +18 -0
- package/templates/hosts/opencode/agents/pr-verifier.md +18 -0
- package/templates/hosts/opencode/agents/ui-verifier.md +45 -0
- package/templates/hosts/opencode/agents/wiki-compiler.md +51 -0
- package/templates/hosts/opencode/commands/wf-deploy.md +7 -0
- package/templates/hosts/opencode/commands/wf-maintain.md +7 -0
- package/templates/hosts/opencode/commands/wf-new-task.md +7 -0
- package/templates/hosts/opencode/commands/wf-pipeline-run.md +7 -0
- package/templates/hosts/opencode/commands/wf-pr-review.md +7 -0
- package/templates/hosts/opencode/commands/wf-review.md +7 -0
- package/templates/hosts/opencode/commands/wf-stages.md +7 -0
- package/templates/hosts/pi/agents/implementer.md +10 -0
- package/templates/hosts/pi/agents/independent-reviewer.md +11 -0
- package/templates/hosts/pi/agents/pr-adjudicator.md +11 -0
- package/templates/hosts/pi/agents/pr-finder.md +10 -0
- package/templates/hosts/pi/agents/pr-verifier.md +10 -0
- package/templates/hosts/pi/agents/ui-verifier.md +10 -0
- package/templates/hosts/pi/agents/wiki-compiler.md +10 -0
- package/templates/hosts/pi/extensions/lib/gates-core.cjs +196 -0
- package/templates/hosts/pi/extensions/shipyard-gates.ts +95 -0
- package/templates/hosts/pi/settings.json +5 -0
- package/templates/hosts/qoder/agents/implementer.md +9 -0
- package/templates/hosts/qoder/agents/independent-reviewer.md +10 -0
- package/templates/hosts/qoder/agents/pr-adjudicator.md +10 -0
- package/templates/hosts/qoder/agents/pr-finder.md +10 -0
- package/templates/hosts/qoder/agents/pr-verifier.md +10 -0
- package/templates/hosts/qoder/agents/ui-verifier.md +10 -0
- package/templates/hosts/qoder/agents/wiki-compiler.md +10 -0
- package/templates/hosts/qoder/commands/wf-deploy.md +8 -0
- package/templates/hosts/qoder/commands/wf-maintain.md +8 -0
- package/templates/hosts/qoder/commands/wf-new-task.md +8 -0
- package/templates/hosts/qoder/commands/wf-pipeline-run.md +8 -0
- package/templates/hosts/qoder/commands/wf-pr-review.md +8 -0
- package/templates/hosts/qoder/commands/wf-review.md +8 -0
- package/templates/hosts/qoder/commands/wf-stages.md +8 -0
- package/templates/hosts/qoder/settings.json +61 -0
- package/templates/hosts/qwen/agents/implementer.md +8 -0
- package/templates/hosts/qwen/agents/independent-reviewer.md +8 -0
- package/templates/hosts/qwen/agents/pr-adjudicator.md +8 -0
- package/templates/hosts/qwen/agents/pr-finder.md +8 -0
- package/templates/hosts/qwen/agents/pr-verifier.md +8 -0
- package/templates/hosts/qwen/agents/ui-verifier.md +8 -0
- package/templates/hosts/qwen/agents/wiki-compiler.md +11 -0
- package/templates/hosts/qwen/commands/wf-deploy.md +9 -0
- package/templates/hosts/qwen/commands/wf-maintain.md +9 -0
- package/templates/hosts/qwen/commands/wf-new-task.md +9 -0
- package/templates/hosts/qwen/commands/wf-pipeline-run.md +9 -0
- package/templates/hosts/qwen/commands/wf-pr-review.md +9 -0
- package/templates/hosts/qwen/commands/wf-review.md +9 -0
- package/templates/hosts/qwen/commands/wf-stages.md +9 -0
- package/templates/hosts/qwen/settings.json +57 -0
- package/templates/hosts/trae/agents/implementer.md +9 -0
- package/templates/hosts/trae/agents/independent-reviewer.md +10 -0
- package/templates/hosts/trae/agents/pr-adjudicator.md +10 -0
- package/templates/hosts/trae/agents/pr-finder.md +10 -0
- package/templates/hosts/trae/agents/pr-verifier.md +10 -0
- package/templates/hosts/trae/agents/ui-verifier.md +10 -0
- package/templates/hosts/trae/agents/wiki-compiler.md +10 -0
- package/templates/hosts/trae/commands/wf-deploy.md +8 -0
- package/templates/hosts/trae/commands/wf-maintain.md +8 -0
- package/templates/hosts/trae/commands/wf-new-task.md +8 -0
- package/templates/hosts/trae/commands/wf-pipeline-run.md +8 -0
- package/templates/hosts/trae/commands/wf-pr-review.md +8 -0
- package/templates/hosts/trae/commands/wf-review.md +8 -0
- package/templates/hosts/trae/commands/wf-stages.md +8 -0
- package/templates/hosts/trae/hooks.json +17 -0
- package/templates/hosts/trae/rules/backend-scope.md +5 -0
- package/templates/hosts/trae/rules/frontend-scope.md +5 -0
- package/templates/hosts/zcode/agents/implementer.md +8 -0
- package/templates/hosts/zcode/agents/independent-reviewer.md +8 -0
- package/templates/hosts/zcode/agents/ui-verifier.md +8 -0
- package/templates/hosts/zcode/agents/wiki-compiler.md +8 -0
- package/templates/hosts/zcode/config.json +31 -0
- package/templates/hosts/zcode/workflows/code-review.dwf.ts +428 -0
- package/templates/hosts/zcode/workflows/fullchain-flow-test.dwf.ts +898 -0
- package/templates/profiles/dotnet/.agents/config/lane-surfaces.txt +33 -0
- package/templates/profiles/dotnet/.agents/config/rule-budgets.txt +84 -0
- package/templates/profiles/dotnet/.agents/config/test-impact-map.json +590 -0
- package/templates/profiles/dotnet/.agents/config/workflow-modules.txt +18 -0
- package/templates/profiles/dotnet/.agents/hooks/commit-check.config.json +18 -0
- package/templates/profiles/dotnet/.agents/hooks/delete-guard-allowlist.txt +28 -0
- package/templates/profiles/dotnet/.agents/notes/runtime-env.md +178 -0
- package/templates/profiles/dotnet/AGENTS.md +52 -0
- package/templates/profiles/empty/.agents/config/lane-surfaces.txt +12 -0
- package/templates/profiles/empty/.agents/config/rule-budgets.txt +3 -0
- package/templates/profiles/empty/.agents/config/test-impact-map.json +8 -0
- package/templates/profiles/empty/.agents/config/workflow-modules.txt +2 -0
- package/templates/profiles/empty/.agents/hooks/commit-check.config.json +5 -0
- package/templates/profiles/empty/.agents/hooks/delete-guard-allowlist.txt +2 -0
- package/templates/profiles/empty/.agents/notes/runtime-env.md +44 -0
- package/templates/profiles/empty/AGENTS.md +52 -0
- package/templates/profiles/go/AGENTS.md +52 -0
- package/templates/profiles/java/AGENTS.md +52 -0
- package/templates/profiles/node/.agents/config/lane-surfaces.txt +12 -0
- package/templates/profiles/node/.agents/config/rule-budgets.txt +3 -0
- package/templates/profiles/node/.agents/config/test-impact-map.json +8 -0
- package/templates/profiles/node/.agents/config/workflow-modules.txt +2 -0
- package/templates/profiles/node/.agents/hooks/commit-check.config.json +5 -0
- package/templates/profiles/node/.agents/hooks/delete-guard-allowlist.txt +2 -0
- package/templates/profiles/node/.agents/notes/runtime-env.md +44 -0
- package/templates/profiles/node/AGENTS.md +52 -0
- package/templates/profiles/rust/AGENTS.md +52 -0
- package/templates/profiles/typescript/AGENTS.md +52 -0
- package/templates/scaffold/wiki/INDEX.md +33 -0
- package/templates/scaffold/wiki/drafts-archive/README.md +7 -0
- package/templates/scaffold/wiki//344/272/247/345/223/201/351/234/200/346/261/202/.gitkeep +0 -0
- package/templates/scaffold/wiki//345/274/200/345/217/221/346/226/271/346/241/210/.gitkeep +0 -0
- package/templates/scaffold/wiki//346/225/260/346/215/256/347/273/264/346/212/244/README.md +22 -0
- package/templates/scaffold/wiki//346/265/213/350/257/225/346/212/245/345/221/212/.gitkeep +0 -0
- package/templates/scaffold/wiki//347/224/250/346/210/267/345/212/237/350/203/275/.gitkeep +0 -0
- package/templates/scaffold/wiki//347/237/245/350/257/206/346/262/211/346/267/200/346/200/273/350/247/210.html +230 -0
- package/templates/scaffold/wiki//351/241/271/347/233/256/350/247/204/350/214/203/.gitkeep +0 -0
- package/templates/scaffold/workflow/INDEX.md +29 -0
- package/templates/scaffold/workflow/README.md +69 -0
- package/templates/scaffold/workflow/archive/README.md +3 -0
- package/templates/scaffold/workflow/artifact-sources.md +25 -0
- package/templates/scaffold/workflow/delegations.d/.gitkeep +0 -0
- package/templates/scaffold/workflow/delegations.md +4 -0
- package/templates/scaffold/workflow/effective-policy.md +4 -0
- package/templates/scaffold/workflow/evidence/.gitkeep +0 -0
- package/templates/scaffold/workflow/gate-cost.md +4 -0
- package/templates/scaffold/workflow/gate-metrics.d/.gitkeep +0 -0
- package/templates/scaffold/workflow/incidents/_TEMPLATE.md +49 -0
- package/templates/scaffold/workflow/intents/_TEMPLATE.md +43 -0
- package/templates/scaffold/workflow/metrics.md +4 -0
- package/templates/scaffold/workflow/non-engineer-intent.md +51 -0
- package/templates/scaffold/workflow/papercuts.d/.gitkeep +0 -0
- package/templates/scaffold/workflow/papercuts.md +3 -0
- package/templates/scaffold/workflow/plans/_TEMPLATE.md +47 -0
- package/templates/scaffold/workflow/regression-checklist.d/.gitkeep +0 -0
- package/templates/scaffold/workflow/regression-checklist.md +3 -0
- package/templates/scaffold/workflow/research/.gitkeep +0 -0
- package/templates/scaffold/workflow/reviews.d/.gitkeep +0 -0
- package/templates/scaffold/workflow/specs/_TEMPLATE.md +87 -0
- package/templates/scaffold/workflow/verify-evidence/.gitkeep +0 -0
- package/templates/scaffold/workflow/verify-evidence.md +4 -0
- package/modules/gates/README.md +0 -25
- package/modules/gates/dotnet-ca/README.md +0 -24
- package/modules/gates/dotnet-ca/check-architecture.sh +0 -150
- package/modules/gates/dotnet-ca/local-pre-commit.line +0 -1
- package/modules/gates/generated-readonly/README.md +0 -13
- package/modules/gates/generated-readonly/check-generated.mjs +0 -61
- package/modules/gates/generated-readonly/local-pre-commit.line +0 -1
- package/modules/gates/node-layer/README.md +0 -9
- package/modules/gates/node-layer/check-node-layer.mjs +0 -29
- package/modules/gates/node-layer/local-pre-commit.line +0 -1
- package/modules/gates/py-import/README.md +0 -9
- package/modules/gates/py-import/check-py-import.mjs +0 -30
- package/modules/gates/py-import/local-pre-commit.line +0 -1
- package/modules/gates/test-protect/README.md +0 -23
- package/modules/gates/test-protect/check-test-protect.mjs +0 -64
- package/modules/gates/test-protect/local-pre-commit.line +0 -1
- package/modules/hosts/README.md +0 -57
- package/modules/hosts/claude/agents/implementer.md +0 -51
- package/modules/hosts/claude/agents/independent-reviewer.md +0 -49
- package/modules/hosts/claude/agents/ui-verifier.md +0 -48
- package/modules/hosts/claude/commands/wf-build.md +0 -69
- package/modules/hosts/claude/commands/wf-deploy.md +0 -58
- package/modules/hosts/claude/commands/wf-design.md +0 -49
- package/modules/hosts/claude/commands/wf-gate-checklist.md +0 -77
- package/modules/hosts/claude/commands/wf-maintain.md +0 -76
- package/modules/hosts/claude/commands/wf-new-task.md +0 -102
- package/modules/hosts/claude/commands/wf-pipeline-run.md +0 -35
- package/modules/hosts/claude/commands/wf-plan.md +0 -40
- package/modules/hosts/claude/commands/wf-review.md +0 -49
- package/modules/hosts/claude/commands/wf-sync-hosts.md +0 -64
- package/modules/hosts/claude/commands/wf-test.md +0 -68
- package/modules/hosts/codex/agents/implementer.md +0 -51
- package/modules/hosts/codex/agents/independent-reviewer.md +0 -49
- package/modules/hosts/codex/agents/ui-verifier.md +0 -48
- package/modules/hosts/codex/commands/wf-build.md +0 -69
- package/modules/hosts/codex/commands/wf-deploy.md +0 -58
- package/modules/hosts/codex/commands/wf-design.md +0 -49
- package/modules/hosts/codex/commands/wf-gate-checklist.md +0 -77
- package/modules/hosts/codex/commands/wf-maintain.md +0 -76
- package/modules/hosts/codex/commands/wf-new-task.md +0 -102
- package/modules/hosts/codex/commands/wf-pipeline-run.md +0 -35
- package/modules/hosts/codex/commands/wf-plan.md +0 -40
- package/modules/hosts/codex/commands/wf-review.md +0 -49
- package/modules/hosts/codex/commands/wf-sync-hosts.md +0 -64
- package/modules/hosts/codex/commands/wf-test.md +0 -68
- package/modules/hosts/codex/skills/flow-kit/SKILL.md +0 -14
- package/modules/hosts/cursor/agents/implementer.md +0 -51
- package/modules/hosts/cursor/agents/independent-reviewer.md +0 -49
- package/modules/hosts/cursor/agents/ui-verifier.md +0 -48
- package/modules/hosts/cursor/commands/wf-build.md +0 -69
- package/modules/hosts/cursor/commands/wf-deploy.md +0 -58
- package/modules/hosts/cursor/commands/wf-design.md +0 -49
- package/modules/hosts/cursor/commands/wf-gate-checklist.md +0 -77
- package/modules/hosts/cursor/commands/wf-maintain.md +0 -76
- package/modules/hosts/cursor/commands/wf-new-task.md +0 -102
- package/modules/hosts/cursor/commands/wf-pipeline-run.md +0 -35
- package/modules/hosts/cursor/commands/wf-plan.md +0 -40
- package/modules/hosts/cursor/commands/wf-review.md +0 -49
- package/modules/hosts/cursor/commands/wf-sync-hosts.md +0 -64
- package/modules/hosts/cursor/commands/wf-test.md +0 -68
- package/modules/hosts/omp/agents/implementer.md +0 -52
- package/modules/hosts/omp/agents/independent-reviewer.md +0 -50
- package/modules/hosts/omp/agents/ui-verifier.md +0 -49
- package/modules/hosts/opencode/agents/implementer.md +0 -59
- package/modules/hosts/opencode/agents/independent-reviewer.md +0 -53
- package/modules/hosts/opencode/agents/ui-verifier.md +0 -52
- package/modules/hosts/opencode/commands/wf-build.md +0 -69
- package/modules/hosts/opencode/commands/wf-deploy.md +0 -58
- package/modules/hosts/opencode/commands/wf-design.md +0 -49
- package/modules/hosts/opencode/commands/wf-gate-checklist.md +0 -77
- package/modules/hosts/opencode/commands/wf-maintain.md +0 -76
- package/modules/hosts/opencode/commands/wf-new-task.md +0 -102
- package/modules/hosts/opencode/commands/wf-pipeline-run.md +0 -35
- package/modules/hosts/opencode/commands/wf-plan.md +0 -40
- package/modules/hosts/opencode/commands/wf-review.md +0 -49
- package/modules/hosts/opencode/commands/wf-sync-hosts.md +0 -64
- package/modules/hosts/opencode/commands/wf-test.md +0 -68
- package/modules/hosts/trae/agents/implementer.md +0 -52
- package/modules/hosts/trae/agents/independent-reviewer.md +0 -51
- package/modules/hosts/trae/agents/ui-verifier.md +0 -50
- package/modules/hosts/trae/commands/wf-build.md +0 -70
- package/modules/hosts/trae/commands/wf-deploy.md +0 -59
- package/modules/hosts/trae/commands/wf-design.md +0 -50
- package/modules/hosts/trae/commands/wf-gate-checklist.md +0 -78
- package/modules/hosts/trae/commands/wf-maintain.md +0 -77
- package/modules/hosts/trae/commands/wf-new-task.md +0 -103
- package/modules/hosts/trae/commands/wf-pipeline-run.md +0 -36
- package/modules/hosts/trae/commands/wf-plan.md +0 -41
- package/modules/hosts/trae/commands/wf-review.md +0 -50
- package/modules/hosts/trae/commands/wf-sync-hosts.md +0 -65
- package/modules/hosts/trae/commands/wf-test.md +0 -69
- package/modules/hosts/trae/hooks/post-edit-check.cjs +0 -98
- package/modules/hosts/trae/hooks/pre-shell-check.cjs +0 -192
- package/modules/hosts/trae/hooks/resolve-shell.cjs +0 -30
- package/modules/hosts/trae/hooks.json +0 -29
- package/modules/hosts/trae/rules/beautify-input-chinese.md +0 -6
- package/modules/hosts/trae/rules/git-commit-message.md +0 -10
- package/modules/hosts/trae/rules/project-workflow.md +0 -14
- package/modules/hosts/zcode/agents/implementer.md +0 -51
- package/modules/hosts/zcode/agents/independent-reviewer.md +0 -49
- package/modules/hosts/zcode/agents/ui-verifier.md +0 -48
- package/src/add-gate.mjs +0 -116
- package/src/add-gate.test.mjs +0 -103
- package/src/add-host.mjs +0 -68
- package/src/cli.mjs +0 -169
- package/src/doctor.mjs +0 -629
- package/src/executor.mjs +0 -262
- package/src/executor.test.mjs +0 -295
- package/src/fresh-init.test.mjs +0 -64
- package/src/gate-dotnet-ca.test.mjs +0 -124
- package/src/gates.test.mjs +0 -143
- package/src/init.mjs +0 -382
- package/src/init.test.mjs +0 -163
- package/src/instance-ref.test.mjs +0 -62
- package/src/jscpd-drift.test.mjs +0 -145
- package/src/pack.test.mjs +0 -24
- package/src/profiles.mjs +0 -183
- package/src/render.mjs +0 -132
- package/src/rule-budget.test.mjs +0 -103
- package/src/run-tests.mjs +0 -56
- package/src/stack-profile.test.mjs +0 -95
- package/src/sync-hosts.mjs +0 -257
- package/src/sync-hosts.test.mjs +0 -291
- package/src/sync.mjs +0 -228
- package/src/sync.test.mjs +0 -452
- package/src/trae-hooks.test.mjs +0 -127
- package/src/validate.mjs +0 -77
- package/src/validate.test.mjs +0 -95
- package/templates/.gitattributes +0 -17
- package/templates/AGENTS.md +0 -58
- package/templates/_agents/board/index.html +0 -676
- package/templates/_agents/commands/build.md +0 -84
- package/templates/_agents/commands/deploy.md +0 -66
- package/templates/_agents/commands/design.md +0 -63
- package/templates/_agents/commands/gate-checklist.md +0 -91
- package/templates/_agents/commands/maintain.md +0 -90
- package/templates/_agents/commands/new-task.md +0 -110
- package/templates/_agents/commands/pipeline-run.md +0 -43
- package/templates/_agents/commands/plan.md +0 -48
- package/templates/_agents/commands/review.md +0 -62
- package/templates/_agents/commands/sync-hosts.md +0 -77
- package/templates/_agents/commands/test.md +0 -87
- package/templates/_agents/control-surfaces.txt +0 -53
- package/templates/_agents/engine-lock.json +0 -342
- package/templates/_agents/hooks/check-index-incremental.mjs +0 -48
- package/templates/_agents/hooks/check-pairing-incremental.mjs +0 -66
- package/templates/_agents/hooks/check-wiki-ledger.mjs +0 -30
- package/templates/_agents/hooks/commit-check.cjs +0 -193
- package/templates/_agents/hooks/local-pre-commit +0 -6
- package/templates/_agents/lane-surfaces.txt +0 -17
- package/templates/_agents/level-hints.txt +0 -30
- package/templates/_agents/loop/papercut-debt/DESIGN.md +0 -112
- package/templates/_agents/mechanism-registry.md +0 -35
- package/templates/_agents/metric-claims.txt +0 -81
- package/templates/_agents/notes/engine-internals.md +0 -17
- package/templates/_agents/notes/runtime-env.md +0 -18
- package/templates/_agents/roles/implementer.md +0 -47
- package/templates/_agents/roles/independent-reviewer.md +0 -45
- package/templates/_agents/roles/ui-verifier.md +0 -44
- package/templates/_agents/rule-budgets.txt +0 -20
- package/templates/_agents/scripts/agg-delegations.cjs +0 -302
- package/templates/_agents/scripts/agg-delegations.test.mjs +0 -282
- package/templates/_agents/scripts/agg-gate-stats.mjs +0 -113
- package/templates/_agents/scripts/agg-gate-stats.test.mjs +0 -95
- package/templates/_agents/scripts/agg-judgments.mjs +0 -156
- package/templates/_agents/scripts/agg-judgments.test.mjs +0 -93
- package/templates/_agents/scripts/archive-sweep.mjs +0 -235
- package/templates/_agents/scripts/archive-sweep.test.mjs +0 -129
- package/templates/_agents/scripts/check-attribution.mjs +0 -37
- package/templates/_agents/scripts/check-convergence.mjs +0 -124
- package/templates/_agents/scripts/check-engine-integrity.mjs +0 -220
- package/templates/_agents/scripts/check-engine-integrity.test.mjs +0 -215
- package/templates/_agents/scripts/check-funnel.mjs +0 -56
- package/templates/_agents/scripts/check-hygiene.mjs +0 -167
- package/templates/_agents/scripts/check-hygiene.test.mjs +0 -182
- package/templates/_agents/scripts/check-index-incremental.test.mjs +0 -73
- package/templates/_agents/scripts/check-lane-surface.mjs +0 -238
- package/templates/_agents/scripts/check-lane-surface.test.mjs +0 -302
- package/templates/_agents/scripts/check-ledger-invariant.mjs +0 -586
- package/templates/_agents/scripts/check-ledger-invariant.test.mjs +0 -639
- package/templates/_agents/scripts/check-loop-rev.test.mjs +0 -336
- package/templates/_agents/scripts/check-loop-unit.test.mjs +0 -103
- package/templates/_agents/scripts/check-loop.mjs +0 -1987
- package/templates/_agents/scripts/check-loop.sh +0 -6
- package/templates/_agents/scripts/check-loop.test.mjs +0 -3912
- package/templates/_agents/scripts/check-metric-claims.mjs +0 -277
- package/templates/_agents/scripts/check-prejudgment.mjs +0 -64
- package/templates/_agents/scripts/check-registry.mjs +0 -45
- package/templates/_agents/scripts/check-scope.mjs +0 -96
- package/templates/_agents/scripts/check-scope.test.mjs +0 -99
- package/templates/_agents/scripts/check-scripts-syntax.mjs +0 -84
- package/templates/_agents/scripts/check-scripts-syntax.test.mjs +0 -72
- package/templates/_agents/scripts/check-spec-verif.mjs +0 -47
- package/templates/_agents/scripts/check-stage-index.mjs +0 -40
- package/templates/_agents/scripts/check-stage-index.test.mjs +0 -77
- package/templates/_agents/scripts/closeout-l1.mjs +0 -217
- package/templates/_agents/scripts/closeout-l1.test.mjs +0 -105
- package/templates/_agents/scripts/commit-check-trigger.test.mjs +0 -205
- package/templates/_agents/scripts/compact-ledgers.mjs +0 -97
- package/templates/_agents/scripts/compact-ledgers.test.mjs +0 -162
- package/templates/_agents/scripts/confirm-doc.mjs +0 -610
- package/templates/_agents/scripts/confirm-doc.test.mjs +0 -1119
- package/templates/_agents/scripts/doctor.test.mjs +0 -770
- package/templates/_agents/scripts/draft-sediment.mjs +0 -178
- package/templates/_agents/scripts/draft-sediment.test.mjs +0 -272
- package/templates/_agents/scripts/edit-face-check.mjs +0 -109
- package/templates/_agents/scripts/edit-face-check.test.mjs +0 -99
- package/templates/_agents/scripts/ensure-board.mjs +0 -185
- package/templates/_agents/scripts/fill-intent.mjs +0 -91
- package/templates/_agents/scripts/fill-intent.test.mjs +0 -113
- package/templates/_agents/scripts/fill-plan.mjs +0 -79
- package/templates/_agents/scripts/fill-plan.test.mjs +0 -224
- package/templates/_agents/scripts/fill-spec.mjs +0 -70
- package/templates/_agents/scripts/fill-spec.test.mjs +0 -266
- package/templates/_agents/scripts/fixture-scripts.mjs +0 -153
- package/templates/_agents/scripts/fixture-scripts.test.mjs +0 -112
- package/templates/_agents/scripts/gate-checklist.mjs +0 -209
- package/templates/_agents/scripts/gate-checklist.test.mjs +0 -201
- package/templates/_agents/scripts/gate-seg.mjs +0 -54
- package/templates/_agents/scripts/gate-seg.test.mjs +0 -112
- package/templates/_agents/scripts/gen-effective-policy.mjs +0 -107
- package/templates/_agents/scripts/gen-effective-policy.test.mjs +0 -100
- package/templates/_agents/scripts/gen-verify-evidence.mjs +0 -107
- package/templates/_agents/scripts/gen-verify-evidence.test.mjs +0 -84
- package/templates/_agents/scripts/gen-wiki-board.mjs +0 -276
- package/templates/_agents/scripts/gen-wiki-board.test.mjs +0 -249
- package/templates/_agents/scripts/gen-workflow-dashboard.mjs +0 -251
- package/templates/_agents/scripts/gen-workflow-dashboard.test.mjs +0 -188
- package/templates/_agents/scripts/gen-workflow-index.mjs +0 -201
- package/templates/_agents/scripts/gen-workflow-index.test.mjs +0 -152
- package/templates/_agents/scripts/gen-workflow-metrics.mjs +0 -466
- package/templates/_agents/scripts/gen-workflow-metrics.test.mjs +0 -343
- package/templates/_agents/scripts/git-merge-jsonl.mjs +0 -63
- package/templates/_agents/scripts/git-merge-jsonl.test.mjs +0 -125
- package/templates/_agents/scripts/judgment-ledger.mjs +0 -65
- package/templates/_agents/scripts/judgment-ledger.test.mjs +0 -129
- package/templates/_agents/scripts/kb-cache-evict.mjs +0 -50
- package/templates/_agents/scripts/kb-cache-evict.test.mjs +0 -104
- package/templates/_agents/scripts/kb-search.mjs +0 -413
- package/templates/_agents/scripts/kb-search.test.mjs +0 -299
- package/templates/_agents/scripts/lane-surface-audit.mjs +0 -143
- package/templates/_agents/scripts/lane-surface-audit.test.mjs +0 -93
- package/templates/_agents/scripts/ledger-doc-chain.test.mjs +0 -166
- package/templates/_agents/scripts/ledger-loader.mjs +0 -108
- package/templates/_agents/scripts/ledger-loader.test.mjs +0 -131
- package/templates/_agents/scripts/ledger-prune.mjs +0 -96
- package/templates/_agents/scripts/ledger-prune.test.mjs +0 -120
- package/templates/_agents/scripts/ledger-shards.mjs +0 -344
- package/templates/_agents/scripts/ledger-shards.test.mjs +0 -356
- package/templates/_agents/scripts/ledger-ts-monotonic.test.mjs +0 -135
- package/templates/_agents/scripts/level-criteria.mjs +0 -231
- package/templates/_agents/scripts/level-criteria.test.mjs +0 -281
- package/templates/_agents/scripts/mechanism-retire-watch.mjs +0 -183
- package/templates/_agents/scripts/mechanism-retire-watch.test.mjs +0 -114
- package/templates/_agents/scripts/papercut-debt-controller.mjs +0 -141
- package/templates/_agents/scripts/papercut-debt-controller.test.mjs +0 -127
- package/templates/_agents/scripts/papercut-debt-sensor.mjs +0 -170
- package/templates/_agents/scripts/papercut-debt-sensor.test.mjs +0 -146
- package/templates/_agents/scripts/pipeline-run-docs.mjs +0 -76
- package/templates/_agents/scripts/pipeline-run-run.mjs +0 -63
- package/templates/_agents/scripts/pipeline-run.mjs +0 -867
- package/templates/_agents/scripts/pipeline-run.test.mjs +0 -517
- package/templates/_agents/scripts/policy.mjs +0 -281
- package/templates/_agents/scripts/pre-push.test.mjs +0 -105
- package/templates/_agents/scripts/resolve-merge-conflicts.mjs +0 -110
- package/templates/_agents/scripts/resolve-merge-conflicts.test.mjs +0 -87
- package/templates/_agents/scripts/rewrite-file.mjs +0 -133
- package/templates/_agents/scripts/rewrite-file.test.mjs +0 -148
- package/templates/_agents/scripts/rule-budget.mjs +0 -96
- package/templates/_agents/scripts/rule-budget.test.mjs +0 -118
- package/templates/_agents/scripts/run-tests.mjs +0 -99
- package/templates/_agents/scripts/run-tests.test.mjs +0 -105
- package/templates/_agents/scripts/solidify-task.mjs +0 -109
- package/templates/_agents/scripts/solidify-task.test.mjs +0 -129
- package/templates/_agents/scripts/stage-gates.mjs +0 -343
- package/templates/_agents/scripts/stage-gates.test.mjs +0 -105
- package/templates/_agents/scripts/trust-mode.mjs +0 -67
- package/templates/_agents/scripts/trust-mode.test.mjs +0 -110
- package/templates/_agents/scripts/verify-wiki-consistency.mjs +0 -253
- package/templates/_agents/scripts/verify-wiki-consistency.test.mjs +0 -123
- package/templates/_agents/scripts/verify.mjs +0 -345
- package/templates/_agents/scripts/verify.test.mjs +0 -373
- package/templates/_agents/scripts/wf-journal.mjs +0 -231
- package/templates/_agents/scripts/wf-journal.test.mjs +0 -216
- package/templates/_agents/scripts/wiki-search.mjs +0 -19
- package/templates/_agents/scripts/wiki-search.test.mjs +0 -57
- package/templates/_agents/scripts/workflow-board-server.mjs +0 -393
- package/templates/_agents/scripts/workflow-board-server.test.mjs +0 -201
- package/templates/_agents/scripts/workflow-enums.mjs +0 -70
- package/templates/_agents/scripts/workflow-enums.test.mjs +0 -118
- package/templates/_agents/scripts/workflows-check.mjs +0 -260
- package/templates/_agents/scripts/workflows-check.test.mjs +0 -278
- package/templates/_agents/scripts-test-exempt.txt +0 -16
- package/templates/_agents/skills/papercut-fix/SKILL.md +0 -60
- package/templates/_agents/skills/papercut-fix/references/response-template.md +0 -81
- package/templates/_agents/skills/review-method/SKILL.md +0 -58
- package/templates/_agents/skills/verify-ui/SKILL.md +0 -61
- package/templates/_agents/skills/wiki/SKILL.md +0 -106
- package/templates/_agents/workflow-enums.txt +0 -26
- package/templates/_agents/workflow-modules.txt +0 -11
- package/templates/_agents/workflows/_TEMPLATE.md +0 -75
- package/templates/_agents/workflows/pipeline-closing.md +0 -28
- package/templates/_agents/workflows//347/244/272/344/276/213-/345/271/266/350/241/214/345/256/236/347/216/260/350/257/204/345/256/241.md +0 -16
- package/templates/_githooks/commit-msg +0 -17
- package/templates/_githooks/post-commit +0 -10
- package/templates/_githooks/pre-commit +0 -126
- package/templates/_githooks/pre-merge-commit +0 -29
- package/templates/_githooks/pre-push +0 -136
- package/templates/_github/workflows/kit-ci.yml +0 -49
- package/templates/wiki/INDEX.md +0 -73
- package/templates/wiki/drafts-archive/README.md +0 -3
- package/templates/wiki//344/272/247/345/223/201/351/234/200/346/261/202/README.md +0 -3
- package/templates/wiki//345/274/200/345/217/221/346/226/271/346/241/210/README.md +0 -3
- package/templates/wiki//346/225/260/346/215/256/347/273/264/346/212/244/README.md +0 -3
- package/templates/wiki//346/265/213/350/257/225/346/212/245/345/221/212/README.md +0 -3
- package/templates/wiki//347/224/250/346/210/267/345/212/237/350/203/275/README.md +0 -3
- package/templates/wiki//347/237/245/350/257/206/346/262/211/346/267/200/346/200/273/350/247/210.html +0 -77
- package/templates/wiki//351/241/271/347/233/256/350/247/204/350/214/203/README.md +0 -3
- package/templates/wiki//351/241/271/347/233/256/350/256/241/345/210/222/README.md +0 -3
- package/templates/workflow/README.md +0 -91
- package/templates/workflow/delegations.md +0 -29
- package/templates/workflow/incidents/_TEMPLATE.md +0 -51
- package/templates/workflow/intents/_TEMPLATE.md +0 -51
- package/templates/workflow/papercuts.md +0 -9
- package/templates/workflow/plans/_TEMPLATE.md +0 -47
- package/templates/workflow/regression-checklist.md +0 -23
- package/templates/workflow/specs/_TEMPLATE.md +0 -80
- /package/templates/{_agents → engine/.agents}/board/marked.min.js +0 -0
- /package/templates/{_agents/workflows → engine/.agents/pipelines}/steps//347/244/272/344/276/213-/351/203/250/347/275/262/351/252/214/350/257/201.md" +0 -0
- /package/templates/{_agents → engine/.agents}/scripts/git-core.mjs +0 -0
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// tfs-pr.mjs — 内网 TFS / Azure DevOps Server PR 工具(REST + PAT)
|
|
3
|
+
//
|
|
4
|
+
// 目标:任意内网 TFS 仓库都能用。collection/project/repo 从当前 git 仓库的 remote 推导,
|
|
5
|
+
// 也可用 --base / --project / --repo 或 TFS_BASE / TFS_PROJECT / TFS_REPO 覆盖。
|
|
6
|
+
// 凭据:PAT 只从 env 读取:多台服务器可按 base 主机名分存 TFS_PAT_<HOST>(非字母数字转 _ 大写,命中优先),
|
|
7
|
+
// 回落全局 TFS_PAT;兜底 --pat-file <path>。不打印、不落盘。
|
|
8
|
+
// 响应:先判 status / content-type 再 JSON.parse;认证失败常见形态是 401 + text/html。
|
|
9
|
+
// 命令:target | setup | whoami | list | get | context | create | desc | conflicts
|
|
10
|
+
// 退出:0 成功(含 EXISTING 幂等命中);1 HTTP/API/网络错误;2 用法/配置错误。
|
|
11
|
+
//
|
|
12
|
+
// 用法:node tfs-pr.mjs target # 只解析并打印 base/project/repo/remote
|
|
13
|
+
// node tfs-pr.mjs setup # PAT 配置指引(门户地址由 base 推导)
|
|
14
|
+
// node tfs-pr.mjs whoami # 验证 PAT
|
|
15
|
+
// node tfs-pr.mjs list [--source b] [--target b] [--status active|all] [--json]
|
|
16
|
+
// node tfs-pr.mjs get <id> [--json]
|
|
17
|
+
// node tfs-pr.mjs context [--source b] [--target b] [--no-fetch] [--patch] [--json]
|
|
18
|
+
// node tfs-pr.mjs create [--source b] [--target b] --title t --body-file f|- [--dry-run]
|
|
19
|
+
// node tfs-pr.mjs desc <id> --body-file f|- [--dry-run]
|
|
20
|
+
// node tfs-pr.mjs conflicts <id> [--no-fetch] [--json]
|
|
21
|
+
// node tfs-pr.mjs conflicts --source b --target b [--no-fetch] [--json]
|
|
22
|
+
// 测试:node tfs-pr.test.mjs(本地 http 桩 + 临时 git 仓库,不触真实服务)
|
|
23
|
+
import fs from 'node:fs';
|
|
24
|
+
import { spawnSync } from 'node:child_process';
|
|
25
|
+
|
|
26
|
+
const argv = process.argv.slice(2);
|
|
27
|
+
const cmd = argv[0] && !argv[0].startsWith('-') ? argv[0] : '';
|
|
28
|
+
|
|
29
|
+
class UsageError extends Error {}
|
|
30
|
+
|
|
31
|
+
function flag(key) {
|
|
32
|
+
return argv.includes(key);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function opt(key) {
|
|
36
|
+
const prefix = `${key}=`;
|
|
37
|
+
for (let i = 0; i < argv.length; i++) {
|
|
38
|
+
if (argv[i] === key) {
|
|
39
|
+
const v = argv[i + 1];
|
|
40
|
+
// 缺值不静默回落(2026-10-24 复核 m4):`--source --title x` 曾把空串当取值,
|
|
41
|
+
// 于是静默用当前分支/远端默认建 PR——建到错分支且无任何提示。缺值即用法错。
|
|
42
|
+
if (v === undefined || v.startsWith('--')) {
|
|
43
|
+
throw new UsageError(`${key} 缺少取值(后随「${v === undefined ? '(无)' : v}」)——用 ${key} <值> 或 ${key}=<值>`);
|
|
44
|
+
}
|
|
45
|
+
return v;
|
|
46
|
+
}
|
|
47
|
+
if (argv[i].startsWith(prefix)) return argv[i].slice(prefix.length);
|
|
48
|
+
}
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const json = flag('--json');
|
|
53
|
+
const apiVersion = opt('--api-version') || process.env.TFS_API_VERSION || '6.0';
|
|
54
|
+
const scriptPath = process.argv[1] || 'tfs-pr.mjs';
|
|
55
|
+
|
|
56
|
+
class ApiError extends Error {
|
|
57
|
+
constructor(message, { status = 0, hint = '' } = {}) {
|
|
58
|
+
super(message);
|
|
59
|
+
this.status = status;
|
|
60
|
+
this.hint = hint;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const die = (msg, code = 2) => {
|
|
65
|
+
console.error(`tfs-pr: ${msg}`);
|
|
66
|
+
process.exit(code);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const decodeEntities = (s) =>
|
|
70
|
+
s.replace(/&#(\d+);/g, (_, d) => String.fromCharCode(Number(d)))
|
|
71
|
+
.replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&');
|
|
72
|
+
|
|
73
|
+
const decodeSafe = (s) => {
|
|
74
|
+
try {
|
|
75
|
+
return decodeURIComponent(s);
|
|
76
|
+
} catch {
|
|
77
|
+
return s;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const escapeRegex = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
82
|
+
const stripRef = (b) => String(b || '').replace(/^refs\/heads\//, '');
|
|
83
|
+
const refOf = (b) => (String(b).startsWith('refs/') ? String(b) : `refs/heads/${b}`);
|
|
84
|
+
const printJson = (v) => console.log(JSON.stringify(v, null, 2));
|
|
85
|
+
|
|
86
|
+
// ---------- git / remote ----------
|
|
87
|
+
function gitRun(args, { allowFail = false, cwd } = {}) {
|
|
88
|
+
const r = spawnSync('git', args, { encoding: 'utf8', cwd });
|
|
89
|
+
if (r.error) {
|
|
90
|
+
if (allowFail) return r;
|
|
91
|
+
throw new UsageError(`无法执行 git:${r.error.message}`);
|
|
92
|
+
}
|
|
93
|
+
if (r.status !== 0 && !allowFail) {
|
|
94
|
+
const detail = (r.stderr || r.stdout || '').trim().split(/\r?\n/).slice(0, 3).join(' ');
|
|
95
|
+
throw new UsageError(`git ${args.join(' ')} 失败${detail ? `:${detail}` : ''}`);
|
|
96
|
+
}
|
|
97
|
+
return r;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const asText = (v) => String(v || '');
|
|
101
|
+
const gitOut = (args, opts) => asText(gitRun(args, opts).stdout).replace(/\r\n/g, '\n').trim();
|
|
102
|
+
|
|
103
|
+
function gitConfig(key) {
|
|
104
|
+
const r = gitRun(['config', '--get', key], { allowFail: true });
|
|
105
|
+
return r.status === 0 ? asText(r.stdout).trim() : '';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isGitWorkTree() {
|
|
109
|
+
const r = gitRun(['rev-parse', '--is-inside-work-tree'], { allowFail: true });
|
|
110
|
+
return r.status === 0 && asText(r.stdout).trim() === 'true';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function currentBranch() {
|
|
114
|
+
const r = gitRun(['symbolic-ref', '--quiet', '--short', 'HEAD'], { allowFail: true });
|
|
115
|
+
return r.status === 0 ? asText(r.stdout).trim() : '';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getRemoteName() {
|
|
119
|
+
const explicit = opt('--remote') || process.env.TFS_REMOTE || gitConfig('tfs-pr.remote');
|
|
120
|
+
if (explicit) return explicit;
|
|
121
|
+
if (!isGitWorkTree()) return '';
|
|
122
|
+
const r = gitRun(['remote'], { allowFail: true });
|
|
123
|
+
const names = r.status === 0 ? asText(r.stdout).trim().split(/\s+/).filter(Boolean) : [];
|
|
124
|
+
if (names.length <= 1) return names[0] || '';
|
|
125
|
+
// 多 remote 消歧(2026-10-24 复核 M5):原口径「有 origin 就 origin,否则取第一个」——
|
|
126
|
+
// origin 指向另一 TFS 仓(或 fork)时会静默推导出错误的 project/repo,PR 建到别的仓。
|
|
127
|
+
// 现:origin 可解析为 TFS 才用它;否则在「可解析为 TFS 的 remote」中取唯一者;仍多于一个即报歧义。
|
|
128
|
+
const tfsRemotes = names.filter((n) => {
|
|
129
|
+
const u = gitRun(['remote', 'get-url', n], { allowFail: true });
|
|
130
|
+
return u.status === 0 && !!parseRemoteUrl(asText(u.stdout).trim(), n);
|
|
131
|
+
});
|
|
132
|
+
if (tfsRemotes.length === 1) return tfsRemotes[0];
|
|
133
|
+
if (tfsRemotes.length > 1) {
|
|
134
|
+
// 多个 TFS remote(如 origin + upstream 镜像)时不再默认取 origin——猜错的代价是把 PR 建到别的仓,
|
|
135
|
+
// 而代价更低的动作是让用户显式指定一次。
|
|
136
|
+
throw new UsageError(`多 remote 无法消歧(可解析为 TFS 的有:${tfsRemotes.join('、')})——用 --remote <name> 或 TFS_REMOTE 显式指定`);
|
|
137
|
+
}
|
|
138
|
+
return names[0] || '';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function sanitizeRemote(url) {
|
|
142
|
+
return String(url || '').replace(/^([a-z]+:\/\/)(?:[^@/]+)@/i, '$1***@');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function parseRemoteUrl(input, remoteName) {
|
|
146
|
+
const raw = String(input || '').trim();
|
|
147
|
+
if (!raw) return null;
|
|
148
|
+
let scheme = '';
|
|
149
|
+
let host = '';
|
|
150
|
+
let port = '';
|
|
151
|
+
let path = '';
|
|
152
|
+
|
|
153
|
+
let m = /^(https?|ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::(\d+))?\/(.+)$/i.exec(raw);
|
|
154
|
+
if (m) {
|
|
155
|
+
scheme = m[1].toLowerCase();
|
|
156
|
+
host = m[2];
|
|
157
|
+
port = m[3] || '';
|
|
158
|
+
path = m[4];
|
|
159
|
+
} else {
|
|
160
|
+
// scp-like: git@host:tfs/COLL/PROJ/_git/REPO
|
|
161
|
+
m = /^(?:[^@/]+@)?([^:/]+):(.+)$/.exec(raw);
|
|
162
|
+
if (!m) return null;
|
|
163
|
+
scheme = 'ssh';
|
|
164
|
+
host = m[1];
|
|
165
|
+
port = '22';
|
|
166
|
+
path = m[2];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
path = path.replace(/\/+$/, '');
|
|
170
|
+
let seg = path.split('/').filter(Boolean);
|
|
171
|
+
const tfsPrefix = seg[0] === 'tfs';
|
|
172
|
+
if (tfsPrefix) seg = seg.slice(1);
|
|
173
|
+
const gi = seg.indexOf('_git');
|
|
174
|
+
if (gi < 1 || gi === seg.length - 1) return null;
|
|
175
|
+
|
|
176
|
+
let collection = '';
|
|
177
|
+
let project = '';
|
|
178
|
+
if (gi === 1) {
|
|
179
|
+
// Azure DevOps Services(dev.azure.com)必须带 project 段:`/<org>/_git/<repo>` 不是合法克隆地址,
|
|
180
|
+
// 按「project==collection」硬解会拼出 /<org>/<org>/_apis/… → 404(2026-10-24 复核 m7)
|
|
181
|
+
if (/^dev\.azure\.com$/i.test(host)) return null;
|
|
182
|
+
if (tfsPrefix || !/\.visualstudio\.com$/i.test(host)) {
|
|
183
|
+
// 内网自托管短形态(project==collection):/tfs/COLL/_git/R 或根挂载 /COLL/_git/R,base 必须含 collection
|
|
184
|
+
collection = decodeSafe(seg[0]);
|
|
185
|
+
project = collection;
|
|
186
|
+
} else {
|
|
187
|
+
// Azure DevOps Services 旧式:https://org.visualstudio.com/project/_git/repo(collection 即主机)
|
|
188
|
+
project = decodeSafe(seg[0]);
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
collection = decodeSafe(seg[0]);
|
|
192
|
+
project = decodeSafe(seg.slice(1, gi).join('/'));
|
|
193
|
+
}
|
|
194
|
+
let repo = decodeSafe(seg.slice(gi + 1).join('/')).replace(/\.git$/i, '');
|
|
195
|
+
if (!project || !repo) return null;
|
|
196
|
+
|
|
197
|
+
const webScheme = process.env.TFS_WEB_SCHEME || (scheme === 'ssh' ? 'http' : scheme);
|
|
198
|
+
const webPort = scheme === 'ssh' ? (process.env.TFS_WEB_PORT ?? '8080') : port;
|
|
199
|
+
const basePath = collection ? (tfsPrefix ? `/tfs/${collection}` : `/${collection}`) : '';
|
|
200
|
+
const base = `${webScheme}://${host}${webPort ? `:${webPort}` : ''}${basePath}`;
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
base,
|
|
204
|
+
project,
|
|
205
|
+
repo,
|
|
206
|
+
collection,
|
|
207
|
+
remote: remoteName || '',
|
|
208
|
+
remoteUrl: sanitizeRemote(raw),
|
|
209
|
+
scheme,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function parseRemote() {
|
|
214
|
+
const name = getRemoteName();
|
|
215
|
+
if (!name) return null;
|
|
216
|
+
const r = gitRun(['remote', 'get-url', name], { allowFail: true });
|
|
217
|
+
if (r.status !== 0) return null;
|
|
218
|
+
const raw = asText(r.stdout).trim();
|
|
219
|
+
const parsed = parseRemoteUrl(raw, name);
|
|
220
|
+
// dev.azure.com 形态缺 project 段(2026-10-24 复核 m7):`https://dev.azure.com/<org>/_git/<repo>`
|
|
221
|
+
// 不是合法克隆地址——原实现把 org 当 project,拼出 /<org>/<org>/_apis/… 后 404。此处提前点名,
|
|
222
|
+
// 不让用户对着「无法识别内网 TFS 地址」猜。
|
|
223
|
+
if (!parsed && /^https?:\/\/dev\.azure\.com\/[^/]+\/_git\//i.test(raw)) {
|
|
224
|
+
throw new UsageError(
|
|
225
|
+
`远端 ${sanitizeRemote(raw)} 缺 project 段:Azure DevOps 形态须为 https://dev.azure.com/<org>/<project>/_git/<repo>;`
|
|
226
|
+
+ '请修正 remote URL,或用 --project/--repo 显式指定'
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
return parsed;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function resolveTarget() {
|
|
233
|
+
const remote = parseRemote();
|
|
234
|
+
// base 内嵌 userinfo(user:pass@)时剥除:WHATWG fetch 禁止带凭据 URL(直接 TypeError),
|
|
235
|
+
// 且认证一律走 PAT——凭据只影响分存键推导(2026-10-24 复核 E3)
|
|
236
|
+
const base = (opt('--base') || process.env.TFS_BASE || gitConfig('tfs-pr.base') || (remote && remote.base) || '')
|
|
237
|
+
.replace(/\/+$/, '')
|
|
238
|
+
.replace(/^(https?:\/\/)[^/@]+@/i, '$1');
|
|
239
|
+
if (!base) {
|
|
240
|
+
throw new UsageError(
|
|
241
|
+
'无法识别内网 TFS 地址:请确认当前目录是 git 仓库且远端指向 TFS;' +
|
|
242
|
+
'或显式指定 --base <集合地址,如 http://host:8080/tfs/COLLECTION>、--project、--repo。'
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
const project = opt('--project') || process.env.TFS_PROJECT || (remote && remote.project) || '';
|
|
246
|
+
const repo = opt('--repo') || process.env.TFS_REPO || (remote && remote.repo) || '';
|
|
247
|
+
if (!project) {
|
|
248
|
+
throw new UsageError('缺少 project:用 --project / TFS_PROJECT 指定,或检查远端地址是否包含 /<project>/_git/<repo>。');
|
|
249
|
+
}
|
|
250
|
+
if (!repo) {
|
|
251
|
+
throw new UsageError('缺少 repo:用 --repo / TFS_REPO 指定,或检查远端地址是否包含 /_git/<repo>。');
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
base,
|
|
255
|
+
project,
|
|
256
|
+
repo,
|
|
257
|
+
collection: (remote && remote.collection) || '',
|
|
258
|
+
remote: (remote && remote.remote) || '',
|
|
259
|
+
remoteUrl: (remote && remote.remoteUrl) || '',
|
|
260
|
+
tokenUrl: `${base}/_usersSettings/tokens`,
|
|
261
|
+
prPage: `${base}/${encodeURIComponent(project)}/_git/${encodeURIComponent(repo)}/pullrequests`,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ---------- 凭据 / 正文 ----------
|
|
266
|
+
// PAT 环境变量查找顺序:按 base 主机名分存的 TFS_PAT_<HOST>(非字母数字转 _、大写)优先,回落全局 TFS_PAT。
|
|
267
|
+
function patEnvKeys(target) {
|
|
268
|
+
// host 提取前先剥 scheme 与 userinfo(user:pass@ 形态)——否则分存键静默错位(2026-10-24 复核 E3)
|
|
269
|
+
const host = String(target && target.base ? target.base : '')
|
|
270
|
+
.replace(/^https?:\/\//, '')
|
|
271
|
+
.replace(/^[^/]*@/, '')
|
|
272
|
+
.split(/[/:]/)[0];
|
|
273
|
+
return host ? [`TFS_PAT_${host.replace(/[^A-Za-z0-9]/g, '_').toUpperCase()}`, 'TFS_PAT'] : ['TFS_PAT'];
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function resolvePat(target, { optional = false } = {}) {
|
|
277
|
+
const keys = patEnvKeys(target);
|
|
278
|
+
const fromEnv = () => keys.map((k) => process.env[k]).find(Boolean) || '';
|
|
279
|
+
if (optional) return fromEnv();
|
|
280
|
+
const file = opt('--pat-file');
|
|
281
|
+
let pat = fromEnv();
|
|
282
|
+
if (!pat && file) {
|
|
283
|
+
if (!fs.existsSync(file)) throw new UsageError(`--pat-file 不存在:${file}`);
|
|
284
|
+
pat = fs.readFileSync(file, 'utf8');
|
|
285
|
+
}
|
|
286
|
+
pat = pat.replace(/^\uFEFF/, '').trim();
|
|
287
|
+
if (!pat) {
|
|
288
|
+
throw new UsageError(
|
|
289
|
+
`缺少 PAT(${keys.join(' / ')} 均未配置)。到 ${target.tokenUrl} 生成 Personal Access Token,` +
|
|
290
|
+
'scopes 勾 Code (Read & Write) + Pull Request (Read & Write);' +
|
|
291
|
+
`Windows 持久化:setx ${keys[0]} "<PAT>"(多台服务器按主机分存,单台用 TFS_PAT;新开终端生效);` +
|
|
292
|
+
'Linux/macOS:在 shell profile 中 export;' +
|
|
293
|
+
`自检:node "${scriptPath}" whoami。` +
|
|
294
|
+
'PAT 不要粘贴到对话或命令行;兜底可用 --pat-file <临时文件>。'
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
return pat;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function readBodyFile() {
|
|
301
|
+
const f = opt('--body-file');
|
|
302
|
+
if (!f) throw new UsageError('缺少 --body-file(UTF-8 正文文件;传 - 从 stdin 读取)');
|
|
303
|
+
let raw;
|
|
304
|
+
if (f === '-') {
|
|
305
|
+
raw = fs.readFileSync(0, 'utf8');
|
|
306
|
+
} else {
|
|
307
|
+
if (!fs.existsSync(f)) throw new UsageError(`--body-file 不存在:${f}`);
|
|
308
|
+
raw = fs.readFileSync(f, 'utf8');
|
|
309
|
+
}
|
|
310
|
+
raw = raw.replace(/^\uFEFF/, '');
|
|
311
|
+
if (!raw.trim()) throw new UsageError('--body-file 为空');
|
|
312
|
+
return raw;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// ---------- HTTP ----------
|
|
316
|
+
const authHeader = (pat) => `Basic ${Buffer.from(`:${pat}`).toString('base64')}`;
|
|
317
|
+
|
|
318
|
+
const authHint = (status, target) => {
|
|
319
|
+
if (status === 401 || status === 403) {
|
|
320
|
+
return `认证失败:PAT 无效/过期/scope 不足(Code R&W + Pull Request R&W)。` +
|
|
321
|
+
`到 ${target.tokenUrl} 重新生成,并确认 ${patEnvKeys(target).join(' 或 ')} 已在新进程生效。`;
|
|
322
|
+
}
|
|
323
|
+
if (status === 404) {
|
|
324
|
+
return '404:确认 base 是集合地址(如 http://host:8080/tfs/COLLECTION)、project/repo 拼写正确。' +
|
|
325
|
+
'先运行 target 子命令核对;若 API 在 8080 而 base 指向 80,用 --base 覆盖。';
|
|
326
|
+
}
|
|
327
|
+
return '';
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
async function request(target, pat, method, path, body, { projectLevel = true } = {}) {
|
|
331
|
+
const url = projectLevel
|
|
332
|
+
? `${target.base}/${encodeURIComponent(target.project)}${path}`
|
|
333
|
+
: `${target.base}${path}`;
|
|
334
|
+
// URL 输出一律过 sanitizeRemote——base 内嵌 userinfo(user:pass@)时凭据不露终端(2026-10-24 复核 E3)
|
|
335
|
+
if (flag('--verbose')) console.log(`> ${method} ${sanitizeRemote(url)}`);
|
|
336
|
+
const headers = { Authorization: authHeader(pat), Accept: 'application/json' };
|
|
337
|
+
if (body !== undefined) headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
338
|
+
|
|
339
|
+
let res;
|
|
340
|
+
try {
|
|
341
|
+
res = await fetch(url, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
|
|
342
|
+
} catch (e) {
|
|
343
|
+
throw new ApiError(`请求失败 ${method} ${sanitizeRemote(url)}:${e.message}`, {
|
|
344
|
+
hint: '检查 base 地址、网络/证书、代理设置。',
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const text = await res.text();
|
|
349
|
+
const ctype = res.headers.get('content-type') || '';
|
|
350
|
+
if (!/json/i.test(ctype)) {
|
|
351
|
+
const title = (text.match(/<title>([^<]*)<\/title>/i) || [])[1] || text.slice(0, 200).replace(/\s+/g, ' ');
|
|
352
|
+
throw new ApiError(`HTTP ${res.status} ${ctype || '(无 content-type)'} — ${decodeEntities(title).trim()}`, {
|
|
353
|
+
status: res.status,
|
|
354
|
+
hint: authHint(res.status, target) || '非 JSON 响应:确认 base / project / repo 与 api-version。',
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
let data;
|
|
359
|
+
try {
|
|
360
|
+
data = JSON.parse(text);
|
|
361
|
+
} catch {
|
|
362
|
+
throw new ApiError(`HTTP ${res.status} — 响应声明 JSON 但解析失败:${text.slice(0, 200)}`, { status: res.status });
|
|
363
|
+
}
|
|
364
|
+
if (!res.ok) {
|
|
365
|
+
throw new ApiError(`HTTP ${res.status}: ${data.message || JSON.stringify(data).slice(0, 300)}`, {
|
|
366
|
+
status: res.status,
|
|
367
|
+
hint: authHint(res.status, target),
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
return data;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const repoPath = (t) => `/_apis/git/repositories/${encodeURIComponent(t.repo)}/pullrequests`;
|
|
374
|
+
const prUrl = (t, id) =>
|
|
375
|
+
`${t.base}/${encodeURIComponent(t.project)}/_git/${encodeURIComponent(t.repo)}/pullrequest/${id}`;
|
|
376
|
+
|
|
377
|
+
// ---------- 分支解析 ----------
|
|
378
|
+
function resolveSourceBranch() {
|
|
379
|
+
const explicit = opt('--source') || process.env.TFS_SOURCE || gitConfig('tfs-pr.source');
|
|
380
|
+
if (explicit) return stripRef(explicit);
|
|
381
|
+
const cur = currentBranch();
|
|
382
|
+
if (!cur) throw new UsageError('当前处于 detached HEAD,无法推断源分支;请用 --source 指定。');
|
|
383
|
+
return cur;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function resolveTargetBranch() {
|
|
387
|
+
const explicit = opt('--target') || process.env.TFS_TARGET || gitConfig('tfs-pr.target');
|
|
388
|
+
if (explicit) return stripRef(explicit);
|
|
389
|
+
const remote = getRemoteName() || 'origin';
|
|
390
|
+
const r = gitRun(['symbolic-ref', '--quiet', '--short', `refs/remotes/${remote}/HEAD`], { allowFail: true });
|
|
391
|
+
if (r.status === 0 && asText(r.stdout).trim()) {
|
|
392
|
+
const ref = asText(r.stdout).trim();
|
|
393
|
+
return stripRef(ref.replace(new RegExp(`^${escapeRegex(remote)}/`), ''));
|
|
394
|
+
}
|
|
395
|
+
throw new UsageError(
|
|
396
|
+
`无法确定目标分支:${remote}/HEAD 未设置。` +
|
|
397
|
+
'用 --target <branch> 指定,或固化:git config tfs-pr.target <branch>。'
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function refExists(ref) {
|
|
402
|
+
if (!ref) return false;
|
|
403
|
+
const r = gitRun(['rev-parse', '--verify', '--quiet', `${ref}^{commit}`], { allowFail: true });
|
|
404
|
+
return r.status === 0;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function fetchBranches(remote, branches) {
|
|
408
|
+
const unique = [...new Set(branches.map(stripRef).filter(Boolean))];
|
|
409
|
+
if (!unique.length) return;
|
|
410
|
+
const refspecs = unique.map((b) => `+refs/heads/${b}:refs/remotes/${remote}/${b}`);
|
|
411
|
+
const args = ['fetch', ...(flag('--verbose') ? [] : ['--quiet']), remote, ...refspecs];
|
|
412
|
+
const r = gitRun(args, { allowFail: true });
|
|
413
|
+
if (r.status !== 0) {
|
|
414
|
+
const detail = (r.stderr || r.stdout || '').trim().split(/\r?\n/).slice(0, 3).join(' ');
|
|
415
|
+
throw new UsageError(
|
|
416
|
+
`拉取 ${unique.join(', ')} 失败${detail ? `:${detail}` : ''}。` +
|
|
417
|
+
'确认分支已推送、remote 可访问;若 PR 源分支来自 fork/其他仓库,请在对应仓库中操作。' +
|
|
418
|
+
'也可加 --no-fetch 使用本地已有 refs。'
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function mergeTree(a, b) {
|
|
424
|
+
const r = spawnSync('git', ['merge-tree', '--write-tree', '--name-only', a, b], { encoding: 'utf8' });
|
|
425
|
+
if (r.error) return { supported: false, files: [], error: r.error.message };
|
|
426
|
+
if (r.status === 0) {
|
|
427
|
+
return { supported: true, files: [], tree: (r.stdout || '').split(/\r?\n/)[0] || '' };
|
|
428
|
+
}
|
|
429
|
+
if (r.status === 1) {
|
|
430
|
+
const lines = (r.stdout || '').split(/\r?\n/).filter(Boolean);
|
|
431
|
+
return { supported: true, files: lines.slice(1), tree: lines[0] || '' };
|
|
432
|
+
}
|
|
433
|
+
return {
|
|
434
|
+
supported: false,
|
|
435
|
+
files: [],
|
|
436
|
+
error: ((r.stderr || r.stdout || '').trim().split(/\r?\n/)[0]) || `exit ${r.status}`,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function analyzeRefs(sourceRef, targetRef) {
|
|
441
|
+
const mb = gitOut(['merge-base', sourceRef, targetRef], { allowFail: true });
|
|
442
|
+
if (!mb) throw new UsageError(`找不到 ${sourceRef} 与 ${targetRef} 的共同祖先,无法比较。`);
|
|
443
|
+
const diffNames = (ref) => gitOut(['diff', '--name-only', mb, ref]).split(/\r?\n/).filter(Boolean);
|
|
444
|
+
const sourceChanged = diffNames(sourceRef);
|
|
445
|
+
const targetChanged = diffNames(targetRef);
|
|
446
|
+
const targetSet = new Set(targetChanged);
|
|
447
|
+
const overlap = sourceChanged.filter((f) => targetSet.has(f));
|
|
448
|
+
const conflicts = mergeTree(sourceRef, targetRef);
|
|
449
|
+
return { mergeBase: mb, sourceChanged, targetChanged, overlap, conflicts };
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function pushState(remote, sourceRef) {
|
|
453
|
+
const branch = currentBranch();
|
|
454
|
+
if (!branch) {
|
|
455
|
+
return { branch: '', remote, upstream: '', ahead: null, behind: null, unpushed: null, note: 'detached HEAD,未比较推送状态' };
|
|
456
|
+
}
|
|
457
|
+
const upstream = `refs/remotes/${remote}/${branch}`;
|
|
458
|
+
if (sourceRef !== 'HEAD') {
|
|
459
|
+
return { branch, remote, upstream: `${remote}/${branch}`, ahead: null, behind: null, unpushed: null, note: '源 ref 不是当前 HEAD,未比较推送状态' };
|
|
460
|
+
}
|
|
461
|
+
if (!refExists(upstream)) {
|
|
462
|
+
return { branch, remote, upstream: `${remote}/${branch}`, ahead: null, behind: null, unpushed: true, note: '远端还没有该分支(需要 push)' };
|
|
463
|
+
}
|
|
464
|
+
const counts = gitOut(['rev-list', '--left-right', '--count', `${upstream}...HEAD`]).split(/\s+/).map(Number);
|
|
465
|
+
const behind = counts[0] || 0;
|
|
466
|
+
const ahead = counts[1] || 0;
|
|
467
|
+
return { branch, remote, upstream: `${remote}/${branch}`, ahead, behind, unpushed: ahead > 0, note: '' };
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// ---------- 子命令 ----------
|
|
471
|
+
async function fetchPr(target, pat, id) {
|
|
472
|
+
return request(target, pat, 'GET', `${repoPath(target)}/${id}?api-version=${apiVersion}`);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
async function fetchPrs(target, pat, { status = 'active', source = '', target: targetBranch = '' } = {}) {
|
|
476
|
+
const q = new URLSearchParams();
|
|
477
|
+
q.set('searchCriteria.status', status);
|
|
478
|
+
if (source) q.set('searchCriteria.sourceRefName', refOf(source));
|
|
479
|
+
if (targetBranch) q.set('searchCriteria.targetRefName', refOf(targetBranch));
|
|
480
|
+
q.set('api-version', apiVersion);
|
|
481
|
+
return request(target, pat, 'GET', `/_apis/git/pullrequests?${q}`);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
async function listPrs(t, pat) {
|
|
485
|
+
const status = opt('--status') || 'active';
|
|
486
|
+
const data = await fetchPrs(t, pat, { status, source: opt('--source'), target: opt('--target') });
|
|
487
|
+
const rows = (data.value || []).map((p) => ({
|
|
488
|
+
id: p.pullRequestId,
|
|
489
|
+
status: p.status,
|
|
490
|
+
mergeStatus: p.mergeStatus,
|
|
491
|
+
source: stripRef(p.sourceRefName),
|
|
492
|
+
target: stripRef(p.targetRefName),
|
|
493
|
+
title: p.title,
|
|
494
|
+
url: prUrl(t, p.pullRequestId),
|
|
495
|
+
}));
|
|
496
|
+
if (json) {
|
|
497
|
+
printJson(rows);
|
|
498
|
+
return rows;
|
|
499
|
+
}
|
|
500
|
+
for (const r of rows) console.log(`#${r.id} [${r.status}/${r.mergeStatus}] ${r.source} → ${r.target} ${r.title}`);
|
|
501
|
+
console.log(`共 ${rows.length} 条(status=${status})`);
|
|
502
|
+
return rows;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
506
|
+
|
|
507
|
+
async function getPr(t, pat, id) {
|
|
508
|
+
const data = await fetchPr(t, pat, id);
|
|
509
|
+
if (json) {
|
|
510
|
+
printJson(data);
|
|
511
|
+
return data;
|
|
512
|
+
}
|
|
513
|
+
console.log(`#${data.pullRequestId} status=${data.status} mergeStatus=${data.mergeStatus}`);
|
|
514
|
+
console.log(` ${stripRef(data.sourceRefName)} → ${stripRef(data.targetRefName)}`);
|
|
515
|
+
console.log(` ${data.title}`);
|
|
516
|
+
console.log(` description=${String(data.description || '').length} 字符`);
|
|
517
|
+
console.log(` ${prUrl(t, data.pullRequestId)}`);
|
|
518
|
+
return data;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
async function waitMerge(t, pat, id) {
|
|
522
|
+
let pr;
|
|
523
|
+
for (let i = 0; i < 15; i++) {
|
|
524
|
+
pr = await fetchPr(t, pat, id);
|
|
525
|
+
if (pr.mergeStatus && !['queued', 'notSet'].includes(pr.mergeStatus)) return pr;
|
|
526
|
+
await sleep(1000);
|
|
527
|
+
}
|
|
528
|
+
return pr;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
async function createPr(t, pat) {
|
|
532
|
+
const source = resolveSourceBranch();
|
|
533
|
+
const target = resolveTargetBranch();
|
|
534
|
+
const title = opt('--title').trim();
|
|
535
|
+
if (!title) throw new UsageError('create 需要 --title');
|
|
536
|
+
if (source === target) throw new UsageError(`源分支与目标分支相同:${source}`);
|
|
537
|
+
const description = readBodyFile();
|
|
538
|
+
const payload = {
|
|
539
|
+
sourceRefName: refOf(source),
|
|
540
|
+
targetRefName: refOf(target),
|
|
541
|
+
title,
|
|
542
|
+
description,
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
if (flag('--dry-run')) {
|
|
546
|
+
if (json) {
|
|
547
|
+
printJson({
|
|
548
|
+
method: 'POST',
|
|
549
|
+
url: `${t.base}/${encodeURIComponent(t.project)}${repoPath(t)}?api-version=${apiVersion}`,
|
|
550
|
+
source,
|
|
551
|
+
target,
|
|
552
|
+
title,
|
|
553
|
+
descriptionLength: description.length,
|
|
554
|
+
});
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
console.log(`> POST ${t.base}/${encodeURIComponent(t.project)}${repoPath(t)}?api-version=${apiVersion}`);
|
|
558
|
+
console.log(JSON.stringify({ ...payload, description: `<${description.length} 字符>` }, null, 2));
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// 幂等查询取 all(2026-10-24 复核 m6):原只查 status=active——上一单 completed/abandoned 时查不到,
|
|
563
|
+
// 重跑即建重复单。现:active 命中照旧返回 EXISTING;仅历史命中则拒绝并提示 --force-new(显式重开一轮)。
|
|
564
|
+
if (!flag('--force-new')) {
|
|
565
|
+
const existing = await fetchPrs(t, pat, { status: 'all', source, target });
|
|
566
|
+
const samePair = (existing.value || []).filter(
|
|
567
|
+
(p) => stripRef(p.sourceRefName) === source && stripRef(p.targetRefName) === target
|
|
568
|
+
);
|
|
569
|
+
const hit = samePair.find((p) => p.status === 'active') || samePair[0];
|
|
570
|
+
if (hit) {
|
|
571
|
+
const result = {
|
|
572
|
+
id: hit.pullRequestId,
|
|
573
|
+
status: hit.status,
|
|
574
|
+
mergeStatus: hit.mergeStatus,
|
|
575
|
+
url: prUrl(t, hit.pullRequestId),
|
|
576
|
+
existing: true,
|
|
577
|
+
};
|
|
578
|
+
if (hit.status !== 'active') {
|
|
579
|
+
if (json) printJson(result);
|
|
580
|
+
else console.log(`EXISTING-HISTORY #${result.id} ${result.status}/${result.mergeStatus} ${result.url}`);
|
|
581
|
+
throw new UsageError(`源→目标分支已存在历史 PR #${hit.pullRequestId}(${hit.status})——确需再开一轮请加 --force-new`);
|
|
582
|
+
}
|
|
583
|
+
if (json) printJson(result);
|
|
584
|
+
else console.log(`EXISTING #${result.id} ${result.status}/${result.mergeStatus} ${result.url}`);
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
const created = await request(t, pat, 'POST', `${repoPath(t)}?api-version=${apiVersion}`, payload);
|
|
590
|
+
const settled = await waitMerge(t, pat, created.pullRequestId);
|
|
591
|
+
const result = {
|
|
592
|
+
id: settled.pullRequestId,
|
|
593
|
+
status: settled.status,
|
|
594
|
+
mergeStatus: settled.mergeStatus,
|
|
595
|
+
url: prUrl(t, settled.pullRequestId),
|
|
596
|
+
existing: false,
|
|
597
|
+
};
|
|
598
|
+
if (json) printJson(result);
|
|
599
|
+
else console.log(`CREATED #${result.id} status=${result.status} mergeStatus=${result.mergeStatus} ${result.url}`);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
async function updateDesc(t, pat, id) {
|
|
603
|
+
const description = readBodyFile();
|
|
604
|
+
if (flag('--dry-run')) {
|
|
605
|
+
if (json) {
|
|
606
|
+
printJson({
|
|
607
|
+
method: 'PATCH',
|
|
608
|
+
url: `${t.base}/${encodeURIComponent(t.project)}${repoPath(t)}/${id}?api-version=${apiVersion}`,
|
|
609
|
+
descriptionLength: description.length,
|
|
610
|
+
});
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
console.log(`> PATCH ${t.base}/${encodeURIComponent(t.project)}${repoPath(t)}/${id}?api-version=${apiVersion}`);
|
|
614
|
+
console.log(JSON.stringify({ description: `<${description.length} 字符>` }, null, 2));
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
await request(t, pat, 'PATCH', `${repoPath(t)}/${id}?api-version=${apiVersion}`, { description });
|
|
619
|
+
const back = await fetchPr(t, pat, id);
|
|
620
|
+
const norm = (s) => String(s || '').replace(/\r\n/g, '\n').trim();
|
|
621
|
+
if (norm(back.description) !== norm(description)) {
|
|
622
|
+
throw new ApiError(`描述回读不一致:写入 ${description.length} 字符,回读 ${String(back.description || '').length} 字符`);
|
|
623
|
+
}
|
|
624
|
+
const result = {
|
|
625
|
+
id: back.pullRequestId,
|
|
626
|
+
descriptionLength: String(back.description || '').length,
|
|
627
|
+
url: prUrl(t, back.pullRequestId),
|
|
628
|
+
updated: true,
|
|
629
|
+
};
|
|
630
|
+
if (json) printJson(result);
|
|
631
|
+
else console.log(`UPDATED #${result.id} description=${result.descriptionLength} 字符 ${result.url}`);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
function buildContext(t) {
|
|
635
|
+
if (!isGitWorkTree()) throw new UsageError('context 需要当前目录是 git 仓库。');
|
|
636
|
+
const source = resolveSourceBranch();
|
|
637
|
+
const target = resolveTargetBranch();
|
|
638
|
+
if (source === target) throw new UsageError(`源分支与目标分支相同:${source}`);
|
|
639
|
+
const remote = getRemoteName() || 'origin';
|
|
640
|
+
|
|
641
|
+
if (!flag('--no-fetch')) fetchBranches(remote, [target]);
|
|
642
|
+
const targetRef = `refs/remotes/${remote}/${target}`;
|
|
643
|
+
if (!refExists(targetRef)) {
|
|
644
|
+
throw new UsageError(`本地缺少 ${targetRef}:先 git fetch ${remote} ${target},或去掉 --no-fetch。`);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
let sourceRef = '';
|
|
648
|
+
if (source === currentBranch()) sourceRef = 'HEAD';
|
|
649
|
+
else if (refExists(`refs/heads/${source}`)) sourceRef = source;
|
|
650
|
+
else if (refExists(`refs/remotes/${remote}/${source}`)) sourceRef = `refs/remotes/${remote}/${source}`;
|
|
651
|
+
if (!sourceRef) throw new UsageError(`找不到源分支 ${source}(本地与 ${remote} 都没有)。`);
|
|
652
|
+
|
|
653
|
+
const analysis = analyzeRefs(sourceRef, targetRef);
|
|
654
|
+
const range = `${targetRef}...${sourceRef}`;
|
|
655
|
+
const countRaw = Number(gitOut(['rev-list', '--count', `${targetRef}..${sourceRef}`], { allowFail: true }) || 0);
|
|
656
|
+
const commitCount = Number.isFinite(countRaw) ? countRaw : 0;
|
|
657
|
+
const limitRaw = Number(opt('--limit'));
|
|
658
|
+
const commitLimit = Number.isFinite(limitRaw) && limitRaw > 0 ? Math.floor(limitRaw) : 50;
|
|
659
|
+
const commits = gitOut(['log', '--no-decorate', '--oneline', `-${commitLimit}`, `${targetRef}..${sourceRef}`])
|
|
660
|
+
.split(/\r?\n/).filter(Boolean);
|
|
661
|
+
const nameStatus = gitOut(['diff', '--name-status', range]).split(/\r?\n/).filter(Boolean);
|
|
662
|
+
const files = nameStatus.map((line) => {
|
|
663
|
+
const [status, ...rest] = line.split('\t');
|
|
664
|
+
return { status, path: rest.join(' -> ') };
|
|
665
|
+
});
|
|
666
|
+
const stat = gitOut(['diff', '--stat', range]);
|
|
667
|
+
const shortstat = gitOut(['diff', '--shortstat', range]);
|
|
668
|
+
const push = pushState(remote, sourceRef);
|
|
669
|
+
const dirtyFiles = gitOut(['status', '--porcelain']).split(/\r?\n/).filter(Boolean);
|
|
670
|
+
const patch = flag('--patch') ? gitRun(['diff', '--no-color', range], { allowFail: true }).stdout : '';
|
|
671
|
+
|
|
672
|
+
return {
|
|
673
|
+
source,
|
|
674
|
+
target,
|
|
675
|
+
remote,
|
|
676
|
+
sourceRef,
|
|
677
|
+
targetRef,
|
|
678
|
+
mergeBase: analysis.mergeBase,
|
|
679
|
+
commitCount,
|
|
680
|
+
commits,
|
|
681
|
+
files,
|
|
682
|
+
nameStatus,
|
|
683
|
+
stat,
|
|
684
|
+
shortstat,
|
|
685
|
+
overlap: analysis.overlap,
|
|
686
|
+
conflicts: analysis.conflicts,
|
|
687
|
+
push,
|
|
688
|
+
dirty: dirtyFiles.length > 0,
|
|
689
|
+
dirtyFiles: dirtyFiles.slice(0, 50),
|
|
690
|
+
patch,
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function printContext(c) {
|
|
695
|
+
console.log(`source=${c.source} target=${c.target} remote=${c.remote}`);
|
|
696
|
+
console.log(`merge-base=${c.mergeBase}`);
|
|
697
|
+
console.log(`commits=${c.commitCount}${c.commits.length < c.commitCount ? `(仅显示最近 ${c.commits.length} 条)` : ''}`);
|
|
698
|
+
for (const line of c.commits) console.log(` ${line}`);
|
|
699
|
+
console.log(`changed files=${c.files.length}`);
|
|
700
|
+
for (const line of c.nameStatus) console.log(` ${line}`);
|
|
701
|
+
console.log(`overlap(双方都改过的文件)=${c.overlap.length ? c.overlap.join(', ') : '无'}`);
|
|
702
|
+
console.log(
|
|
703
|
+
c.conflicts.supported
|
|
704
|
+
? `conflicts=${c.conflicts.files.length ? c.conflicts.files.join(', ') : '无(merge-tree clean)'}`
|
|
705
|
+
: `conflicts=无法本地预检(${c.conflicts.error})`
|
|
706
|
+
);
|
|
707
|
+
if (c.push.note) console.log(`push=${c.push.note}`);
|
|
708
|
+
else console.log(`push=${c.push.unpushed ? `未推送 ${c.push.ahead} 个提交(behind ${c.push.behind})` : '已推送'}`);
|
|
709
|
+
console.log(`dirty=${c.dirty ? `是(${c.dirtyFiles.length >= 50 ? '50+' : c.dirtyFiles.length} 个文件)` : '否'}`);
|
|
710
|
+
console.log('diffstat:');
|
|
711
|
+
console.log(c.stat || '(无变更)');
|
|
712
|
+
if (c.shortstat) console.log(c.shortstat);
|
|
713
|
+
if (c.patch) {
|
|
714
|
+
console.log('--- patch ---');
|
|
715
|
+
console.log(c.patch);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
async function conflicts(t, pat, idArg) {
|
|
720
|
+
const remote = getRemoteName() || 'origin';
|
|
721
|
+
let source = '';
|
|
722
|
+
let target = '';
|
|
723
|
+
let prStatus = '';
|
|
724
|
+
let mergeStatus = '';
|
|
725
|
+
let prId = null;
|
|
726
|
+
|
|
727
|
+
if (idArg) {
|
|
728
|
+
const pr = await fetchPr(t, pat, idArg);
|
|
729
|
+
prId = pr.pullRequestId;
|
|
730
|
+
prStatus = pr.status || '';
|
|
731
|
+
mergeStatus = pr.mergeStatus || '';
|
|
732
|
+
source = stripRef(pr.sourceRefName);
|
|
733
|
+
target = stripRef(pr.targetRefName);
|
|
734
|
+
} else {
|
|
735
|
+
source = stripRef(opt('--source'));
|
|
736
|
+
target = stripRef(opt('--target') || resolveTargetBranch());
|
|
737
|
+
if (!source) throw new UsageError('conflicts 需要 PR id,或 --source <源分支> --target <目标分支>');
|
|
738
|
+
}
|
|
739
|
+
if (!source || !target) throw new UsageError('conflicts 缺少源分支或目标分支。');
|
|
740
|
+
|
|
741
|
+
if (!flag('--no-fetch')) fetchBranches(remote, [source, target]);
|
|
742
|
+
|
|
743
|
+
const pick = (branch, preferRemote) => {
|
|
744
|
+
const remoteRef = `refs/remotes/${remote}/${branch}`;
|
|
745
|
+
if (preferRemote && refExists(remoteRef)) return remoteRef;
|
|
746
|
+
if (branch === currentBranch()) return 'HEAD';
|
|
747
|
+
if (refExists(`refs/heads/${branch}`)) return branch;
|
|
748
|
+
if (refExists(remoteRef)) return remoteRef;
|
|
749
|
+
return '';
|
|
750
|
+
};
|
|
751
|
+
const sourceRef = pick(source, !!prId);
|
|
752
|
+
const targetRef = pick(target, true);
|
|
753
|
+
if (!sourceRef) throw new UsageError(`找不到源分支 ${source}(本地与 ${remote} 都没有)。`);
|
|
754
|
+
if (!targetRef) throw new UsageError(`找不到目标分支 ${target}(本地与 ${remote} 都没有)。`);
|
|
755
|
+
|
|
756
|
+
const analysis = analyzeRefs(sourceRef, targetRef);
|
|
757
|
+
const result = {
|
|
758
|
+
id: prId,
|
|
759
|
+
status: prStatus,
|
|
760
|
+
mergeStatus,
|
|
761
|
+
source,
|
|
762
|
+
target,
|
|
763
|
+
sourceRef,
|
|
764
|
+
targetRef,
|
|
765
|
+
mergeBase: analysis.mergeBase,
|
|
766
|
+
conflictsSupported: analysis.conflicts.supported,
|
|
767
|
+
conflicts: analysis.conflicts.files,
|
|
768
|
+
conflictsError: analysis.conflicts.error || '',
|
|
769
|
+
overlap: analysis.overlap,
|
|
770
|
+
sourceChanged: analysis.sourceChanged,
|
|
771
|
+
targetChanged: analysis.targetChanged,
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
if (json) {
|
|
775
|
+
printJson(result);
|
|
776
|
+
return result;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
console.log(`${prId ? `PR #${prId} ` : ''}source=${source} → target=${target}${mergeStatus ? ` mergeStatus=${mergeStatus}` : ''}`);
|
|
780
|
+
console.log(`merge-base=${analysis.mergeBase}`);
|
|
781
|
+
console.log(
|
|
782
|
+
analysis.conflicts.supported
|
|
783
|
+
? `conflicts=${analysis.conflicts.files.length ? analysis.conflicts.files.join(', ') : '无(merge-tree clean)'}`
|
|
784
|
+
: `conflicts=无法本地预检(${analysis.conflicts.error})`
|
|
785
|
+
);
|
|
786
|
+
console.log(`overlap(双方都改过的文件)=${analysis.overlap.length ? analysis.overlap.join(', ') : '无'}`);
|
|
787
|
+
if (analysis.overlap.length && !analysis.conflicts.files.length) {
|
|
788
|
+
console.log('提示:文本可自动合并,但双方改了同一批文件,仍需人工检查语义冲突。');
|
|
789
|
+
}
|
|
790
|
+
if (mergeStatus === 'conflicts' && analysis.conflicts.supported && !analysis.conflicts.files.length) {
|
|
791
|
+
console.log('提示:服务端仍标记 conflicts,本地预检可能基于过期 refs;重新 fetch 或等待服务端刷新。');
|
|
792
|
+
}
|
|
793
|
+
return result;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
async function whoami(t, pat) {
|
|
797
|
+
// 部分版本(如 ADS 2020 / api-version 6.0)的 connectionData 要求预览版 API 标志,失败自动补 -preview 重试
|
|
798
|
+
const hit = (v) => request(t, pat, 'GET', `/_apis/connectionData?api-version=${v}`, undefined, {
|
|
799
|
+
projectLevel: false,
|
|
800
|
+
});
|
|
801
|
+
let data;
|
|
802
|
+
try {
|
|
803
|
+
data = await hit(apiVersion);
|
|
804
|
+
} catch (e) {
|
|
805
|
+
if (e instanceof ApiError && e.status === 400 && /preview|预览/i.test(e.message)) {
|
|
806
|
+
data = await hit(`${apiVersion}-preview`);
|
|
807
|
+
} else {
|
|
808
|
+
throw e;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
const u = data.authenticatedUser || {};
|
|
812
|
+
const result = {
|
|
813
|
+
id: u.id || '',
|
|
814
|
+
displayName: u.displayName || u.providerDisplayName || '',
|
|
815
|
+
uniqueName: u.uniqueName || '',
|
|
816
|
+
base: t.base,
|
|
817
|
+
project: t.project,
|
|
818
|
+
repo: t.repo,
|
|
819
|
+
prPage: t.prPage,
|
|
820
|
+
};
|
|
821
|
+
if (json) {
|
|
822
|
+
printJson(result);
|
|
823
|
+
return result;
|
|
824
|
+
}
|
|
825
|
+
console.log(`authenticated: ${result.displayName || '(未知)'} <${result.uniqueName || '?'}>`);
|
|
826
|
+
console.log(`base=${result.base} project=${result.project} repo=${result.repo}`);
|
|
827
|
+
console.log(`prPage=${result.prPage}`);
|
|
828
|
+
return result;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
function userEnvPresence(name) {
|
|
832
|
+
if (process.platform !== 'win32') return null;
|
|
833
|
+
const r = spawnSync(
|
|
834
|
+
'powershell',
|
|
835
|
+
['-NoProfile', '-Command', `[Environment]::GetEnvironmentVariable('${name}','User') -ne $null`],
|
|
836
|
+
{ encoding: 'utf8' }
|
|
837
|
+
);
|
|
838
|
+
if (r.status !== 0) return null;
|
|
839
|
+
return r.stdout.trim().toLowerCase() === 'true';
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function setup(t) {
|
|
843
|
+
const keys = patEnvKeys(t);
|
|
844
|
+
const hostKey = keys.length > 1 ? keys[0] : '';
|
|
845
|
+
const stateOf = (name) => {
|
|
846
|
+
const user = userEnvPresence(name);
|
|
847
|
+
return `${name}: 进程${process.env[name] ? 'set' : 'unset'}${user === null ? '' : ` / 用户级${user ? 'set' : 'unset'}`}`;
|
|
848
|
+
};
|
|
849
|
+
console.log(`target: base=${t.base} project=${t.project} repo=${t.repo}`);
|
|
850
|
+
if (t.remote) console.log(`remote: ${t.remote} ${t.remoteUrl}`);
|
|
851
|
+
console.log(`PAT 状态: ${stateOf('TFS_PAT')}${hostKey ? `;${stateOf(hostKey)}(${hostKey} 命中优先)` : ''}`);
|
|
852
|
+
console.log(`PAT 门户: ${t.tokenUrl}`);
|
|
853
|
+
console.log('scopes: Code (Read & Write) + Pull Request (Read & Write)');
|
|
854
|
+
console.log(hostKey
|
|
855
|
+
? `Windows 持久化: setx ${hostKey} "<PAT>"(多台服务器按主机分存;单台也可 setx TFS_PAT "<PAT>")——新开终端后生效`
|
|
856
|
+
: 'Windows 持久化: setx TFS_PAT "<PAT>" (新开终端后生效)');
|
|
857
|
+
console.log('Linux/macOS: 在 ~/.bashrc 或 ~/.zshrc 中 export <变量名>="<PAT>",重开终端');
|
|
858
|
+
console.log(`自检: node "${scriptPath}" whoami`);
|
|
859
|
+
console.log('目标分支固化(可选): git config tfs-pr.target <branch>');
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
function usage() {
|
|
863
|
+
console.log(`tfs-pr — 内网 TFS / Azure DevOps Server PR 工具
|
|
864
|
+
|
|
865
|
+
用法(脚本位于本技能目录 scripts/tfs-pr.mjs):
|
|
866
|
+
target | --print-target 解析并打印 base/project/repo/remote(不发请求)
|
|
867
|
+
setup 打印 PAT 配置指引(门户地址由 base 推导)
|
|
868
|
+
whoami 验证 PAT 并显示当前身份
|
|
869
|
+
list [--source b] [--target b] [--status active|all] [--json]
|
|
870
|
+
get <id> [--json]
|
|
871
|
+
context [--source b] [--target b] [--no-fetch] [--patch] [--json]
|
|
872
|
+
create [--source b] [--target b] --title t --body-file f|- [--dry-run] [--json]
|
|
873
|
+
desc <id> --body-file f|- [--dry-run] [--json]
|
|
874
|
+
conflicts <id> [--no-fetch] [--json]
|
|
875
|
+
conflicts --source b --target b [--no-fetch] [--json]
|
|
876
|
+
|
|
877
|
+
通用选项: --base --project --repo --remote --api-version --verbose --pat-file
|
|
878
|
+
环境变量: TFS_PAT(可按主机分存 TFS_PAT_<HOST>,命中优先) TFS_BASE TFS_PROJECT TFS_REPO TFS_REMOTE TFS_WEB_PORT TFS_WEB_SCHEME TFS_API_VERSION TFS_TARGET TFS_SOURCE
|
|
879
|
+
退出码: 0 成功 / 1 HTTP/API/网络错误 / 2 用法或配置错误`);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// ---------- 入口 ----------
|
|
883
|
+
async function main() {
|
|
884
|
+
if (flag('--help') || flag('-h')) {
|
|
885
|
+
usage();
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
if (flag('--print-target') || cmd === 'target') {
|
|
889
|
+
printJson(resolveTarget());
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
if (!cmd) {
|
|
893
|
+
usage();
|
|
894
|
+
process.exitCode = 2;
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
const known = new Set(['setup', 'whoami', 'list', 'get', 'create', 'desc', 'context', 'conflicts']);
|
|
899
|
+
if (!known.has(cmd)) throw new UsageError(`未知子命令:${cmd}(可用:${[...known].join(', ')})`);
|
|
900
|
+
|
|
901
|
+
const t = resolveTarget();
|
|
902
|
+
if (cmd === 'setup') {
|
|
903
|
+
setup(t);
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
if (cmd === 'context') {
|
|
907
|
+
const c = buildContext(t);
|
|
908
|
+
if (json) printJson(c);
|
|
909
|
+
else printContext(c);
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
// 位置参数 PR id:只认未被带值 flag 消费的独立数字参数——`conflicts --source 123 --target x` 的
|
|
914
|
+
// 123 是 flag 值不是 id(2026-10-24 复核 E4:纯数字分支名曾被误判进 PR-id 模式发 HTTP)
|
|
915
|
+
const VALUE_FLAGS = new Set(['--source', '--target', '--body-file', '--base', '--project', '--repo', '--remote', '--status', '--limit', '--api-version', '--pat-file']);
|
|
916
|
+
let idArg = '';
|
|
917
|
+
for (let i = 1; i < argv.length; i++) {
|
|
918
|
+
const a = argv[i];
|
|
919
|
+
if (a.startsWith('--')) {
|
|
920
|
+
if (VALUE_FLAGS.has(a) && !a.includes('=')) i++; // 空格分隔的带值 flag 连值一起跳
|
|
921
|
+
continue;
|
|
922
|
+
}
|
|
923
|
+
if (/^\d+$/.test(a)) { idArg = a; break; }
|
|
924
|
+
}
|
|
925
|
+
if ((cmd === 'get' || cmd === 'desc') && !idArg) throw new UsageError(`${cmd} 需要一个数字 PR id`);
|
|
926
|
+
|
|
927
|
+
const dryRun = flag('--dry-run') && (cmd === 'create' || cmd === 'desc');
|
|
928
|
+
const localConflicts = cmd === 'conflicts' && !idArg;
|
|
929
|
+
const pat = dryRun || localConflicts ? '' : resolvePat(t);
|
|
930
|
+
|
|
931
|
+
if (cmd === 'whoami') await whoami(t, pat);
|
|
932
|
+
else if (cmd === 'list') await listPrs(t, pat);
|
|
933
|
+
else if (cmd === 'get') await getPr(t, pat, idArg);
|
|
934
|
+
else if (cmd === 'create') await createPr(t, pat);
|
|
935
|
+
else if (cmd === 'desc') await updateDesc(t, pat, idArg);
|
|
936
|
+
else if (cmd === 'conflicts') await conflicts(t, pat, idArg);
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
main().catch((e) => {
|
|
940
|
+
if (e instanceof UsageError) die(e.message, 2);
|
|
941
|
+
if (e instanceof ApiError) {
|
|
942
|
+
console.error(`tfs-pr: ${e.message}`);
|
|
943
|
+
if (e.hint) console.error(`tfs-pr: ${e.hint}`);
|
|
944
|
+
process.exit(1);
|
|
945
|
+
}
|
|
946
|
+
die(`未预期错误:${e && e.stack ? e.stack : e}`, 1);
|
|
947
|
+
});
|