@punks/cli 2.1.10 → 2.2.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/README.md +3 -1
- package/dist/index.js +0 -0
- package/package.json +1 -1
- package/dist/data/AGENTS.md +0 -119
- package/dist/data/catalog/hooks.ts +0 -26
- package/dist/data/catalog/lint.ts +0 -266
- package/dist/data/catalog/packs.ts +0 -320
- package/dist/data/catalog/skills.ts +0 -441
- package/dist/data/catalog/tools.ts +0 -48
- package/dist/data/control-plane.json +0 -3
- package/dist/data/hooks/format-edited-file.mjs +0 -699
- package/dist/data/hooks/format-edited-file.sh +0 -37
- package/dist/data/hooks/require-tests-for-pr.mjs +0 -206
- package/dist/data/hooks/scaffold-update-check.mjs +0 -181
- package/dist/data/hooks.test.ts +0 -109
- package/dist/data/scripts/sync-subagents.mjs +0 -491
- package/dist/data/subagents/manifest.mjs +0 -487
- package/dist/data/subagents/manifest.test.ts +0 -40
- package/dist/skills/agnostic/backend/backend-domain-structure/SKILL.md +0 -50
- package/dist/skills/agnostic/backend/backend-domain-structure/agents/openai.yaml +0 -4
- package/dist/skills/agnostic/backend/backend-domain-structure/references/layout.md +0 -167
- package/dist/skills/agnostic/backend/backend-recoverable-actions/SKILL.md +0 -49
- package/dist/skills/agnostic/backend/backend-recoverable-actions/agents/openai.yaml +0 -4
- package/dist/skills/agnostic/backend/backend-recoverable-actions/references/strategy-matrix.md +0 -34
- package/dist/skills/agnostic/backend/backend-recoverable-actions/references/test-matrix.md +0 -34
- package/dist/skills/agnostic/backend/logging-best-practices/SKILL.md +0 -127
- package/dist/skills/agnostic/backend/logging-best-practices/rules/context.md +0 -157
- package/dist/skills/agnostic/backend/logging-best-practices/rules/pitfalls.md +0 -118
- package/dist/skills/agnostic/backend/logging-best-practices/rules/structure.md +0 -193
- package/dist/skills/agnostic/backend/logging-best-practices/rules/wide-events.md +0 -113
- package/dist/skills/agnostic/cli/dp-cli/SKILL.md +0 -125
- package/dist/skills/agnostic/cli/dp-cli/references/commands.md +0 -70
- package/dist/skills/agnostic/cli/dp-cli/references/post-command-flow.md +0 -70
- package/dist/skills/agnostic/debug/debug-agent/SKILL.md +0 -184
- package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +0 -46
- package/dist/skills/agnostic/docs/docs-onboarding/agents/openai.yaml +0 -4
- package/dist/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +0 -67
- package/dist/skills/agnostic/docs/upstream/mattpocock-writing-skills.md +0 -41
- package/dist/skills/agnostic/docs/writing-beats/SKILL.md +0 -69
- package/dist/skills/agnostic/docs/writing-fragments/SKILL.md +0 -76
- package/dist/skills/agnostic/docs/writing-shape/SKILL.md +0 -75
- package/dist/skills/agnostic/frontend/agent-browser/.clawdhub/origin.json +0 -7
- package/dist/skills/agnostic/frontend/agent-browser/SKILL.md +0 -229
- package/dist/skills/agnostic/frontend/agent-browser/references/authentication.md +0 -202
- package/dist/skills/agnostic/frontend/agent-browser/references/commands.md +0 -259
- package/dist/skills/agnostic/frontend/agent-browser/references/proxy-support.md +0 -188
- package/dist/skills/agnostic/frontend/agent-browser/references/session-management.md +0 -193
- package/dist/skills/agnostic/frontend/agent-browser/references/snapshot-refs.md +0 -194
- package/dist/skills/agnostic/frontend/agent-browser/references/video-recording.md +0 -173
- package/dist/skills/agnostic/frontend/agent-browser/templates/authenticated-session.sh +0 -97
- package/dist/skills/agnostic/frontend/agent-browser/templates/capture-workflow.sh +0 -69
- package/dist/skills/agnostic/frontend/agent-browser/templates/form-automation.sh +0 -62
- package/dist/skills/agnostic/frontend/design-taste-frontend/SKILL.md +0 -226
- package/dist/skills/agnostic/frontend/frontend-domain-structure/SKILL.md +0 -55
- package/dist/skills/agnostic/frontend/frontend-domain-structure/agents/openai.yaml +0 -4
- package/dist/skills/agnostic/frontend/frontend-domain-structure/references/react/structure.md +0 -102
- package/dist/skills/agnostic/frontend/frontend-domain-structure/references/structure.md +0 -257
- package/dist/skills/agnostic/frontend/gpt-taste/SKILL.md +0 -74
- package/dist/skills/agnostic/frontend/image-taste-frontend/SKILL.md +0 -1102
- package/dist/skills/agnostic/frontend/redesign-existing-projects/SKILL.md +0 -178
- package/dist/skills/agnostic/planning/create-plan/REFERENCE.md +0 -37
- package/dist/skills/agnostic/planning/create-plan/SKILL.md +0 -87
- package/dist/skills/agnostic/planning/create-plan/references/backlog-sync.md +0 -44
- package/dist/skills/agnostic/planning/create-plan/references/grill-phase.md +0 -87
- package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +0 -70
- package/dist/skills/agnostic/planning/create-plan/references/planner-phase.md +0 -42
- package/dist/skills/agnostic/planning/create-plan/references/stop-conditions.md +0 -18
- package/dist/skills/agnostic/planning/create-plan/references/tdd-phase.md +0 -26
- package/dist/skills/agnostic/planning/create-spec/SKILL.md +0 -110
- package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +0 -91
- package/dist/skills/agnostic/planning/create-spec/references/backlog-sync.md +0 -49
- package/dist/skills/agnostic/planning/create-spec/references/discovery.md +0 -54
- package/dist/skills/agnostic/planning/create-spec/references/folder-naming.md +0 -33
- package/dist/skills/agnostic/planning/create-spec/references/grill-phase.md +0 -47
- package/dist/skills/agnostic/planning/create-spec/references/handoff.md +0 -47
- package/dist/skills/agnostic/planning/create-spec/references/questioning.md +0 -51
- package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +0 -58
- package/dist/skills/agnostic/planning/create-spec/references/wiki-bookkeeping.md +0 -50
- package/dist/skills/agnostic/planning/grill-me/SKILL.md +0 -28
- package/dist/skills/agnostic/planning/implement-spec/SKILL.md +0 -99
- package/dist/skills/agnostic/planning/implement-spec/assets/IMPLEMENTATION-NOTES-TEMPLATE.md +0 -53
- package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +0 -193
- package/dist/skills/agnostic/planning/implement-spec/references/parallel-orchestration.md +0 -102
- package/dist/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +0 -67
- package/dist/skills/agnostic/planning/implement-spec/references/parallel.md +0 -56
- package/dist/skills/agnostic/planning/implement-spec/references/sequential.md +0 -38
- package/dist/skills/agnostic/planning/stack/SKILL.md +0 -89
- package/dist/skills/agnostic/planning/swarm-planner/SKILL.md +0 -179
- package/dist/skills/agnostic/quality/autoreview/SKILL.md +0 -191
- package/dist/skills/agnostic/quality/autoreview/scripts/autoreview +0 -1176
- package/dist/skills/agnostic/quality/autoreview/scripts/test-review-harness +0 -176
- package/dist/skills/agnostic/quality/simplify/SKILL.md +0 -14
- package/dist/skills/agnostic/quality/tdd/SKILL.md +0 -107
- package/dist/skills/agnostic/quality/tdd/deep-modules.md +0 -33
- package/dist/skills/agnostic/quality/tdd/interface-design.md +0 -31
- package/dist/skills/agnostic/quality/tdd/mocking.md +0 -59
- package/dist/skills/agnostic/quality/tdd/refactoring.md +0 -10
- package/dist/skills/agnostic/quality/tdd/tests.md +0 -61
- package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +0 -43
- package/dist/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +0 -157
- package/dist/skills/agnostic/requirements/requirements-grill/references/grilling-flow.md +0 -69
- package/dist/skills/agnostic/requirements/requirements-grill/references/wiki-output.md +0 -101
- package/dist/skills/agnostic/requirements/write-backlog/EXAMPLES.md +0 -67
- package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +0 -262
- package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +0 -71
- package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +0 -69
- package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/story-shape.md +0 -66
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +0 -63
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +0 -224
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +0 -76
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +0 -146
- package/dist/skills/agnostic/research/improve-codebase-architecture/REFERENCE.md +0 -78
- package/dist/skills/agnostic/research/improve-codebase-architecture/SKILL.md +0 -76
- package/dist/skills/agnostic/research/parallel-research/SKILL.md +0 -68
- package/dist/skills/agnostic/research/parallel-research/agents/openai.yaml +0 -4
- package/dist/skills/agnostic/subagents/swarm-planner/SKILL.md +0 -179
- package/dist/skills/agnostic/write-a-skill/SKILL.md +0 -117
- package/dist/skills/frameworks/better-auth/better-auth-best-practices/SKILL.md +0 -166
- package/dist/skills/frameworks/better-auth/better-auth-security-best-practices/SKILL.MD +0 -432
- package/dist/skills/frameworks/effect/effect-authoring/SKILL.md +0 -116
- package/dist/skills/frameworks/effect/effect-authoring/references/branded-types.md +0 -98
- package/dist/skills/frameworks/effect/effect-authoring/references/effect-atom-patterns.md +0 -257
- package/dist/skills/frameworks/effect/effect-authoring/references/effect-primitives.md +0 -144
- package/dist/skills/frameworks/effect/effect-authoring/references/error-patterns.md +0 -156
- package/dist/skills/frameworks/effect/effect-authoring/references/otel-patterns.md +0 -113
- package/dist/skills/frameworks/effect/effect-authoring/references/test-patterns.md +0 -146
- package/dist/skills/frameworks/effect/effect-backend-structure/SKILL.md +0 -96
- package/dist/skills/frameworks/effect/effect-backend-structure/agents/openai.yaml +0 -4
- package/dist/skills/frameworks/effect/effect-backend-structure/references/layout.md +0 -68
- package/dist/skills/frameworks/effect/effect-best-practices/SKILL.md +0 -517
- package/dist/skills/frameworks/effect/effect-best-practices/references/anti-patterns.md +0 -392
- package/dist/skills/frameworks/effect/effect-best-practices/references/effect-atom-patterns.md +0 -653
- package/dist/skills/frameworks/effect/effect-best-practices/references/error-patterns.md +0 -464
- package/dist/skills/frameworks/effect/effect-best-practices/references/language-server.md +0 -287
- package/dist/skills/frameworks/effect/effect-best-practices/references/layer-patterns.md +0 -495
- package/dist/skills/frameworks/effect/effect-best-practices/references/observability-patterns.md +0 -342
- package/dist/skills/frameworks/effect/effect-best-practices/references/rpc-cluster-patterns.md +0 -418
- package/dist/skills/frameworks/effect/effect-best-practices/references/schema-patterns.md +0 -353
- package/dist/skills/frameworks/effect/effect-best-practices/references/service-patterns.md +0 -299
- package/dist/skills/frameworks/effect/effect-recoverable-actions/SKILL.md +0 -65
- package/dist/skills/frameworks/effect/effect-recoverable-actions/agents/openai.yaml +0 -4
- package/dist/skills/frameworks/effect/effect-recoverable-actions/references/flow-examples.md +0 -154
- package/dist/skills/frameworks/effect/effect-recoverable-actions/references/source-backed-primitives.md +0 -104
- package/dist/skills/frameworks/effect/effect-recoverable-actions/references/strategy-matrix.md +0 -34
- package/dist/skills/frameworks/effect/effect-recoverable-actions/references/test-matrix.md +0 -36
- package/dist/skills/frameworks/elysia/elysiajs/SKILL.md +0 -475
- package/dist/skills/frameworks/elysia/elysiajs/examples/basic.ts +0 -9
- package/dist/skills/frameworks/elysia/elysiajs/examples/body-parser.ts +0 -33
- package/dist/skills/frameworks/elysia/elysiajs/examples/complex.ts +0 -112
- package/dist/skills/frameworks/elysia/elysiajs/examples/cookie.ts +0 -45
- package/dist/skills/frameworks/elysia/elysiajs/examples/error.ts +0 -38
- package/dist/skills/frameworks/elysia/elysiajs/examples/file.ts +0 -10
- package/dist/skills/frameworks/elysia/elysiajs/examples/guard.ts +0 -34
- package/dist/skills/frameworks/elysia/elysiajs/examples/map-response.ts +0 -15
- package/dist/skills/frameworks/elysia/elysiajs/examples/redirect.ts +0 -6
- package/dist/skills/frameworks/elysia/elysiajs/examples/rename.ts +0 -32
- package/dist/skills/frameworks/elysia/elysiajs/examples/schema.ts +0 -61
- package/dist/skills/frameworks/elysia/elysiajs/examples/state.ts +0 -6
- package/dist/skills/frameworks/elysia/elysiajs/examples/upload-file.ts +0 -20
- package/dist/skills/frameworks/elysia/elysiajs/examples/websocket.ts +0 -25
- package/dist/skills/frameworks/elysia/elysiajs/integrations/ai-sdk.md +0 -92
- package/dist/skills/frameworks/elysia/elysiajs/integrations/astro.md +0 -59
- package/dist/skills/frameworks/elysia/elysiajs/integrations/better-auth.md +0 -117
- package/dist/skills/frameworks/elysia/elysiajs/integrations/cloudflare-worker.md +0 -95
- package/dist/skills/frameworks/elysia/elysiajs/integrations/deno.md +0 -34
- package/dist/skills/frameworks/elysia/elysiajs/integrations/drizzle.md +0 -258
- package/dist/skills/frameworks/elysia/elysiajs/integrations/expo.md +0 -95
- package/dist/skills/frameworks/elysia/elysiajs/integrations/nextjs.md +0 -103
- package/dist/skills/frameworks/elysia/elysiajs/integrations/nodejs.md +0 -64
- package/dist/skills/frameworks/elysia/elysiajs/integrations/nuxt.md +0 -67
- package/dist/skills/frameworks/elysia/elysiajs/integrations/prisma.md +0 -93
- package/dist/skills/frameworks/elysia/elysiajs/integrations/react-email.md +0 -134
- package/dist/skills/frameworks/elysia/elysiajs/integrations/sveltekit.md +0 -53
- package/dist/skills/frameworks/elysia/elysiajs/integrations/tanstack-start.md +0 -87
- package/dist/skills/frameworks/elysia/elysiajs/integrations/vercel.md +0 -55
- package/dist/skills/frameworks/elysia/elysiajs/patterns/mvc.md +0 -380
- package/dist/skills/frameworks/elysia/elysiajs/plugins/bearer.md +0 -30
- package/dist/skills/frameworks/elysia/elysiajs/plugins/cors.md +0 -141
- package/dist/skills/frameworks/elysia/elysiajs/plugins/cron.md +0 -265
- package/dist/skills/frameworks/elysia/elysiajs/plugins/graphql-apollo.md +0 -90
- package/dist/skills/frameworks/elysia/elysiajs/plugins/graphql-yoga.md +0 -87
- package/dist/skills/frameworks/elysia/elysiajs/plugins/html.md +0 -188
- package/dist/skills/frameworks/elysia/elysiajs/plugins/jwt.md +0 -197
- package/dist/skills/frameworks/elysia/elysiajs/plugins/openapi.md +0 -246
- package/dist/skills/frameworks/elysia/elysiajs/plugins/opentelemetry.md +0 -167
- package/dist/skills/frameworks/elysia/elysiajs/plugins/server-timing.md +0 -71
- package/dist/skills/frameworks/elysia/elysiajs/plugins/static.md +0 -84
- package/dist/skills/frameworks/elysia/elysiajs/references/bun-fullstack-dev-server.md +0 -129
- package/dist/skills/frameworks/elysia/elysiajs/references/cookie.md +0 -187
- package/dist/skills/frameworks/elysia/elysiajs/references/deployment.md +0 -413
- package/dist/skills/frameworks/elysia/elysiajs/references/eden.md +0 -158
- package/dist/skills/frameworks/elysia/elysiajs/references/lifecycle.md +0 -198
- package/dist/skills/frameworks/elysia/elysiajs/references/macro.md +0 -83
- package/dist/skills/frameworks/elysia/elysiajs/references/plugin.md +0 -207
- package/dist/skills/frameworks/elysia/elysiajs/references/route.md +0 -331
- package/dist/skills/frameworks/elysia/elysiajs/references/testing.md +0 -385
- package/dist/skills/frameworks/elysia/elysiajs/references/validation.md +0 -491
- package/dist/skills/frameworks/elysia/elysiajs/references/websocket.md +0 -250
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/.github/workflows/branch-protection.yml +0 -24
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/.github/workflows/deploy.yml +0 -61
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/AGENTS.md +0 -5958
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/SKILL.md +0 -130
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/api-use-dto-serialization.md +0 -182
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/api-use-interceptors.md +0 -202
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/api-use-pipes.md +0 -205
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/api-versioning.md +0 -191
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-avoid-circular-deps.md +0 -80
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-feature-modules.md +0 -82
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-module-sharing.md +0 -141
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-single-responsibility.md +0 -106
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-use-events.md +0 -108
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-use-repository-pattern.md +0 -97
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/db-avoid-n-plus-one.md +0 -139
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/db-use-migrations.md +0 -129
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/db-use-transactions.md +0 -140
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/devops-graceful-shutdown.md +0 -222
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/devops-use-config-module.md +0 -167
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/devops-use-logging.md +0 -232
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-avoid-service-locator.md +0 -104
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-interface-segregation.md +0 -165
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-liskov-substitution.md +0 -221
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-prefer-constructor-injection.md +0 -86
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-scope-awareness.md +0 -94
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-use-interfaces-tokens.md +0 -101
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/error-handle-async-errors.md +0 -125
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/error-throw-http-exceptions.md +0 -114
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/error-use-exception-filters.md +0 -140
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/micro-use-health-checks.md +0 -226
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/micro-use-patterns.md +0 -167
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/micro-use-queues.md +0 -252
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/perf-async-hooks.md +0 -109
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/perf-lazy-loading.md +0 -121
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/perf-optimize-database.md +0 -131
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/perf-use-caching.md +0 -128
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-auth-jwt.md +0 -146
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-rate-limiting.md +0 -125
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-sanitize-output.md +0 -139
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-use-guards.md +0 -135
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-validate-all-input.md +0 -150
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/test-e2e-supertest.md +0 -178
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/test-mock-external-services.md +0 -179
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/test-use-testing-module.md +0 -153
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/scripts/build-agents.ts +0 -299
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/scripts/build.sh +0 -16
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/scripts/package-lock.json +0 -237
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/scripts/package.json +0 -15
- package/dist/skills/frameworks/nestjs/nestjs-expert/SKILL.md +0 -208
- package/dist/skills/frameworks/nestjs/nestjs-expert/references/authentication.md +0 -166
- package/dist/skills/frameworks/nestjs/nestjs-expert/references/controllers-routing.md +0 -111
- package/dist/skills/frameworks/nestjs/nestjs-expert/references/dtos-validation.md +0 -153
- package/dist/skills/frameworks/nestjs/nestjs-expert/references/migration-from-express.md +0 -1237
- package/dist/skills/frameworks/nestjs/nestjs-expert/references/services-di.md +0 -140
- package/dist/skills/frameworks/nestjs/nestjs-expert/references/testing-patterns.md +0 -186
- package/dist/skills/frameworks/nextjs/next-best-practices/SKILL.md +0 -153
- package/dist/skills/frameworks/nextjs/next-best-practices/async-patterns.md +0 -87
- package/dist/skills/frameworks/nextjs/next-best-practices/bundling.md +0 -180
- package/dist/skills/frameworks/nextjs/next-best-practices/data-patterns.md +0 -297
- package/dist/skills/frameworks/nextjs/next-best-practices/debug-tricks.md +0 -105
- package/dist/skills/frameworks/nextjs/next-best-practices/directives.md +0 -73
- package/dist/skills/frameworks/nextjs/next-best-practices/error-handling.md +0 -227
- package/dist/skills/frameworks/nextjs/next-best-practices/file-conventions.md +0 -140
- package/dist/skills/frameworks/nextjs/next-best-practices/font.md +0 -245
- package/dist/skills/frameworks/nextjs/next-best-practices/functions.md +0 -108
- package/dist/skills/frameworks/nextjs/next-best-practices/hydration-error.md +0 -91
- package/dist/skills/frameworks/nextjs/next-best-practices/image.md +0 -173
- package/dist/skills/frameworks/nextjs/next-best-practices/metadata.md +0 -301
- package/dist/skills/frameworks/nextjs/next-best-practices/parallel-routes.md +0 -287
- package/dist/skills/frameworks/nextjs/next-best-practices/route-handlers.md +0 -146
- package/dist/skills/frameworks/nextjs/next-best-practices/rsc-boundaries.md +0 -159
- package/dist/skills/frameworks/nextjs/next-best-practices/runtime-selection.md +0 -39
- package/dist/skills/frameworks/nextjs/next-best-practices/scripts.md +0 -141
- package/dist/skills/frameworks/nextjs/next-best-practices/self-hosting.md +0 -371
- package/dist/skills/frameworks/nextjs/next-best-practices/suspense-boundaries.md +0 -67
- package/dist/skills/frameworks/nextjs/next-cache-components/SKILL.md +0 -360
- package/dist/skills/frameworks/react/async-react-patterns/SKILL.md +0 -78
- package/dist/skills/frameworks/react/vercel-composition-patterns/AGENTS.md +0 -946
- package/dist/skills/frameworks/react/vercel-composition-patterns/SKILL.md +0 -89
- package/dist/skills/frameworks/react/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +0 -100
- package/dist/skills/frameworks/react/vercel-composition-patterns/rules/architecture-compound-components.md +0 -112
- package/dist/skills/frameworks/react/vercel-composition-patterns/rules/patterns-children-over-render-props.md +0 -87
- package/dist/skills/frameworks/react/vercel-composition-patterns/rules/patterns-explicit-variants.md +0 -100
- package/dist/skills/frameworks/react/vercel-composition-patterns/rules/react19-no-forwardref.md +0 -42
- package/dist/skills/frameworks/react/vercel-composition-patterns/rules/state-context-interface.md +0 -191
- package/dist/skills/frameworks/react/vercel-composition-patterns/rules/state-decouple-implementation.md +0 -113
- package/dist/skills/frameworks/react/vercel-composition-patterns/rules/state-lift-state.md +0 -125
- package/dist/skills/frameworks/react/vercel-react-best-practices/AGENTS.md +0 -3750
- package/dist/skills/frameworks/react/vercel-react-best-practices/SKILL.md +0 -148
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/advanced-effect-event-deps.md +0 -56
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/advanced-event-handler-refs.md +0 -55
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/advanced-init-once.md +0 -42
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/advanced-use-latest.md +0 -39
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-api-routes.md +0 -38
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-cheap-condition-before-await.md +0 -37
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-defer-await.md +0 -82
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-dependencies.md +0 -51
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-parallel.md +0 -28
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-suspense-boundaries.md +0 -99
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-barrel-imports.md +0 -60
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-conditional.md +0 -31
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-defer-third-party.md +0 -49
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-dynamic-imports.md +0 -35
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-preload.md +0 -50
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/client-event-listeners.md +0 -74
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/client-localstorage-schema.md +0 -71
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/client-passive-event-listeners.md +0 -48
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/client-swr-dedup.md +0 -56
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-batch-dom-css.md +0 -107
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-cache-function-results.md +0 -80
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-cache-property-access.md +0 -28
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-cache-storage.md +0 -70
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-combine-iterations.md +0 -32
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-early-exit.md +0 -50
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-flatmap-filter.md +0 -60
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-hoist-regexp.md +0 -45
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-index-maps.md +0 -37
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-length-check-first.md +0 -49
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-min-max-loop.md +0 -82
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-request-idle-callback.md +0 -105
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-set-map-lookups.md +0 -24
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-tosorted-immutable.md +0 -57
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-activity.md +0 -26
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +0 -47
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-conditional-render.md +0 -40
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-content-visibility.md +0 -38
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-hoist-jsx.md +0 -46
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +0 -82
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +0 -30
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-resource-hints.md +0 -85
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-script-defer-async.md +0 -68
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-svg-precision.md +0 -28
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-usetransition-loading.md +0 -75
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-defer-reads.md +0 -39
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-dependencies.md +0 -45
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +0 -40
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-derived-state.md +0 -29
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-functional-setstate.md +0 -74
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-lazy-state-init.md +0 -58
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +0 -38
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-memo.md +0 -44
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +0 -45
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-no-inline-components.md +0 -82
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +0 -35
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-split-combined-hooks.md +0 -64
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-transitions.md +0 -40
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-use-deferred-value.md +0 -59
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +0 -73
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-after-nonblocking.md +0 -73
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-auth-actions.md +0 -96
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-cache-lru.md +0 -41
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-cache-react.md +0 -76
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-dedup-props.md +0 -65
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-hoist-static-io.md +0 -149
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-no-shared-module-state.md +0 -50
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-parallel-fetching.md +0 -83
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-parallel-nested-fetching.md +0 -34
- package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-serialization.md +0 -38
- package/dist/skills/frameworks/tanstack-query/tanstack-query/.claude-plugin/plugin.json +0 -12
- package/dist/skills/frameworks/tanstack-query/tanstack-query/SKILL.md +0 -849
- package/dist/skills/frameworks/tanstack-query/tanstack-query/assets/example-template.txt +0 -14
- package/dist/skills/frameworks/tanstack-query/tanstack-query/references/best-practices.md +0 -304
- package/dist/skills/frameworks/tanstack-query/tanstack-query/references/common-patterns.md +0 -271
- package/dist/skills/frameworks/tanstack-query/tanstack-query/references/example-reference.md +0 -26
- package/dist/skills/frameworks/tanstack-query/tanstack-query/references/testing.md +0 -282
- package/dist/skills/frameworks/tanstack-query/tanstack-query/references/top-errors.md +0 -332
- package/dist/skills/frameworks/tanstack-query/tanstack-query/references/typescript-patterns.md +0 -291
- package/dist/skills/frameworks/tanstack-query/tanstack-query/references/v4-to-v5-migration.md +0 -231
- package/dist/skills/frameworks/tanstack-query/tanstack-query/rules/tanstack-query.md +0 -126
- package/dist/skills/frameworks/tanstack-query/tanstack-query/scripts/example-script.sh +0 -15
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/custom-hooks-pattern.tsx +0 -281
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/devtools-setup.tsx +0 -248
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/error-boundary.tsx +0 -243
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/package.json +0 -31
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/provider-setup.tsx +0 -50
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/query-client-config.ts +0 -72
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/use-infinite-query.tsx +0 -214
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/use-mutation-basic.tsx +0 -201
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/use-mutation-optimistic.tsx +0 -234
- package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/use-query-basic.tsx +0 -119
- package/dist/skills/frameworks/tanstack-start/tanstack-start/SKILL.md +0 -250
- package/dist/skills/frameworks/trpc/tanstack-query/.claude-plugin/plugin.json +0 -12
- package/dist/skills/frameworks/trpc/tanstack-query/SKILL.md +0 -1058
- package/dist/skills/frameworks/trpc/tanstack-query/assets/example-template.txt +0 -14
- package/dist/skills/frameworks/trpc/tanstack-query/references/best-practices.md +0 -304
- package/dist/skills/frameworks/trpc/tanstack-query/references/common-patterns.md +0 -271
- package/dist/skills/frameworks/trpc/tanstack-query/references/example-reference.md +0 -26
- package/dist/skills/frameworks/trpc/tanstack-query/references/testing.md +0 -282
- package/dist/skills/frameworks/trpc/tanstack-query/references/top-errors.md +0 -332
- package/dist/skills/frameworks/trpc/tanstack-query/references/typescript-patterns.md +0 -291
- package/dist/skills/frameworks/trpc/tanstack-query/references/v4-to-v5-migration.md +0 -231
- package/dist/skills/frameworks/trpc/tanstack-query/rules/tanstack-query.md +0 -126
- package/dist/skills/frameworks/trpc/tanstack-query/scripts/example-script.sh +0 -15
- package/dist/skills/frameworks/trpc/tanstack-query/templates/custom-hooks-pattern.tsx +0 -281
- package/dist/skills/frameworks/trpc/tanstack-query/templates/devtools-setup.tsx +0 -248
- package/dist/skills/frameworks/trpc/tanstack-query/templates/error-boundary.tsx +0 -243
- package/dist/skills/frameworks/trpc/tanstack-query/templates/package.json +0 -31
- package/dist/skills/frameworks/trpc/tanstack-query/templates/provider-setup.tsx +0 -50
- package/dist/skills/frameworks/trpc/tanstack-query/templates/query-client-config.ts +0 -72
- package/dist/skills/frameworks/trpc/tanstack-query/templates/use-infinite-query.tsx +0 -214
- package/dist/skills/frameworks/trpc/tanstack-query/templates/use-mutation-basic.tsx +0 -201
- package/dist/skills/frameworks/trpc/tanstack-query/templates/use-mutation-optimistic.tsx +0 -234
- package/dist/skills/frameworks/trpc/tanstack-query/templates/use-query-basic.tsx +0 -119
- package/dist/skills/frameworks/turborepo/turborepo/SKILL.md +0 -914
- package/dist/skills/frameworks/turborepo/turborepo/command/turborepo.md +0 -70
- package/dist/skills/frameworks/turborepo/turborepo/references/best-practices/RULE.md +0 -241
- package/dist/skills/frameworks/turborepo/turborepo/references/best-practices/dependencies.md +0 -246
- package/dist/skills/frameworks/turborepo/turborepo/references/best-practices/packages.md +0 -335
- package/dist/skills/frameworks/turborepo/turborepo/references/best-practices/structure.md +0 -270
- package/dist/skills/frameworks/turborepo/turborepo/references/boundaries/RULE.md +0 -126
- package/dist/skills/frameworks/turborepo/turborepo/references/caching/RULE.md +0 -107
- package/dist/skills/frameworks/turborepo/turborepo/references/caching/gotchas.md +0 -169
- package/dist/skills/frameworks/turborepo/turborepo/references/caching/remote-cache.md +0 -127
- package/dist/skills/frameworks/turborepo/turborepo/references/ci/RULE.md +0 -79
- package/dist/skills/frameworks/turborepo/turborepo/references/ci/github-actions.md +0 -162
- package/dist/skills/frameworks/turborepo/turborepo/references/ci/patterns.md +0 -145
- package/dist/skills/frameworks/turborepo/turborepo/references/ci/vercel.md +0 -103
- package/dist/skills/frameworks/turborepo/turborepo/references/cli/RULE.md +0 -100
- package/dist/skills/frameworks/turborepo/turborepo/references/cli/commands.md +0 -297
- package/dist/skills/frameworks/turborepo/turborepo/references/configuration/RULE.md +0 -211
- package/dist/skills/frameworks/turborepo/turborepo/references/configuration/global-options.md +0 -187
- package/dist/skills/frameworks/turborepo/turborepo/references/configuration/gotchas.md +0 -348
- package/dist/skills/frameworks/turborepo/turborepo/references/configuration/tasks.md +0 -285
- package/dist/skills/frameworks/turborepo/turborepo/references/environment/RULE.md +0 -96
- package/dist/skills/frameworks/turborepo/turborepo/references/environment/gotchas.md +0 -141
- package/dist/skills/frameworks/turborepo/turborepo/references/environment/modes.md +0 -101
- package/dist/skills/frameworks/turborepo/turborepo/references/filtering/RULE.md +0 -148
- package/dist/skills/frameworks/turborepo/turborepo/references/filtering/patterns.md +0 -152
- package/dist/skills/frameworks/turborepo/turborepo/references/watch/RULE.md +0 -99
- package/dist/skills/languages/python/async-python-patterns/SKILL.md +0 -735
- package/dist/skills/languages/python/python-code-style/SKILL.md +0 -360
- package/dist/skills/languages/python/python-design-patterns/SKILL.md +0 -433
- package/dist/skills/languages/python/python-project-structure/SKILL.md +0 -252
- package/dist/skills/languages/python/python-testing-patterns/SKILL.md +0 -622
- package/dist/skills/languages/python/python-testing-patterns/references/advanced-patterns.md +0 -411
- package/dist/skills/languages/typescript/quality-types/SKILL.md +0 -93
- package/dist/skills/phases/bug-discovery-phase/REFERENCE.md +0 -140
- package/dist/skills/phases/bug-discovery-phase/SKILL.md +0 -78
- package/dist/skills/phases/bug-resolution-phase/REFERENCE.md +0 -160
- package/dist/skills/phases/bug-resolution-phase/SKILL.md +0 -64
- package/dist/skills/phases/debugging-phase/SKILL.md +0 -87
- package/dist/skills/phases/delivery-phase/SKILL.md +0 -87
- package/dist/skills/phases/docs-ingest-phase/SKILL.md +0 -96
- package/dist/skills/phases/docs-ingest-phase/agents/openai.yaml +0 -4
- package/dist/skills/phases/docs-ingest-phase/references/concept-pages.md +0 -70
- package/dist/skills/phases/docs-ingest-phase/references/flow-pages.md +0 -56
- package/dist/skills/phases/docs-ingest-phase/references/fumadocs-routing.md +0 -74
- package/dist/skills/phases/docs-ingest-phase/references/public-docs.md +0 -82
- package/dist/skills/phases/docs-ingest-phase/references/repo-docs.md +0 -38
- package/dist/skills/phases/docs-ingest-phase/references/wiki-ingest.md +0 -133
- package/dist/skills/phases/goalify/EXAMPLES.md +0 -78
- package/dist/skills/phases/goalify/SKILL.md +0 -129
- package/dist/skills/phases/requirements-phase/SKILL.md +0 -69
- package/dist/skills/phases/resolve-debt-phase/SKILL.md +0 -87
- package/dist/skills/phases/review-phase/SKILL.md +0 -116
|
@@ -1,1176 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
import argparse
|
|
5
|
-
import concurrent.futures
|
|
6
|
-
import copy
|
|
7
|
-
import json
|
|
8
|
-
import os
|
|
9
|
-
import queue
|
|
10
|
-
import subprocess
|
|
11
|
-
import sys
|
|
12
|
-
import tempfile
|
|
13
|
-
import textwrap
|
|
14
|
-
import threading
|
|
15
|
-
import time
|
|
16
|
-
from pathlib import Path
|
|
17
|
-
from typing import Any, Callable
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
ENGINES = ("codex", "claude", "droid", "copilot")
|
|
21
|
-
THINKING_LEVELS_BY_ENGINE = {
|
|
22
|
-
"codex": {"low", "medium", "high", "xhigh"},
|
|
23
|
-
"claude": {"low", "medium", "high", "xhigh", "max"},
|
|
24
|
-
"droid": set(),
|
|
25
|
-
"copilot": set(),
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
SCHEMA: dict[str, Any] = {
|
|
30
|
-
"type": "object",
|
|
31
|
-
"additionalProperties": False,
|
|
32
|
-
"required": [
|
|
33
|
-
"findings",
|
|
34
|
-
"overall_correctness",
|
|
35
|
-
"overall_explanation",
|
|
36
|
-
"overall_confidence",
|
|
37
|
-
],
|
|
38
|
-
"properties": {
|
|
39
|
-
"findings": {
|
|
40
|
-
"type": "array",
|
|
41
|
-
"items": {
|
|
42
|
-
"type": "object",
|
|
43
|
-
"additionalProperties": False,
|
|
44
|
-
"required": [
|
|
45
|
-
"title",
|
|
46
|
-
"body",
|
|
47
|
-
"priority",
|
|
48
|
-
"confidence",
|
|
49
|
-
"category",
|
|
50
|
-
"code_location",
|
|
51
|
-
],
|
|
52
|
-
"properties": {
|
|
53
|
-
"title": {"type": "string", "minLength": 1, "maxLength": 140},
|
|
54
|
-
"body": {"type": "string", "minLength": 1, "maxLength": 2000},
|
|
55
|
-
"priority": {"type": "string", "enum": ["P0", "P1", "P2", "P3"]},
|
|
56
|
-
"confidence": {"type": "number", "minimum": 0, "maximum": 1},
|
|
57
|
-
"category": {
|
|
58
|
-
"type": "string",
|
|
59
|
-
"enum": ["bug", "security", "regression", "test_gap", "maintainability"],
|
|
60
|
-
},
|
|
61
|
-
"code_location": {
|
|
62
|
-
"type": "object",
|
|
63
|
-
"additionalProperties": False,
|
|
64
|
-
"required": ["file_path", "line"],
|
|
65
|
-
"properties": {
|
|
66
|
-
"file_path": {"type": "string", "minLength": 1},
|
|
67
|
-
"line": {"type": "integer", "minimum": 1},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
"overall_correctness": {
|
|
74
|
-
"type": "string",
|
|
75
|
-
"enum": ["patch is correct", "patch is incorrect"],
|
|
76
|
-
},
|
|
77
|
-
"overall_explanation": {"type": "string", "minLength": 1, "maxLength": 3000},
|
|
78
|
-
"overall_confidence": {"type": "number", "minimum": 0, "maximum": 1},
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def run(args: list[str], cwd: Path, *, input_text: str | None = None, check: bool = True) -> subprocess.CompletedProcess[str]:
|
|
84
|
-
result = subprocess.run(
|
|
85
|
-
args,
|
|
86
|
-
cwd=cwd,
|
|
87
|
-
input=input_text,
|
|
88
|
-
text=True,
|
|
89
|
-
stdout=subprocess.PIPE,
|
|
90
|
-
stderr=subprocess.PIPE,
|
|
91
|
-
)
|
|
92
|
-
if check and result.returncode != 0:
|
|
93
|
-
cmd = " ".join(args)
|
|
94
|
-
raise SystemExit(f"command failed ({result.returncode}): {cmd}\n{result.stderr or result.stdout}")
|
|
95
|
-
return result
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def run_with_heartbeat(
|
|
99
|
-
args: list[str],
|
|
100
|
-
cwd: Path,
|
|
101
|
-
*,
|
|
102
|
-
input_text: str | None = None,
|
|
103
|
-
label: str,
|
|
104
|
-
heartbeat_seconds: int = 60,
|
|
105
|
-
stream_output: bool = False,
|
|
106
|
-
stream_display: Callable[[str, str], str | None] | None = None,
|
|
107
|
-
) -> subprocess.CompletedProcess[str]:
|
|
108
|
-
if stream_output:
|
|
109
|
-
return run_with_stream(
|
|
110
|
-
args,
|
|
111
|
-
cwd,
|
|
112
|
-
input_text=input_text,
|
|
113
|
-
label=label,
|
|
114
|
-
heartbeat_seconds=heartbeat_seconds,
|
|
115
|
-
stream_display=stream_display,
|
|
116
|
-
)
|
|
117
|
-
started = time.monotonic()
|
|
118
|
-
proc = subprocess.Popen(
|
|
119
|
-
args,
|
|
120
|
-
cwd=cwd,
|
|
121
|
-
stdin=subprocess.PIPE if input_text is not None else None,
|
|
122
|
-
stdout=subprocess.PIPE,
|
|
123
|
-
stderr=subprocess.PIPE,
|
|
124
|
-
text=True,
|
|
125
|
-
)
|
|
126
|
-
first_communicate = True
|
|
127
|
-
while True:
|
|
128
|
-
try:
|
|
129
|
-
stdout, stderr = proc.communicate(
|
|
130
|
-
input=input_text if first_communicate else None,
|
|
131
|
-
timeout=heartbeat_seconds,
|
|
132
|
-
)
|
|
133
|
-
return subprocess.CompletedProcess(args, int(proc.returncode or 0), stdout, stderr)
|
|
134
|
-
except subprocess.TimeoutExpired:
|
|
135
|
-
first_communicate = False
|
|
136
|
-
elapsed = int(time.monotonic() - started)
|
|
137
|
-
print(f"review still running: {label} elapsed={elapsed}s pid={proc.pid}", file=sys.stderr, flush=True)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
def run_with_stream(
|
|
141
|
-
args: list[str],
|
|
142
|
-
cwd: Path,
|
|
143
|
-
*,
|
|
144
|
-
input_text: str | None,
|
|
145
|
-
label: str,
|
|
146
|
-
heartbeat_seconds: int,
|
|
147
|
-
stream_display: Callable[[str, str], str | None] | None,
|
|
148
|
-
) -> subprocess.CompletedProcess[str]:
|
|
149
|
-
started = time.monotonic()
|
|
150
|
-
proc = subprocess.Popen(
|
|
151
|
-
args,
|
|
152
|
-
cwd=cwd,
|
|
153
|
-
stdin=subprocess.PIPE if input_text is not None else None,
|
|
154
|
-
stdout=subprocess.PIPE,
|
|
155
|
-
stderr=subprocess.PIPE,
|
|
156
|
-
text=True,
|
|
157
|
-
bufsize=1,
|
|
158
|
-
)
|
|
159
|
-
events: queue.Queue[tuple[str, str | None]] = queue.Queue()
|
|
160
|
-
stdout_parts: list[str] = []
|
|
161
|
-
stderr_parts: list[str] = []
|
|
162
|
-
|
|
163
|
-
def read_stream(name: str, stream: Any) -> None:
|
|
164
|
-
try:
|
|
165
|
-
for line in iter(stream.readline, ""):
|
|
166
|
-
events.put((name, line))
|
|
167
|
-
finally:
|
|
168
|
-
events.put((name, None))
|
|
169
|
-
|
|
170
|
-
def write_stdin() -> None:
|
|
171
|
-
if proc.stdin is None or input_text is None:
|
|
172
|
-
return
|
|
173
|
-
try:
|
|
174
|
-
proc.stdin.write(input_text)
|
|
175
|
-
proc.stdin.close()
|
|
176
|
-
except BrokenPipeError:
|
|
177
|
-
return
|
|
178
|
-
|
|
179
|
-
threads = [
|
|
180
|
-
threading.Thread(target=read_stream, args=("stdout", proc.stdout), daemon=True),
|
|
181
|
-
threading.Thread(target=read_stream, args=("stderr", proc.stderr), daemon=True),
|
|
182
|
-
]
|
|
183
|
-
for thread in threads:
|
|
184
|
-
thread.start()
|
|
185
|
-
stdin_thread = threading.Thread(target=write_stdin, daemon=True)
|
|
186
|
-
stdin_thread.start()
|
|
187
|
-
|
|
188
|
-
open_streams = 2
|
|
189
|
-
while open_streams:
|
|
190
|
-
try:
|
|
191
|
-
name, line = events.get(timeout=heartbeat_seconds)
|
|
192
|
-
except queue.Empty:
|
|
193
|
-
elapsed = int(time.monotonic() - started)
|
|
194
|
-
print(f"review still running: {label} elapsed={elapsed}s pid={proc.pid}", file=sys.stderr, flush=True)
|
|
195
|
-
continue
|
|
196
|
-
if line is None:
|
|
197
|
-
open_streams -= 1
|
|
198
|
-
continue
|
|
199
|
-
if name == "stdout":
|
|
200
|
-
stdout_parts.append(line)
|
|
201
|
-
else:
|
|
202
|
-
stderr_parts.append(line)
|
|
203
|
-
display = stream_display(name, line) if stream_display else line
|
|
204
|
-
if display:
|
|
205
|
-
target = sys.stdout if name == "stdout" else sys.stderr
|
|
206
|
-
target.write(display)
|
|
207
|
-
target.flush()
|
|
208
|
-
|
|
209
|
-
for thread in threads:
|
|
210
|
-
thread.join()
|
|
211
|
-
stdin_thread.join(timeout=1)
|
|
212
|
-
returncode = proc.wait()
|
|
213
|
-
return subprocess.CompletedProcess(args, returncode, "".join(stdout_parts), "".join(stderr_parts))
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
def git(repo: Path, *args: str, check: bool = True) -> str:
|
|
217
|
-
return run(["git", *args], repo, check=check).stdout
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
def repo_root() -> Path:
|
|
221
|
-
result = subprocess.run(
|
|
222
|
-
["git", "rev-parse", "--show-toplevel"],
|
|
223
|
-
text=True,
|
|
224
|
-
stdout=subprocess.PIPE,
|
|
225
|
-
stderr=subprocess.PIPE,
|
|
226
|
-
)
|
|
227
|
-
if result.returncode != 0:
|
|
228
|
-
raise SystemExit("autoreview must run inside a git repository")
|
|
229
|
-
return Path(result.stdout.strip()).resolve()
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
def current_branch(repo: Path) -> str:
|
|
233
|
-
return git(repo, "branch", "--show-current", check=False).strip() or "detached"
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
def is_dirty(repo: Path) -> bool:
|
|
237
|
-
return bool(git(repo, "status", "--porcelain").strip())
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
def choose_target(repo: Path, mode: str, base_ref: str | None) -> tuple[str, str | None]:
|
|
241
|
-
branch = current_branch(repo)
|
|
242
|
-
if mode == "local" or (mode == "auto" and is_dirty(repo)):
|
|
243
|
-
return "local", None
|
|
244
|
-
if mode == "commit":
|
|
245
|
-
return "commit", None
|
|
246
|
-
if mode == "branch" or (mode == "auto" and branch != "main"):
|
|
247
|
-
return "branch", base_ref or detect_pr_base(repo) or "origin/main"
|
|
248
|
-
raise SystemExit("no review target: clean main checkout and no forced mode")
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
def detect_pr_base(repo: Path) -> str | None:
|
|
252
|
-
if not shutil_which("gh"):
|
|
253
|
-
return None
|
|
254
|
-
result = run(["gh", "pr", "view", "--json", "baseRefName", "--jq", ".baseRefName"], repo, check=False)
|
|
255
|
-
base = result.stdout.strip()
|
|
256
|
-
return f"origin/{base}" if result.returncode == 0 and base else None
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
def shutil_which(name: str) -> str | None:
|
|
260
|
-
for part in os.environ.get("PATH", "").split(os.pathsep):
|
|
261
|
-
candidate = Path(part) / name
|
|
262
|
-
if candidate.exists() and os.access(candidate, os.X_OK):
|
|
263
|
-
return str(candidate)
|
|
264
|
-
return None
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
def bounded(text: str, limit: int = 180_000) -> str:
|
|
268
|
-
if len(text) <= limit:
|
|
269
|
-
return text
|
|
270
|
-
return text[:limit] + f"\n\n[truncated at {limit} characters]\n"
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
def bounded_field(text: str, limit: int) -> str:
|
|
274
|
-
if len(text) <= limit:
|
|
275
|
-
return text
|
|
276
|
-
suffix = "\n\n[truncated]"
|
|
277
|
-
return text[: max(0, limit - len(suffix))] + suffix
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
def read_text(path: Path, limit: int = 40_000) -> str:
|
|
281
|
-
try:
|
|
282
|
-
data = path.read_bytes()
|
|
283
|
-
except OSError as exc:
|
|
284
|
-
return f"[unreadable: {exc}]"
|
|
285
|
-
if b"\0" in data:
|
|
286
|
-
return "[binary file omitted]"
|
|
287
|
-
text = data.decode("utf-8", errors="replace")
|
|
288
|
-
return bounded(text, limit)
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
def local_bundle(repo: Path) -> str:
|
|
292
|
-
parts = [
|
|
293
|
-
"# Git Status",
|
|
294
|
-
git(repo, "status", "--short"),
|
|
295
|
-
"# Staged Diff",
|
|
296
|
-
git(repo, "diff", "--cached", "--stat"),
|
|
297
|
-
bounded(git(repo, "diff", "--cached", "--patch", "--find-renames")),
|
|
298
|
-
"# Unstaged Diff",
|
|
299
|
-
git(repo, "diff", "--stat"),
|
|
300
|
-
bounded(git(repo, "diff", "--patch", "--find-renames")),
|
|
301
|
-
]
|
|
302
|
-
untracked = [line for line in git(repo, "ls-files", "--others", "--exclude-standard").splitlines() if line]
|
|
303
|
-
if untracked:
|
|
304
|
-
parts.append("# Untracked Files")
|
|
305
|
-
for rel in untracked:
|
|
306
|
-
path = repo / rel
|
|
307
|
-
parts.append(f"## {rel}\n{read_text(path)}")
|
|
308
|
-
return "\n\n".join(parts)
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
def branch_bundle(repo: Path, base_ref: str) -> str:
|
|
312
|
-
git(repo, "fetch", "origin", "--quiet", check=False)
|
|
313
|
-
return "\n\n".join(
|
|
314
|
-
[
|
|
315
|
-
"# Branch Diff",
|
|
316
|
-
f"base: {base_ref}",
|
|
317
|
-
git(repo, "diff", "--stat", f"{base_ref}...HEAD"),
|
|
318
|
-
bounded(git(repo, "diff", "--patch", "--find-renames", f"{base_ref}...HEAD")),
|
|
319
|
-
]
|
|
320
|
-
)
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
def commit_bundle(repo: Path, commit_ref: str) -> str:
|
|
324
|
-
return "\n\n".join(
|
|
325
|
-
[
|
|
326
|
-
"# Commit Diff",
|
|
327
|
-
f"commit: {commit_ref}",
|
|
328
|
-
git(repo, "show", "--stat", "--format=fuller", commit_ref),
|
|
329
|
-
bounded(git(repo, "show", "--patch", "--find-renames", "--format=fuller", commit_ref)),
|
|
330
|
-
]
|
|
331
|
-
)
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
def review_paths(repo: Path, target: str, target_ref: str | None, commit_ref: str) -> set[str]:
|
|
335
|
-
names: set[str] = set()
|
|
336
|
-
if target == "local":
|
|
337
|
-
sources = [
|
|
338
|
-
git(repo, "diff", "--name-only", "--cached"),
|
|
339
|
-
git(repo, "diff", "--name-only"),
|
|
340
|
-
git(repo, "ls-files", "--others", "--exclude-standard"),
|
|
341
|
-
]
|
|
342
|
-
elif target == "branch":
|
|
343
|
-
assert target_ref
|
|
344
|
-
sources = [git(repo, "diff", "--name-only", f"{target_ref}...HEAD")]
|
|
345
|
-
else:
|
|
346
|
-
sources = [git(repo, "show", "--name-only", "--format=", commit_ref)]
|
|
347
|
-
for source in sources:
|
|
348
|
-
for line in source.splitlines():
|
|
349
|
-
path = line.strip()
|
|
350
|
-
if path:
|
|
351
|
-
names.add(path)
|
|
352
|
-
return names
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
def load_extra_prompt(args: argparse.Namespace) -> str:
|
|
356
|
-
chunks: list[str] = []
|
|
357
|
-
for value in args.prompt or []:
|
|
358
|
-
chunks.append(value)
|
|
359
|
-
for path in args.prompt_file or []:
|
|
360
|
-
chunks.append(Path(path).read_text())
|
|
361
|
-
return "\n\n".join(chunks)
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
def load_datasets(args: argparse.Namespace) -> str:
|
|
365
|
-
chunks: list[str] = []
|
|
366
|
-
for spec in args.dataset or []:
|
|
367
|
-
path = Path(spec)
|
|
368
|
-
if path.is_dir():
|
|
369
|
-
raise SystemExit(f"--dataset must be a file, got directory: {path}")
|
|
370
|
-
chunks.append(f"# Dataset: {path}\n{read_text(path)}")
|
|
371
|
-
return "\n\n".join(chunks)
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
def build_prompt(repo: Path, target: str, target_ref: str | None, bundle: str, extra_prompt: str, datasets: str) -> str:
|
|
375
|
-
target_line = f"{target} {target_ref}" if target_ref else target
|
|
376
|
-
return textwrap.dedent(
|
|
377
|
-
f"""
|
|
378
|
-
You are a senior code reviewer. Review the provided git change bundle only.
|
|
379
|
-
|
|
380
|
-
Hard rules:
|
|
381
|
-
- Return exactly one JSON object and nothing else. Do not wrap it in Markdown.
|
|
382
|
-
- The JSON object must match this schema exactly:
|
|
383
|
-
{json.dumps(SCHEMA, indent=2)}
|
|
384
|
-
- Do not modify files.
|
|
385
|
-
- Do not invoke nested reviewers or review tools.
|
|
386
|
-
- Forbidden nested review commands include: codex review, autoreview, claude review, oracle review.
|
|
387
|
-
- You may use read-only tools and web search to inspect files, dependency contracts, upstream docs, current behavior, and security implications.
|
|
388
|
-
- Shell commands, if available, must be read-only inspection commands. Do not run tests, formatters, package installs, generators, network mutation commands, git mutation commands, or commands that write files.
|
|
389
|
-
- Report only actionable defects introduced or exposed by this change.
|
|
390
|
-
- Prefer high-signal findings over style feedback.
|
|
391
|
-
- Include security findings: injection, secret leaks, authz/authn bypass, path traversal, unsafe deserialization, unsafe filesystem or shell use, privacy leaks, and credential handling.
|
|
392
|
-
- Do not reject legitimate functionality merely because it touches shell, filesystem, network, auth, or sensitive data. Report a security finding only when the patch creates a concrete exploitable risk, removes an important safety check, or lacks validation at a trust boundary.
|
|
393
|
-
- For each finding, use the smallest file/line location that demonstrates the issue.
|
|
394
|
-
- If there are no actionable findings, return an empty findings array and mark the patch correct.
|
|
395
|
-
|
|
396
|
-
Review target: {target_line}
|
|
397
|
-
Repository: {repo}
|
|
398
|
-
|
|
399
|
-
{extra_prompt}
|
|
400
|
-
|
|
401
|
-
{datasets}
|
|
402
|
-
|
|
403
|
-
# Change Bundle
|
|
404
|
-
{bundle}
|
|
405
|
-
"""
|
|
406
|
-
).strip()
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
def write_json_temp(data: dict[str, Any]) -> Path:
|
|
410
|
-
handle = tempfile.NamedTemporaryFile("w", suffix=".json", delete=False)
|
|
411
|
-
with handle:
|
|
412
|
-
json.dump(data, handle)
|
|
413
|
-
return Path(handle.name)
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
def run_codex(args: argparse.Namespace, repo: Path, prompt: str) -> str:
|
|
417
|
-
if not args.tools:
|
|
418
|
-
raise SystemExit("--no-tools is not supported by the Codex engine; use --engine claude --no-tools for a no-tools run")
|
|
419
|
-
schema_path = write_json_temp(SCHEMA)
|
|
420
|
-
output_path = Path(tempfile.NamedTemporaryFile("w", suffix=".json", delete=False).name)
|
|
421
|
-
cmd = [args.codex_bin, "--ask-for-approval", "never"]
|
|
422
|
-
if args.web_search:
|
|
423
|
-
cmd.append("--search")
|
|
424
|
-
if args.model:
|
|
425
|
-
cmd.extend(["--model", args.model])
|
|
426
|
-
if args.thinking:
|
|
427
|
-
cmd.extend(["-c", f'model_reasoning_effort="{args.thinking}"'])
|
|
428
|
-
cmd.append("exec")
|
|
429
|
-
if args.stream_engine_output:
|
|
430
|
-
cmd.append("--json")
|
|
431
|
-
cmd.extend(
|
|
432
|
-
[
|
|
433
|
-
"--ephemeral",
|
|
434
|
-
"-C",
|
|
435
|
-
str(repo),
|
|
436
|
-
"-s",
|
|
437
|
-
"read-only",
|
|
438
|
-
"--output-schema",
|
|
439
|
-
str(schema_path),
|
|
440
|
-
"--output-last-message",
|
|
441
|
-
str(output_path),
|
|
442
|
-
"-",
|
|
443
|
-
]
|
|
444
|
-
)
|
|
445
|
-
result = run_with_heartbeat(
|
|
446
|
-
cmd,
|
|
447
|
-
repo,
|
|
448
|
-
input_text=prompt,
|
|
449
|
-
label="codex",
|
|
450
|
-
stream_output=args.stream_engine_output,
|
|
451
|
-
stream_display=CodexStreamDisplay() if args.stream_engine_output else None,
|
|
452
|
-
)
|
|
453
|
-
try:
|
|
454
|
-
output = output_path.read_text()
|
|
455
|
-
finally:
|
|
456
|
-
schema_path.unlink(missing_ok=True)
|
|
457
|
-
output_path.unlink(missing_ok=True)
|
|
458
|
-
if result.returncode != 0:
|
|
459
|
-
raise SystemExit(f"codex engine failed ({result.returncode})\n{result.stderr or result.stdout}")
|
|
460
|
-
return output or result.stdout
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
def run_claude(args: argparse.Namespace, repo: Path, prompt: str) -> str:
|
|
464
|
-
cmd = [
|
|
465
|
-
args.claude_bin,
|
|
466
|
-
"--print",
|
|
467
|
-
"--no-session-persistence",
|
|
468
|
-
"--output-format",
|
|
469
|
-
"stream-json" if args.stream_engine_output else "json",
|
|
470
|
-
"--json-schema",
|
|
471
|
-
json.dumps(SCHEMA),
|
|
472
|
-
]
|
|
473
|
-
if args.tools:
|
|
474
|
-
cmd.extend(["--allowedTools", claude_allowed_tools(args)])
|
|
475
|
-
else:
|
|
476
|
-
cmd.extend(["--tools", ""])
|
|
477
|
-
if args.stream_engine_output:
|
|
478
|
-
cmd.append("--verbose")
|
|
479
|
-
if args.model:
|
|
480
|
-
cmd.extend(["--model", args.model])
|
|
481
|
-
if args.thinking:
|
|
482
|
-
cmd.extend(["--effort", args.thinking])
|
|
483
|
-
result = run_with_heartbeat(
|
|
484
|
-
cmd,
|
|
485
|
-
repo,
|
|
486
|
-
input_text=prompt,
|
|
487
|
-
label="claude",
|
|
488
|
-
stream_output=args.stream_engine_output,
|
|
489
|
-
stream_display=ClaudeStreamDisplay() if args.stream_engine_output else None,
|
|
490
|
-
)
|
|
491
|
-
if result.returncode != 0:
|
|
492
|
-
raise SystemExit(f"claude engine failed ({result.returncode})\n{result.stderr or result.stdout}")
|
|
493
|
-
return result.stdout
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
def run_droid(args: argparse.Namespace, repo: Path, prompt: str) -> str:
|
|
497
|
-
if args.thinking:
|
|
498
|
-
raise SystemExit("--thinking is not supported by the droid engine")
|
|
499
|
-
prompt_path = Path(tempfile.NamedTemporaryFile("w", suffix=".txt", delete=False).name)
|
|
500
|
-
prompt_path.write_text(prompt)
|
|
501
|
-
cmd = [
|
|
502
|
-
args.droid_bin,
|
|
503
|
-
"exec",
|
|
504
|
-
"--cwd",
|
|
505
|
-
str(repo),
|
|
506
|
-
"--output-format",
|
|
507
|
-
"json",
|
|
508
|
-
"-f",
|
|
509
|
-
str(prompt_path),
|
|
510
|
-
]
|
|
511
|
-
if args.model:
|
|
512
|
-
cmd.extend(["--model", args.model])
|
|
513
|
-
if not args.tools:
|
|
514
|
-
cmd.extend(["--disabled-tools", "*"])
|
|
515
|
-
result = run_with_heartbeat(cmd, repo, label="droid", stream_output=args.stream_engine_output)
|
|
516
|
-
prompt_path.unlink(missing_ok=True)
|
|
517
|
-
if result.returncode != 0:
|
|
518
|
-
raise SystemExit(f"droid engine failed ({result.returncode})\n{result.stderr or result.stdout}")
|
|
519
|
-
return result.stdout
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
def run_copilot(args: argparse.Namespace, repo: Path, prompt: str) -> str:
|
|
523
|
-
if args.thinking:
|
|
524
|
-
raise SystemExit("--thinking is not supported by the copilot engine")
|
|
525
|
-
if not args.tools:
|
|
526
|
-
raise SystemExit("--no-tools is not supported by the copilot engine; copilot requires a read-only file view tool to load the review bundle without exposing it in argv")
|
|
527
|
-
with tempfile.TemporaryDirectory(prefix="autoreview-copilot.") as tempdir:
|
|
528
|
-
prompt_path = Path(tempdir) / "prompt.txt"
|
|
529
|
-
prompt_path.write_text(prompt)
|
|
530
|
-
os.chmod(prompt_path, 0o600)
|
|
531
|
-
cmd = [
|
|
532
|
-
args.copilot_bin,
|
|
533
|
-
"-C",
|
|
534
|
-
tempdir,
|
|
535
|
-
"-p",
|
|
536
|
-
"Read ./prompt.txt and follow it exactly. Return only the requested JSON object.",
|
|
537
|
-
"--output-format",
|
|
538
|
-
"json",
|
|
539
|
-
"--stream",
|
|
540
|
-
"on" if args.stream_engine_output else "off",
|
|
541
|
-
"--no-ask-user",
|
|
542
|
-
"--disable-builtin-mcps",
|
|
543
|
-
]
|
|
544
|
-
if args.model:
|
|
545
|
-
cmd.extend(["--model", args.model])
|
|
546
|
-
cmd.extend(
|
|
547
|
-
[
|
|
548
|
-
"--available-tools=read_agent,rg,view,web_fetch",
|
|
549
|
-
"--allow-tool=read_agent",
|
|
550
|
-
"--allow-tool=rg",
|
|
551
|
-
"--allow-tool=view",
|
|
552
|
-
"--allow-tool=web_fetch",
|
|
553
|
-
]
|
|
554
|
-
)
|
|
555
|
-
if args.web_search:
|
|
556
|
-
cmd.append("--allow-all-urls")
|
|
557
|
-
result = run_with_heartbeat(cmd, Path(tempdir), label="copilot", stream_output=args.stream_engine_output)
|
|
558
|
-
if result.returncode != 0:
|
|
559
|
-
raise SystemExit(f"copilot engine failed ({result.returncode})\n{result.stderr or result.stdout}")
|
|
560
|
-
return result.stdout
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
class CodexStreamDisplay:
|
|
564
|
-
def __init__(self, *, activity_seconds: int = 20) -> None:
|
|
565
|
-
self.activity_seconds = activity_seconds
|
|
566
|
-
self.hidden_events = 0
|
|
567
|
-
self.last_visible = time.monotonic()
|
|
568
|
-
|
|
569
|
-
def __call__(self, name: str, line: str) -> str | None:
|
|
570
|
-
if name != "stdout":
|
|
571
|
-
return line
|
|
572
|
-
try:
|
|
573
|
-
event = json.loads(line)
|
|
574
|
-
except json.JSONDecodeError:
|
|
575
|
-
return self.visible(line)
|
|
576
|
-
event_type = event.get("type")
|
|
577
|
-
if event_type == "thread.started":
|
|
578
|
-
return self.visible(f"codex thread: {event.get('thread_id', '<unknown>')}\n")
|
|
579
|
-
if event_type == "turn.started":
|
|
580
|
-
return self.visible("codex turn started\n")
|
|
581
|
-
if event_type == "turn.completed":
|
|
582
|
-
usage = event.get("usage")
|
|
583
|
-
message = format_codex_usage(usage) + "\n" if isinstance(usage, dict) else "codex turn completed\n"
|
|
584
|
-
return self.visible(self.flush_hidden() + message)
|
|
585
|
-
item = event.get("item")
|
|
586
|
-
if isinstance(item, dict) and item.get("type") == "agent_message" and isinstance(item.get("text"), str):
|
|
587
|
-
return self.visible(self.flush_hidden() + item["text"].rstrip() + "\n")
|
|
588
|
-
return self.hidden_activity()
|
|
589
|
-
|
|
590
|
-
def hidden_activity(self) -> str | None:
|
|
591
|
-
self.hidden_events += 1
|
|
592
|
-
if time.monotonic() - self.last_visible < self.activity_seconds:
|
|
593
|
-
return None
|
|
594
|
-
return self.visible(self.flush_hidden())
|
|
595
|
-
|
|
596
|
-
def flush_hidden(self) -> str:
|
|
597
|
-
if not self.hidden_events:
|
|
598
|
-
return ""
|
|
599
|
-
count = self.hidden_events
|
|
600
|
-
self.hidden_events = 0
|
|
601
|
-
return f"codex activity: {count} hidden tool/status events\n"
|
|
602
|
-
|
|
603
|
-
def visible(self, text: str) -> str:
|
|
604
|
-
self.last_visible = time.monotonic()
|
|
605
|
-
return text
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
class ClaudeStreamDisplay:
|
|
609
|
-
def __init__(self, *, activity_seconds: int = 20) -> None:
|
|
610
|
-
self.activity_seconds = activity_seconds
|
|
611
|
-
self.hidden_events = 0
|
|
612
|
-
self.last_visible = time.monotonic()
|
|
613
|
-
self.started = False
|
|
614
|
-
|
|
615
|
-
def __call__(self, name: str, line: str) -> str | None:
|
|
616
|
-
if name != "stdout":
|
|
617
|
-
return line
|
|
618
|
-
try:
|
|
619
|
-
event = json.loads(line)
|
|
620
|
-
except json.JSONDecodeError:
|
|
621
|
-
return self.visible(line)
|
|
622
|
-
event_type = event.get("type")
|
|
623
|
-
if event_type == "system" and not self.started:
|
|
624
|
-
self.started = True
|
|
625
|
-
return self.visible("claude turn started\n")
|
|
626
|
-
if event_type == "assistant":
|
|
627
|
-
return self.assistant_message(event)
|
|
628
|
-
if event_type == "result":
|
|
629
|
-
return self.visible(self.flush_hidden() + self.result_summary(event))
|
|
630
|
-
return self.hidden_activity()
|
|
631
|
-
|
|
632
|
-
def assistant_message(self, event: dict[str, Any]) -> str | None:
|
|
633
|
-
message = event.get("message")
|
|
634
|
-
if not isinstance(message, dict):
|
|
635
|
-
return self.hidden_activity()
|
|
636
|
-
chunks: list[str] = []
|
|
637
|
-
for item in message.get("content", []):
|
|
638
|
-
if not isinstance(item, dict):
|
|
639
|
-
continue
|
|
640
|
-
if item.get("type") == "text" and isinstance(item.get("text"), str):
|
|
641
|
-
chunks.append(item["text"].rstrip())
|
|
642
|
-
if chunks:
|
|
643
|
-
return self.visible(self.flush_hidden() + "\n".join(chunks) + "\n")
|
|
644
|
-
return self.hidden_activity()
|
|
645
|
-
|
|
646
|
-
def result_summary(self, event: dict[str, Any]) -> str:
|
|
647
|
-
usage = event.get("usage")
|
|
648
|
-
fields: list[str] = []
|
|
649
|
-
if isinstance(usage, dict):
|
|
650
|
-
for key in (
|
|
651
|
-
"input_tokens",
|
|
652
|
-
"cache_read_input_tokens",
|
|
653
|
-
"cache_creation_input_tokens",
|
|
654
|
-
"output_tokens",
|
|
655
|
-
):
|
|
656
|
-
value = usage.get(key)
|
|
657
|
-
if isinstance(value, int):
|
|
658
|
-
fields.append(f"{key}={value}")
|
|
659
|
-
cost = event.get("total_cost_usd")
|
|
660
|
-
if isinstance(cost, (int, float)) and not isinstance(cost, bool):
|
|
661
|
-
fields.append(f"cost_usd={cost:.6f}")
|
|
662
|
-
return "claude usage: " + " ".join(fields) + "\n" if fields else "claude turn completed\n"
|
|
663
|
-
|
|
664
|
-
def hidden_activity(self) -> str | None:
|
|
665
|
-
self.hidden_events += 1
|
|
666
|
-
if time.monotonic() - self.last_visible < self.activity_seconds:
|
|
667
|
-
return None
|
|
668
|
-
return self.visible(self.flush_hidden())
|
|
669
|
-
|
|
670
|
-
def flush_hidden(self) -> str:
|
|
671
|
-
if not self.hidden_events:
|
|
672
|
-
return ""
|
|
673
|
-
count = self.hidden_events
|
|
674
|
-
self.hidden_events = 0
|
|
675
|
-
return f"claude activity: {count} hidden tool/status events\n"
|
|
676
|
-
|
|
677
|
-
def visible(self, text: str) -> str:
|
|
678
|
-
self.last_visible = time.monotonic()
|
|
679
|
-
return text
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
def format_codex_usage(usage: dict[str, Any]) -> str:
|
|
683
|
-
fields = [
|
|
684
|
-
"input_tokens",
|
|
685
|
-
"cached_input_tokens",
|
|
686
|
-
"output_tokens",
|
|
687
|
-
"reasoning_output_tokens",
|
|
688
|
-
]
|
|
689
|
-
parts = [f"{field}={usage[field]}" for field in fields if isinstance(usage.get(field), int)]
|
|
690
|
-
return "codex usage: " + " ".join(parts) if parts else "codex usage: unavailable"
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
def claude_allowed_tools(args: argparse.Namespace) -> str:
|
|
694
|
-
tools = [tool.strip() for tool in args.claude_allowed_tools.split(",") if tool.strip()]
|
|
695
|
-
if not args.web_search:
|
|
696
|
-
tools = [tool for tool in tools if tool not in {"WebSearch", "WebFetch"}]
|
|
697
|
-
return ",".join(tools)
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
def extract_json(text: str) -> dict[str, Any]:
|
|
701
|
-
stripped = text.strip()
|
|
702
|
-
if not stripped:
|
|
703
|
-
raise SystemExit("review engine returned empty output")
|
|
704
|
-
try:
|
|
705
|
-
parsed = json.loads(stripped)
|
|
706
|
-
except json.JSONDecodeError as exc:
|
|
707
|
-
fenced_report = parse_json_candidate(stripped)
|
|
708
|
-
if isinstance(fenced_report, dict) and "findings" in fenced_report:
|
|
709
|
-
return fenced_report
|
|
710
|
-
jsonl_report = extract_json_from_jsonl(stripped)
|
|
711
|
-
if jsonl_report:
|
|
712
|
-
return jsonl_report
|
|
713
|
-
raise SystemExit(f"review engine returned non-JSON output: {exc}\n{stripped[:2000]}")
|
|
714
|
-
if isinstance(parsed, dict) and "findings" in parsed:
|
|
715
|
-
return parsed
|
|
716
|
-
if isinstance(parsed, dict) and isinstance(parsed.get("structured_output"), dict):
|
|
717
|
-
return parsed["structured_output"]
|
|
718
|
-
if isinstance(parsed, dict) and isinstance(parsed.get("result"), str):
|
|
719
|
-
result_json = parse_json_candidate(parsed["result"])
|
|
720
|
-
if isinstance(result_json, dict) and "findings" in result_json:
|
|
721
|
-
return result_json
|
|
722
|
-
raise SystemExit(f"review engine result was not structured JSON:\n{parsed['result'][:2000]}")
|
|
723
|
-
jsonl_report = extract_json_from_jsonl(stripped)
|
|
724
|
-
if jsonl_report:
|
|
725
|
-
return jsonl_report
|
|
726
|
-
raise SystemExit(f"review engine returned unexpected JSON shape:\n{json.dumps(parsed)[:2000]}")
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
def extract_json_from_jsonl(text: str) -> dict[str, Any] | None:
|
|
730
|
-
candidates: list[str | dict[str, Any]] = []
|
|
731
|
-
for line in text.splitlines():
|
|
732
|
-
line = line.strip()
|
|
733
|
-
if not line:
|
|
734
|
-
continue
|
|
735
|
-
try:
|
|
736
|
-
event = json.loads(line)
|
|
737
|
-
except json.JSONDecodeError:
|
|
738
|
-
continue
|
|
739
|
-
if not isinstance(event, dict):
|
|
740
|
-
continue
|
|
741
|
-
part = event.get("part")
|
|
742
|
-
if isinstance(part, dict) and isinstance(part.get("text"), str):
|
|
743
|
-
candidates.append(part["text"])
|
|
744
|
-
data = event.get("data")
|
|
745
|
-
if isinstance(data, dict) and isinstance(data.get("content"), str):
|
|
746
|
-
candidates.append(data["content"])
|
|
747
|
-
if isinstance(event.get("result"), str):
|
|
748
|
-
candidates.append(event["result"])
|
|
749
|
-
if isinstance(event.get("structured_output"), dict):
|
|
750
|
-
candidates.append(event["structured_output"])
|
|
751
|
-
for candidate in reversed(candidates):
|
|
752
|
-
if isinstance(candidate, dict):
|
|
753
|
-
if "findings" in candidate:
|
|
754
|
-
return candidate
|
|
755
|
-
continue
|
|
756
|
-
parsed = parse_json_candidate(candidate)
|
|
757
|
-
if isinstance(parsed, dict) and "findings" in parsed:
|
|
758
|
-
return parsed
|
|
759
|
-
return None
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
def parse_json_candidate(text: str) -> Any | None:
|
|
763
|
-
stripped = text.strip()
|
|
764
|
-
if stripped.startswith("```"):
|
|
765
|
-
lines = stripped.splitlines()
|
|
766
|
-
if lines and lines[0].startswith("```") and lines[-1].strip() == "```":
|
|
767
|
-
stripped = "\n".join(lines[1:-1]).strip()
|
|
768
|
-
try:
|
|
769
|
-
parsed = json.loads(stripped)
|
|
770
|
-
except json.JSONDecodeError:
|
|
771
|
-
return None
|
|
772
|
-
if isinstance(parsed, str) and parsed != text:
|
|
773
|
-
nested = parse_json_candidate(parsed)
|
|
774
|
-
return nested if nested is not None else parsed
|
|
775
|
-
return parsed
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
def validate_report(report: dict[str, Any], repo: Path, changed_paths: set[str], required: list[str]) -> None:
|
|
779
|
-
allowed_top = {"findings", "overall_correctness", "overall_explanation", "overall_confidence"}
|
|
780
|
-
extra_top = set(report) - allowed_top
|
|
781
|
-
if extra_top:
|
|
782
|
-
raise SystemExit(f"review JSON has unexpected top-level keys: {sorted(extra_top)}")
|
|
783
|
-
for key in SCHEMA["required"]:
|
|
784
|
-
if key not in report:
|
|
785
|
-
raise SystemExit(f"review JSON missing required key: {key}")
|
|
786
|
-
if not isinstance(report["findings"], list):
|
|
787
|
-
raise SystemExit("review JSON findings must be an array")
|
|
788
|
-
if report.get("overall_correctness") not in {"patch is correct", "patch is incorrect"}:
|
|
789
|
-
raise SystemExit(f"review JSON has invalid overall_correctness: {report.get('overall_correctness')}")
|
|
790
|
-
if not isinstance(report.get("overall_explanation"), str) or not report["overall_explanation"]:
|
|
791
|
-
raise SystemExit("review JSON overall_explanation must be a non-empty string")
|
|
792
|
-
if len(report["overall_explanation"]) > 3000:
|
|
793
|
-
raise SystemExit("review JSON overall_explanation is too long")
|
|
794
|
-
if not number_in_range(report.get("overall_confidence")):
|
|
795
|
-
raise SystemExit("review JSON overall_confidence must be numeric")
|
|
796
|
-
finding_text = ""
|
|
797
|
-
kept_findings: list[dict[str, Any]] = []
|
|
798
|
-
ignored_findings: list[tuple[int, dict[str, Any], str, int]] = []
|
|
799
|
-
for index, finding in enumerate(report["findings"]):
|
|
800
|
-
if not isinstance(finding, dict):
|
|
801
|
-
raise SystemExit(f"finding {index} must be an object")
|
|
802
|
-
allowed_finding = {"title", "body", "priority", "confidence", "category", "code_location"}
|
|
803
|
-
extra_finding = set(finding) - allowed_finding
|
|
804
|
-
if extra_finding:
|
|
805
|
-
raise SystemExit(f"finding {index} has unexpected keys: {sorted(extra_finding)}")
|
|
806
|
-
for key in allowed_finding:
|
|
807
|
-
if key not in finding:
|
|
808
|
-
raise SystemExit(f"finding {index} missing required key: {key}")
|
|
809
|
-
title = finding.get("title")
|
|
810
|
-
if not isinstance(title, str) or not title or len(title) > 140:
|
|
811
|
-
raise SystemExit(f"finding {index} has invalid title")
|
|
812
|
-
body = finding.get("body")
|
|
813
|
-
if not isinstance(body, str) or not body or len(body) > 2000:
|
|
814
|
-
raise SystemExit(f"finding {index} has invalid body")
|
|
815
|
-
priority = finding.get("priority")
|
|
816
|
-
if priority not in {"P0", "P1", "P2", "P3"}:
|
|
817
|
-
raise SystemExit(f"finding {index} has invalid priority: {priority}")
|
|
818
|
-
if not number_in_range(finding.get("confidence")):
|
|
819
|
-
raise SystemExit(f"finding {index} has invalid confidence")
|
|
820
|
-
category = finding.get("category")
|
|
821
|
-
if category not in {"bug", "security", "regression", "test_gap", "maintainability"}:
|
|
822
|
-
raise SystemExit(f"finding {index} has invalid category: {category}")
|
|
823
|
-
location = finding.get("code_location")
|
|
824
|
-
if not isinstance(location, dict):
|
|
825
|
-
raise SystemExit(f"finding {index} missing code_location")
|
|
826
|
-
rel = str(location.get("file_path", "")).strip()
|
|
827
|
-
line = location.get("line")
|
|
828
|
-
if not rel or not isinstance(line, int) or line < 1:
|
|
829
|
-
raise SystemExit(f"finding {index} has invalid location: {location}")
|
|
830
|
-
if Path(rel).is_absolute() or ".." in Path(rel).parts:
|
|
831
|
-
raise SystemExit(f"finding {index} uses invalid file path: {rel}")
|
|
832
|
-
if rel not in changed_paths:
|
|
833
|
-
ignored_findings.append((index, finding, rel, line))
|
|
834
|
-
continue
|
|
835
|
-
kept_findings.append(finding)
|
|
836
|
-
finding_text += "\n" + json.dumps(finding, sort_keys=True)
|
|
837
|
-
if ignored_findings:
|
|
838
|
-
for index, finding, rel, line in ignored_findings:
|
|
839
|
-
title = finding.get("title", "<untitled>")
|
|
840
|
-
print(
|
|
841
|
-
f"autoreview ignored out-of-scope finding {index}: {title} ({rel}:{line})",
|
|
842
|
-
file=sys.stderr,
|
|
843
|
-
)
|
|
844
|
-
print(bounded_field(str(finding.get("body", "")), 500), file=sys.stderr)
|
|
845
|
-
report["findings"] = kept_findings
|
|
846
|
-
if not kept_findings and report["overall_correctness"] == "patch is incorrect":
|
|
847
|
-
note = f"Ignored {len(ignored_findings)} out-of-scope finding(s) outside the reviewed change."
|
|
848
|
-
explanation = report["overall_explanation"].rstrip()
|
|
849
|
-
report["overall_correctness"] = "patch is correct"
|
|
850
|
-
report["overall_explanation"] = bounded_field(f"{explanation}\n\n{note}", 3000)
|
|
851
|
-
haystack = finding_text.lower()
|
|
852
|
-
for needle in required:
|
|
853
|
-
if needle.lower() not in haystack:
|
|
854
|
-
raise SystemExit(f"required finding text not found: {needle}")
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
def number_in_range(value: Any) -> bool:
|
|
858
|
-
return isinstance(value, (int, float)) and not isinstance(value, bool) and 0 <= value <= 1
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
def print_report(report: dict[str, Any], *, label: str = "autoreview") -> None:
|
|
862
|
-
findings = report["findings"]
|
|
863
|
-
if findings:
|
|
864
|
-
print(f"{label} findings: {len(findings)}")
|
|
865
|
-
elif report["overall_correctness"] == "patch is incorrect":
|
|
866
|
-
print(f"{label} verdict: patch is incorrect without discrete findings")
|
|
867
|
-
else:
|
|
868
|
-
print(f"{label} clean: no accepted/actionable findings reported")
|
|
869
|
-
for finding in findings:
|
|
870
|
-
loc = finding["code_location"]
|
|
871
|
-
print(f"[{finding['priority']}] {finding['title']}")
|
|
872
|
-
print(f"{loc['file_path']}:{loc['line']}")
|
|
873
|
-
print(f"{finding['body']}")
|
|
874
|
-
print()
|
|
875
|
-
print(f"overall: {report['overall_correctness']} ({report['overall_confidence']})")
|
|
876
|
-
print(report["overall_explanation"])
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
def start_parallel_tests(command: str, repo: Path) -> tuple[subprocess.Popen, float]:
|
|
880
|
-
print(f"tests: {command}")
|
|
881
|
-
return subprocess.Popen(command, cwd=repo, shell=True), time.time()
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
def finish_parallel_tests(proc: subprocess.Popen, started: float) -> int:
|
|
885
|
-
proc.wait()
|
|
886
|
-
print(f"tests exit: {proc.returncode} after {int(time.time() - started)}s")
|
|
887
|
-
return int(proc.returncode or 0)
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
def parse_args() -> argparse.Namespace:
|
|
891
|
-
parser = argparse.ArgumentParser(description="Bundle-driven AI code review.")
|
|
892
|
-
parser.add_argument("--mode", choices=["auto", "local", "branch", "commit"], default="auto")
|
|
893
|
-
parser.add_argument("--base")
|
|
894
|
-
parser.add_argument("--commit", default="HEAD")
|
|
895
|
-
parser.add_argument("--engine", choices=ENGINES, default=os.environ.get("AUTOREVIEW_ENGINE", "codex"))
|
|
896
|
-
parser.add_argument("--reviewers", help="Comma-separated review panel, e.g. codex,claude or codex:gpt-5:high.")
|
|
897
|
-
parser.add_argument("--panel", action="store_true", help="Run a Codex/Claude review panel unless --engine changes the first reviewer.")
|
|
898
|
-
parser.add_argument("--model", action="append", help="Model for all reviewers or engine=model. Repeatable.")
|
|
899
|
-
parser.add_argument("--thinking", action="append", help="Thinking/effort for all reviewers or engine=level. Repeatable. Codex: low, medium, high, xhigh. Claude: low, medium, high, xhigh, max.")
|
|
900
|
-
parser.add_argument("--allow-partial-panel", action="store_true", help="Continue panel output when one reviewer fails.")
|
|
901
|
-
parser.add_argument("--codex-bin", default=os.environ.get("CODEX_BIN", "codex"))
|
|
902
|
-
parser.add_argument("--claude-bin", default=os.environ.get("CLAUDE_BIN", "claude"))
|
|
903
|
-
parser.add_argument("--droid-bin", default=os.environ.get("DROID_BIN", "droid"))
|
|
904
|
-
parser.add_argument("--copilot-bin", default=os.environ.get("COPILOT_BIN", "copilot"))
|
|
905
|
-
parser.add_argument("--no-tools", dest="tools", action="store_false", default=True, help="Disable tools for engines that support it. Codex and copilot reject no-tools review.")
|
|
906
|
-
parser.add_argument("--no-web-search", dest="web_search", action="store_false", default=True)
|
|
907
|
-
parser.add_argument(
|
|
908
|
-
"--claude-allowed-tools",
|
|
909
|
-
default=os.environ.get(
|
|
910
|
-
"AUTOREVIEW_CLAUDE_TOOLS",
|
|
911
|
-
"Read,Grep,Glob,WebSearch,WebFetch",
|
|
912
|
-
),
|
|
913
|
-
)
|
|
914
|
-
parser.add_argument("--prompt", action="append", help="Additional review instruction text.")
|
|
915
|
-
parser.add_argument("--prompt-file", action="append", help="Additional review instruction file.")
|
|
916
|
-
parser.add_argument("--dataset", action="append", help="Extra evidence file to include in the review bundle.")
|
|
917
|
-
parser.add_argument("--output", help="Write human output to a file as well as stdout.")
|
|
918
|
-
parser.add_argument("--json-output", help="Write validated structured review JSON.")
|
|
919
|
-
parser.add_argument(
|
|
920
|
-
"--stream-engine-output",
|
|
921
|
-
action="store_true",
|
|
922
|
-
default=os.environ.get("AUTOREVIEW_STREAM_ENGINE_OUTPUT") == "1",
|
|
923
|
-
help="Stream review engine output while preserving buffered output for validation. Codex output is filtered to hide tool/file chatter.",
|
|
924
|
-
)
|
|
925
|
-
parser.add_argument("--parallel-tests", help="Run a test command concurrently with review; failure fails the helper.")
|
|
926
|
-
parser.add_argument("--require-finding", action="append", default=[], help="Require finding text to contain this substring.")
|
|
927
|
-
parser.add_argument("--expect-findings", action="store_true", help="Treat findings as success; for harness acceptance tests.")
|
|
928
|
-
parser.add_argument("--dry-run", action="store_true")
|
|
929
|
-
args = parser.parse_args()
|
|
930
|
-
if args.engine not in ENGINES:
|
|
931
|
-
raise SystemExit(f"invalid --engine/AUTOREVIEW_ENGINE: {args.engine}")
|
|
932
|
-
return args
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
def run_engine(args: argparse.Namespace, repo: Path, prompt: str) -> str:
|
|
936
|
-
if args.engine == "codex":
|
|
937
|
-
return run_codex(args, repo, prompt)
|
|
938
|
-
if args.engine == "claude":
|
|
939
|
-
return run_claude(args, repo, prompt)
|
|
940
|
-
if args.engine == "droid":
|
|
941
|
-
return run_droid(args, repo, prompt)
|
|
942
|
-
if args.engine == "copilot":
|
|
943
|
-
return run_copilot(args, repo, prompt)
|
|
944
|
-
raise SystemExit(f"unsupported engine: {args.engine}")
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
def parse_keyed_options(values: list[str] | None, option: str) -> tuple[str | None, dict[str, str]]:
|
|
948
|
-
global_value: str | None = None
|
|
949
|
-
per_engine: dict[str, str] = {}
|
|
950
|
-
for raw in values or []:
|
|
951
|
-
value = raw.strip()
|
|
952
|
-
if not value:
|
|
953
|
-
raise SystemExit(f"--{option} cannot be empty")
|
|
954
|
-
if "=" in value:
|
|
955
|
-
engine, engine_value = value.split("=", 1)
|
|
956
|
-
engine = engine.strip()
|
|
957
|
-
engine_value = engine_value.strip()
|
|
958
|
-
if engine not in ENGINES:
|
|
959
|
-
raise SystemExit(f"--{option} uses unknown engine: {engine}")
|
|
960
|
-
if not engine_value:
|
|
961
|
-
raise SystemExit(f"--{option} for {engine} cannot be empty")
|
|
962
|
-
if engine in per_engine:
|
|
963
|
-
raise SystemExit(f"--{option} specified more than once for {engine}")
|
|
964
|
-
per_engine[engine] = engine_value
|
|
965
|
-
else:
|
|
966
|
-
if global_value is not None:
|
|
967
|
-
raise SystemExit(f"--{option} global value specified more than once")
|
|
968
|
-
global_value = value
|
|
969
|
-
return global_value, per_engine
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
def parse_reviewer_token(token: str) -> tuple[str, str | None, str | None]:
|
|
973
|
-
parts = [part.strip() for part in token.split(":")]
|
|
974
|
-
if len(parts) > 3 or not parts[0]:
|
|
975
|
-
raise SystemExit(f"invalid reviewer spec: {token}")
|
|
976
|
-
engine = parts[0]
|
|
977
|
-
if engine not in ENGINES:
|
|
978
|
-
raise SystemExit(f"unknown reviewer engine: {engine}")
|
|
979
|
-
model = parts[1] if len(parts) >= 2 and parts[1] else None
|
|
980
|
-
thinking = parts[2] if len(parts) == 3 and parts[2] else None
|
|
981
|
-
return engine, model, thinking
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
def reviewer_args(args: argparse.Namespace) -> list[argparse.Namespace]:
|
|
985
|
-
global_model, model_by_engine = parse_keyed_options(args.model, "model")
|
|
986
|
-
global_thinking, thinking_by_engine = parse_keyed_options(args.thinking, "thinking")
|
|
987
|
-
reviewers: list[tuple[str, str | None, str | None]] = []
|
|
988
|
-
if args.reviewers:
|
|
989
|
-
tokens = [token.strip() for token in args.reviewers.split(",") if token.strip()]
|
|
990
|
-
if len(tokens) == 1 and tokens[0] == "all":
|
|
991
|
-
tokens = list(ENGINES)
|
|
992
|
-
reviewers = [parse_reviewer_token(token) for token in tokens]
|
|
993
|
-
elif args.panel:
|
|
994
|
-
engines = [args.engine]
|
|
995
|
-
for engine in ("codex", "claude"):
|
|
996
|
-
if engine not in engines:
|
|
997
|
-
engines.append(engine)
|
|
998
|
-
reviewers = [(engine, None, None) for engine in engines]
|
|
999
|
-
else:
|
|
1000
|
-
reviewers = [(args.engine, None, None)]
|
|
1001
|
-
|
|
1002
|
-
seen: set[str] = set()
|
|
1003
|
-
result: list[argparse.Namespace] = []
|
|
1004
|
-
for engine, inline_model, inline_thinking in reviewers:
|
|
1005
|
-
if engine in seen:
|
|
1006
|
-
raise SystemExit(f"reviewer specified more than once: {engine}")
|
|
1007
|
-
seen.add(engine)
|
|
1008
|
-
model = inline_model or model_by_engine.get(engine) or global_model
|
|
1009
|
-
thinking = inline_thinking or thinking_by_engine.get(engine) or global_thinking
|
|
1010
|
-
if thinking and thinking not in THINKING_LEVELS_BY_ENGINE[engine]:
|
|
1011
|
-
valid = ", ".join(sorted(THINKING_LEVELS_BY_ENGINE[engine])) or "none"
|
|
1012
|
-
raise SystemExit(f"invalid thinking level for {engine}: {thinking} (valid: {valid})")
|
|
1013
|
-
clone = copy.copy(args)
|
|
1014
|
-
clone.engine = engine
|
|
1015
|
-
clone.model = model
|
|
1016
|
-
clone.thinking = thinking
|
|
1017
|
-
result.append(clone)
|
|
1018
|
-
return result
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
def reviewer_label(args: argparse.Namespace) -> str:
|
|
1022
|
-
parts = [args.engine]
|
|
1023
|
-
if args.model:
|
|
1024
|
-
parts.append(f"model={args.model}")
|
|
1025
|
-
if args.thinking:
|
|
1026
|
-
parts.append(f"thinking={args.thinking}")
|
|
1027
|
-
return " ".join(parts)
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
def run_reviewer(args: argparse.Namespace, repo: Path, prompt: str, changed_paths: set[str], required: list[str]) -> dict[str, Any]:
|
|
1031
|
-
raw = run_engine(args, repo, prompt)
|
|
1032
|
-
report = extract_json(raw)
|
|
1033
|
-
validate_report(report, repo, changed_paths, required)
|
|
1034
|
-
return report
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
def merge_panel_reports(reports: list[tuple[str, dict[str, Any]]]) -> dict[str, Any]:
|
|
1038
|
-
findings: list[dict[str, Any]] = []
|
|
1039
|
-
seen: set[tuple[str, int, str, str]] = set()
|
|
1040
|
-
for label, report in reports:
|
|
1041
|
-
for finding in report["findings"]:
|
|
1042
|
-
location = finding["code_location"]
|
|
1043
|
-
key = (
|
|
1044
|
-
location["file_path"],
|
|
1045
|
-
location["line"],
|
|
1046
|
-
finding["category"],
|
|
1047
|
-
" ".join(finding["title"].lower().split()),
|
|
1048
|
-
)
|
|
1049
|
-
if key in seen:
|
|
1050
|
-
continue
|
|
1051
|
-
seen.add(key)
|
|
1052
|
-
merged = copy.deepcopy(finding)
|
|
1053
|
-
merged["body"] = bounded_field(f"Reviewer: {label}\n\n{merged['body']}", 2000)
|
|
1054
|
-
findings.append(merged)
|
|
1055
|
-
incorrect = bool(findings) or any(report["overall_correctness"] == "patch is incorrect" for _, report in reports)
|
|
1056
|
-
summary = ", ".join(f"{label}: {len(report['findings'])} finding(s)" for label, report in reports)
|
|
1057
|
-
return {
|
|
1058
|
-
"findings": findings,
|
|
1059
|
-
"overall_correctness": "patch is incorrect" if incorrect else "patch is correct",
|
|
1060
|
-
"overall_explanation": f"Panel review complete. {summary}.",
|
|
1061
|
-
"overall_confidence": max((report["overall_confidence"] for _, report in reports), default=0.5),
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
def run_panel(args: argparse.Namespace, reviewers: list[argparse.Namespace], repo: Path, prompt: str, changed_paths: set[str]) -> dict[str, Any]:
|
|
1066
|
-
reports: list[tuple[str, dict[str, Any]]] = []
|
|
1067
|
-
failures: list[str] = []
|
|
1068
|
-
with concurrent.futures.ThreadPoolExecutor(max_workers=len(reviewers)) as executor:
|
|
1069
|
-
future_by_label = {
|
|
1070
|
-
executor.submit(run_reviewer, reviewer, repo, prompt, changed_paths, []): reviewer_label(reviewer)
|
|
1071
|
-
for reviewer in reviewers
|
|
1072
|
-
}
|
|
1073
|
-
for future in concurrent.futures.as_completed(future_by_label):
|
|
1074
|
-
label = future_by_label[future]
|
|
1075
|
-
try:
|
|
1076
|
-
reports.append((label, future.result()))
|
|
1077
|
-
except SystemExit as exc:
|
|
1078
|
-
failures.append(f"{label}: {exc}")
|
|
1079
|
-
except Exception as exc:
|
|
1080
|
-
failures.append(f"{label}: {exc}")
|
|
1081
|
-
if failures and not args.allow_partial_panel:
|
|
1082
|
-
raise SystemExit("autoreview panel failed\n" + "\n".join(failures))
|
|
1083
|
-
if failures:
|
|
1084
|
-
for failure in failures:
|
|
1085
|
-
print(f"panel reviewer failed: {failure}")
|
|
1086
|
-
if not reports:
|
|
1087
|
-
raise SystemExit("autoreview panel produced no reports")
|
|
1088
|
-
reports.sort(key=lambda item: item[0])
|
|
1089
|
-
report = merge_panel_reports(reports)
|
|
1090
|
-
validate_report(report, repo, changed_paths, args.require_finding)
|
|
1091
|
-
return report
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
def main() -> int:
|
|
1095
|
-
args = parse_args()
|
|
1096
|
-
reviewers = reviewer_args(args)
|
|
1097
|
-
repo = repo_root()
|
|
1098
|
-
target, target_ref = choose_target(repo, args.mode, args.base)
|
|
1099
|
-
print(f"autoreview target: {target}")
|
|
1100
|
-
print(f"branch: {current_branch(repo)}")
|
|
1101
|
-
if len(reviewers) == 1 and not args.reviewers and not args.panel:
|
|
1102
|
-
print(f"engine: {reviewers[0].engine}")
|
|
1103
|
-
if reviewers[0].model:
|
|
1104
|
-
print(f"model: {reviewers[0].model}")
|
|
1105
|
-
if reviewers[0].thinking:
|
|
1106
|
-
print(f"thinking: {reviewers[0].thinking}")
|
|
1107
|
-
else:
|
|
1108
|
-
print(f"reviewers: {', '.join(reviewer_label(reviewer) for reviewer in reviewers)}")
|
|
1109
|
-
print(f"tools: {'on' if args.tools else 'off'}")
|
|
1110
|
-
print(f"web_search: {'on' if args.web_search else 'off'}")
|
|
1111
|
-
display_ref = args.commit if target == "commit" else target_ref
|
|
1112
|
-
if display_ref:
|
|
1113
|
-
print(f"ref: {display_ref}")
|
|
1114
|
-
if args.dry_run:
|
|
1115
|
-
return 0
|
|
1116
|
-
|
|
1117
|
-
if target == "local":
|
|
1118
|
-
bundle = local_bundle(repo)
|
|
1119
|
-
elif target == "branch":
|
|
1120
|
-
assert target_ref
|
|
1121
|
-
bundle = branch_bundle(repo, target_ref)
|
|
1122
|
-
else:
|
|
1123
|
-
bundle = commit_bundle(repo, args.commit)
|
|
1124
|
-
target_ref = args.commit
|
|
1125
|
-
prompt = build_prompt(repo, target, target_ref, bundle, load_extra_prompt(args), load_datasets(args))
|
|
1126
|
-
changed_paths = review_paths(repo, target, target_ref, args.commit)
|
|
1127
|
-
print(f"bundle: {len(prompt)} chars")
|
|
1128
|
-
|
|
1129
|
-
tests_proc: tuple[subprocess.Popen, float] | None = None
|
|
1130
|
-
if args.parallel_tests:
|
|
1131
|
-
tests_proc = start_parallel_tests(args.parallel_tests, repo)
|
|
1132
|
-
try:
|
|
1133
|
-
if len(reviewers) == 1:
|
|
1134
|
-
report = run_reviewer(reviewers[0], repo, prompt, changed_paths, args.require_finding)
|
|
1135
|
-
label = "autoreview"
|
|
1136
|
-
else:
|
|
1137
|
-
report = run_panel(args, reviewers, repo, prompt, changed_paths)
|
|
1138
|
-
label = "autoreview panel"
|
|
1139
|
-
if args.json_output:
|
|
1140
|
-
Path(args.json_output).write_text(json.dumps(report, indent=2) + "\n")
|
|
1141
|
-
|
|
1142
|
-
if args.output:
|
|
1143
|
-
original_stdout = sys.stdout
|
|
1144
|
-
with Path(args.output).open("w") as handle:
|
|
1145
|
-
sys.stdout = Tee(original_stdout, handle)
|
|
1146
|
-
print_report(report, label=label)
|
|
1147
|
-
sys.stdout = original_stdout
|
|
1148
|
-
else:
|
|
1149
|
-
print_report(report, label=label)
|
|
1150
|
-
finally:
|
|
1151
|
-
tests_status = finish_parallel_tests(*tests_proc) if tests_proc else 0
|
|
1152
|
-
|
|
1153
|
-
has_findings = bool(report["findings"])
|
|
1154
|
-
overall_incorrect = report["overall_correctness"] == "patch is incorrect"
|
|
1155
|
-
if tests_status != 0:
|
|
1156
|
-
return 1
|
|
1157
|
-
if args.expect_findings:
|
|
1158
|
-
return 0 if has_findings else 1
|
|
1159
|
-
return 1 if has_findings or overall_incorrect else 0
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
class Tee:
|
|
1163
|
-
def __init__(self, *streams: Any) -> None:
|
|
1164
|
-
self.streams = streams
|
|
1165
|
-
|
|
1166
|
-
def write(self, data: str) -> None:
|
|
1167
|
-
for stream in self.streams:
|
|
1168
|
-
stream.write(data)
|
|
1169
|
-
|
|
1170
|
-
def flush(self) -> None:
|
|
1171
|
-
for stream in self.streams:
|
|
1172
|
-
stream.flush()
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
if __name__ == "__main__":
|
|
1176
|
-
raise SystemExit(main())
|