diff --git a/docs/superpowers/plans/2026-07-02-rbac-refactor.md b/docs/superpowers/plans/2026-07-02-rbac-refactor.md index db20353..db843f9 100644 --- a/docs/superpowers/plans/2026-07-02-rbac-refactor.md +++ b/docs/superpowers/plans/2026-07-02-rbac-refactor.md @@ -2,6 +2,7 @@ change: rbac-refactor design-doc: docs/superpowers/specs/2026-07-02-rbac-refactor-design.md base-ref: 78676a124a80542ff89c55cdd6a63af02ac21782 +archived-with: 2026-07-03-rbac-refactor --- # RBAC 鉴权重构 实施计划 @@ -25,6 +26,7 @@ base-ref: 78676a124a80542ff89c55cdd6a63af02ac21782 - 前端权限存储在 localStorage `permissions` key 中,注销时清除 - Users 表移除 `role`(VARCHAR)和 `allowedMenus`(TEXT)字段,改为关联表 +archived-with: 2026-07-03-rbac-refactor --- ## 文件结构 @@ -77,6 +79,7 @@ base-ref: 78676a124a80542ff89c55cdd6a63af02ac21782 | `frontend/src/pages/Login/index.tsx` | 登录成功存储 permissions 到 localStorage | | `frontend/src/pages/Users/index.tsx` | 重构:角色列显示多角色 Tag;编辑弹窗使用 Select multiple;移除 allowedMenus 相关代码;API 端点改为 /rbac/users | +archived-with: 2026-07-03-rbac-refactor --- ### Task 1: 数据库实体与种子数据 @@ -246,6 +249,7 @@ git add backend/src/entities/permission.entity.ts backend/src/entities/role.enti git commit -m "feat(rbac): add Permission and Role entities, update User entity" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 2: RBAC 服务层 (RbacModule + RbacService) @@ -544,6 +548,7 @@ git add backend/src/rbac/ git commit -m "feat(rbac): add RbacModule and RbacService with seed data and role CRUD" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 3: 权限守卫装饰器 (PermissionGuard + @Public + @RequirePermission) @@ -745,6 +750,7 @@ git add backend/src/auth/decorators/ backend/src/auth/guards/permission.guard.ts git commit -m "feat(rbac): add PermissionGuard, @Public and @RequirePermission decorators" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 4: 修改 Auth 模块(JWT 变更 + 与 RbacModule 集成) @@ -992,6 +998,7 @@ git add backend/src/auth/ git commit -m "feat(rbac): integrate RbacService into AuthService login, update JWT payload" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 5: RbacController(角色 CRUD + 权限树 + 用户管理) @@ -1314,6 +1321,7 @@ git add backend/src/rbac/ git commit -m "feat(rbac): add RbacController with role CRUD, permissions tree, and user management endpoints" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 6: AppModule 注册 RbacModule 和 PermissionGuard @@ -1437,6 +1445,7 @@ git add backend/src/app.module.ts git commit -m "feat(rbac): register RbacModule and PermissionGuard in AppModule" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 7: 现有接口批量加 @RequirePermission @@ -1560,6 +1569,7 @@ git add backend/src/students/ backend/src/rooms/ backend/src/occupancies/ backen git commit -m "feat(rbac): add @RequirePermission decorators to all business controllers" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 8: 前端权限基础设施 @@ -1732,6 +1742,7 @@ git add frontend/src/hooks/ frontend/src/components/PermissionButton.tsx fronten git commit -m "feat(frontend): add usePermission hook, PermissionButton, PermissionRoute, and 403 handling" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 9: 前端角色管理和权限一览页面 @@ -2055,6 +2066,7 @@ git add frontend/src/pages/Roles/ frontend/src/pages/Permissions/ git commit -m "feat(frontend): add Roles management page and Permissions overview page" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 10: 前端路由、菜单和用户管理页面适配 @@ -2556,6 +2568,7 @@ git add frontend/src/App.tsx frontend/src/layouts/MainLayout.tsx frontend/src/pa git commit -m "feat(frontend): adapt routes, menus, Users page, and business pages for RBAC" ``` +archived-with: 2026-07-03-rbac-refactor --- ### Task 11: 验证与收尾 @@ -2681,6 +2694,7 @@ git add -A git commit -m "chore(rbac): final verification and lint fixes" ``` +archived-with: 2026-07-03-rbac-refactor --- ## 自检 diff --git a/docs/superpowers/specs/2026-07-02-rbac-refactor-design.md b/docs/superpowers/specs/2026-07-02-rbac-refactor-design.md index 7c604d7..78f546c 100644 --- a/docs/superpowers/specs/2026-07-02-rbac-refactor-design.md +++ b/docs/superpowers/specs/2026-07-02-rbac-refactor-design.md @@ -2,6 +2,8 @@ comet_change: rbac-refactor role: technical-design canonical_spec: openspec +archived-with: 2026-07-03-rbac-refactor +status: final --- # RBAC 鉴权重构技术设计 diff --git a/openspec/changes/rbac-refactor/.openspec.yaml b/openspec/changes/archive/2026-07-03-rbac-refactor/.openspec.yaml similarity index 100% rename from openspec/changes/rbac-refactor/.openspec.yaml rename to openspec/changes/archive/2026-07-03-rbac-refactor/.openspec.yaml diff --git a/openspec/changes/rbac-refactor/design.md b/openspec/changes/archive/2026-07-03-rbac-refactor/design.md similarity index 100% rename from openspec/changes/rbac-refactor/design.md rename to openspec/changes/archive/2026-07-03-rbac-refactor/design.md diff --git a/openspec/changes/rbac-refactor/proposal.md b/openspec/changes/archive/2026-07-03-rbac-refactor/proposal.md similarity index 100% rename from openspec/changes/rbac-refactor/proposal.md rename to openspec/changes/archive/2026-07-03-rbac-refactor/proposal.md diff --git a/openspec/changes/rbac-refactor/tasks.md b/openspec/changes/archive/2026-07-03-rbac-refactor/tasks.md similarity index 100% rename from openspec/changes/rbac-refactor/tasks.md rename to openspec/changes/archive/2026-07-03-rbac-refactor/tasks.md diff --git a/openspec/specs/monorepo-structure/spec.md b/openspec/specs/monorepo-structure/spec.md new file mode 100644 index 0000000..9c3be37 --- /dev/null +++ b/openspec/specs/monorepo-structure/spec.md @@ -0,0 +1,49 @@ +# monorepo-structure Specification + +## Purpose +TBD - created by archiving change migrate-to-turborepo. Update Purpose after archive. +## Requirements +### Requirement: Monorepo directory structure +The project SHALL adopt the Turborepo-recommended directory structure with `apps/` for applications and `packages/` for shared libraries. + +#### Scenario: Directory layout exists +- **WHEN** a developer clones the repository +- **THEN** the root directory contains `apps/server/`, `apps/admin/`, and `packages/typescript-config/` as npm workspace packages + +#### Scenario: Legacy paths removed +- **WHEN** the migration is complete +- **THEN** top-level `backend/` (moved to `apps/server/`) and `frontend/` (moved to `apps/admin/`) directories no longer exist + +### Requirement: npm workspaces configuration +The root `package.json` SHALL declare `workspaces` field listing all app and package directories, enabling unified dependency management via npm. + +#### Scenario: Install from root +- **WHEN** `npm install` is run at the project root +- **THEN** dependencies for all workspaces are installed and hoisted to root `node_modules/` + +#### Scenario: Workspace-scoped scripts +- **WHEN** `npm run test --workspace=apps/server` is executed +- **THEN** only the backend test suite runs + +### Requirement: Shared TypeScript configuration +The project SHALL provide shared TypeScript configuration presets via `packages/typescript-config/`, including `base.json`, `nestjs.json`, and `react-vite.json`. + +#### Scenario: Server inherits NestJS preset +- **WHEN** `apps/server/tsconfig.json` is read +- **THEN** it extends `@gongxue/typescript-config/nestjs.json` + +#### Scenario: Admin inherits React preset +- **WHEN** `apps/admin/tsconfig.json` is read +- **THEN** it extends `@gongxue/typescript-config/react-vite.json` + +### Requirement: Docker Compose path compatibility +The `docker-compose.yml` SHALL reference build contexts using the new `apps/` paths, and all services MUST build and start successfully. + +#### Scenario: Docker compose build succeeds +- **WHEN** `docker compose build` is executed +- **THEN** server and admin images build without errors + +#### Scenario: Docker compose up succeeds +- **WHEN** `docker compose up` is executed +- **THEN** all services (MySQL, server, admin) start and respond to requests + diff --git a/openspec/specs/oxlint-oxfmt-toolchain/spec.md b/openspec/specs/oxlint-oxfmt-toolchain/spec.md new file mode 100644 index 0000000..71b43a5 --- /dev/null +++ b/openspec/specs/oxlint-oxfmt-toolchain/spec.md @@ -0,0 +1,49 @@ +# oxlint-oxfmt-toolchain Specification + +## Purpose +TBD - created by archiving change migrate-to-turborepo. Update Purpose after archive. +## Requirements +### Requirement: oxfmt replaces Prettier +The project SHALL use oxfmt for all code formatting, with a root `.oxfmtrc.json` configuration that replicates the existing Prettier conventions. + +#### Scenario: Format check passes +- **WHEN** `npm run format` is executed at root +- **THEN** all TypeScript/JavaScript/JSON source files are formatted according to `.oxfmtrc.json` rules + +#### Scenario: CI format gate +- **WHEN** `npm run format -- --check` is executed in CI +- **THEN** it exits with non-zero code if any file is not formatted correctly + +### Requirement: Frontend oxlint replaces ESLint +The admin application (`apps/admin/`) SHALL use oxlint for linting, with a configuration that covers TypeScript and React rules equivalent to the existing ESLint setup. + +#### Scenario: Admin lint passes +- **WHEN** `npm run lint` is executed at root +- **THEN** admin source files are linted with oxlint and pass without errors + +#### Scenario: Rules-of-hooks violations detected +- **WHEN** a React hook is called conditionally in admin source +- **THEN** oxlint reports a rules-of-hooks violation + +### Requirement: Backend retains ESLint +The server application (`apps/server/`) SHALL retain its existing ESLint configuration due to NestJS-specific rules that oxlint does not support. + +#### Scenario: Server lint passes +- **WHEN** `npm run lint` is executed at root +- **THEN** server source files are linted with ESLint and pass without errors + +#### Scenario: NestJS decorator checks work +- **WHEN** ESLint runs on server source +- **THEN** `@typescript-eslint/no-unsafe-*` rules and NestJS-specific patterns are enforced + +### Requirement: Pre-existing Prettier/ESLint cleanup +All Prettier configuration files (`.prettierrc`, `eslint-plugin-prettier` references) SHALL be removed, and ESLint configurations SHALL be updated to remove Prettier integration. + +#### Scenario: No Prettier remnants +- **WHEN** the migration is complete +- **THEN** `grep -r "prettier"` across config files returns no results (excluding oxfmt config which is separate) + +#### Scenario: No Prettier dependencies +- **WHEN** `npm ls prettier eslint-plugin-prettier eslint-config-prettier` is run +- **THEN** no Prettier-related packages are installed in any workspace + diff --git a/openspec/specs/turborepo-pipeline/spec.md b/openspec/specs/turborepo-pipeline/spec.md new file mode 100644 index 0000000..78af4cb --- /dev/null +++ b/openspec/specs/turborepo-pipeline/spec.md @@ -0,0 +1,42 @@ +# turborepo-pipeline Specification + +## Purpose +TBD - created by archiving change migrate-to-turborepo. Update Purpose after archive. +## Requirements +### Requirement: Turbo pipeline configuration +The project SHALL define a `turbo.json` at the repository root that configures build, dev, lint, test, format, and typecheck pipelines with appropriate caching and dependency ordering. + +#### Scenario: Build pipeline with caching +- **WHEN** `turbo run build` is executed twice without source changes +- **THEN** the second run uses cached outputs and completes with "FULL TURBO" status + +#### Scenario: Topological build ordering +- **WHEN** `turbo run build` is executed +- **THEN** packages (shared configs, types) build before apps that depend on them + +#### Scenario: Parallel execution +- **WHEN** `turbo run lint` is executed +- **THEN** server and admin linting run in parallel where dependency graph allows + +### Requirement: Unified root scripts +The root `package.json` SHALL provide top-level scripts (`dev`, `build`, `lint`, `format`, `test`, `typecheck`) that delegate to Turborepo or workspace-level commands. + +#### Scenario: Dev mode starts all apps +- **WHEN** `npm run dev` is executed at root +- **THEN** both server (NestJS on port 3003) and admin (Vite on port 3002) start in dev mode + +#### Scenario: Build produces all outputs +- **WHEN** `npm run build` is executed at root +- **THEN** server `dist/` and admin `dist/` are produced + +### Requirement: Independent workspace scripts +Each workspace SHALL retain the ability to run its own scripts independently (e.g., `npm run test` inside `apps/server/`). + +#### Scenario: Server tests run independently +- **WHEN** `npm run test` is executed inside `apps/server/` +- **THEN** the NestJS Jest test suite runs and reports results + +#### Scenario: Admin dev runs independently +- **WHEN** `npm run dev` is executed inside `apps/admin/` +- **THEN** the Vite dev server starts on port 3002 with API proxy configured +