{
  "$schema": "https://biomejs.dev/schemas/2.5.1/schema.json",
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true
  },
  "plugins": [
    // Project-wide source shape and placement.
    {
      "path": "./scripts/grit/source-shape/no-handwritten-reexports.grit",
      "includes": ["**/*.{ts,tsx,mjs}"]
    },
    {
      "path": "./scripts/grit/source-shape/no-responsibility-root-module-files.grit",
      "includes": ["**/src/{app-server,domain}/*.{ts,tsx}", "**/src/features/{chat,threads}/*.{ts,tsx}"]
    },
    {
      "path": "./scripts/grit/source-shape/no-misplaced-tsx.grit",
      "includes": [
        "**/src/**/*.tsx",
        "!**/src/{settings,shared/ui}/**",
        "!**/src/features/chat/{panel,ui}/**",
        "!**/src/features/{selection-rewrite,threads-view,turn-diff}/*.dom.tsx",
        "!**/src/shared/dom/*.dom.tsx",
        "!**/src/shared/obsidian/*.obsidian.tsx"
      ]
    },
    {
      "path": "./scripts/grit/source-shape/no-self-referential-initializer-callback.grit",
      "includes": ["**/*.{ts,tsx,mjs}"]
    },
    {
      "path": "./scripts/grit/source-shape/no-unsafe-iterator-value.grit",
      "includes": ["**/*.{ts,tsx,mjs}"]
    },
    {
      "path": "./scripts/grit/source-shape/no-uncontrolled-preact-form-state.grit",
      "includes": ["**/src/**/*.tsx"]
    },

    // Cross-cutting source-layer import boundaries.
    {
      "path": "./scripts/grit/import-boundaries/no-domain-outer-layer-imports.grit",
      "includes": ["**/src/domain/**/*.ts", "**/src/features/chat/domain/**/*.ts"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-lower-level-feature-imports.grit",
      "includes": ["**/src/app-server/**/*.ts", "**/src/shared/**/*.{ts,tsx}"]
    },

    // App-server and generated protocol boundaries.
    {
      "path": "./scripts/grit/import-boundaries/no-app-server-subfolder-root-imports.grit",
      "includes": ["**/src/app-server/**/*.ts"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-app-server-connection-boundary-imports.grit",
      "includes": [
        "**/src/app-server/protocol/**/*.ts",
        "**/src/domain/**/*.ts",
        "**/src/shared/**/*.{ts,tsx}",
        "**/src/features/selection-rewrite/**/*.{ts,tsx}",
        "!**/src/features/selection-rewrite/app-server-transport.ts"
      ]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-app-server-protocol-boundary-imports.grit",
      "includes": ["**/src/**/*.{ts,tsx}", "!**/src/app-server/**", "!**/src/features/chat/app-server/mappers/thread-stream/turn-items.ts"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-chat-turn-item-non-turn-protocol-imports.grit",
      "includes": ["**/src/features/chat/app-server/mappers/thread-stream/turn-items.ts"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-generated-app-server-boundary-imports.grit",
      "includes": [
        "**/src/**/*.{ts,tsx}",
        "!**/src/app-server/connection/**",
        "!**/src/app-server/protocol/server-requests.ts",
        "!**/src/app-server/protocol/thread.ts",
        "!**/src/app-server/protocol/turn.ts"
      ]
    },
    {
      "path": "./scripts/grit/runtime/no-app-server-direct-rpcs.grit",
      "includes": ["**/src/**/*.{ts,tsx}", "!**/src/app-server/**", "!**/src/features/chat/app-server/**"]
    },
    // Workspace and feature coordination boundaries.
    {
      "path": "./scripts/grit/import-boundaries/no-chat-workspace-boundary-imports.grit",
      "includes": ["**/src/features/chat/**/*.{ts,tsx}"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-feature-workspace-boundary-imports.grit",
      "includes": ["**/src/features/**/*.{ts,tsx}", "!**/src/features/chat/**"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-workspace-chat-internal-imports.grit",
      "includes": ["**/src/workspace/**/*.ts"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-thread-workflow-app-server-imports.grit",
      "includes": ["**/src/features/threads/workflows/**/*.ts"]
    },

    // Chat feature layer boundaries.
    {
      "path": "./scripts/grit/import-boundaries/no-chat-application-outer-layer-imports.grit",
      "includes": ["**/src/features/chat/application/**/*.ts"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-chat-app-server-outer-layer-imports.grit",
      "includes": ["**/src/features/chat/app-server/**/*.ts"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-chat-host-rendering-layer-imports.grit",
      "includes": ["**/src/features/chat/host/**/*.ts"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-chat-panel-runtime-boundary-imports.grit",
      "includes": ["**/src/features/chat/panel/**/*.{ts,tsx}"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-chat-presentation-outer-layer-imports.grit",
      "includes": ["**/src/features/chat/presentation/**/*.ts"]
    },
    {
      "path": "./scripts/grit/import-boundaries/no-chat-ui-outer-layer-imports.grit",
      "includes": ["**/src/features/chat/ui/**/*.{ts,tsx}"]
    },

    // Chat state and runtime ownership.
    {
      "path": "./scripts/grit/runtime/no-state-module-side-effects.grit",
      "includes": ["**/src/features/chat/application/state/**/*.ts"]
    },

    // DOM bridge and Preact root boundaries.
    {
      "path": "./scripts/grit/dom/no-implicit-dom-bridges.grit",
      "includes": ["**/src/**/*.{ts,tsx}", "!**/src/**/*.{dom,obsidian,measure}.{ts,tsx}"]
    },
    {
      "path": "./scripts/grit/dom/no-dom-events-imports.grit",
      "includes": ["**/src/**/*.{ts,tsx}", "!**/src/**/*.{dom,obsidian,measure}.{ts,tsx}"]
    },
    {
      "path": "./scripts/grit/dom/no-preact-root-imports.grit",
      "includes": ["**/src/**/*.{ts,tsx}", "!**/src/**/*.{dom,obsidian}.{ts,tsx}"]
    },

    // CSS source policy.
    {
      "path": "./scripts/grit/no-restricted-css-policy.grit",
      "includes": ["**/src/styles/**/*.css"]
    }
  ],
  "files": {
    "includes": [
      "*.config.mjs",
      "*.config.ts",
      "*.css",
      "*.json",
      "*.jsonc",
      "*.mjs",
      "scripts/**/*.{json,jsonc}",
      "scripts/**/*.grit",
      "scripts/**/*.mjs",
      "src/**/*.{css,ts,tsx}",
      "tests/**/*.{mjs,ts,tsx}",
      "!src/generated"
    ]
  },
  "formatter": {
    "indentStyle": "space",
    "lineWidth": 140
  },
  "assist": {
    "actions": {
      "source": {
        "noDuplicateClasses": "on",
        "organizeImports": "on"
      }
    }
  },
  "linter": {
    "domains": {
      "react": "recommended",
      "test": "recommended"
    },
    "rules": {
      "preset": "recommended",
      "complexity": {
        "useLiteralKeys": "off"
      },
      "correctness": {
        "useExhaustiveDependencies": {
          "level": "error",
          "options": {
            "reportUnnecessaryDependencies": false
          }
        }
      },
      "nursery": {
        "noExcessiveSelectorClasses": {
          "level": "error",
          "options": {
            "maxClasses": 4
          }
        }
      },
      "style": {
        "noCommonJs": "error"
      },
      "suspicious": {
        "noImportCycles": "error"
      }
    }
  }
}
