loadwise 0.8.0 → 0.9.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/PERFORMANCE.md +17 -0
- package/README.md +238 -713
- package/agent/hooks/check-edited-file.mjs +682 -0
- package/dist/bin/github-action.js +143 -18
- package/dist/bin/loadwise.js +15 -28
- package/dist/lib/accessibility/angular-literal.js +1 -1
- package/dist/lib/accessibility/astro-template.js +111 -0
- package/dist/lib/accessibility/autofocus.js +94 -0
- package/dist/lib/accessibility/document-reference-rules.js +133 -0
- package/dist/lib/accessibility/form-context.js +7 -2
- package/dist/lib/accessibility/frontend-detect.js +18 -8
- package/dist/lib/accessibility/heading-order.js +59 -0
- package/dist/lib/accessibility/interaction-semantics.js +90 -0
- package/dist/lib/accessibility/jinja-template.js +150 -0
- package/dist/lib/accessibility/jsx-elements.js +134 -9
- package/dist/lib/accessibility/language-tags.js +18 -0
- package/dist/lib/accessibility/markup-files.js +44 -17
- package/dist/lib/accessibility/markup.js +4 -1
- package/dist/lib/accessibility/media-rules.js +81 -0
- package/dist/lib/accessibility/native-interactive.js +107 -0
- package/dist/lib/accessibility/rule-ids.js +30 -0
- package/dist/lib/accessibility/rule-utilities.js +92 -0
- package/dist/lib/accessibility/rules.js +74 -139
- package/dist/lib/accessibility/site-fixes/buttons.js +4 -11
- package/dist/lib/accessibility/site-fixes/email-autocomplete.js +103 -0
- package/dist/lib/accessibility/site-fixes/html-language.js +48 -0
- package/dist/lib/accessibility/site-fixes/media-autoplay.js +87 -0
- package/dist/lib/accessibility/site-fixes/positive-tabindex.js +102 -0
- package/dist/lib/accessibility/site-fixes/source-position.js +11 -0
- package/dist/lib/accessibility/site-fixes/viewport.js +107 -0
- package/dist/lib/accessibility/table-headers.js +70 -0
- package/dist/lib/accessibility/template-attributes.js +13 -2
- package/dist/lib/accessibility/template-binding-scope.js +122 -0
- package/dist/lib/accessibility/template-elements.js +257 -109
- package/dist/lib/accessibility/template-file.js +111 -22
- package/dist/lib/accessibility/template-tag-tables.js +86 -0
- package/dist/lib/accessibility/usage.js +1 -1
- package/dist/lib/editor/accessibility-examples.js +5 -0
- package/dist/lib/editor/actions.js +11 -5
- package/dist/lib/editor/apply-fix.js +30 -2
- package/dist/lib/editor/configured-setup.js +9 -14
- package/dist/lib/editor/diagnostics.js +9 -26
- package/dist/lib/editor/dismissals.js +21 -10
- package/dist/lib/editor/doctor.js +167 -0
- package/dist/lib/editor/editor-document.js +17 -1
- package/dist/lib/editor/editor-launcher.js +60 -26
- package/dist/lib/editor/fix-edits.js +87 -8
- package/dist/lib/editor/jetbrains-setup.js +2 -1
- package/dist/lib/editor/language-server.js +220 -47
- package/dist/lib/editor/native-setup.js +7 -2
- package/dist/lib/editor/perf-watch.js +7 -5
- package/dist/lib/editor/performance-examples.js +31 -0
- package/dist/lib/editor/polyglot-selection.js +193 -0
- package/dist/lib/editor/project-policy.js +146 -0
- package/dist/lib/editor/project-watches.js +86 -0
- package/dist/lib/editor/release-vsix.js +23 -1
- package/dist/lib/editor/reliability-examples.js +36 -0
- package/dist/lib/editor/scan-session.js +210 -61
- package/dist/lib/editor/security-examples.js +24 -14
- package/dist/lib/editor/server-commands.js +24 -11
- package/dist/lib/editor/setup.js +7 -12
- package/dist/lib/editor/standalone-performance-examples.js +3 -0
- package/dist/lib/editor/workspace-files.js +32 -8
- package/dist/lib/editor/workspace-paths.js +29 -7
- package/dist/lib/editor/zed-settings.js +118 -0
- package/dist/lib/editor/zed-setup.js +88 -0
- package/dist/lib/maintainability/analysis/analyze-source.js +6 -3
- package/dist/lib/maintainability/analysis/source-exclusions.js +2 -1
- package/dist/lib/maintainability/analysis/source-facts.js +2 -2
- package/dist/lib/maintainability/architecture/graph.js +2 -1
- package/dist/lib/maintainability/architecture/layout.js +2 -1
- package/dist/lib/maintainability/cli/apply-fix.js +32 -7
- package/dist/lib/maintainability/cli/changed-lines.js +7 -113
- package/dist/lib/maintainability/cli/finding-ids.js +3 -6
- package/dist/lib/maintainability/cli/fix-cli.js +1 -9
- package/dist/lib/maintainability/cli/git-inventory.js +5 -6
- package/dist/lib/maintainability/cli/inputs.js +12 -11
- package/dist/lib/maintainability/cli/scan-arguments.js +33 -0
- package/dist/lib/maintainability/cli/site-fix.js +28 -13
- package/dist/lib/maintainability/cli.js +25 -35
- package/dist/lib/maintainability/entry-points/entry-points.js +27 -68
- package/dist/lib/maintainability/examples.js +12 -0
- package/dist/lib/maintainability/polyglot-duplicates.js +1 -0
- package/dist/lib/maintainability/polyglot.js +337 -12
- package/dist/lib/maintainability/project.js +4 -4
- package/dist/lib/maintainability/quality/console-tooling.js +114 -0
- package/dist/lib/maintainability/quality/declarative-imports.js +18 -0
- package/dist/lib/maintainability/quality/deprecated-apis.js +227 -40
- package/dist/lib/maintainability/quality/duplicates.js +5 -11
- package/dist/lib/maintainability/quality/generic-assertion-target.js +75 -0
- package/dist/lib/maintainability/quality/limits.js +5 -1
- package/dist/lib/maintainability/quality/size-limits.js +2 -1
- package/dist/lib/maintainability/quality/stray-console.js +31 -7
- package/dist/lib/maintainability/quality/tsconfig-strict.js +125 -6
- package/dist/lib/maintainability/quality/type-escape-hatches.js +411 -0
- package/dist/lib/maintainability/quality/type-safety-hygiene.js +132 -42
- package/dist/lib/maintainability/quality/unowned-source.js +15 -0
- package/dist/lib/maintainability/rule-ids.js +9 -0
- package/dist/lib/maintainability/scan-changed.js +6 -1
- package/dist/lib/maintainability/scan-worker.js +3 -5
- package/dist/lib/maintainability/scan.js +16 -3
- package/dist/lib/maintainability/site-fixes/duplicate-edits.js +3 -2
- package/dist/lib/maintainability/site-fixes/duplicate-methods.js +7 -2
- package/dist/lib/maintainability/site-fixes/duplicates.js +3 -2
- package/dist/lib/maintainability/site-fixes/focused-test.js +230 -0
- package/dist/lib/maintainability/site-fixes/helpers.js +2 -6
- package/dist/lib/maintainability/site-fixes/if-rewrites.js +1 -7
- package/dist/lib/maintainability/site-fixes/large-module.js +2 -1
- package/dist/lib/maintainability/unused/ancestor-aliases.js +2 -2
- package/dist/lib/maintainability/unused/module-usage-dynamic.js +2 -1
- package/dist/lib/maintainability/unused/module-usage-named-exports.js +125 -0
- package/dist/lib/maintainability/unused/module-usage.js +8 -3
- package/dist/lib/maintainability/unused/unused-modules.js +35 -1
- package/dist/lib/performance/analysis/call-syntax.js +2 -1
- package/dist/lib/performance/analysis/function-kinds.js +1 -5
- package/dist/lib/performance/analysis/missing-packages.js +10 -7
- package/dist/lib/performance/analysis/package-types.js +10 -2
- package/dist/lib/performance/analysis/schema-tooling.js +157 -8
- package/dist/lib/performance/analysis/source-inputs.js +17 -12
- package/dist/lib/performance/analysis/unscanned-javascript.js +6 -5
- package/dist/lib/performance/analyze.js +22 -6
- package/dist/lib/performance/async/async-errors.js +162 -14
- package/dist/lib/performance/async/await-before-early-exit.js +1 -6
- package/dist/lib/performance/async/floating-promises.js +2 -2
- package/dist/lib/performance/async/promise-return-escapes-catch.js +35 -2
- package/dist/lib/performance/async/stream-errors.js +1 -3
- package/dist/lib/performance/cli/changed-lines.js +14 -111
- package/dist/lib/performance/cli/cli-arguments.js +11 -9
- package/dist/lib/performance/cli/cli-markup.js +42 -0
- package/dist/lib/performance/cli/cli-policy.js +150 -16
- package/dist/lib/performance/cli/cli-scan.js +148 -118
- package/dist/lib/performance/cli/finding-ids.js +7 -7
- package/dist/lib/performance/cli/fix-cli.js +83 -34
- package/dist/lib/performance/cli/prisma-schema-findings.js +23 -0
- package/dist/lib/performance/cli/watch-security.js +33 -0
- package/dist/lib/performance/cli/watch.js +17 -9
- package/dist/lib/performance/cli.js +8 -7
- package/dist/lib/performance/collections/array-drains.js +354 -0
- package/dist/lib/performance/collections/collection-bindings.js +1 -2
- package/dist/lib/performance/collections/collection-bounds.js +3 -2
- package/dist/lib/performance/collections/collection-copy.js +51 -1
- package/dist/lib/performance/collections/collection-lookups.js +47 -3
- package/dist/lib/performance/collections/collection-reduce.js +0 -4
- package/dist/lib/performance/collections/collections.js +6 -2
- package/dist/lib/performance/collections/json-clone.js +137 -17
- package/dist/lib/performance/collections/regex-allocation.js +156 -0
- package/dist/lib/performance/collections/repeated.js +2 -8
- package/dist/lib/performance/collections/sort-extreme.js +18 -1
- package/dist/lib/performance/collections/workbook-decodes.js +3 -2
- package/dist/lib/performance/contracts/cli.js +329 -21
- package/dist/lib/performance/contracts/git-files.js +57 -5
- package/dist/lib/performance/contracts/openapi-schema.js +187 -0
- package/dist/lib/performance/contracts/openapi-sources.js +260 -0
- package/dist/lib/performance/contracts/openapi.js +172 -233
- package/dist/lib/performance/contracts/protobuf.js +301 -0
- package/dist/lib/performance/contracts/trpc-moves.js +46 -0
- package/dist/lib/performance/contracts/trpc.js +477 -0
- package/dist/lib/performance/datastores/pg-integrity.js +2 -1
- package/dist/lib/performance/datastores/pooling.js +2 -1
- package/dist/lib/performance/datastores/redis-keys.js +4 -3
- package/dist/lib/performance/datastores/redis.js +8 -1
- package/dist/lib/performance/datastores/repeated-reads.js +104 -0
- package/dist/lib/performance/datastores/search-clients.js +9 -0
- package/dist/lib/performance/datastores/session-store.js +166 -7
- package/dist/lib/performance/datastores/supabase.js +73 -0
- package/dist/lib/performance/db/checks.js +1 -1
- package/dist/lib/performance/db/cli-mysql.js +12 -2
- package/dist/lib/performance/db/cli.js +38 -5
- package/dist/lib/performance/db/drivers.js +20 -4
- package/dist/lib/performance/db/measure.js +1 -1
- package/dist/lib/performance/db/mysql-catalog.js +1 -1
- package/dist/lib/performance/db/plan-estimates.js +46 -7
- package/dist/lib/performance/db/redact.js +1 -3
- package/dist/lib/performance/db/snapshot.js +1 -1
- package/dist/lib/performance/db/sqlite-plan.js +95 -0
- package/dist/lib/performance/engine/compiler.js +3 -2
- package/dist/lib/performance/engine/native-checker.js +85 -10
- package/dist/lib/performance/engine/native-syntax.js +17 -0
- package/dist/lib/performance/engine/native-workspaces.js +36 -8
- package/dist/lib/performance/engine/native.js +38 -16
- package/dist/lib/performance/engine/review-config-inputs.js +57 -0
- package/dist/lib/performance/evidence/plans.js +14 -16
- package/dist/lib/performance/evidence/trace-formats.js +182 -0
- package/dist/lib/performance/evidence/traces.js +6 -6
- package/dist/lib/performance/frontend/angular-bootstrap.js +309 -0
- package/dist/lib/performance/frontend/barrel-subpaths.js +204 -0
- package/dist/lib/performance/frontend/effect-cleanup.js +30 -4
- package/dist/lib/performance/frontend/frontend-dom-perf.js +11 -7
- package/dist/lib/performance/frontend/frontend-perf.js +4 -5
- package/dist/lib/performance/frontend/frontend-render-perf.js +10 -10
- package/dist/lib/performance/frontend/layout-binary-probe.js +186 -0
- package/dist/lib/performance/frontend/next-fetch-waterfall.js +88 -0
- package/dist/lib/performance/frontend/template-tracking.js +131 -0
- package/dist/lib/performance/index-rules/index-rules-table.js +3 -3
- package/dist/lib/performance/index-rules/redundant-indexes.js +6 -13
- package/dist/lib/performance/migrations/cli.js +65 -14
- package/dist/lib/performance/migrations/discover.js +63 -32
- package/dist/lib/performance/migrations/enforce.js +5 -12
- package/dist/lib/performance/migrations/extract-code-sql.js +10 -7
- package/dist/lib/performance/migrations/extract-code.js +1 -0
- package/dist/lib/performance/migrations/extract-sql.js +45 -4
- package/dist/lib/performance/migrations/extract-sqlite.js +302 -0
- package/dist/lib/performance/migrations/operations.js +122 -8
- package/dist/lib/performance/migrations/postgres-registry.js +6 -6
- package/dist/lib/performance/migrations/postgres-table-history.js +147 -0
- package/dist/lib/performance/migrations/rules-postgres-shared.js +4 -6
- package/dist/lib/performance/migrations/rules-postgres.js +67 -13
- package/dist/lib/performance/migrations/rules-sqlite.js +118 -0
- package/dist/lib/performance/migrations/sqlserver-creation.js +131 -0
- package/dist/lib/performance/migrations/sqlserver.js +81 -0
- package/dist/lib/performance/models/client-imports.js +286 -0
- package/dist/lib/performance/models/index.js +46 -8
- package/dist/lib/performance/orm/cartesian-includes.js +49 -22
- package/dist/lib/performance/orm/drizzle.js +86 -27
- package/dist/lib/performance/orm/knex-loop-operations.js +96 -0
- package/dist/lib/performance/orm/orm-owners.js +3 -5
- package/dist/lib/performance/orm/orm-queries.js +50 -152
- package/dist/lib/performance/orm/orm-result-uses.js +116 -0
- package/dist/lib/performance/orm/prisma-integrity.js +24 -3
- package/dist/lib/performance/orm/prisma.js +31 -8
- package/dist/lib/performance/orm/typeorm-batch-filter.js +43 -0
- package/dist/lib/performance/orm/typeorm-projection.js +2 -2
- package/dist/lib/performance/orm/typeorm-transaction-loops.js +3 -4
- package/dist/lib/performance/orm/typeorm-updates.js +1 -3
- package/dist/lib/performance/orm/unbounded-list-page-size.js +179 -0
- package/dist/lib/performance/orm/unbounded-list-queries.js +63 -146
- package/dist/lib/performance/polyglot.js +173 -61
- package/dist/lib/performance/probe-caches.js +42 -0
- package/dist/lib/performance/program-batches.js +138 -0
- package/dist/lib/performance/projects.js +85 -89
- package/dist/lib/performance/query-loops/guard-queries.js +2 -1
- package/dist/lib/performance/query-loops/parallel-reads-policy.js +1 -3
- package/dist/lib/performance/query-loops/query-loop-batch.js +81 -7
- package/dist/lib/performance/query-loops/query-loop-bounds.js +1 -13
- package/dist/lib/performance/query-loops/query-policy.js +19 -20
- package/dist/lib/performance/query-loops/query-results.js +1 -6
- package/dist/lib/performance/query-loops/query-write-context.js +89 -0
- package/dist/lib/performance/query-loops/sequential-loops.js +6 -24
- package/dist/lib/performance/query-loops/service-call-resolution.js +17 -2
- package/dist/lib/performance/query-loops/service-loop-source.js +124 -0
- package/dist/lib/performance/query-loops/service-loops.js +48 -17
- package/dist/lib/performance/query-loops/throw-on-miss-loops.js +141 -0
- package/dist/lib/performance/request/backend-mastery.js +18 -30
- package/dist/lib/performance/request/fixed-emitter-loop.js +98 -0
- package/dist/lib/performance/request/fresh-mapped-elements.js +137 -0
- package/dist/lib/performance/request/graphql-list-lookups.js +258 -0
- package/dist/lib/performance/request/http-options-writes.js +2 -8
- package/dist/lib/performance/request/http-timeouts.js +3 -2
- package/dist/lib/performance/request/json-stringify-output.js +139 -0
- package/dist/lib/performance/request/llm-max-tokens.js +27 -8
- package/dist/lib/performance/request/mongoose-lean.js +15 -10
- package/dist/lib/performance/request/node-event-listener-leak.js +190 -35
- package/dist/lib/performance/request/node-fs-context.js +6 -8
- package/dist/lib/performance/request/node-fs.js +4 -6
- package/dist/lib/performance/request/password-hashing.js +4 -3
- package/dist/lib/performance/request/phase5-ast.js +3 -9
- package/dist/lib/performance/request/phase5-rules.js +50 -102
- package/dist/lib/performance/request/pure-js-hashing.js +2 -1
- package/dist/lib/performance/request/request-handlers.js +1 -3
- package/dist/lib/performance/request/request-inputs.js +121 -26
- package/dist/lib/performance/request/unbounded-promise-all.js +132 -3
- package/dist/lib/performance/rule-ids.js +47 -4
- package/dist/lib/performance/schema/context.js +7 -16
- package/dist/lib/performance/schema/model.js +1 -9
- package/dist/lib/performance/schema/prisma-owners.js +15 -1
- package/dist/lib/performance/schema/prisma-schema.js +5 -6
- package/dist/lib/performance/schema/project-indexes-events.js +8 -2
- package/dist/lib/performance/schema/project-indexes.js +4 -2
- package/dist/lib/performance/schema/query-site-support.js +1 -1
- package/dist/lib/performance/schema/sequelize-schema.js +1 -3
- package/dist/lib/performance/schema/ts-helpers.js +3 -7
- package/dist/lib/performance/shared-libs.js +48 -0
- package/dist/lib/performance/site-fix.js +32 -7
- package/dist/lib/performance/site-fixes/collection-copy.js +2 -1
- package/dist/lib/performance/site-fixes/collection-existence.js +2 -1
- package/dist/lib/performance/site-fixes/collection-find.js +2 -1
- package/dist/lib/performance/site-fixes/collection-helpers.js +0 -6
- package/dist/lib/performance/site-fixes/collection-lookups.js +2 -1
- package/dist/lib/performance/site-fixes/database.js +7 -16
- package/dist/lib/performance/site-fixes/drizzle-index.js +2 -9
- package/dist/lib/performance/site-fixes/frontend-fixes.js +47 -15
- package/dist/lib/performance/site-fixes/helpers.js +19 -18
- package/dist/lib/performance/site-fixes/last-insert-id.js +2 -1
- package/dist/lib/performance/site-fixes/llm-max-tokens.js +56 -0
- package/dist/lib/performance/site-fixes/migration-column-rules.js +11 -7
- package/dist/lib/performance/site-fixes/migration-lock-rules.js +6 -3
- package/dist/lib/performance/site-fixes/migrations.js +4 -0
- package/dist/lib/performance/site-fixes/pure-js-hashing.js +2 -2
- package/dist/lib/performance/site-fixes/query-shapes.js +1 -4
- package/dist/lib/performance/site-fixes/service-loop-ast.js +1 -9
- package/dist/lib/performance/site-fixes/small-rewrites.js +28 -2
- package/dist/lib/performance/site-fixes/template-tracking-fixes.js +82 -0
- package/dist/lib/performance/site-fixes/writes.js +1 -6
- package/dist/lib/performance/sql/local-statements.js +108 -0
- package/dist/lib/performance/sql/mysql-tokens.js +1 -4
- package/dist/lib/performance/sql/pg-parser.js +3 -5
- package/dist/lib/performance/sql/sqlserver-control.js +43 -0
- package/dist/lib/reliability/analyze.js +48 -5
- package/dist/lib/reliability/boundary-access.js +34 -27
- package/dist/lib/reliability/callback-completion.js +10 -2
- package/dist/lib/reliability/child-process.js +2 -2
- package/dist/lib/reliability/crlf-line-split.js +124 -73
- package/dist/lib/reliability/crlf-references.js +78 -0
- package/dist/lib/reliability/default-numeric-sort.js +25 -0
- package/dist/lib/reliability/error-cause-plan.js +29 -0
- package/dist/lib/reliability/error-values.js +68 -27
- package/dist/lib/reliability/json-cast.js +368 -0
- package/dist/lib/reliability/key-test-callee.js +50 -0
- package/dist/lib/reliability/lossy-text-rewrite.js +94 -0
- package/dist/lib/reliability/manifest-boundary.js +466 -0
- package/dist/lib/reliability/manifest-snapshot.js +40 -0
- package/dist/lib/reliability/parse-failure-flow.js +5 -2
- package/dist/lib/reliability/parse-failure-paths.js +39 -8
- package/dist/lib/reliability/parse-failure-reset.js +5 -17
- package/dist/lib/reliability/pool-timeout.js +31 -7
- package/dist/lib/reliability/promise-usage.js +281 -0
- package/dist/lib/reliability/react-bugs.js +7 -6
- package/dist/lib/reliability/react-state-order.js +2 -2
- package/dist/lib/reliability/react-state-paths.js +2 -2
- package/dist/lib/reliability/react-state-setter.js +5 -11
- package/dist/lib/reliability/react-state-walker.js +3 -3
- package/dist/lib/reliability/required-member.js +19 -0
- package/dist/lib/reliability/resource-leak-intervals.js +4 -7
- package/dist/lib/reliability/resource-leaks.js +4 -7
- package/dist/lib/reliability/rule-ids.js +70 -1
- package/dist/lib/reliability/same-file-io.js +135 -0
- package/dist/lib/reliability/short-write.js +220 -0
- package/dist/lib/reliability/site-fixes/crlf-line-split.js +71 -0
- package/dist/lib/reliability/site-fixes/error-values.js +40 -0
- package/dist/lib/reliability/site-fixes/pool-timeout.js +51 -0
- package/dist/lib/reliability/source-helpers.js +18 -8
- package/dist/lib/reliability/standalone-sources.js +8 -6
- package/dist/lib/reliability/suspicious-logic.js +6 -8
- package/dist/lib/reliability/swallowed-errors.js +3 -7
- package/dist/lib/reliability/switch-exhaustive.js +195 -5
- package/dist/lib/reliability/test-cleanup-after-await.js +2 -2
- package/dist/lib/reliability/throw-string-plan.js +121 -0
- package/dist/lib/reliability/uncaught-exception.js +2 -7
- package/dist/lib/reliability/usage.js +1 -1
- package/dist/lib/reliability/working-directory.js +101 -0
- package/dist/lib/security/analyze.js +2 -0
- package/dist/lib/security/auth-crypto/hashing.js +21 -4
- package/dist/lib/security/auth-crypto/index.js +6 -1
- package/dist/lib/security/auth-crypto/jwt-decode-helpers.js +163 -0
- package/dist/lib/security/auth-crypto/jwt.js +52 -36
- package/dist/lib/security/auth-crypto/plaintext-password.js +2 -1
- package/dist/lib/security/auth-crypto/random.js +2 -1
- package/dist/lib/security/auth-crypto/rate-limits.js +79 -8
- package/dist/lib/security/auth-crypto/rule-ids.js +2 -0
- package/dist/lib/security/auth-crypto/secrets.js +11 -3
- package/dist/lib/security/auth-crypto/shared.js +1 -4
- package/dist/lib/security/auth-crypto/signature-verification.js +29 -0
- package/dist/lib/security/auth-crypto/transport-and-ciphers.js +43 -3
- package/dist/lib/security/auth-crypto/weak-hash.js +183 -0
- package/dist/lib/security/bindings.js +41 -9
- package/dist/lib/security/cli.js +83 -26
- package/dist/lib/security/cookie-csrf.js +316 -7
- package/dist/lib/security/deps/cargo-lock.js +78 -0
- package/dist/lib/security/deps/cli.js +4 -4
- package/dist/lib/security/deps/fixed-version.js +2 -2
- package/dist/lib/security/deps/lockfiles.js +204 -16
- package/dist/lib/security/deps/osv.js +190 -59
- package/dist/lib/security/deps/scan.js +87 -19
- package/dist/lib/security/examples/{auth-crypto.cjs → auth-crypto.js} +11 -5
- package/dist/lib/security/examples/{deps.cjs → deps.js} +1 -3
- package/dist/lib/security/examples/{exposure.cjs → exposure.js} +17 -3
- package/dist/lib/security/examples/{files.cjs → files.js} +9 -3
- package/dist/lib/security/examples/{injection.cjs → injection.js} +13 -3
- package/dist/lib/security/examples/{moved.cjs → moved.js} +1 -3
- package/dist/lib/security/examples/{request-forgery.cjs → request-forgery.js} +1 -3
- package/dist/lib/security/exposure/backend-security-mastery.js +2 -1
- package/dist/lib/security/exposure/client-env.js +2 -1
- package/dist/lib/security/exposure/content-disposition.js +71 -0
- package/dist/lib/security/exposure/cookies.js +200 -1
- package/dist/lib/security/exposure/cors.js +63 -4
- package/dist/lib/security/exposure/frontend-security.js +7 -60
- package/dist/lib/security/exposure/index.js +9 -0
- package/dist/lib/security/exposure/js-yaml.js +203 -0
- package/dist/lib/security/exposure/message-effects.js +266 -0
- package/dist/lib/security/exposure/package-manifest.js +2 -2
- package/dist/lib/security/exposure/prototype-pollution.js +26 -1
- package/dist/lib/security/exposure/reflected-xss.js +47 -12
- package/dist/lib/security/exposure/response-content-type.js +181 -0
- package/dist/lib/security/exposure/rule-ids.js +4 -0
- package/dist/lib/security/exposure/trust-boundary.js +142 -0
- package/dist/lib/security/exposure/url-secrets.js +38 -2
- package/dist/lib/security/exposure/webhook-verification.js +231 -0
- package/dist/lib/security/express-registration.js +45 -0
- package/dist/lib/security/express-router-factories.js +118 -0
- package/dist/lib/security/files/component-markup.js +66 -0
- package/dist/lib/security/files/compose.js +2 -1
- package/dist/lib/security/files/index.js +121 -27
- package/dist/lib/security/files/kubernetes.js +136 -0
- package/dist/lib/security/files/project-files.js +98 -31
- package/dist/lib/security/files/rule-ids.js +2 -0
- package/dist/lib/security/files/secrets.js +9 -5
- package/dist/lib/security/injection/code.js +33 -5
- package/dist/lib/security/injection/command.js +51 -4
- package/dist/lib/security/injection/escape-preserving.js +219 -0
- package/dist/lib/security/injection/escape-replace.js +174 -2
- package/dist/lib/security/injection/index.js +5 -1
- package/dist/lib/security/injection/nosql.js +1 -1
- package/dist/lib/security/injection/redos.js +25 -4
- package/dist/lib/security/injection/rule-ids.js +3 -0
- package/dist/lib/security/injection/shell-output-guard.js +97 -0
- package/dist/lib/security/injection/sql.js +51 -0
- package/dist/lib/security/injection/xpath.js +35 -0
- package/dist/lib/security/pg-identifier-guards.js +58 -6
- package/dist/lib/security/phase5-rules.js +1 -0
- package/dist/lib/security/polyglot.js +35 -3
- package/dist/lib/security/provider-credentials.js +29 -0
- package/dist/lib/security/redirect-settings.js +131 -6
- package/dist/lib/security/request-forgery/contained-helper.js +75 -0
- package/dist/lib/security/request-forgery/open-redirect-query.js +2 -1
- package/dist/lib/security/request-forgery/open-redirect.js +25 -2
- package/dist/lib/security/request-forgery/parsed-host-guard.js +213 -0
- package/dist/lib/security/request-forgery/path-traversal.js +36 -1
- package/dist/lib/security/request-forgery/shared.js +187 -27
- package/dist/lib/security/request-forgery/ssrf.js +145 -1
- package/dist/lib/security/rule-descriptions.js +17 -1
- package/dist/lib/security/rule-ids.js +21 -0
- package/dist/lib/security/scope/drizzle-policy.js +2 -1
- package/dist/lib/security/scope/kysely-policy.js +173 -0
- package/dist/lib/security/site-fixes/auth-crypto.js +3 -1
- package/dist/lib/security/taint/accessors.js +364 -0
- package/dist/lib/security/taint/array-writes.js +139 -0
- package/dist/lib/security/taint/binding-inputs.js +4 -3
- package/dist/lib/security/taint/field-access.js +80 -0
- package/dist/lib/security/taint/filename-guard.js +81 -6
- package/dist/lib/security/taint/guards.js +150 -17
- package/dist/lib/security/taint/index.js +41 -116
- package/dist/lib/security/taint/propagate.js +5 -6
- package/dist/lib/security/taint/resolution-cache.js +10 -1
- package/dist/lib/security/taint/sanitizers.js +5 -5
- package/dist/lib/security/taint/shape-flows.js +128 -0
- package/dist/lib/security/taint/sink-alphabets.js +237 -0
- package/dist/lib/security/taint/sources.js +151 -8
- package/dist/lib/security/taint/trace-nodes.js +35 -2
- package/dist/lib/security/taint/validators.js +58 -19
- package/dist/lib/security/trusted-bindings.js +44 -0
- package/dist/lib/shared/agent/agent-init.js +84 -9
- package/dist/lib/shared/agent/agent-integrations.js +626 -0
- package/dist/lib/shared/agent/agent-prompt.js +2 -1
- package/dist/lib/shared/agent/agent-session.js +1 -1
- package/dist/lib/shared/agent/agent-toml.js +98 -0
- package/dist/lib/shared/agent/agent-verify.js +21 -3
- package/dist/lib/shared/agent/git-hook.js +31 -4
- package/dist/lib/shared/agent/notify-editor.js +2 -1
- package/dist/lib/shared/agent/review-mcp.js +67 -13
- package/dist/lib/shared/agent/review-request.js +4 -0
- package/dist/lib/shared/analysis/ast-helpers.js +50 -0
- package/dist/lib/shared/analysis/ast-semantics.js +7 -1
- package/dist/lib/shared/analysis/binding-names.js +13 -0
- package/dist/lib/shared/analysis/execution-context.js +49 -9
- package/dist/lib/shared/analysis/polyglot-compatibility.js +102 -23
- package/dist/lib/shared/analysis/scan-cache-storage.js +180 -0
- package/dist/lib/shared/analysis/scan-cache.js +342 -119
- package/dist/lib/shared/analysis/valid-javascript.js +118 -0
- package/dist/lib/shared/changed-lines.js +129 -0
- package/dist/lib/shared/check-options.js +63 -0
- package/dist/lib/shared/check-watch-inputs.js +152 -0
- package/dist/lib/shared/check-watch-process.js +57 -0
- package/dist/lib/shared/check-watch.js +136 -0
- package/dist/lib/shared/check.js +73 -37
- package/dist/lib/shared/completion-shells.js +127 -0
- package/dist/lib/shared/completion.js +124 -0
- package/dist/lib/shared/config-rule-validation.js +135 -0
- package/dist/lib/shared/config.js +330 -163
- package/dist/lib/shared/declarative-rule-packs.js +173 -0
- package/dist/lib/shared/explain.js +47 -9
- package/dist/lib/shared/fix/fix-convergence.js +45 -128
- package/dist/lib/shared/fix/fix-history.js +130 -26
- package/dist/lib/shared/fix/fix-interactive.js +78 -0
- package/dist/lib/shared/fix/fix-patch.js +89 -0
- package/dist/lib/shared/fix/fix-polyglot-preview.js +166 -0
- package/dist/lib/shared/fix/fix-presentation-biome.js +120 -0
- package/dist/lib/shared/fix/fix-presentation-prettier.js +27 -10
- package/dist/lib/shared/fix/fix-presentation-rows.js +5 -1
- package/dist/lib/shared/fix/fix-presentation.js +22 -15
- package/dist/lib/shared/fix/fix-project-membership.js +79 -0
- package/dist/lib/shared/fix/fix-reversal-proof.js +107 -0
- package/dist/lib/shared/fix/fix-reverse.js +37 -0
- package/dist/lib/shared/fix/fix-safety.js +4 -4
- package/dist/lib/shared/fix/fix-scope.js +13 -9
- package/dist/lib/shared/fix/fix-source-snapshot.js +92 -0
- package/dist/lib/shared/fix/fix-staging.js +129 -0
- package/dist/lib/shared/fix/fix-terminal.js +34 -9
- package/dist/lib/shared/fix/fix-typecheck.js +21 -8
- package/dist/lib/shared/fix/project-file-access.js +44 -11
- package/dist/lib/shared/fix/read-fix-text.js +23 -0
- package/dist/lib/shared/fix/reversal-lock.js +37 -0
- package/dist/lib/shared/fix/review-fix-mode.js +9 -0
- package/dist/lib/shared/fix.js +162 -26
- package/dist/lib/shared/formats/ci-consumers.js +84 -0
- package/dist/lib/shared/formats/finding-location.js +52 -3
- package/dist/lib/shared/formats/github.js +22 -7
- package/dist/lib/shared/formats/index.js +21 -5
- package/dist/lib/shared/formats/readable.js +63 -0
- package/dist/lib/shared/formats/report-rows.js +38 -0
- package/dist/lib/shared/formats/sarif-fixes.js +261 -0
- package/dist/lib/shared/formats/sarif.js +175 -33
- package/dist/lib/shared/formats/security-cwe.js +113 -0
- package/dist/lib/shared/node-scan.js +64 -0
- package/dist/lib/shared/package-root.js +2 -0
- package/dist/lib/shared/project-root.js +27 -1
- package/dist/lib/shared/reporting/action-summary.js +31 -0
- package/dist/lib/shared/reporting/baseline.js +12 -12
- package/dist/lib/shared/reporting/finding-id-hash.js +7 -0
- package/dist/lib/shared/reporting/impact-levels.js +1 -1
- package/dist/lib/shared/reporting/pillar-rules.js +13 -1
- package/dist/lib/shared/reporting/pillars.js +37 -19
- package/dist/lib/shared/reporting/rule-docs.js +2 -2
- package/dist/lib/shared/reporting/rule-pack-fingerprint.js +21 -0
- package/dist/lib/shared/reporting/source-report.js +16 -2
- package/dist/lib/shared/reporting/stray-console-methods.js +1 -0
- package/dist/lib/shared/rule-registry.js +6 -1
- package/dist/lib/shared/system/atomic-write.js +12 -6
- package/dist/lib/shared/system/component-source.js +28 -0
- package/dist/lib/shared/system/environment.js +12 -0
- package/dist/lib/shared/system/file-key.js +8 -0
- package/dist/lib/shared/system/git.js +47 -0
- package/dist/lib/shared/system/glob.js +92 -14
- package/dist/lib/shared/system/jsonc-config.js +63 -0
- package/dist/lib/shared/system/path-inside.js +19 -0
- package/dist/lib/shared/system/posix-path.js +22 -0
- package/dist/lib/shared/system/read-json.js +10 -0
- package/dist/lib/shared/system/sentry.js +6 -3
- package/dist/lib/shared/system/text-helpers.js +40 -0
- package/dist/lib/shared/system/windows-orphans-script.js +75 -0
- package/dist/lib/shared/system/windows-orphans.js +28 -0
- package/dist/lib/shared/types/changed-lines.js +1 -0
- package/dist/lib/shared/types/completion.js +1 -0
- package/dist/lib/shared/workspace-selection.js +67 -0
- package/dist/lib/shared/workspaces.js +210 -68
- package/dist/polyglot/maintainability/rules.js +119 -3
- package/examples/README.md +45 -0
- package/examples/clean/avatar.html +1 -0
- package/examples/clean/source.ts +10 -0
- package/examples/clean/tsconfig.json +4 -0
- package/examples/findings/avatar.html +1 -0
- package/examples/findings/source.ts +11 -0
- package/examples/findings/tsconfig.json +4 -0
- package/examples/labels-clean.py +5 -0
- package/integrations/zed/Cargo.lock +1 -1
- package/integrations/zed/Cargo.toml +1 -1
- package/integrations/zed/LICENSE +201 -0
- package/integrations/zed/extension.toml +3 -3
- package/integrations/zed/extension.wasm +0 -0
- package/integrations/zed/src/lib.rs +108 -8
- package/package.json +25 -14
- package/polyglot/performance/rules/csharp.yml +173 -10
- package/polyglot/performance/rules/go.yml +15 -7
- package/polyglot/performance/rules/input.yml +12 -0
- package/polyglot/performance/rules/java.yml +52 -1
- package/polyglot/performance/rules/php.yml +146 -0
- package/polyglot/performance/rules/python.yml +7 -3
- package/polyglot/performance/rules/ruby.yml +81 -0
- package/polyglot/performance/sgconfig.yml +2 -0
- package/polyglot/reliability/rules/csharp.yml +105 -0
- package/polyglot/reliability/rules/go.yml +339 -0
- package/polyglot/reliability/rules/input.yml +6 -0
- package/polyglot/reliability/rules/java.yml +218 -0
- package/polyglot/reliability/rules/kotlin.yml +49 -0
- package/polyglot/reliability/rules/python.yml +288 -0
- package/polyglot/reliability/rules/rust.yml +83 -0
- package/polyglot/reliability/sgconfig.yml +1 -0
- package/polyglot/security/rules/csharp.yml +143 -3
- package/polyglot/security/rules/go.yml +59 -4
- package/polyglot/security/rules/java.yml +103 -0
- package/polyglot/security/rules/python.yml +413 -21
- package/polyglot/security/rules/rust.yml +176 -3
- package/polyglot/security/sgconfig.yml +2 -0
- package/polyglot/security/utils/java-imported-jca-cipher.yml +32 -0
- package/polyglot/security/utils/java-unshadowed-javax.yml +29 -0
- package/schema/loadwise.config.schema.json +1051 -600
- package/schema/loadwise.outcomes.schema.json +43 -0
- package/types/scan.d.ts +53 -0
- package/dist/lib/maintainability/site-fixes/exports.js +0 -25
- package/docs/assets/cli-workflow.gif +0 -0
- package/plugin/.claude-plugin/plugin.json +0 -9
- package/plugin/commands/loadwise.md +0 -29
- package/plugin/hooks/check-edited-file.mjs +0 -173
- package/plugin/hooks/hooks.json +0 -17
- /package/dist/lib/{maintainability/types/changed-lines.js → editor/types/workspace-fix.js} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Loadwise review outcomes",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": ["outcomes"],
|
|
6
|
+
"properties": {
|
|
7
|
+
"outcomes": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"required": ["checker", "id", "status", "evidence"],
|
|
12
|
+
"properties": {
|
|
13
|
+
"checker": {
|
|
14
|
+
"enum": [
|
|
15
|
+
"perf",
|
|
16
|
+
"rel",
|
|
17
|
+
"maint",
|
|
18
|
+
"sec",
|
|
19
|
+
"a11y",
|
|
20
|
+
"performance",
|
|
21
|
+
"reliability",
|
|
22
|
+
"maintainability",
|
|
23
|
+
"security",
|
|
24
|
+
"accessibility"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"id": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"pattern": "^\\S(?:[\\s\\S]*\\S)?(?![\\s\\S])"
|
|
30
|
+
},
|
|
31
|
+
"status": {
|
|
32
|
+
"enum": ["fixed", "verified", "intentional", "false-positive", "deferred"]
|
|
33
|
+
},
|
|
34
|
+
"evidence": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"pattern": "\\S",
|
|
37
|
+
"description": "Record specific evidence from the source, tests or verified behavior."
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/types/scan.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type ScanChecker =
|
|
2
|
+
| 'performance'
|
|
3
|
+
| 'reliability'
|
|
4
|
+
| 'maintainability'
|
|
5
|
+
| 'security'
|
|
6
|
+
| 'accessibility'
|
|
7
|
+
| 'perf'
|
|
8
|
+
| 'rel'
|
|
9
|
+
| 'maint'
|
|
10
|
+
| 'sec'
|
|
11
|
+
| 'a11y';
|
|
12
|
+
|
|
13
|
+
export interface ScanOptions {
|
|
14
|
+
directory?: string;
|
|
15
|
+
checkers?: readonly ScanChecker[];
|
|
16
|
+
config?: string;
|
|
17
|
+
workspace?: readonly string[];
|
|
18
|
+
staged?: boolean;
|
|
19
|
+
uncommitted?: boolean;
|
|
20
|
+
changedSince?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ScanFinding {
|
|
24
|
+
ruleId: string;
|
|
25
|
+
message: string;
|
|
26
|
+
id?: string;
|
|
27
|
+
file?: string;
|
|
28
|
+
line?: number;
|
|
29
|
+
column?: number;
|
|
30
|
+
[detail: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CheckerResult {
|
|
34
|
+
findings: ScanFinding[];
|
|
35
|
+
skippedFiles?: readonly { file: string; reason: string }[] | number;
|
|
36
|
+
[detail: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ScanReport {
|
|
40
|
+
performance?: CheckerResult | null;
|
|
41
|
+
reliability?: CheckerResult | null;
|
|
42
|
+
maintainability?: CheckerResult | null;
|
|
43
|
+
security?: CheckerResult | null;
|
|
44
|
+
accessibility?: CheckerResult | null;
|
|
45
|
+
_coverage?: Record<string, { status: 'not-applicable'; reason: string } | { status: 'incomplete'; exitCode: number }>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type ScanResult =
|
|
49
|
+
| { status: 'complete'; exitCode: 0 | 1; report: ScanReport; notes: string }
|
|
50
|
+
| { status: 'incomplete'; exitCode: 0 | 1 | 2; report: ScanReport | null; notes: string }
|
|
51
|
+
| { status: 'invalid-input'; exitCode: 2; notes: string };
|
|
52
|
+
|
|
53
|
+
export function scan(options?: ScanOptions): Promise<ScanResult>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
function unusedExportFix({ node, sourceFile }) {
|
|
3
|
-
if (!node || !sourceFile)
|
|
4
|
-
return;
|
|
5
|
-
const target = ts.findAncestor(node, (candidate) => ts.canHaveModifiers(candidate) &&
|
|
6
|
-
Boolean(ts.getModifiers(candidate)?.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword)));
|
|
7
|
-
if (!target || !ts.canHaveModifiers(target))
|
|
8
|
-
return;
|
|
9
|
-
const exportMod = ts.getModifiers(target)?.find((mod) => mod.kind === ts.SyntaxKind.ExportKeyword);
|
|
10
|
-
if (!exportMod)
|
|
11
|
-
return;
|
|
12
|
-
const start = exportMod.getStart(sourceFile);
|
|
13
|
-
let end = exportMod.end;
|
|
14
|
-
if (sourceFile.text[end] === ' ')
|
|
15
|
-
end++;
|
|
16
|
-
return {
|
|
17
|
-
edits: [{ start, end, text: '' }],
|
|
18
|
-
requiresReview: true,
|
|
19
|
-
note: 'Removes the unused `export` modifier; verify no external package or dynamic import relies on it.',
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const builders = {
|
|
23
|
-
'unused-export': unusedExportFix,
|
|
24
|
-
};
|
|
25
|
-
export default builders;
|
|
Binary file
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "loadwise",
|
|
3
|
-
"version": "0.8.0",
|
|
4
|
-
"description": "Runs the project's local loadwise checkers on each file Claude edits and sends findings back with their fix commands.",
|
|
5
|
-
"author": { "name": "Ibrahim Hafez" },
|
|
6
|
-
"homepage": "https://loadwise.mintlify.app/",
|
|
7
|
-
"repository": "https://github.com/IbrahimHafez1/loadwise",
|
|
8
|
-
"keywords": ["performance", "reliability", "maintainability", "security", "accessibility", "static-analysis"]
|
|
9
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Check a project or fix its Loadwise findings in this session
|
|
3
|
-
argument-hint: "[directory] [--only perf,rel,maint,sec,a11y] [--staged|--uncommitted] | fix [--dry-run|--apply|--yes|--all|--handoff] [--id id] [--uncommitted] [performance reliability maintainability security accessibility]"
|
|
4
|
-
allowed-tools: Bash(npx loadwise:*), Bash(node_modules/.bin/loadwise:*)
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
Use the project's Loadwise launcher for every command. Prefer `node_modules/.bin/loadwise` when present, otherwise use `npx loadwise`. Interpret the user's arguments (`$ARGUMENTS`) as follows.
|
|
8
|
-
|
|
9
|
-
For the default check, pass the supplied directory and scan flags to `loadwise check --json`. Summarize the findings by checker, id, rule and file:line. Keep checks and handoff-only requests read-only.
|
|
10
|
-
|
|
11
|
-
On every run, review all in-scope findings, including changes already applied. Retrieve `loadwise agent history` for the selected checkers and inspect earlier reports if available. A clean rescan still requires checking the recorded edits against the code and tests. In both check and fix mode, record a status and evidence for each checker and id. Run `loadwise agent verify --outcomes outcomes.json before.json history.json after.json` on the applicable scoped reports and address any missing outcomes. Keep the files in local scratch space. State which prior changes could not be reconstructed.
|
|
12
|
-
|
|
13
|
-
Use `{"outcomes":[{"checker":"perf","id":"...","status":"verified","evidence":"..."}]}` for the decisions file, replacing the placeholders with actual findings and evidence. Supported statuses are `fixed`, `verified`, `intentional`, `false-positive` and `deferred`. In a detected agent session or an initialized project add `--save` to retain the decisions locally for the next agent unless the user requested no persistence.
|
|
14
|
-
|
|
15
|
-
Explicit flags select the matching CLI operation. Handle these requests before the agent-guided edit workflow below. Pass through the supplied directory, checker selection, configuration, workspace, rule and Git filters, including `--uncommitted`.
|
|
16
|
-
|
|
17
|
-
- For any `fix --dry-run` or explicit preview request, run the requested fix with `--dry-run`, including when combined with `--apply`, `--yes`, `--all` or `--id`. Show the proposed edits and stop. Leave source files untouched and treat the printed apply command as information for the user.
|
|
18
|
-
- For `fix --handoff`, show the read-only brief and stop.
|
|
19
|
-
- For `fix --apply`, `fix --yes`, `fix --all` or an explicit `--id` selection, record existing working changes and run the requested operation with its supplied scope. Capture the applied hunks and outstanding findings with `--json` when compatible with the requested output. Review the actual changes using steps 5 and 6 below. When manual findings remain, use the printed scoped handoff command. Only edit manual findings if the user requested that work.
|
|
20
|
-
- If the CLI rejects a flag combination, report the error and stop.
|
|
21
|
-
|
|
22
|
-
For the agent-guided `/loadwise fix [checker names]` workflow, including a scope such as `--uncommitted`, review findings before choosing edits.
|
|
23
|
-
|
|
24
|
-
1. Record existing working changes and start with a read-only JSON scan. For example, `fix performance security` starts with `loadwise check --only perf,sec --json`. Preserve the selected project, configuration, workspaces and changed-line filters. Restrict work to the named files or ids if provided.
|
|
25
|
-
2. Evaluate both generated and manual findings against the actual code, callers and tests. Inspect proposed diffs and notes and check their assumptions. Use a generated edit only when you can justify that exact change. Adapt a suggestion or implement a manual fix yourself when warranted. Keep intentional behavior and false positives with a reason. Defer unresolved decisions and continue with independent findings.
|
|
26
|
-
3. For a unified project scan, apply confirmed IDs with `loadwise fix --only <checker> --id <id>` and the original directory, config, workspaces and Git filters. For direct file or checker-specific scans, use the scoped report's per-ID fix command with its original settings. Review-marked changes require individual approval unless already authorized.
|
|
27
|
-
4. For changed-line requests, confirm every hunk fits the authorized range and current working tree, including when using a checker-specific fix command. Leave the Git index untouched.
|
|
28
|
-
5. After any fix, including a command the user already ran, inspect every applied hunk against code, callers and tests. Use the before/after report or original diff/output, and rescan. Review applied, skipped, review-marked and manual findings even when none are manual. Correct only attributable changes in scope. Preserve pre-existing work, thresholds and baselines.
|
|
29
|
-
6. Run the affected tests or typecheck and repeat the scoped check. If an id shifted, match the rule, location and code. Report verified edits and reasons for remaining findings. If earlier evidence is unavailable, verify the current code and state which prior edits cannot be identified. Request the original diff/output only if needed.
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
// PostToolUse hook: runs the project's local loadwise on the file Claude just edited.
|
|
2
|
-
// It must never break a session, so every failure path ends in a silent exit 0.
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { spawnSync } from 'node:child_process';
|
|
6
|
-
const SOURCE_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs']);
|
|
7
|
-
// The only files the accessibility checker reads besides the script files that can hold JSX.
|
|
8
|
-
const MARKUP_EXTENSIONS = new Set(['.html', '.htm', '.vue', '.svelte']);
|
|
9
|
-
const ACCESSIBILITY_EXTENSIONS = new Set(['.tsx', '.jsx', ...MARKUP_EXTENSIONS]);
|
|
10
|
-
const DEFAULT_TIMEOUT_MS = 20000;
|
|
11
|
-
const MAX_OUTPUT_BYTES = 16 * 1024 * 1024;
|
|
12
|
-
|
|
13
|
-
function readStdin() {
|
|
14
|
-
try {
|
|
15
|
-
return fs.readFileSync(0, 'utf8');
|
|
16
|
-
} catch {
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function findLocalBinary(startDirectory, stopRoot) {
|
|
22
|
-
let directory = path.resolve(startDirectory);
|
|
23
|
-
const boundary = path.resolve(stopRoot);
|
|
24
|
-
for (;;) {
|
|
25
|
-
const rel = path.relative(boundary, directory);
|
|
26
|
-
if (rel === '..' || rel.startsWith('..' + path.sep) || path.isAbsolute(rel)) return null;
|
|
27
|
-
const installedPackage = path.join(directory, 'node_modules', 'loadwise');
|
|
28
|
-
for (const entryPath of ['dist/bin/loadwise.js', 'bin/loadwise.js']) {
|
|
29
|
-
const entry = path.join(installedPackage, entryPath);
|
|
30
|
-
if (fs.existsSync(entry)) return { projectRoot: directory, binary: entry };
|
|
31
|
-
}
|
|
32
|
-
const candidate = path.join(directory, 'node_modules', '.bin', 'loadwise');
|
|
33
|
-
if (fs.existsSync(candidate)) return { projectRoot: directory, binary: candidate };
|
|
34
|
-
if (directory === boundary) return null;
|
|
35
|
-
const parent = path.dirname(directory);
|
|
36
|
-
if (parent === directory) return null;
|
|
37
|
-
directory = parent;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function launcherFor(binary, args) {
|
|
42
|
-
if (binary.endsWith('.js') || binary.endsWith('.cjs')) return { command: process.execPath, args: [binary, ...args] };
|
|
43
|
-
const firstLine = fs.readFileSync(binary, 'utf8').split('\n', 1)[0];
|
|
44
|
-
if (firstLine.startsWith('#!') && firstLine.includes('node')) {
|
|
45
|
-
return { command: process.execPath, args: [binary, ...args] };
|
|
46
|
-
}
|
|
47
|
-
return { command: binary, args };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function runLoadwise(binary, args, cwd, deadline) {
|
|
51
|
-
const remaining = deadline - Date.now();
|
|
52
|
-
if (remaining <= 0) return null;
|
|
53
|
-
const launcher = launcherFor(binary, args);
|
|
54
|
-
const result = spawnSync(launcher.command, launcher.args, {
|
|
55
|
-
cwd,
|
|
56
|
-
encoding: 'utf8',
|
|
57
|
-
timeout: remaining,
|
|
58
|
-
windowsHide: true,
|
|
59
|
-
maxBuffer: MAX_OUTPUT_BYTES,
|
|
60
|
-
});
|
|
61
|
-
if (result.error || result.signal) return null;
|
|
62
|
-
try {
|
|
63
|
-
return JSON.parse(result.stdout);
|
|
64
|
-
} catch {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function findingsFor(report, relativeFile, checkerCommand) {
|
|
70
|
-
const findings = report && Array.isArray(report.findings) ? report.findings : [];
|
|
71
|
-
return findings
|
|
72
|
-
.filter((finding) => path.normalize(finding.file ?? '') === relativeFile)
|
|
73
|
-
.map((finding) => ({ ...finding, checkerCommand }));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function quoteTarget(relativeFile, platform = process.platform) {
|
|
77
|
-
const normalized = './' + relativeFile.split(path.sep).join('/');
|
|
78
|
-
if (platform === 'win32') return "'" + normalized.replaceAll("'", "''") + "'";
|
|
79
|
-
return "'" + normalized.replaceAll("'", "'\\''") + "'";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function formatFeedback(projectRoot, relativeFile, findings) {
|
|
83
|
-
const sourceArgument = quoteTarget(relativeFile);
|
|
84
|
-
const lines = findings.map((finding) => {
|
|
85
|
-
const target = finding.checkerCommand === 'maint' ? '.' : sourceArgument;
|
|
86
|
-
const action = finding.fixable
|
|
87
|
-
? ` ${finding.fix?.requiresReview ? 'Review-marked fix' : 'Fix'} from ${projectRoot}: npx loadwise ${finding.checkerCommand} ${target} --fix --only ${finding.id}`
|
|
88
|
-
: ' Manual finding. On an authorized fix request, inspect the callers, implement a justified edit here and run the relevant tests.';
|
|
89
|
-
return `- #${finding.id} ${finding.ruleId} at ${relativeFile}:${finding.line}: ${finding.message}${action}`;
|
|
90
|
-
});
|
|
91
|
-
return `loadwise found ${findings.length} issue(s) in ${relativeFile}. Check each finding against the actual code, callers and tests. Apply or adapt a justified change within the user's request. Keep intentional behavior and explain why.\n${lines.join('\n')}`;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function sourceFindings(local, relativeFile, safeRelativeFile, deadline) {
|
|
95
|
-
const perfReport = runLoadwise(local.binary, ['perf', safeRelativeFile, '--json'], local.projectRoot, deadline);
|
|
96
|
-
const relReport = runLoadwise(local.binary, ['rel', safeRelativeFile, '--json'], local.projectRoot, deadline);
|
|
97
|
-
const secReport = runLoadwise(local.binary, ['sec', safeRelativeFile, '--json'], local.projectRoot, deadline);
|
|
98
|
-
// maint has no explicit-file mode, so scan the uncommitted changes and keep this file's findings.
|
|
99
|
-
const maintReport = runLoadwise(
|
|
100
|
-
local.binary,
|
|
101
|
-
['maint', '--changed-since', 'HEAD', '--json'],
|
|
102
|
-
local.projectRoot,
|
|
103
|
-
deadline,
|
|
104
|
-
);
|
|
105
|
-
return [
|
|
106
|
-
...findingsFor(perfReport, relativeFile, 'perf'),
|
|
107
|
-
...findingsFor(relReport, relativeFile, 'rel'),
|
|
108
|
-
...findingsFor(maintReport, relativeFile, 'maint'),
|
|
109
|
-
...findingsFor(secReport, relativeFile, 'sec'),
|
|
110
|
-
];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function hasInlineTemplate(filename) {
|
|
114
|
-
try {
|
|
115
|
-
return fs.readFileSync(filename, 'utf8').includes('@Component');
|
|
116
|
-
} catch {
|
|
117
|
-
// Each source checker can report its own coverage even if the optional template probe fails.
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function main() {
|
|
123
|
-
const input = JSON.parse(readStdin());
|
|
124
|
-
const filePath = input?.tool_input?.file_path;
|
|
125
|
-
if (typeof filePath !== 'string') return;
|
|
126
|
-
const extension = path.extname(filePath).toLowerCase();
|
|
127
|
-
const isSourceFile = SOURCE_EXTENSIONS.has(extension);
|
|
128
|
-
if (!isSourceFile && !MARKUP_EXTENSIONS.has(extension)) return;
|
|
129
|
-
const suppliedRoot = path.resolve(input?.cwd ?? process.cwd());
|
|
130
|
-
const suppliedFile = path.resolve(suppliedRoot, filePath);
|
|
131
|
-
if (path.relative(suppliedRoot, suppliedFile).split(path.sep).includes('node_modules')) return;
|
|
132
|
-
// The client can send the folder and the edited file through different spellings of one path.
|
|
133
|
-
const workspaceRoot = fs.realpathSync.native(suppliedRoot);
|
|
134
|
-
const absoluteFile = fs.realpathSync.native(suppliedFile);
|
|
135
|
-
if (path.relative(workspaceRoot, absoluteFile).split(path.sep).includes('node_modules')) return;
|
|
136
|
-
const local = findLocalBinary(path.dirname(absoluteFile), workspaceRoot);
|
|
137
|
-
if (!local) return;
|
|
138
|
-
const relativeFile = path.relative(local.projectRoot, absoluteFile);
|
|
139
|
-
if (
|
|
140
|
-
relativeFile === '..' ||
|
|
141
|
-
relativeFile.startsWith('..' + path.sep) ||
|
|
142
|
-
relativeFile.split(path.sep).includes('node_modules')
|
|
143
|
-
)
|
|
144
|
-
return;
|
|
145
|
-
const safeRelativeFile = relativeFile.startsWith('-') ? `./${relativeFile}` : relativeFile;
|
|
146
|
-
const parsedTimeout = Number(process.env.LOADWISE_HOOK_TIMEOUT_MS);
|
|
147
|
-
const timeoutMs = Number.isFinite(parsedTimeout) && parsedTimeout > 0 ? parsedTimeout : DEFAULT_TIMEOUT_MS;
|
|
148
|
-
const deadline = Date.now() + timeoutMs;
|
|
149
|
-
// Match the accessibility analyzer's inline Angular template prefilter for script extensions.
|
|
150
|
-
const checkAccessibility =
|
|
151
|
-
ACCESSIBILITY_EXTENSIONS.has(extension) || (isSourceFile && hasInlineTemplate(absoluteFile));
|
|
152
|
-
const findings = [
|
|
153
|
-
...(isSourceFile ? sourceFindings(local, relativeFile, safeRelativeFile, deadline) : []),
|
|
154
|
-
...(checkAccessibility
|
|
155
|
-
? findingsFor(
|
|
156
|
-
runLoadwise(local.binary, ['a11y', safeRelativeFile, '--json'], local.projectRoot, deadline),
|
|
157
|
-
relativeFile,
|
|
158
|
-
'a11y',
|
|
159
|
-
)
|
|
160
|
-
: []),
|
|
161
|
-
];
|
|
162
|
-
if (findings.length === 0) return;
|
|
163
|
-
process.stdout.write(
|
|
164
|
-
JSON.stringify({ decision: 'block', reason: formatFeedback(local.projectRoot, relativeFile, findings) }),
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
try {
|
|
169
|
-
main();
|
|
170
|
-
} catch {
|
|
171
|
-
// Swallowed on purpose: a checker problem must not interrupt the session.
|
|
172
|
-
}
|
|
173
|
-
process.exitCode = 0;
|
package/plugin/hooks/hooks.json
DELETED
|
File without changes
|