Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8790 chore: enforce the dependency catalog and narrow mobile's core imports; sync boundary docs (#10142)
Jiayuan Zhangf0033556c268
diff --git a/.github/actions/frontend-quality/action.yml b/.github/actions/frontend-quality/action.ymlindex ac36b44a9f..db79eb5639 100644--- a/.github/actions/frontend-quality/action.yml+++ b/.github/actions/frontend-quality/action.yml@@ -15,6 +15,12 @@ runs:node --test scripts/check-ui-radius-tokens.test.mjsnode scripts/check-ui-radius-tokens.mjs+ - name: Check shared dependencies use the pnpm catalog+ shell: bash+ run: |+ node --test scripts/check-dependency-catalog.test.mjs+ node scripts/check-dependency-catalog.mjs+# Keep existing knip findings advisory in either caller.- name: Check for dead code and phantom dependencies (knip)continue-on-error: truediff --git a/AGENTS.md b/AGENTS.mdindex a0ecf8eb21..6f83661a4f 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -13,18 +13,19 @@ Multica is a task management platform where people and agents collaborate on iss| Location | Responsibility and constraints || --- | --- || `server/` | Go backend; Chi, sqlc, WebSocket |-| `packages/core/` | Headless logic, API client, Query hooks, shared Zustand stores. No UI libraries, `react-dom`, `localStorage`, or `process.env`; use `StorageAdapter` for persistence. Lint enforces this outside tests (`packages/core/eslint.config.mjs`). |+| `packages/core/` | Headless logic, API client, Query hooks, shared Zustand stores. No UI libraries, `react-dom`, `next/*`, or `process.env`. Client persistence goes through `StorageAdapter`; only the default adapter (`platform/storage.ts`) and tab-scoped exception dedupe (`analytics/exception-dedupe.ts`) touch Web Storage. Cookies are only for values the server or Next.js proxy reads. Lint enforces the import, `process.env`, and Web Storage rules outside tests (`packages/core/eslint.config.mjs`). || `packages/ui/` | UI primitives and shared styles. No business logic or `@multica/core` imports. || `packages/views/` | Shared web/desktop pages and business components. No store definitions, `next/*`, or `react-router-dom`; use `NavigationAdapter`, `useNavigation()`, and `<AppLink>`. Lint enforces the store rule outside tests (`packages/views/eslint.config.mjs`). || `apps/web/` | Next.js routes/layouts and web-only UI. Framework APIs stay here; shared navigation adapters live in `apps/web/platform/`. || `apps/desktop/` | Electron and desktop-only UI/state. Application navigation goes through `apps/desktop/src/renderer/src/platform/`. |-| `apps/mobile/` | Independent Expo/React Native client: owns UI, state, hooks, providers, i18n, build, and release. Shares core types and pure utilities, including platform-independent schemas. |+| `apps/mobile/` | Independent Expo/React Native client: owns UI, state, hooks, providers, i18n, build, and release. Shares core types and pure utilities, including platform-independent schemas; runtime imports use the pure module's own subpath, not a barrel that also re-exports hooks or stores (lint-enforced). || `apps/docs/` | Fumadocs documentation site |- Dependency direction is `views -> core + ui`; core and ui remain independent. Shared packages export raw TypeScript compiled by consuming apps.- Extract logic used by both web and desktop into the appropriate shared package. Keep framework/Electron APIs in the app layer; inject platform-specific UI through props/slots.- Wire shared features into both web routes and the desktop router or overlay. Reuse existing guards/providers such as `DashboardGuard` in `packages/views/layout/`.-- Each workspace declares its directly imported external dependencies. Use `catalog:` for shared dependencies; mobile pins Expo/React Native dependencies in its own manifest.+- Each workspace declares its directly imported external dependencies. A dependency declared by two or more workspaces, or already in the `pnpm-workspace.yaml` catalog, uses `catalog:`; CI runs `scripts/check-dependency-catalog.mjs`, whose allowlist records known drift awaiting an upgrade. Mobile is exempt and pins Expo/React Native-aligned versions in its own manifest.+- This section is the source for the package-boundary table in `apps/docs/content/docs/developers/conventions*.mdx` (every locale); change them together.## Development and Verificationdiff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex ab6abee1ff..8ebabd9ac5 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -33,10 +33,10 @@"postinstall": "electron-builder install-app-deps"},"dependencies": {- "@dnd-kit/core": "^6.3.1",- "@dnd-kit/modifiers": "^9.0.0",- "@dnd-kit/sortable": "^10.0.0",- "@dnd-kit/utilities": "^3.2.2",+ "@dnd-kit/core": "catalog:",+ "@dnd-kit/modifiers": "catalog:",+ "@dnd-kit/sortable": "catalog:",+ "@dnd-kit/utilities": "catalog:","@electron-toolkit/preload": "^3.0.2","@electron-toolkit/utils": "^4.0.0","@fontsource-variable/geist-mono": "^5.3.0",@@ -48,13 +48,13 @@"@tanstack/react-query": "catalog:","electron-updater": "^6.8.3","fix-path": "^5.0.0",- "motion": "^12.38.0",+ "motion": "catalog:","react": "catalog:","react-dom": "catalog:","react-router-dom": "^7.6.0",- "shadcn": "^4.1.0",- "sonner": "^2.0.7",- "tw-animate-css": "^1.4.0",+ "shadcn": "catalog:",+ "sonner": "catalog:",+ "tw-animate-css": "catalog:","zustand": "catalog:"},"devDependencies": {@@ -62,7 +62,7 @@"@multica/eslint-config": "workspace:*","@multica/tsconfig": "workspace:*","@multica/vitest-setup": "workspace:*",- "@tailwindcss/vite": "^4",+ "@tailwindcss/vite": "catalog:","@testing-library/jest-dom": "catalog:","@testing-library/react": "catalog:","@types/node": "catalog:",@@ -75,7 +75,7 @@"electron-vite": "^5.0.0","globals": "^16.0.0","jsdom": "catalog:",- "tailwindcss": "^4",+ "tailwindcss": "catalog:","typescript": "catalog:","vitest": "catalog:"}diff --git a/apps/docs/content/docs/developers/conventions.fr.mdx b/apps/docs/content/docs/developers/conventions.fr.mdxindex 392d08a216..1e032ddfc7 100644--- a/apps/docs/content/docs/developers/conventions.fr.mdx+++ b/apps/docs/content/docs/developers/conventions.fr.mdx@@ -30,12 +30,14 @@ Le monorepo impose des frontières strictes entre les packages :| Package | Peut dépendre de | Ne doit PAS dépendre de || --- | --- | --- |-| `packages/core` | rien de spécifique à une application | `react-dom`, `localStorage`, `process.env`, `next/*`, bibliothèques d'UI |+| `packages/core` | rien de spécifique à une application | `react-dom`, `next/*`, bibliothèques d'UI, `process.env`, `localStorage` en direct (persister via `StorageAdapter`) || `packages/ui` | rien | `@multica/core`, logique métier |-| `packages/views` | `core/`, `ui/` | `next/*`, `react-router-dom`, stores |+| `packages/views` | `core/`, `ui/` | `next/*`, `react-router-dom`, définitions de stores || `apps/web/platform/` | `next/*` | autres applications || `apps/desktop/.../platform/` | `react-router-dom`, electron | autres applications |-| `apps/mobile/` | types et fonctions pures de `@multica/core` | pages React, stores et implémentations de plateforme de Web/Desktop |+| `apps/mobile/` | types et fonctions pures de `@multica/core`, via le sous-chemin propre à chaque module | pages React, stores et implémentations de plateforme de Web/Desktop, y compris les barrels de core qui les réexportent |++Le fichier `AGENTS.md` à la racine fait foi pour ces frontières et leurs rares exceptions ; modifiez les deux ensemble. Le lint impose la ligne `packages/core` (`packages/core/eslint.config.mjs`) et les imports de core dans mobile (`apps/mobile/eslint.config.js`).Si une logique apparaît dans les deux applications, elle DOIT être extraite dans un package partagé. Aucune exception pour une « petite » duplication. Mobile possède sa propre UI, sa propre couche de données et son propre processus de publication ; il ne partage que les types et les fonctions pures.diff --git a/apps/docs/content/docs/developers/conventions.ja.mdx b/apps/docs/content/docs/developers/conventions.ja.mdxindex 2b96d9fdd4..63c7f5d103 100644--- a/apps/docs/content/docs/developers/conventions.ja.mdx+++ b/apps/docs/content/docs/developers/conventions.ja.mdx@@ -30,12 +30,14 @@ Multica のコードを書く、翻訳を変更する、あるいは中国語の| パッケージ | 依存可能 | 依存禁止 || --- | --- | --- |-| `packages/core` | アプリ固有でないもののみ | `react-dom`, `localStorage`, `process.env`, `next/*`, UI ライブラリ |+| `packages/core` | アプリ固有でないもののみ | `react-dom`, `next/*`, UI ライブラリ, `process.env`, `localStorage` の直接利用(永続化は `StorageAdapter` 経由) || `packages/ui` | なし | `@multica/core`, ビジネスロジック |-| `packages/views` | `core/`, `ui/` | `next/*`, `react-router-dom`, stores |+| `packages/views` | `core/`, `ui/` | `next/*`, `react-router-dom`, store の定義 || `apps/web/platform/` | `next/*` | 他のアプリ || `apps/desktop/.../platform/` | `react-router-dom`, electron | 他のアプリ |-| `apps/mobile/` | `@multica/core` の型と純粋関数 | Web/Desktop の React ページ、store、プラットフォーム実装 |+| `apps/mobile/` | `@multica/core` の型と純粋関数(各モジュール自身のサブパスから import) | Web/Desktop の React ページ、store、プラットフォーム実装、およびそれらを再エクスポートする core の barrel |++パッケージ境界とその限定的な例外は、ルートの `AGENTS.md` を正とします。変更するときは両方を更新してください。`packages/core` の行は `packages/core/eslint.config.mjs`、mobile の core import は `apps/mobile/eslint.config.js` が lint で強制します。両方のアプリに同じロジックが現れる場合は、必ず共有パッケージに抽出しなければなりません。「ささいな」重複という例外はありません。Mobile は独自の UI、データ層、リリースフローを持ち、型と純粋関数だけを共有します。diff --git a/apps/docs/content/docs/developers/conventions.ko.mdx b/apps/docs/content/docs/developers/conventions.ko.mdxindex eb417ee21a..d3e6a3cb9b 100644--- a/apps/docs/content/docs/developers/conventions.ko.mdx+++ b/apps/docs/content/docs/developers/conventions.ko.mdx@@ -30,12 +30,14 @@ Multica 코드를 작성하거나, 번역을 변경하거나, 중국어 제품| 패키지 | 의존 가능 | 의존 금지 || --- | --- | --- |-| `packages/core` | 앱 종속적이지 않은 것만 | `react-dom`, `localStorage`, `process.env`, `next/*`, UI 라이브러리 |+| `packages/core` | 앱 종속적이지 않은 것만 | `react-dom`, `next/*`, UI 라이브러리, `process.env`, `localStorage` 직접 사용(영속화는 `StorageAdapter` 경유) || `packages/ui` | 없음 | `@multica/core`, 비즈니스 로직 |-| `packages/views` | `core/`, `ui/` | `next/*`, `react-router-dom`, stores |+| `packages/views` | `core/`, `ui/` | `next/*`, `react-router-dom`, store 정의 || `apps/web/platform/` | `next/*` | 다른 앱 || `apps/desktop/.../platform/` | `react-router-dom`, electron | 다른 앱 |-| `apps/mobile/` | `@multica/core`의 유형과 순수 함수 | Web/Desktop의 React 페이지, store, 플랫폼 구현 |+| `apps/mobile/` | `@multica/core`의 유형과 순수 함수(각 모듈 자체의 하위 경로로 import) | Web/Desktop의 React 페이지, store, 플랫폼 구현, 그리고 이를 다시 내보내는 core barrel |++패키지 경계와 그 제한적인 예외는 루트 `AGENTS.md`를 기준으로 합니다. 변경할 때는 두 곳을 함께 수정하세요. `packages/core` 행은 `packages/core/eslint.config.mjs`가, mobile의 core import는 `apps/mobile/eslint.config.js`가 lint로 강제합니다.두 앱 모두에 동일한 로직이 나타난다면 반드시 공유 패키지로 추출해야 합니다. "사소한" 중복이라는 예외는 없습니다. Mobile은 독립된 UI, 데이터 계층, 출시 절차를 가지며 유형과 순수 함수만 공유합니다.diff --git a/apps/docs/content/docs/developers/conventions.mdx b/apps/docs/content/docs/developers/conventions.mdxindex f38f241d40..5dbf0c50c5 100644--- a/apps/docs/content/docs/developers/conventions.mdx+++ b/apps/docs/content/docs/developers/conventions.mdx@@ -30,12 +30,14 @@ The monorepo enforces strict package boundaries:| Package | May depend on | Must NOT depend on || --- | --- | --- |-| `packages/core` | nothing app-specific | `react-dom`, `localStorage`, `process.env`, `next/*`, UI libraries |+| `packages/core` | nothing app-specific | `react-dom`, `next/*`, UI libraries, `process.env`, direct `localStorage` (persist through `StorageAdapter`) || `packages/ui` | nothing | `@multica/core`, business logic |-| `packages/views` | `core/`, `ui/` | `next/*`, `react-router-dom`, stores |+| `packages/views` | `core/`, `ui/` | `next/*`, `react-router-dom`, store definitions || `apps/web/platform/` | `next/*` | other apps || `apps/desktop/.../platform/` | `react-router-dom`, electron | other apps |-| `apps/mobile/` | types and pure functions from `@multica/core` | Web/Desktop React pages, stores, and platform implementations |+| `apps/mobile/` | types and pure functions from `@multica/core`, through each module's own subpath | Web/Desktop React pages, stores, and platform implementations, including core barrels that re-export them |++The root `AGENTS.md` is the source for these boundaries and their narrow exceptions; change both together. Lint enforces the `packages/core` row (`packages/core/eslint.config.mjs`) and mobile's core imports (`apps/mobile/eslint.config.js`).If logic appears in both apps, it MUST be extracted to a shared package. There are no exceptions for "small" duplication. Mobile owns a separate UI, data layer, and release process; it shares only types and pure functions.diff --git a/apps/docs/content/docs/developers/conventions.zh-Hant.mdx b/apps/docs/content/docs/developers/conventions.zh-Hant.mdxindex 9db3451076..34f466cb08 100644--- a/apps/docs/content/docs/developers/conventions.zh-Hant.mdx+++ b/apps/docs/content/docs/developers/conventions.zh-Hant.mdx@@ -28,12 +28,14 @@ monorepo 的包邊界是硬約束:| 包 | 可依賴 | 不能依賴 || --- | --- | --- |-| `packages/core` | 僅平臺無關基礎庫 | `react-dom`、`localStorage`、`process.env`、`next/*`、UI 庫 |+| `packages/core` | 僅平臺無關基礎庫 | `react-dom`、`next/*`、UI 庫、`process.env`、直接使用 `localStorage`(持久化走 `StorageAdapter`) || `packages/ui` | 無業務依賴 | `@multica/core`、業務邏輯 |-| `packages/views` | `core/`、`ui/` | `next/*`、`react-router-dom`、stores |+| `packages/views` | `core/`、`ui/` | `next/*`、`react-router-dom`、store 定義 || `apps/web/platform/` | `next/*` | 其他 app || `apps/desktop/.../platform/` | `react-router-dom`、electron | 其他 app |-| `apps/mobile/` | `@multica/core` 的類型和純函式 | Web/Desktop 的 React 頁面、store 和平臺實現 |+| `apps/mobile/` | `@multica/core` 的類型和純函式,透過各模組自己的子路徑匯入 | Web/Desktop 的 React 頁面、store 和平臺實現,以及重新匯出它們的 core barrel |++包邊界及其少數例外以根目錄 `AGENTS.md` 為準,修改時兩處同步。`packages/core` 這一行由 `packages/core/eslint.config.mjs` 透過 lint 強制,mobile 對 core 的匯入由 `apps/mobile/eslint.config.js` 強制。Web 和 Desktop 都有的邏輯,**必須**抽到共享包。"小段重複"也不算例外。Mobile 擁有獨立的 UI、資料層和發布流程,只共享類型與純函式。diff --git a/apps/docs/content/docs/developers/conventions.zh.mdx b/apps/docs/content/docs/developers/conventions.zh.mdxindex fda042caf7..dc65cb55a1 100644--- a/apps/docs/content/docs/developers/conventions.zh.mdx+++ b/apps/docs/content/docs/developers/conventions.zh.mdx@@ -28,12 +28,14 @@ monorepo 的包边界是硬约束:| 包 | 可依赖 | 不能依赖 || --- | --- | --- |-| `packages/core` | 仅平台无关基础库 | `react-dom`、`localStorage`、`process.env`、`next/*`、UI 库 |+| `packages/core` | 仅平台无关基础库 | `react-dom`、`next/*`、UI 库、`process.env`、直接使用 `localStorage`(持久化走 `StorageAdapter`) || `packages/ui` | 无业务依赖 | `@multica/core`、业务逻辑 |-| `packages/views` | `core/`、`ui/` | `next/*`、`react-router-dom`、stores |+| `packages/views` | `core/`、`ui/` | `next/*`、`react-router-dom`、store 定义 || `apps/web/platform/` | `next/*` | 其他 app || `apps/desktop/.../platform/` | `react-router-dom`、electron | 其他 app |-| `apps/mobile/` | `@multica/core` 的类型和纯函数 | Web/Desktop 的 React 页面、store 和平台实现 |+| `apps/mobile/` | `@multica/core` 的类型和纯函数,通过各模块自己的子路径导入 | Web/Desktop 的 React 页面、store 和平台实现,以及重新导出它们的 core barrel |++包边界及其少数例外以根目录 `AGENTS.md` 为准,修改时两处同步。`packages/core` 这一行由 `packages/core/eslint.config.mjs` 通过 lint 强制,mobile 对 core 的导入由 `apps/mobile/eslint.config.js` 强制。Web 和 Desktop 都有的逻辑,**必须**抽到共享包。"小段重复"也不算例外。Mobile 拥有独立的 UI、数据层和发布流程,只共享类型与纯函数。diff --git a/apps/docs/package.json b/apps/docs/package.jsonindex 6a8c654022..7f8bfd15c3 100644--- a/apps/docs/package.json+++ b/apps/docs/package.json@@ -17,12 +17,12 @@"fumadocs-core": "^16.17.8","fumadocs-mdx": "^15.4.10","fumadocs-ui": "^16.17.8",- "mermaid": "^11.14.0",- "next": "^16.4.5",- "next-themes": "^0.4.6",+ "mermaid": "catalog:",+ "next": "catalog:",+ "next-themes": "catalog:","react": "catalog:","react-dom": "catalog:",- "tw-animate-css": "^1.4.0"+ "tw-animate-css": "catalog:"},"devDependencies": {"@tailwindcss/postcss": "catalog:",diff --git a/apps/mobile/AGENTS.md b/apps/mobile/AGENTS.mdindex 3268e60178..b513292604 100644--- a/apps/mobile/AGENTS.md+++ b/apps/mobile/AGENTS.md@@ -4,7 +4,7 @@ These rules apply only to `apps/mobile/`, in addition to the [root instructions]## Sharing and Dependencies-- Mobile owns its UI, state, hooks, providers, API client, QueryClient, i18n, and build/release workflow. Import core types with `import type`; runtime imports are limited to pure utilities and platform-independent schemas. Do not import web/desktop stores, hooks, Query factories, or WS updaters.+- Mobile owns its UI, state, hooks, providers, API client, QueryClient, i18n, and build/release workflow. Import core types with `import type`; runtime imports are limited to pure utilities and platform-independent schemas. Do not import web/desktop stores, hooks, Query factories, or WS updaters. Import runtime values through the pure module's own subpath (e.g. `@multica/core/agents/derive-presence`); `eslint.config.js` rejects value imports from core barrels other than `types` and `markdown`, because the rest also load hooks, queries, stores, or React context. Add the narrow subpath to `packages/core/package.json` exports when it is missing.- Use `package.json` and the lockfile for current versions. Mobile pins Expo/React Native dependencies rather than taking the root React catalog.- Add SDK-aligned native packages with `pnpm exec expo install <package>` from this directory. Check compatibility before adding other dependencies; do not pick versions from memory.- Follow [README.md](README.md) for setup, simulator/device builds, and environment variants. Keep iOS scripts routed through `scripts/ios-run.sh`, which prebuilds before running iOS so config plugins are reapplied. Preserve the caller's `APP_ENV`; avoid clean prebuilds in the normal edit loop.diff --git a/apps/mobile/app/(app)/[workspace]/(tabs)/chat.tsx b/apps/mobile/app/(app)/[workspace]/(tabs)/chat.tsxindex 331cd2cd33..ae7fbb0ffd 100644--- a/apps/mobile/app/(app)/[workspace]/(tabs)/chat.tsx+++ b/apps/mobile/app/(app)/[workspace]/(tabs)/chat.tsx@@ -49,7 +49,7 @@ import {hideQueuedChatMessages,removePendingChatTask,} from "@multica/core/chat/pending";-import { canAssignAgentToIssue } from "@multica/core/permissions";+import { canAssignAgentToIssue } from "@multica/core/permissions/rules";import { api } from "@/data/api";import { useAuthStore } from "@/data/auth-store";import { useWorkspaceStore } from "@/data/workspace-store";diff --git a/apps/mobile/app/(app)/[workspace]/inbox/[id].tsx b/apps/mobile/app/(app)/[workspace]/inbox/[id].tsxindex 108143107f..3ca8b8549a 100644--- a/apps/mobile/app/(app)/[workspace]/inbox/[id].tsx+++ b/apps/mobile/app/(app)/[workspace]/inbox/[id].tsx@@ -5,7 +5,7 @@ import {resolveBillingRecovery,type BillingRecoveryKind,} from "@multica/core/billing/recovery";-import { BILLING_WORKSPACE_SUBSCRIPTIONS_FLAG } from "@multica/core/feature-flags";+import { BILLING_WORKSPACE_SUBSCRIPTIONS_FLAG } from "@multica/core/feature-flags/keys";import { Text } from "@/components/ui/text";import { Button } from "@/components/ui/button";import { IconButton } from "@/components/ui/icon-button";diff --git a/apps/mobile/app/(app)/[workspace]/project/[id]/add-resource.tsx b/apps/mobile/app/(app)/[workspace]/project/[id]/add-resource.tsxindex b946814a3d..03d84eccc5 100644--- a/apps/mobile/app/(app)/[workspace]/project/[id]/add-resource.tsx+++ b/apps/mobile/app/(app)/[workspace]/project/[id]/add-resource.tsx@@ -21,7 +21,7 @@ import {looksLikeCommitSha,splitGithubUrlRef,validateGitRef,-} from "@multica/core/github";+} from "@multica/core/github/repo-ref";import { Text } from "@/components/ui/text";import { TextField } from "@/components/ui/text-field";import { useCreateProjectResource } from "@/data/mutations/projects";diff --git a/apps/mobile/components/issue/mention-suggestion-bar.tsx b/apps/mobile/components/issue/mention-suggestion-bar.tsxindex 26fe86bfb1..ee7062aad9 100644--- a/apps/mobile/components/issue/mention-suggestion-bar.tsx+++ b/apps/mobile/components/issue/mention-suggestion-bar.tsx@@ -26,7 +26,7 @@ import { useMemo } from "react";import { FlatList, Pressable, View } from "react-native";import { useQueries, useQuery } from "@tanstack/react-query";import type { Agent, Issue, MemberWithUser, Squad } from "@multica/core/types";-import { canAssignAgentToIssue } from "@multica/core/permissions";+import { canAssignAgentToIssue } from "@multica/core/permissions/rules";import { Text } from "@/components/ui/text";import { ActorAvatar } from "@/components/ui/actor-avatar";import { StatusIcon } from "@/components/ui/status-icon";diff --git a/apps/mobile/eslint.config.js b/apps/mobile/eslint.config.jsindex 2e19dbede7..a6120f4ccd 100644--- a/apps/mobile/eslint.config.js+++ b/apps/mobile/eslint.config.js@@ -1,6 +1,19 @@// https://docs.expo.dev/guides/using-eslint/const { defineConfig } = require('eslint/config');const expoConfig = require("eslint-config-expo/flat");+const coreExports = require("../../packages/core/package.json").exports;++// Mobile shares only types and pure helpers with core. These barrels re-export+// nothing else; every other core barrel also pulls in hooks, Query factories,+// stores or React context, which must not load under React Native.+const PURE_CORE_BARRELS = new Set(["./types", "./markdown"]);+const coreBarrelImports = Object.entries(coreExports)+ .filter(([subpath, target]) => target.endsWith("/index.ts") && !PURE_CORE_BARRELS.has(subpath))+ .map(([subpath]) => ({+ name: subpath === "." ? "@multica/core" : `@multica/core/${subpath.slice(2)}`,+ allowTypeImports: true,+ message: "This core barrel also loads hooks, queries, stores or React context. Import the pure module through its own subpath (for example @multica/core/agents/derive-presence); type-only imports are fine.",+ }));module.exports = defineConfig([expoConfig,@@ -17,5 +30,11 @@ module.exports = defineConfig([}],}],},- }+ },+ {+ files: ["**/*.{ts,tsx}"],+ rules: {+ "@typescript-eslint/no-restricted-imports": ["error", { paths: coreBarrelImports }],+ },+ },]);diff --git a/apps/mobile/lib/use-agent-presence.test.ts b/apps/mobile/lib/use-agent-presence.test.tsindex de8f99c56a..368992f941 100644--- a/apps/mobile/lib/use-agent-presence.test.ts+++ b/apps/mobile/lib/use-agent-presence.test.ts@@ -29,7 +29,7 @@ vi.mock("react-native", () => ({},}));vi.mock("@tanstack/react-query", () => ({ useQuery: () => ({ data: [] }), queryOptions: (options: unknown) => options }));-vi.mock("@multica/core/agents", () => ({ buildPresenceMap: clock.derive }));+vi.mock("@multica/core/agents/derive-presence", () => ({ buildPresenceMap: clock.derive }));vi.mock("@/data/api", () => ({ api: {} }));describe("presence clock", () => {diff --git a/apps/mobile/lib/use-agent-presence.ts b/apps/mobile/lib/use-agent-presence.tsindex de49b73ce9..78f5d8767a 100644--- a/apps/mobile/lib/use-agent-presence.ts+++ b/apps/mobile/lib/use-agent-presence.ts@@ -7,8 +7,8 @@* QueryClient + query keys.** Pure derivation is shared though — `deriveAgentPresenceDetail` /- * `buildPresenceMap` are imported from `@multica/core/agents` (pure functions,- * on the whitelist). Don't re-implement the three-state logic locally; the+ * `buildPresenceMap` are imported from `@multica/core/agents/derive-presence`+ * (pure functions, on the whitelist). Don't re-implement the three-state logic locally; the* web/desktop/mobile semantics MUST agree (apps/mobile/CLAUDE.md* "State enums and transitions must agree").*@@ -25,11 +25,11 @@import { useEffect, useMemo, useState } from "react";import { AppState, type AppStateStatus } from "react-native";import { useQuery } from "@tanstack/react-query";+import type { AgentPresenceDetail } from "@multica/core/agents";import {buildPresenceMap,deriveAgentPresenceDetail,- type AgentPresenceDetail,-} from "@multica/core/agents";+} from "@multica/core/agents/derive-presence";import { agentListOptions } from "@/data/queries/agents";import { runtimeListOptions } from "@/data/queries/runtimes";import { agentTaskSnapshotOptions } from "@/data/queries/agent-task-snapshot";diff --git a/apps/mobile/lib/workspace-agent-availability.ts b/apps/mobile/lib/workspace-agent-availability.tsindex 283652fe1e..e755f4d975 100644--- a/apps/mobile/lib/workspace-agent-availability.ts+++ b/apps/mobile/lib/workspace-agent-availability.ts@@ -11,7 +11,7 @@* mount.*/import { useQuery } from "@tanstack/react-query";-import { canAssignAgentToIssue } from "@multica/core/permissions";+import { canAssignAgentToIssue } from "@multica/core/permissions/rules";import { useAuthStore } from "@/data/auth-store";import { useWorkspaceStore } from "@/data/workspace-store";import { agentListOptions } from "@/data/queries/agents";diff --git a/apps/web/package.json b/apps/web/package.jsonindex 8428c6f79e..c525e6c951 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -21,11 +21,11 @@"dotenv": "^17.4.1","fumadocs-core": "^15.5.2","fumadocs-mdx": "^12.0.3",- "next": "^16.4.5",+ "next": "catalog:","react": "catalog:","react-dom": "catalog:",- "shadcn": "^4.1.0",- "tw-animate-css": "^1.4.0",+ "shadcn": "catalog:",+ "tw-animate-css": "catalog:","zod": "catalog:"},"devDependencies": {diff --git a/package.json b/package.jsonindex 81d8091581..b7f1da8bb0 100644--- a/package.json+++ b/package.json@@ -26,6 +26,7 @@"knip": "knip","check:ui-exports": "node scripts/check-ui-wildcard-exports.mjs","check:ui-radii": "node scripts/check-ui-radius-tokens.mjs",+ "check:deps-catalog": "node scripts/check-dependency-catalog.mjs","clean": "turbo clean && rm -rf node_modules","ui:add": "cd packages/ui && npx shadcn@latest add","generate:brand": "node scripts/brand/generate.mjs",diff --git a/packages/core/package.json b/packages/core/package.jsonindex fcbcb6382c..0c738c7eb7 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -94,6 +94,7 @@"./squads": "./squads/index.ts","./squads/stores": "./squads/stores/index.ts","./permissions": "./permissions/index.ts",+ "./permissions/rules": "./permissions/rules.ts","./search/cancelled-rank": "./search/cancelled-rank.ts","./search-index": "./search-index/index.ts","./projects": "./projects/index.ts",@@ -138,6 +139,7 @@"./billing/mutations": "./billing/mutations.ts","./github": "./github/index.ts","./github/queries": "./github/queries.ts",+ "./github/repo-ref": "./github/repo-ref.ts","./vcs": "./vcs/index.ts","./vcs/queries": "./vcs/queries.ts","./lark": "./lark/index.ts",@@ -169,6 +171,7 @@"./security/redact-secrets": "./security/redact-secrets.ts","./constants/*": "./constants/*.ts","./feature-flags": "./feature-flags/index.ts",+ "./feature-flags/keys": "./feature-flags/keys.ts","./platform": "./platform/index.ts","./drafts": "./drafts/index.ts","./drafts/*": "./drafts/*.ts",diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex c3e1b7949d..452dcae0c2 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -30,32 +30,32 @@"./styles/base.css": "./styles/base.css"},"dependencies": {- "@base-ui/react": "^1.3.0",+ "@base-ui/react": "catalog:","@emoji-mart/data": "^1.2.1","@number-flow/react": "^0.6.1","@tanstack/react-table": "catalog:","@tanstack/react-virtual": "catalog:","class-variance-authority": "catalog:","clsx": "catalog:",- "cmdk": "^1.1.1",+ "cmdk": "catalog:","emoji-mart": "^5.6.0","input-otp": "^1.4.2","linkify-it": "^5.0.0","katex": "catalog:",- "mdast-util-from-markdown": "^2.0.3",- "next-themes": "^0.4.6",+ "mdast-util-from-markdown": "catalog:",+ "next-themes": "catalog:","react-day-picker": "^9.14.0",- "react-markdown": "^10.1.0",- "react-resizable-panels": "^4.7.5",- "recharts": "3.8.0",+ "react-markdown": "catalog:",+ "react-resizable-panels": "catalog:",+ "recharts": "catalog:","rehype-katex": "catalog:",- "rehype-raw": "^7.0.0",- "rehype-sanitize": "^6.0.0",- "remark-breaks": "^4.0.0",- "remark-gfm": "^4.0.1",+ "rehype-raw": "catalog:",+ "rehype-sanitize": "catalog:",+ "remark-breaks": "catalog:",+ "remark-gfm": "catalog:","remark-math": "catalog:","shiki": "^3.21.0",- "sonner": "^2.0.7",+ "sonner": "catalog:","tailwind-merge": "catalog:"},"peerDependencies": {@@ -71,7 +71,7 @@"@testing-library/jest-dom": "catalog:","@testing-library/react": "catalog:","@types/linkify-it": "^5.0.0",- "@types/mdast": "^4.0.4",+ "@types/mdast": "catalog:","@types/react": "catalog:","@types/react-dom": "catalog:","@typescript/native": "catalog:",diff --git a/packages/views/package.json b/packages/views/package.jsonindex f5ea02fab9..82e388360d 100644--- a/packages/views/package.json+++ b/packages/views/package.json@@ -67,11 +67,11 @@"./locales/*": "./locales/*"},"dependencies": {- "@base-ui/react": "^1.3.0",- "@dnd-kit/core": "^6.3.1",- "@dnd-kit/modifiers": "^9.0.0",- "@dnd-kit/sortable": "^10.0.0",- "@dnd-kit/utilities": "^3.2.2",+ "@base-ui/react": "catalog:",+ "@dnd-kit/core": "catalog:",+ "@dnd-kit/modifiers": "catalog:",+ "@dnd-kit/sortable": "catalog:",+ "@dnd-kit/utilities": "catalog:","@floating-ui/dom": "^1.7.6","@multica/core": "workspace:*","@multica/ui": "workspace:*",@@ -97,32 +97,32 @@"@tiptap/react": "3.31.3","@tiptap/starter-kit": "3.31.3","@tiptap/suggestion": "3.31.3",- "cmdk": "^1.1.1",+ "cmdk": "catalog:","hast-util-to-html": "^9.0.5","katex": "catalog:","lowlight": "^3.3.0",- "mdast-util-from-markdown": "^2.0.3",+ "mdast-util-from-markdown": "catalog:","mdast-util-gfm-table": "^2.0.0","mdast-util-math": "^3.0.0","mermaid": "catalog:","micromark-extension-gfm-table": "^2.1.1","micromark-extension-math": "^3.1.0",- "motion": "^12.38.0",+ "motion": "catalog:","pinyin-pro": "3.26.0","react-easy-crop": "^6.2.0",- "react-markdown": "^10.1.0",+ "react-markdown": "catalog:","react-qr-code": "catalog:",- "react-resizable-panels": "^4.7.5",+ "react-resizable-panels": "catalog:","react-virtuoso": "catalog:",- "recharts": "3.8.0",+ "recharts": "catalog:","rehype-katex": "catalog:",- "rehype-raw": "^7.0.0",- "rehype-sanitize": "^6.0.0",- "remark-breaks": "^4.0.0",+ "rehype-raw": "catalog:",+ "rehype-sanitize": "catalog:",+ "remark-breaks": "catalog:","remark-cjk-friendly": "^2.3.1",- "remark-gfm": "^4.0.1",+ "remark-gfm": "catalog:","remark-math": "catalog:",- "sonner": "^2.0.7",+ "sonner": "catalog:","unist-util-visit": "^5.1.0","yaml": "catalog:"},@@ -144,7 +144,7 @@"@testing-library/react": "catalog:","@testing-library/user-event": "catalog:","@types/hast": "^3.0.4",- "@types/mdast": "^4.0.4",+ "@types/mdast": "catalog:","@types/react": "catalog:","@types/react-dom": "catalog:","@typescript-eslint/parser": "^8.35.0",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 9a91cdf6ad..0b412b98bc 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -6,12 +6,30 @@ settings:catalogs:default:+ '@base-ui/react':+ specifier: ^1.3.0+ version: 1.3.0+ '@dnd-kit/core':+ specifier: ^6.3.1+ version: 6.3.1+ '@dnd-kit/modifiers':+ specifier: ^9.0.0+ version: 9.0.0+ '@dnd-kit/sortable':+ specifier: ^10.0.0+ version: 10.0.0+ '@dnd-kit/utilities':+ specifier: ^3.2.2+ version: 3.2.2'@formatjs/intl-localematcher':specifier: ^0.8.4version: 0.8.4'@tailwindcss/postcss':specifier: ^4version: 4.2.2+ '@tailwindcss/vite':+ specifier: ^4+ version: 4.2.2'@tanstack/react-query':specifier: ^5.96.2version: 5.96.2@@ -30,6 +48,9 @@ catalogs:'@testing-library/user-event':specifier: ^14.6.1version: 14.6.1+ '@types/mdast':+ specifier: ^4.0.4+ version: 4.0.4'@types/node':specifier: ^25.0.10version: 25.5.0@@ -45,6 +66,9 @@ catalogs:clsx:specifier: ^2.1.1version: 2.1.1+ cmdk:+ specifier: ^1.1.1+ version: 1.1.1eslint-plugin-i18next:specifier: ^6.1.4version: 6.1.4@@ -60,12 +84,21 @@ catalogs:mdast-util-from-markdown:specifier: ^2.0.3version: 2.0.3- micromark-util-sanitize-uri:- specifier: ^2.0.1- version: 2.0.1mermaid:specifier: ^11.14.0version: 11.14.0+ micromark-util-sanitize-uri:+ specifier: ^2.0.1+ version: 2.0.1+ motion:+ specifier: ^12.38.0+ version: 12.38.0+ next:+ specifier: ^16.4.5+ version: 16.4.5+ next-themes:+ specifier: ^0.4.6+ version: 0.4.6posthog-js:specifier: ^1.176.1version: 1.369.3@@ -78,24 +111,54 @@ catalogs:react-i18next:specifier: ^17.0.6version: 17.0.6+ react-markdown:+ specifier: ^10.1.0+ version: 10.1.0react-qr-code:specifier: ^2.0.18version: 2.0.21+ react-resizable-panels:+ specifier: ^4.7.5+ version: 4.7.5react-virtuoso:specifier: ^4.14.0version: 4.18.7+ recharts:+ specifier: 3.8.0+ version: 3.8.0rehype-katex:specifier: ^7.0.1version: 7.0.1+ rehype-raw:+ specifier: ^7.0.0+ version: 7.0.0+ rehype-sanitize:+ specifier: ^6.0.0+ version: 6.0.0+ remark-breaks:+ specifier: ^4.0.0+ version: 4.0.0+ remark-gfm:+ specifier: ^4.0.1+ version: 4.0.1remark-math:specifier: ^6.0.0version: 6.0.0+ shadcn:+ specifier: ^4.1.0+ version: 4.1.0+ sonner:+ specifier: ^2.0.7+ version: 2.0.7tailwind-merge:specifier: ^3.4.0version: 3.5.0tailwindcss:specifier: ^4version: 4.2.2+ tw-animate-css:+ specifier: ^1.4.0+ version: 1.4.0typescript:specifier: npm:@typescript/[email protected]version: 6.0.2@@ -159,16 +222,16 @@ importers:apps/desktop:dependencies:'@dnd-kit/core':- specifier: ^6.3.1+ specifier: 'catalog:''@dnd-kit/modifiers':- specifier: ^9.0.0+ specifier: 'catalog:'version: 9.0.0(@dnd-kit/[email protected]([email protected]([email protected]))([email protected]))([email protected])'@dnd-kit/sortable':- specifier: ^10.0.0+ specifier: 'catalog:'version: 10.0.0(@dnd-kit/[email protected]([email protected]([email protected]))([email protected]))([email protected])'@dnd-kit/utilities':- specifier: ^3.2.2+ specifier: 'catalog:'version: 3.2.2([email protected])'@electron-toolkit/preload':specifier: ^3.0.2@@ -204,7 +267,7 @@ importers:specifier: ^5.0.0version: 5.0.0motion:- specifier: ^12.38.0+ specifier: 'catalog:'react:specifier: 'catalog:'@@ -216,13 +279,13 @@ importers:specifier: ^7.6.0shadcn:- specifier: ^4.1.0+ specifier: 'catalog:'version: 4.1.0(@types/[email protected])(@typescript/[email protected])sonner:- specifier: ^2.0.7+ specifier: 'catalog:'tw-animate-css:- specifier: ^1.4.0+ specifier: 'catalog:'version: 1.4.0zustand:specifier: 'catalog:'@@ -241,7 +304,7 @@ importers:specifier: workspace:*version: link:../../packages/vitest-setup'@tailwindcss/vite':- specifier: ^4+ specifier: 'catalog:'version: 4.2.2([email protected](@emnapi/[email protected])(@emnapi/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))'@testing-library/jest-dom':specifier: 'catalog:'@@ -280,7 +343,7 @@ importers:specifier: 'catalog:'version: 29.0.1(@noble/[email protected])tailwindcss:- specifier: ^4+ specifier: 'catalog:'version: 4.2.2typescript:specifier: 'catalog:'@@ -304,13 +367,13 @@ importers:specifier: ^16.17.8version: 16.17.8(@types/[email protected])(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected](@mdx-js/[email protected])(@types/[email protected])(@types/[email protected])(@types/[email protected])(@types/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected])([email protected]))([email protected](@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])mermaid:- specifier: ^11.14.0+ specifier: 'catalog:'version: 11.14.0next:- specifier: ^16.4.5+ specifier: 'catalog:'version: 16.4.5(@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])next-themes:- specifier: ^0.4.6+ specifier: 'catalog:'react:specifier: 'catalog:'@@ -319,7 +382,7 @@ importers:specifier: 'catalog:'version: 19.2.3([email protected])tw-animate-css:- specifier: ^1.4.0+ specifier: 'catalog:'version: 1.4.0devDependencies:'@tailwindcss/postcss':@@ -588,7 +651,7 @@ importers:specifier: ^12.0.3version: 12.0.3([email protected](@types/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected]))([email protected](@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])next:- specifier: ^16.4.5+ specifier: 'catalog:'version: 16.4.5(@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])react:specifier: 'catalog:'@@ -597,10 +660,10 @@ importers:specifier: 'catalog:'version: 19.2.3([email protected])shadcn:- specifier: ^4.1.0+ specifier: 'catalog:'version: 4.1.0(@types/[email protected])(@typescript/[email protected])tw-animate-css:- specifier: ^1.4.0+ specifier: 'catalog:'version: 1.4.0zod:specifier: 'catalog:'@@ -766,7 +829,7 @@ importers:packages/ui:dependencies:'@base-ui/react':- specifier: ^1.3.0+ specifier: 'catalog:''@emoji-mart/data':specifier: ^1.2.1@@ -787,7 +850,7 @@ importers:specifier: 'catalog:'version: 2.1.1cmdk:- specifier: ^1.1.1+ specifier: 'catalog:'version: 1.1.1(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])emoji-mart:specifier: ^5.6.0@@ -805,10 +868,10 @@ importers:specifier: ^5.0.0version: 5.0.0mdast-util-from-markdown:- specifier: ^2.0.3+ specifier: 'catalog:'version: 2.0.3next-themes:- specifier: ^0.4.6+ specifier: 'catalog:'react:specifier: 'catalog:'@@ -823,28 +886,28 @@ importers:specifier: 'catalog:'version: 17.0.6(@typescript/[email protected])([email protected](@typescript/[email protected]))([email protected]([email protected]))([email protected])react-markdown:- specifier: ^10.1.0+ specifier: 'catalog:'version: 10.1.0(@types/[email protected])([email protected])react-resizable-panels:- specifier: ^4.7.5+ specifier: 'catalog:'recharts:- specifier: 3.8.0+ specifier: 'catalog:'version: 3.8.0(@types/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])rehype-katex:specifier: 'catalog:'version: 7.0.1rehype-raw:- specifier: ^7.0.0+ specifier: 'catalog:'version: 7.0.0rehype-sanitize:- specifier: ^6.0.0+ specifier: 'catalog:'version: 6.0.0remark-breaks:- specifier: ^4.0.0+ specifier: 'catalog:'version: 4.0.0remark-gfm:- specifier: ^4.0.1+ specifier: 'catalog:'version: 4.0.1remark-math:specifier: 'catalog:'@@ -853,7 +916,7 @@ importers:specifier: ^3.21.0version: 3.23.0sonner:- specifier: ^2.0.7+ specifier: 'catalog:'tailwind-merge:specifier: 'catalog:'@@ -878,7 +941,7 @@ importers:specifier: ^5.0.0version: 5.0.0'@types/mdast':- specifier: ^4.0.4+ specifier: 'catalog:'version: 4.0.4'@types/react':specifier: ^19.2.0@@ -908,19 +971,19 @@ importers:packages/views:dependencies:'@base-ui/react':- specifier: ^1.3.0+ specifier: 'catalog:''@dnd-kit/core':- specifier: ^6.3.1+ specifier: 'catalog:''@dnd-kit/modifiers':- specifier: ^9.0.0+ specifier: 'catalog:'version: 9.0.0(@dnd-kit/[email protected]([email protected]([email protected]))([email protected]))([email protected])'@dnd-kit/sortable':- specifier: ^10.0.0+ specifier: 'catalog:'version: 10.0.0(@dnd-kit/[email protected]([email protected]([email protected]))([email protected]))([email protected])'@dnd-kit/utilities':- specifier: ^3.2.2+ specifier: 'catalog:'version: 3.2.2([email protected])'@floating-ui/dom':specifier: ^1.7.6@@ -1004,7 +1067,7 @@ importers:specifier: 3.31.3version: 3.31.3(@floating-ui/[email protected])(@tiptap/[email protected](@tiptap/[email protected]))(@tiptap/[email protected])cmdk:- specifier: ^1.1.1+ specifier: 'catalog:'version: 1.1.1(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])hast-util-to-html:specifier: ^9.0.5@@ -1019,7 +1082,7 @@ importers:specifier: ^3.3.0version: 3.3.0mdast-util-from-markdown:- specifier: ^2.0.3+ specifier: 'catalog:'version: 2.0.3mdast-util-gfm-table:specifier: ^2.0.0@@ -1037,7 +1100,7 @@ importers:specifier: ^3.1.0version: 3.1.0motion:- specifier: ^12.38.0+ specifier: 'catalog:'pinyin-pro:specifier: 3.26.0@@ -1055,43 +1118,43 @@ importers:specifier: 'catalog:'version: 17.0.6(@typescript/[email protected])([email protected](@typescript/[email protected]))([email protected]([email protected]))([email protected])react-markdown:- specifier: ^10.1.0+ specifier: 'catalog:'version: 10.1.0(@types/[email protected])([email protected])react-qr-code:specifier: 'catalog:'version: 2.0.21([email protected])react-resizable-panels:- specifier: ^4.7.5+ specifier: 'catalog:'react-virtuoso:specifier: 'catalog:'recharts:- specifier: 3.8.0+ specifier: 'catalog:'version: 3.8.0(@types/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])rehype-katex:specifier: 'catalog:'version: 7.0.1rehype-raw:- specifier: ^7.0.0+ specifier: 'catalog:'version: 7.0.0rehype-sanitize:- specifier: ^6.0.0+ specifier: 'catalog:'version: 6.0.0remark-breaks:- specifier: ^4.0.0+ specifier: 'catalog:'version: 4.0.0remark-cjk-friendly:specifier: ^2.3.1remark-gfm:- specifier: ^4.0.1+ specifier: 'catalog:'version: 4.0.1remark-math:specifier: 'catalog:'version: 6.0.0sonner:- specifier: ^2.0.7+ specifier: 'catalog:'unist-util-visit:specifier: ^5.1.0@@ -1128,7 +1191,7 @@ importers:specifier: ^3.0.4version: 3.0.4'@types/mdast':- specifier: ^4.0.4+ specifier: 'catalog:'version: 4.0.4'@types/react':specifier: ^19.2.0diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex 6b34e220ed..eb4a142d3d 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -3,6 +3,11 @@ packages:- packages/*catalog:+ '@base-ui/react': ^1.3.0+ '@dnd-kit/core': ^6.3.1+ '@dnd-kit/modifiers': ^9.0.0+ '@dnd-kit/sortable': ^10.0.0+ '@dnd-kit/utilities': ^3.2.2'@formatjs/intl-localematcher': ^0.8.4'@tailwindcss/postcss': ^4'@tailwindcss/vite': ^4@@ -12,6 +17,7 @@ catalog:'@testing-library/jest-dom': ^6.9.1'@testing-library/react': ^16.3.2'@testing-library/user-event': ^14.6.1+ '@types/mdast': ^4.0.4'@types/node': ^25.0.10'@types/react': ^19.2.0'@types/react-dom': ^19.2.0@@ -19,6 +25,7 @@ catalog:'@vitejs/plugin-react': ^6.0.1class-variance-authority: ^0.7.1clsx: ^2.1.1+ cmdk: ^1.1.1eslint-plugin-i18next: ^6.1.4i18next: ^26.0.8jsdom: ^29.0.1@@ -26,17 +33,30 @@ catalog:mdast-util-from-markdown: ^2.0.3micromark-util-sanitize-uri: ^2.0.1mermaid: ^11.14.0+ motion: ^12.38.0+ next: ^16.4.5+ next-themes: ^0.4.6postcss: ^8posthog-js: ^1.176.1react: 19.2.3react-dom: 19.2.3react-i18next: ^17.0.6+ react-markdown: ^10.1.0react-qr-code: ^2.0.18+ react-resizable-panels: ^4.7.5react-virtuoso: ^4.14.0+ recharts: 3.8.0rehype-katex: ^7.0.1+ rehype-raw: ^7.0.0+ rehype-sanitize: ^6.0.0+ remark-breaks: ^4.0.0+ remark-gfm: ^4.0.1remark-math: ^6.0.0+ shadcn: ^4.1.0+ sonner: ^2.0.7tailwind-merge: ^3.4.0tailwindcss: ^4+ tw-animate-css: ^1.4.0# Keep the compiler API for ESLint, Next.js, and repository scripts; tsc uses @typescript/native.typescript: npm:@typescript/[email protected]vitest: ^4.1.0diff --git a/scripts/check-dependency-catalog.mjs b/scripts/check-dependency-catalog.mjsnew file mode 100644index 0000000000..1ca82defb0--- /dev/null+++ b/scripts/check-dependency-catalog.mjs@@ -0,0 +1,152 @@+#!/usr/bin/env node+/**+ * Keeps shared external dependencies on the pnpm catalog (AGENTS.md).+ *+ * An external dependency declared by two or more workspaces must use+ * `catalog:` everywhere, so one edit to pnpm-workspace.yaml moves every+ * consumer together. A dependency the catalog already defines must use it even+ * in a single workspace, or the two versions drift silently.+ *+ * Peer ranges state compatibility rather than the installed version, so they+ * are not checked. apps/mobile is exempt: it pins Expo/React Native-aligned+ * versions in its own manifest (apps/mobile/AGENTS.md).+ *+ * Run: node scripts/check-dependency-catalog.mjs+ */++import { existsSync, readdirSync, readFileSync } from "node:fs";+import { join, resolve } from "node:path";+import { fileURLToPath } from "node:url";++const repoRoot = resolve(import.meta.dirname, "..");+const checkedFields = ["dependencies", "devDependencies", "optionalDependencies"];+const exemptWorkspaces = new Set(["apps/mobile"]);++// Known drift that needs its own upgrade. Each entry must still be a live+// violation; the check fails once the drift is gone so the entry gets removed.+export const allowlist = new Map([+ [+ "@vitejs/plugin-react",+ "apps/desktop bundles with plugin-react 5; moving it to the catalog's 6 changes how pnpm resolves vite for electron-vite and needs its own verification.",+ ],+ [+ "fumadocs-core",+ "apps/web is on fumadocs 15 and apps/docs on 16; aligning them needs an apps/web fumadocs upgrade.",+ ],+ [+ "fumadocs-mdx",+ "apps/web is on fumadocs-mdx 12 and apps/docs on 15; aligning them needs an apps/web fumadocs upgrade.",+ ],+]);++const unquote = (value) => value.trim().replace(/^(['"])(.*)\1$/, "$2");++/** Reads `packages` and the default `catalog` from pnpm-workspace.yaml. */+export function parseWorkspaceManifest(source) {+ const packages = [];+ const catalog = new Map();+ let section = null;+ for (const raw of source.split("\n")) {+ const line = raw.replace(/\s+#.*$/, "");+ if (!line.trim() || line.trimStart().startsWith("#")) continue;+ if (!/^\s/.test(line)) {+ section = line.replace(/:.*$/, "").trim();+ continue;+ }+ if (section === "packages") {+ const item = line.match(/^\s+-\s+(.+)$/);+ if (item) packages.push(unquote(item[1]));+ } else if (section === "catalog") {+ const entry = line.match(/^\s+('[^']+'|"[^"]+"|[^\s:]+):\s*(.+)$/);+ if (entry) catalog.set(unquote(entry[1]), unquote(entry[2]));+ }+ }+ return { packages, catalog };+}++const isCatalogSpec = (spec) => spec.startsWith("catalog:");+const isWorkspaceSpec = (spec) => spec.startsWith("workspace:");++/**+ * @param {{ catalog: Map<string, string>, workspaces: { dir: string, manifest: object }[], allowlist?: Map<string, string> }} input+ * @returns {string[]} human-readable violations+ */+export function catalogViolations({ catalog, workspaces, allowlist: allowed = new Map() }) {+ const declarations = new Map();+ for (const { dir, manifest } of workspaces) {+ if (exemptWorkspaces.has(dir)) continue;+ for (const field of checkedFields) {+ for (const [name, spec] of Object.entries(manifest[field] ?? {})) {+ if (isWorkspaceSpec(spec)) continue;+ const list = declarations.get(name) ?? [];+ list.push({ dir, field, spec });+ declarations.set(name, list);+ }+ }+ }++ const violations = [];+ const liveAllowlist = new Set();+ for (const [name, list] of [...declarations].sort(([a], [b]) => a.localeCompare(b))) {+ const plain = list.filter(({ spec }) => !isCatalogSpec(spec));+ if (plain.length === 0) continue;+ if (!catalog.has(name) && list.length < 2) continue;+ if (allowed.has(name)) {+ liveAllowlist.add(name);+ continue;+ }++ const where = plain.map(({ dir, field, spec }) => `${dir} ${field} ${spec}`).join(", ");+ violations.push(+ catalog.has(name)+ ? `${name}: catalog defines ${catalog.get(name)}; use "catalog:" in ${where}`+ : `${name}: declared by ${list.length} workspaces; add it to the catalog and use "catalog:" in ${where}`,+ );+ }++ for (const name of allowed.keys()) {+ if (!liveAllowlist.has(name)) {+ violations.push(`${name}: allowlisted but no longer a non-catalog duplicate; remove it from the allowlist`);+ }+ }+ return violations;+}++function workspaceDirs(patterns) {+ const dirs = [""];+ for (const pattern of patterns) {+ if (!pattern.endsWith("/*")) {+ dirs.push(pattern);+ continue;+ }+ const parent = pattern.slice(0, -2);+ for (const entry of readdirSync(join(repoRoot, parent), { withFileTypes: true })) {+ if (entry.isDirectory()) dirs.push(`${parent}/${entry.name}`);+ }+ }+ return dirs.filter((dir) => existsSync(join(repoRoot, dir, "package.json")));+}++function main() {+ const { packages, catalog } = parseWorkspaceManifest(+ readFileSync(join(repoRoot, "pnpm-workspace.yaml"), "utf8"),+ );+ const workspaces = workspaceDirs(packages).map((dir) => ({+ dir: dir || ".",+ manifest: JSON.parse(readFileSync(join(repoRoot, dir, "package.json"), "utf8")),+ }));+ const violations = catalogViolations({ catalog, workspaces, allowlist });++ if (violations.length > 0) {+ console.error(`Dependencies off the pnpm catalog (${violations.length})`);+ for (const violation of violations) console.error(` ${violation}`);+ console.error(+ "\nShared external dependencies use \"catalog:\" with the version in pnpm-workspace.yaml. apps/mobile pins its own versions and is exempt.",+ );+ process.exit(1);+ }++ console.log(`Dependency catalog clean (${workspaces.length} workspaces checked).`);+}++if (resolve(process.argv[1] ?? "") === fileURLToPath(import.meta.url)) main();diff --git a/scripts/check-dependency-catalog.test.mjs b/scripts/check-dependency-catalog.test.mjsnew file mode 100644index 0000000000..43672d6c4c--- /dev/null+++ b/scripts/check-dependency-catalog.test.mjs@@ -0,0 +1,95 @@+import assert from "node:assert/strict";+import test from "node:test";++import { catalogViolations, parseWorkspaceManifest } from "./check-dependency-catalog.mjs";++const workspace = (dir, manifest) => ({ dir, manifest });++test("parses packages and the default catalog, ignoring comments", () => {+ const { packages, catalog } = parseWorkspaceManifest(`packages:+ - apps/*+ - "packages/*"++catalog:+ '@scope/pkg': ^1.2.0+ # Comment about the next entry.+ typescript: npm:@typescript/[email protected]+ react: 19.2.3 # trailing comment++onlyBuiltDependencies:+ - esbuild+`);+ assert.deepEqual(packages, ["apps/*", "packages/*"]);+ assert.deepEqual(+ [...catalog],+ [+ ["@scope/pkg", "^1.2.0"],+ ["typescript", "npm:@typescript/[email protected]"],+ ["react", "19.2.3"],+ ],+ );+});++test("rejects a dependency shared by two workspaces without catalog:", () => {+ const violations = catalogViolations({+ catalog: new Map(),+ workspaces: [+ workspace("packages/ui", { dependencies: { sonner: "^2.0.7" } }),+ workspace("packages/views", { dependencies: { sonner: "catalog:" } }),+ ],+ });+ assert.equal(violations.length, 1);+ assert.match(violations[0], /^sonner: declared by 2 workspaces.*packages\/ui dependencies \^2\.0\.7$/);+});++test("rejects a plain range for a dependency the catalog defines, even in one workspace", () => {+ const violations = catalogViolations({+ catalog: new Map([["tailwindcss", "^4"]]),+ workspaces: [workspace("apps/desktop", { devDependencies: { tailwindcss: "^4" } })],+ });+ assert.equal(violations.length, 1);+ assert.match(violations[0], /^tailwindcss: catalog defines \^4/);+});++test("accepts catalog:, workspace:, single-workspace deps, peers, and mobile pins", () => {+ const violations = catalogViolations({+ catalog: new Map([["react", "19.2.3"]]),+ workspaces: [+ workspace("apps/web", {+ dependencies: { react: "catalog:", "@multica/core": "workspace:*", "web-only": "^1.0.0" },+ }),+ workspace("packages/views", {+ peerDependencies: { react: "^19", eslint: "^9.0.0" },+ devDependencies: { eslint: "^9.0.0" },+ }),+ workspace("packages/eslint-config", { peerDependencies: { eslint: "^9.0.0" } }),+ workspace("apps/mobile", { dependencies: { react: "19.2.3", "web-only": "^0.9.0" } }),+ ],+ });+ assert.deepEqual(violations, []);+});++test("allowlisted drift passes until it is gone, then must be removed", () => {+ const allowlist = new Map([["fumadocs-core", "pending upgrade"]]);+ const drifted = [+ workspace("apps/web", { dependencies: { "fumadocs-core": "^15.5.2" } }),+ workspace("apps/docs", { dependencies: { "fumadocs-core": "^16.17.8" } }),+ ];+ assert.deepEqual(catalogViolations({ catalog: new Map(), workspaces: drifted, allowlist }), []);+ assert.deepEqual(+ catalogViolations({+ catalog: new Map([["fumadocs-core", "^16.17.8"]]),+ workspaces: drifted,+ allowlist,+ }),+ [],+ );++ const aligned = catalogViolations({+ catalog: new Map([["fumadocs-core", "^16.17.8"]]),+ workspaces: drifted.map(({ dir }) => workspace(dir, { dependencies: { "fumadocs-core": "catalog:" } })),+ allowlist,+ });+ assert.equal(aligned.length, 1);+ assert.match(aligned[0], /^fumadocs-core: allowlisted but no longer/);+});