create-fullstack-scaffold 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +439 -0
- package/dist/cli/index.js.map +1 -0
- package/package.json +171 -0
- package/template/.agents/skills/writing-hookify-rules/SKILL.md +408 -0
- package/template/.ai-context.md +368 -0
- package/template/.claude/hookify.block-dangerous-commands.local.md +41 -0
- package/template/.claude/hookify.check-api-types.local.md +111 -0
- package/template/.claude/hookify.check-duplicate-types.local.md +287 -0
- package/template/.claude/hookify.check-test-assertions.local.md +93 -0
- package/template/.claude/hookify.remind-add-tests.local.md +209 -0
- package/template/.claude/hookify.remind-db-migration.local.md +58 -0
- package/template/.claude/hookify.remind-run-tests.local.md +52 -0
- package/template/.claude/hookify.warn-any-type.local.md +203 -0
- package/template/.claude/hookify.warn-console-log.local.md +73 -0
- package/template/.claude/rules/00-project-config.md +147 -0
- package/template/.claude/rules/01-file-types.md +127 -0
- package/template/.claude/rules/02-git-workflow.md +167 -0
- package/template/.claude/rules/10-api-type-inference.md +555 -0
- package/template/.claude/rules/20-server-api.md +349 -0
- package/template/.claude/rules/21-server-entrypoint.md +257 -0
- package/template/.claude/rules/30-client-components.md +314 -0
- package/template/.claude/rules/31-client-services.md +768 -0
- package/template/.claude/rules/32-client-state-zustand.md +324 -0
- package/template/.claude/rules/33-client-app-entry.md +276 -0
- package/template/.claude/rules/34-client-admin-module.md +445 -0
- package/template/.claude/rules/35-cli-module.md +259 -0
- package/template/.claude/rules/40-admin-module.md +495 -0
- package/template/.claude/rules/40-shared-types.md +450 -0
- package/template/.claude/rules/50-websocket.md +245 -0
- package/template/.claude/rules/51-sse.md +372 -0
- package/template/.claude/rules/52-cloudflare-realtime.md +384 -0
- package/template/.claude/rules/60-testing-standards.md +245 -0
- package/template/.claude/rules/61-hono-testing.md +200 -0
- package/template/.claude/scripts/README.md +187 -0
- package/template/.claude/scripts/check-duplicate-types.ts +188 -0
- package/template/.claude/scripts/post-edit-check-incremental.sh +61 -0
- package/template/.claude/scripts/post-edit-check.sh +22 -0
- package/template/.claude/scripts/pre-tool-use-check.sh +86 -0
- package/template/.claude/scripts/test-pre-tool-use.sh +73 -0
- package/template/.claude/scripts/validate-git-changes.sh +38 -0
- package/template/.claude/settings.json +32 -0
- package/template/.claude/skills/writing-hookify-rules/SKILL.md +408 -0
- package/template/.dev-context-compact.md +54 -0
- package/template/.dev-context.md +621 -0
- package/template/.dev-guide.md +243 -0
- package/template/.env.example +60 -0
- package/template/.eslintrc.routes.json +39 -0
- package/template/.husky/_/husky.sh +27 -0
- package/template/.husky/commit-msg +4 -0
- package/template/.husky/post-commit +4 -0
- package/template/.husky/pre-commit +19 -0
- package/template/.husky/pre-push +12 -0
- package/template/.prettierignore +22 -0
- package/template/.prettierrc +8 -0
- package/template/.sessions/3/2026-03-26T05-41-09-154Z_03bb597f-3898-4a2e-8c08-5746bbe8d95e.jsonl +18 -0
- package/template/.sessions/3/2026-03-26T05-48-30-052Z_12de4774-9cb3-494c-9852-bd1e6b0003c3.jsonl +6 -0
- package/template/.vscode/extensions.json +8 -0
- package/template/.vscode/settings.json +4 -0
- package/template/.workspaces/3/hello.py +1 -0
- package/template/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/803c2e37182b913f8857edf6d8776515cef4af6d48fcb25913e457f4b14ffa97.sqlite +0 -0
- package/template/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/803c2e37182b913f8857edf6d8776515cef4af6d48fcb25913e457f4b14ffa97.sqlite-shm +0 -0
- package/template/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/803c2e37182b913f8857edf6d8776515cef4af6d48fcb25913e457f4b14ffa97.sqlite-wal +0 -0
- package/template/CLAUDE.md +296 -0
- package/template/DESIGN.md +260 -0
- package/template/DEV_CONTEXT_GUIDE.md +366 -0
- package/template/DEV_TOOLS_README.md +396 -0
- package/template/FRAMEWORK_HISTORY.md +34 -0
- package/template/PROJECT_SUMMARY.md +325 -0
- package/template/QUICKSTART.md +305 -0
- package/template/README.md +154 -0
- package/template/STRUCTURE.txt +81 -0
- package/template/admin.html +13 -0
- package/template/auth-inject.html +33 -0
- package/template/commitlint.config.js +12 -0
- package/template/docs/PERMISSION_ARCHITECTURE.md +279 -0
- package/template/docs/PERMISSION_EXAMPLES.md +230 -0
- package/template/docs/PERMISSION_SYSTEM.md +301 -0
- package/template/docs/SMART_TEST.md +171 -0
- package/template/docs/runtime-abstract.md +253 -0
- package/template/drizzle/0000_rainy_boomer.sql +101 -0
- package/template/drizzle/0001_add_todo_attachments.sql +12 -0
- package/template/drizzle/0002_chilly_magneto.sql +89 -0
- package/template/drizzle/meta/0000_snapshot.json +652 -0
- package/template/drizzle/meta/0001_snapshot.json +735 -0
- package/template/drizzle/meta/0002_snapshot.json +1198 -0
- package/template/drizzle/meta/_journal.json +27 -0
- package/template/drizzle.config.ts +13 -0
- package/template/eslint-rules/README-no-middleware-in-routes.md +154 -0
- package/template/eslint-rules/__tests__/enforce-valid-method.test.ts +251 -0
- package/template/eslint-rules/__tests__/layer-boundary.test.ts +102 -0
- package/template/eslint-rules/__tests__/module-boundary.test.ts +77 -0
- package/template/eslint-rules/__tests__/no-direct-zod-import-in-file-routes.test.ts +45 -0
- package/template/eslint-rules/__tests__/no-new-old-service-naming.test.ts +76 -0
- package/template/eslint-rules/e2e-test-location.js +153 -0
- package/template/eslint-rules/enforce-valid-method.js +217 -0
- package/template/eslint-rules/flat-routes-services.js +69 -0
- package/template/eslint-rules/framework-protect.js +186 -0
- package/template/eslint-rules/layer-boundary.js +164 -0
- package/template/eslint-rules/limit-type-complexity.js +130 -0
- package/template/eslint-rules/middleware-location.js +162 -0
- package/template/eslint-rules/module-boundary.js +125 -0
- package/template/eslint-rules/no-ambiguous-file-paths.js +64 -0
- package/template/eslint-rules/no-any-on-apiclient.js +173 -0
- package/template/eslint-rules/no-boolean-success.js +43 -0
- package/template/eslint-rules/no-deep-relative-imports.js +69 -0
- package/template/eslint-rules/no-direct-fetch.js +122 -0
- package/template/eslint-rules/no-direct-ws-sse.js +57 -0
- package/template/eslint-rules/no-direct-zod-import-in-file-routes.js +54 -0
- package/template/eslint-rules/no-disable-direct-fetch.js +57 -0
- package/template/eslint-rules/no-disable-type-safe-client.js +58 -0
- package/template/eslint-rules/no-inline-schema.js +220 -0
- package/template/eslint-rules/no-middleware-in-routes.js +81 -0
- package/template/eslint-rules/no-new-old-service-naming.js +123 -0
- package/template/eslint-rules/no-type-assertion-in-rpc.js +99 -0
- package/template/eslint-rules/no-type-assertion-on-shared-types.js +109 -0
- package/template/eslint-rules/no-util-functions-in-service.js +128 -0
- package/template/eslint-rules/prefer-shared-types.js +352 -0
- package/template/eslint-rules/protect-ws-sse-interface.js +66 -0
- package/template/eslint-rules/require-antd-generic-types.js +73 -0
- package/template/eslint-rules/require-file-openapi-props.js +114 -0
- package/template/eslint-rules/require-hono-chain-syntax.js +129 -0
- package/template/eslint-rules/require-nullable-for-optional.js +99 -0
- package/template/eslint-rules/require-response-helpers.js +140 -0
- package/template/eslint-rules/require-type-safe-test-client.js +106 -0
- package/template/eslint-rules/route-location.js +72 -0
- package/template/eslint.config.js +231 -0
- package/template/index.html +17 -0
- package/template/lint-scripts/DIRECTORY_RULES.md +335 -0
- package/template/lint-scripts/README.md +299 -0
- package/template/lint-scripts/TESTING.md +273 -0
- package/template/lint-scripts/ai-context-generator.ts +159 -0
- package/template/lint-scripts/check-framework-modify.sh +8 -0
- package/template/lint-scripts/check-menu-permissions.js +242 -0
- package/template/lint-scripts/check-refs.ts +165 -0
- package/template/lint-scripts/check-route-auth-complete.js +260 -0
- package/template/lint-scripts/check-route-auth.js +212 -0
- package/template/lint-scripts/check-route-permissions.js +210 -0
- package/template/lint-scripts/config/project.config.ts +358 -0
- package/template/lint-scripts/dev-context-analyzer.ts +707 -0
- package/template/lint-scripts/dev-guide-generator.ts +830 -0
- package/template/lint-scripts/dev-server.ts +58 -0
- package/template/lint-scripts/eslint-route-auth.js +158 -0
- package/template/lint-scripts/eslint-routes-permission.js +147 -0
- package/template/lint-scripts/fix-route-auth.js +245 -0
- package/template/lint-scripts/framework/check-modify.ts +152 -0
- package/template/lint-scripts/framework/hash-utils.ts +180 -0
- package/template/lint-scripts/framework/init-baseline.ts +84 -0
- package/template/lint-scripts/framework/update-baseline.ts +148 -0
- package/template/lint-scripts/post-commit-track.ts +66 -0
- package/template/lint-scripts/quick-test.sh +27 -0
- package/template/lint-scripts/smart-test.ts +268 -0
- package/template/lint-scripts/test-history.ts +360 -0
- package/template/lint-scripts/test-tracker.ts +350 -0
- package/template/lint-scripts/validate-all.ts +250 -0
- package/template/lint-scripts/validators/api-coverage.validator.ts +355 -0
- package/template/lint-scripts/validators/client-rpc.validator.ts +190 -0
- package/template/lint-scripts/validators/client-tests.validator.ts +155 -0
- package/template/lint-scripts/validators/console-log.validator.ts +122 -0
- package/template/lint-scripts/validators/directory-structure.validator.ts +181 -0
- package/template/lint-scripts/validators/imports.validator.ts +180 -0
- package/template/lint-scripts/validators/index.ts +271 -0
- package/template/lint-scripts/validators/md-refs.validator.ts +165 -0
- package/template/lint-scripts/validators/module-tests.validator.ts +112 -0
- package/template/lint-scripts/validators/sensitive.validator.ts +185 -0
- package/template/lint-scripts/validators/server-rpc.validator.ts +141 -0
- package/template/lint-scripts/validators/test-quality.validator.ts +257 -0
- package/template/lint-scripts/validators/todos.validator.ts +126 -0
- package/template/lint-scripts/watch-validator.ts +131 -0
- package/template/modules.config.ts +71 -0
- package/template/package-lock.json +14554 -0
- package/template/package.json +158 -0
- package/template/patches/@hono+zod-openapi+1.2.2.patch +67 -0
- package/template/patches/@hono+zod-validator+0.7.6.patch +13 -0
- package/template/patches/hono+4.12.16.patch +246 -0
- package/template/patches/typescript+5.8.3.patch +26 -0
- package/template/playwright.config.ts +60 -0
- package/template/pnpm-lock.yaml +7137 -0
- package/template/postcss.config.js +6 -0
- package/template/scripts/create-template.ts +1724 -0
- package/template/src/admin/App.tsx +59 -0
- package/template/src/admin/components/AccountSwitcher.tsx +104 -0
- package/template/src/admin/components/CaptchaModal.tsx +150 -0
- package/template/src/admin/components/NotificationDrawer.tsx +213 -0
- package/template/src/admin/components/PageHeader.tsx +45 -0
- package/template/src/admin/components/PermissionConfigEditor.tsx +237 -0
- package/template/src/admin/components/PermissionGuard.tsx +108 -0
- package/template/src/admin/components/PermissionTree.tsx +193 -0
- package/template/src/admin/components/ProtectedRoute.tsx +33 -0
- package/template/src/admin/components/StatsCard.tsx +44 -0
- package/template/src/admin/components/UserFormModal.tsx +67 -0
- package/template/src/admin/components/UserTable.tsx +72 -0
- package/template/src/admin/components/__tests__/PageHeader.test.tsx +48 -0
- package/template/src/admin/components/__tests__/PermissionConfigEditor.test.tsx +147 -0
- package/template/src/admin/components/__tests__/PermissionGuard.test.tsx +221 -0
- package/template/src/admin/components/__tests__/PermissionTree.test.tsx +187 -0
- package/template/src/admin/components/__tests__/ProtectedRoute.test.tsx +129 -0
- package/template/src/admin/components/__tests__/StatsCard.test.tsx +44 -0
- package/template/src/admin/components/__tests__/UserFormModal.test.tsx +125 -0
- package/template/src/admin/components/__tests__/UserTable.test.tsx +89 -0
- package/template/src/admin/components/index.ts +7 -0
- package/template/src/admin/hooks/__tests__/useAuditLogs.test.ts +109 -0
- package/template/src/admin/hooks/__tests__/usePermissions.test.tsx +327 -0
- package/template/src/admin/hooks/__tests__/usePermissionsBranches.test.ts +198 -0
- package/template/src/admin/hooks/__tests__/useRoles.test.ts +261 -0
- package/template/src/admin/hooks/useAdminNotifications.ts +156 -0
- package/template/src/admin/hooks/useAuditLogs.ts +44 -0
- package/template/src/admin/hooks/useConfig.ts +168 -0
- package/template/src/admin/hooks/usePermissions.ts +156 -0
- package/template/src/admin/hooks/useRoles.ts +120 -0
- package/template/src/admin/layouts/Header.tsx +93 -0
- package/template/src/admin/layouts/Layout.tsx +23 -0
- package/template/src/admin/layouts/Sidebar.tsx +120 -0
- package/template/src/admin/main.tsx +18 -0
- package/template/src/admin/pages/ContentPage.tsx +252 -0
- package/template/src/admin/pages/DashboardPage.tsx +141 -0
- package/template/src/admin/pages/DisputesPage.tsx +261 -0
- package/template/src/admin/pages/LoginPage.tsx +121 -0
- package/template/src/admin/pages/MediaTestPage.tsx +524 -0
- package/template/src/admin/pages/OrdersPage.tsx +302 -0
- package/template/src/admin/pages/PermissionsPage.tsx +95 -0
- package/template/src/admin/pages/RegisterPage.tsx +103 -0
- package/template/src/admin/pages/RolesPage.tsx +330 -0
- package/template/src/admin/pages/SettingsPage.tsx +73 -0
- package/template/src/admin/pages/SystemLogsPage.tsx +218 -0
- package/template/src/admin/pages/TestCaptchaPage.tsx +120 -0
- package/template/src/admin/pages/TicketsPage.tsx +292 -0
- package/template/src/admin/pages/UsersPage.tsx +282 -0
- package/template/src/admin/pages/__tests__/ContentPage.test.tsx +213 -0
- package/template/src/admin/pages/__tests__/DashboardPage.test.tsx +153 -0
- package/template/src/admin/pages/__tests__/DisputesPage.test.tsx +196 -0
- package/template/src/admin/pages/__tests__/LoginPage.test.tsx +112 -0
- package/template/src/admin/pages/__tests__/OrdersPage.test.tsx +217 -0
- package/template/src/admin/pages/__tests__/PermissionsPage.test.tsx +119 -0
- package/template/src/admin/pages/__tests__/RegisterPage.test.tsx +179 -0
- package/template/src/admin/pages/__tests__/RolesPage.test.tsx +256 -0
- package/template/src/admin/pages/__tests__/SettingsPage.test.tsx +66 -0
- package/template/src/admin/pages/__tests__/SystemLogsPage.test.tsx +125 -0
- package/template/src/admin/pages/__tests__/TicketsPage.test.tsx +202 -0
- package/template/src/admin/pages/__tests__/UsersPage.test.tsx +229 -0
- package/template/src/admin/services/README.md +263 -0
- package/template/src/admin/services/TESTING.md +323 -0
- package/template/src/admin/services/__tests__/skipLoading.test.ts +146 -0
- package/template/src/admin/services/apiClient.ts +66 -0
- package/template/src/admin/services/requestInterceptor.ts +127 -0
- package/template/src/admin/services/types.ts +5 -0
- package/template/src/admin/stores/__tests__/adminStore.test.ts +184 -0
- package/template/src/admin/stores/__tests__/adminStoreBranches.test.ts +148 -0
- package/template/src/admin/stores/__tests__/captchaStore.test.ts +75 -0
- package/template/src/admin/stores/__tests__/captchaStoreBranches.test.ts +37 -0
- package/template/src/admin/stores/__tests__/loadingStore.test.ts +68 -0
- package/template/src/admin/stores/adminStore.ts +88 -0
- package/template/src/admin/stores/captchaStore.ts +47 -0
- package/template/src/admin/stores/loadingStore.ts +27 -0
- package/template/src/cli/index.ts +22 -0
- package/template/src/cli/modules/config/index.ts +132 -0
- package/template/src/cli/modules/index.ts +12 -0
- package/template/src/cli/modules/notification/index.ts +86 -0
- package/template/src/cli/modules/todo/index.ts +60 -0
- package/template/src/cli/rpc/client.ts +23 -0
- package/template/src/cli/rpc/index.ts +1 -0
- package/template/src/cli/utils/api.ts +17 -0
- package/template/src/cli/utils/auto-command.ts +229 -0
- package/template/src/cli/utils/index.ts +8 -0
- package/template/src/cli/utils/logger.ts +79 -0
- package/template/src/client/App.tsx +24 -0
- package/template/src/client/Layout.tsx +27 -0
- package/template/src/client/components/AuthButton.tsx +41 -0
- package/template/src/client/components/ConnectionStatus.tsx +75 -0
- package/template/src/client/components/EmptyState.tsx +26 -0
- package/template/src/client/components/Footer.tsx +17 -0
- package/template/src/client/components/LoadingSpinner.tsx +26 -0
- package/template/src/client/components/MessageCard.tsx +61 -0
- package/template/src/client/components/Navigation.tsx +65 -0
- package/template/src/client/components/StatusBadge.tsx +50 -0
- package/template/src/client/components/__tests__/App.test.tsx +79 -0
- package/template/src/client/components/__tests__/AuthButton.test.tsx +119 -0
- package/template/src/client/components/__tests__/ConnectionStatus.test.tsx +188 -0
- package/template/src/client/components/__tests__/EmptyState.test.tsx +70 -0
- package/template/src/client/components/__tests__/Footer.test.tsx +22 -0
- package/template/src/client/components/__tests__/LoadingSpinner.test.tsx +75 -0
- package/template/src/client/components/__tests__/MessageCard.test.tsx +142 -0
- package/template/src/client/components/__tests__/Navigation.test.tsx +40 -0
- package/template/src/client/components/__tests__/StatusBadge.test.tsx +107 -0
- package/template/src/client/components/index.ts +6 -0
- package/template/src/client/index.css +27 -0
- package/template/src/client/main.tsx +25 -0
- package/template/src/client/pages/ContentDetailPage.tsx +142 -0
- package/template/src/client/pages/ContentListPage.tsx +169 -0
- package/template/src/client/pages/NotificationPage.tsx +288 -0
- package/template/src/client/pages/TodoPage.tsx +389 -0
- package/template/src/client/pages/WebSocketPage.tsx +239 -0
- package/template/src/client/pages/__tests__/ContentDetailPage.test.tsx +176 -0
- package/template/src/client/pages/__tests__/ContentListPage.test.tsx +202 -0
- package/template/src/client/pages/__tests__/NotificationPage.test.tsx +246 -0
- package/template/src/client/pages/__tests__/TodoPage.test.tsx +433 -0
- package/template/src/client/pages/__tests__/WebSocketPage.test.tsx +378 -0
- package/template/src/client/services/apiClient.ts +66 -0
- package/template/src/client/stores/__tests__/authStore.test.ts +139 -0
- package/template/src/client/stores/__tests__/chatWSStore.test.ts +416 -0
- package/template/src/client/stores/__tests__/notificationStore.test.ts +453 -0
- package/template/src/client/stores/__tests__/todoStore.test.ts +509 -0
- package/template/src/client/stores/authStore.ts +51 -0
- package/template/src/client/stores/chatWSStore.ts +122 -0
- package/template/src/client/stores/notificationStore.ts +199 -0
- package/template/src/client/stores/todoStore.ts +207 -0
- package/template/src/server/__tests__/integration/todos-api.test.ts +138 -0
- package/template/src/server/app.ts +105 -0
- package/template/src/server/config.ts +86 -0
- package/template/src/server/core/__tests__/realtime-core.test.ts +329 -0
- package/template/src/server/core/__tests__/realtime-scanner.test.ts +210 -0
- package/template/src/server/core/__tests__/runtime-node.test.ts +330 -0
- package/template/src/server/core/__tests__/runtime.test.ts +219 -0
- package/template/src/server/core/__tests__/typed-runtime.test.ts +178 -0
- package/template/src/server/core/durable-objects/RealtimeDO.ts +206 -0
- package/template/src/server/core/index.ts +83 -0
- package/template/src/server/core/module-loader.ts +281 -0
- package/template/src/server/core/realtime-core.ts +152 -0
- package/template/src/server/core/realtime-scanner.ts +99 -0
- package/template/src/server/core/runtime-cloudflare.ts +207 -0
- package/template/src/server/core/runtime-node.ts +170 -0
- package/template/src/server/core/runtime.ts +129 -0
- package/template/src/server/core/typed-runtime.ts +80 -0
- package/template/src/server/db/__tests__/driver.test.ts +203 -0
- package/template/src/server/db/config.ts +1 -0
- package/template/src/server/db/driver-cloudflare.ts +50 -0
- package/template/src/server/db/driver.ts +116 -0
- package/template/src/server/db/index.ts +3 -0
- package/template/src/server/db/init.ts +412 -0
- package/template/src/server/db/schema/api-endpoints.ts +23 -0
- package/template/src/server/db/schema/contents.ts +31 -0
- package/template/src/server/db/schema/disputes.ts +39 -0
- package/template/src/server/db/schema/index.ts +14 -0
- package/template/src/server/db/schema/notifications.ts +16 -0
- package/template/src/server/db/schema/orders.ts +30 -0
- package/template/src/server/db/schema/permission-audit-logs.ts +17 -0
- package/template/src/server/db/schema/permission-route-mappings.ts +22 -0
- package/template/src/server/db/schema/permissions.ts +17 -0
- package/template/src/server/db/schema/role-permissions.ts +22 -0
- package/template/src/server/db/schema/roles.ts +17 -0
- package/template/src/server/db/schema/tickets.ts +62 -0
- package/template/src/server/db/schema/todo-attachments.ts +22 -0
- package/template/src/server/db/schema/todos.ts +21 -0
- package/template/src/server/db/schema/user-roles.ts +17 -0
- package/template/src/server/db/seeds/index.ts +1 -0
- package/template/src/server/db/seeds/permission-data.ts +354 -0
- package/template/src/server/db/test-setup.ts +647 -0
- package/template/src/server/entries/cloudflare.ts +71 -0
- package/template/src/server/entries/node.ts +190 -0
- package/template/src/server/index.ts +62 -0
- package/template/src/server/middleware/__tests__/auth-simple.test.ts +147 -0
- package/template/src/server/middleware/__tests__/auth.test.ts +276 -0
- package/template/src/server/middleware/__tests__/captcha.test.ts +258 -0
- package/template/src/server/middleware/__tests__/error-handler.test.ts +364 -0
- package/template/src/server/middleware/__tests__/error-response-format.test.ts +80 -0
- package/template/src/server/middleware/__tests__/permission.test.ts +312 -0
- package/template/src/server/middleware/audit-log.ts +101 -0
- package/template/src/server/middleware/auth.ts +235 -0
- package/template/src/server/middleware/captcha.ts +166 -0
- package/template/src/server/middleware/cors.ts +30 -0
- package/template/src/server/middleware/error-handler.ts +135 -0
- package/template/src/server/middleware/index.ts +24 -0
- package/template/src/server/middleware/logger.ts +73 -0
- package/template/src/server/middleware/permission.ts +127 -0
- package/template/src/server/middleware/rate-limit.ts +69 -0
- package/template/src/server/middleware/realtime-env.ts +12 -0
- package/template/src/server/module-admin/__tests__/admin-routes.test.ts +360 -0
- package/template/src/server/module-admin/__tests__/admin-service.test.ts +222 -0
- package/template/src/server/module-admin/__tests__/audit-log-routes.test.ts +261 -0
- package/template/src/server/module-admin/__tests__/export-routes.test.ts +160 -0
- package/template/src/server/module-admin/__tests__/media-routes.test.ts +122 -0
- package/template/src/server/module-admin/module.ts +40 -0
- package/template/src/server/module-admin/routes/admin-notification-routes.ts +197 -0
- package/template/src/server/module-admin/routes/admin-routes.ts +20 -0
- package/template/src/server/module-admin/routes/auth-routes.ts +86 -0
- package/template/src/server/module-admin/routes/export-routes.ts +207 -0
- package/template/src/server/module-admin/routes/media-routes.ts +78 -0
- package/template/src/server/module-admin/routes/system-routes.ts +89 -0
- package/template/src/server/module-admin/routes/user-management-routes.ts +143 -0
- package/template/src/server/module-admin/services/admin-service.ts +268 -0
- package/template/src/server/module-captcha/__tests__/captcha-route.test.ts +35 -0
- package/template/src/server/module-captcha/__tests__/captcha-service.test.ts +53 -0
- package/template/src/server/module-captcha/module.ts +35 -0
- package/template/src/server/module-captcha/routes/captcha-routes.ts +68 -0
- package/template/src/server/module-captcha/services/captcha-service.ts +3 -0
- package/template/src/server/module-chat/__tests__/chat-routes.test.ts +39 -0
- package/template/src/server/module-chat/__tests__/chat-rpc.test.ts +185 -0
- package/template/src/server/module-chat/__tests__/chat-service.test.ts +64 -0
- package/template/src/server/module-chat/module.ts +27 -0
- package/template/src/server/module-chat/routes/chat-routes.ts +46 -0
- package/template/src/server/module-chat/services/chat-service.ts +38 -0
- package/template/src/server/module-content/__tests__/content-route.test.ts +40 -0
- package/template/src/server/module-content/__tests__/content-service.test.ts +107 -0
- package/template/src/server/module-content/module.ts +39 -0
- package/template/src/server/module-content/routes/content-routes.ts +182 -0
- package/template/src/server/module-content/routes/public-content-routes.ts +58 -0
- package/template/src/server/module-content/services/content-service.ts +224 -0
- package/template/src/server/module-dispute/__tests__/dispute-route.test.ts +43 -0
- package/template/src/server/module-dispute/__tests__/dispute-service.test.ts +135 -0
- package/template/src/server/module-dispute/module.ts +30 -0
- package/template/src/server/module-dispute/routes/dispute-routes.ts +153 -0
- package/template/src/server/module-dispute/services/dispute-service.ts +255 -0
- package/template/src/server/module-file/__tests__/file-routes.test.ts +284 -0
- package/template/src/server/module-file/__tests__/file-storage-service.test.ts +323 -0
- package/template/src/server/module-file/module.ts +28 -0
- package/template/src/server/module-file/routes/file-routes.ts +288 -0
- package/template/src/server/module-notifications/__tests__/notification-route-rpc.test.ts +375 -0
- package/template/src/server/module-notifications/__tests__/notification-service.test.ts +241 -0
- package/template/src/server/module-notifications/__tests__/sse-rpc.test.ts +289 -0
- package/template/src/server/module-notifications/module.ts +32 -0
- package/template/src/server/module-notifications/routes/notification-routes.ts +190 -0
- package/template/src/server/module-notifications/services/notification-service.ts +104 -0
- package/template/src/server/module-order/__tests__/order-route.test.ts +258 -0
- package/template/src/server/module-order/__tests__/order-service.test.ts +222 -0
- package/template/src/server/module-order/module.ts +30 -0
- package/template/src/server/module-order/routes/order-routes.ts +202 -0
- package/template/src/server/module-order/services/order-service.ts +268 -0
- package/template/src/server/module-permission/__tests__/permission-middleware.test.ts +90 -0
- package/template/src/server/module-permission/__tests__/permission-routes.test.ts +330 -0
- package/template/src/server/module-permission/__tests__/permission-service-impl.test.ts +388 -0
- package/template/src/server/module-permission/__tests__/permission-service.test.ts +190 -0
- package/template/src/server/module-permission/__tests__/role-routes.test.ts +215 -0
- package/template/src/server/module-permission/module.ts +68 -0
- package/template/src/server/module-permission/routes/audit-log-routes.ts +76 -0
- package/template/src/server/module-permission/routes/permission-routes.ts +184 -0
- package/template/src/server/module-permission/routes/role-routes.ts +263 -0
- package/template/src/server/module-permission/services/audit-log-service.ts +108 -0
- package/template/src/server/module-permission/services/permission-service-impl.ts +233 -0
- package/template/src/server/module-permission/services/permission-service.ts +256 -0
- package/template/src/server/module-permission/services/role-service.ts +122 -0
- package/template/src/server/module-ticket/__tests__/ticket-route.test.ts +173 -0
- package/template/src/server/module-ticket/__tests__/ticket-service.test.ts +201 -0
- package/template/src/server/module-ticket/module.ts +30 -0
- package/template/src/server/module-ticket/routes/ticket-routes.ts +210 -0
- package/template/src/server/module-ticket/services/ticket-service.ts +297 -0
- package/template/src/server/module-todos/__tests__/todo-service.test.ts +196 -0
- package/template/src/server/module-todos/__tests__/todos-file-upload.test.ts +439 -0
- package/template/src/server/module-todos/__tests__/todos-route-rpc.test.ts +575 -0
- package/template/src/server/module-todos/module.ts +30 -0
- package/template/src/server/module-todos/routes/todos-routes.ts +260 -0
- package/template/src/server/module-todos/services/todo-service.ts +202 -0
- package/template/src/server/route-registry.ts +47 -0
- package/template/src/server/test-utils/test-client.ts +66 -0
- package/template/src/server/test-utils/test-server.ts +131 -0
- package/template/src/server/types/bindings.ts +10 -0
- package/template/src/server/utils/__tests__/app-error.test.ts +374 -0
- package/template/src/server/utils/__tests__/auth.test.ts +76 -0
- package/template/src/server/utils/__tests__/captcha.test.ts +80 -0
- package/template/src/server/utils/__tests__/file-storage.test.ts +472 -0
- package/template/src/server/utils/__tests__/logger.test.ts +221 -0
- package/template/src/server/utils/__tests__/route-helpers.test.ts +264 -0
- package/template/src/server/utils/app-error.ts +355 -0
- package/template/src/server/utils/auth.ts +65 -0
- package/template/src/server/utils/captcha.ts +119 -0
- package/template/src/server/utils/date.ts +50 -0
- package/template/src/server/utils/env.ts +4 -0
- package/template/src/server/utils/file-storage.ts +462 -0
- package/template/src/server/utils/generate.ts +26 -0
- package/template/src/server/utils/id-helpers.ts +5 -0
- package/template/src/server/utils/logger.ts +139 -0
- package/template/src/server/utils/permission-utils.ts +6 -0
- package/template/src/server/utils/response.ts +40 -0
- package/template/src/server/utils/route-helpers.ts +200 -0
- package/template/src/server/utils/uuid.ts +8 -0
- package/template/src/server/utils/ws-helper.ts +30 -0
- package/template/src/shared/constants/index.ts +1 -0
- package/template/src/shared/constants/resource-types.ts +72 -0
- package/template/src/shared/core/__tests__/sse-client.test.ts +376 -0
- package/template/src/shared/core/__tests__/ws-client.test.ts +468 -0
- package/template/src/shared/core/api-request.ts +192 -0
- package/template/src/shared/core/api-schemas.ts +41 -0
- package/template/src/shared/core/index.ts +37 -0
- package/template/src/shared/core/module-manifest.ts +120 -0
- package/template/src/shared/core/protocol-types.ts +26 -0
- package/template/src/shared/core/sse-client.ts +185 -0
- package/template/src/shared/core/ws-client.ts +236 -0
- package/template/src/shared/hooks/index.ts +2 -0
- package/template/src/shared/hooks/useSSE.ts +57 -0
- package/template/src/shared/hooks/useWebSocket.ts +66 -0
- package/template/src/shared/index.ts +5 -0
- package/template/src/shared/modules/admin/index.ts +1 -0
- package/template/src/shared/modules/admin/schemas.ts +100 -0
- package/template/src/shared/modules/audit/index.ts +1 -0
- package/template/src/shared/modules/audit/schemas.ts +24 -0
- package/template/src/shared/modules/captcha/index.ts +1 -0
- package/template/src/shared/modules/captcha/schemas.ts +19 -0
- package/template/src/shared/modules/chat/index.ts +38 -0
- package/template/src/shared/modules/content/index.ts +1 -0
- package/template/src/shared/modules/content/schemas.ts +53 -0
- package/template/src/shared/modules/dispute/index.ts +1 -0
- package/template/src/shared/modules/dispute/schemas.ts +62 -0
- package/template/src/shared/modules/files/index.ts +11 -0
- package/template/src/shared/modules/files/schemas.ts +44 -0
- package/template/src/shared/modules/index.ts +70 -0
- package/template/src/shared/modules/notifications/index.ts +26 -0
- package/template/src/shared/modules/notifications/schemas.ts +73 -0
- package/template/src/shared/modules/order/index.ts +1 -0
- package/template/src/shared/modules/order/schemas.ts +63 -0
- package/template/src/shared/modules/permission/index.ts +42 -0
- package/template/src/shared/modules/permission/permission-dependencies.ts +50 -0
- package/template/src/shared/modules/permission/permissions.ts +275 -0
- package/template/src/shared/modules/permission/schemas.ts +92 -0
- package/template/src/shared/modules/permission/types.ts +23 -0
- package/template/src/shared/modules/role/index.ts +1 -0
- package/template/src/shared/modules/role/schemas.ts +46 -0
- package/template/src/shared/modules/ticket/index.ts +1 -0
- package/template/src/shared/modules/ticket/schemas.ts +77 -0
- package/template/src/shared/modules/todos/index.ts +20 -0
- package/template/src/shared/modules/todos/schemas.ts +65 -0
- package/template/src/shared/schemas/index.ts +79 -0
- package/template/src/types/global.d.ts +14 -0
- package/template/src/vite-env.d.ts +21 -0
- package/template/tailwind.config.js +11 -0
- package/template/tests/e2e/admin-crud.spec.ts +81 -0
- package/template/tests/e2e/case-o1.spec.ts +108 -0
- package/template/tests/e2e/global-setup.ts +73 -0
- package/template/tests/e2e/global-teardown.ts +28 -0
- package/template/tests/e2e/notification.spec.ts +458 -0
- package/template/tests/e2e/todo.spec.ts +623 -0
- package/template/tests/e2e/websocket.spec.ts +254 -0
- package/template/tsconfig.json +35 -0
- package/template/tsup.config.ts +95 -0
- package/template/vite-plugins.ts +113 -0
- package/template/vite.config.ts +96 -0
- package/template/vitest.config.ts +53 -0
- package/template/vitest.integration.config.ts +24 -0
- package/template/vitest.integration.setup.ts +22 -0
- package/template/vitest.setup.ts +74 -0
- package/template/wrangler.toml +33 -0
package/package.json
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-fullstack-scaffold",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-fullstack-scaffold": "dist/cli/index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/cli",
|
|
10
|
+
"template"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/dyyz1993/fullstack-scaffold"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "vite",
|
|
21
|
+
"build": "npm run build:client && npm run build:server",
|
|
22
|
+
"build:client": "vite build",
|
|
23
|
+
"build:server": "tsup",
|
|
24
|
+
"build:cli": "tsup --config tsup.cli.config.ts",
|
|
25
|
+
"build:cloudflare": "npm run build:client && tsup --config tsup.config.ts",
|
|
26
|
+
"build:all": "npm run build:client && npm run build:server && npm run build:cli",
|
|
27
|
+
"cli": "node dist/cli/index.js",
|
|
28
|
+
"preview": "vite preview",
|
|
29
|
+
"start": "NODE_ENV=production node dist/server/node.js",
|
|
30
|
+
"start:dev": "NODE_ENV=development node --import tsx src/server/entries/node.ts",
|
|
31
|
+
"dev:cf": "wrangler dev",
|
|
32
|
+
"deploy:cf": "npm run build:cloudflare && wrangler deploy",
|
|
33
|
+
"typecheck": "tsc --noEmit && eslint . --max-warnings=0",
|
|
34
|
+
"typecheck:template": "cd template && npx tsc --noEmit",
|
|
35
|
+
"test": "vitest",
|
|
36
|
+
"test:smart": "node --import tsx/esm lint-scripts/smart-test.ts",
|
|
37
|
+
"test:smart:staged": "node --import tsx/esm lint-scripts/smart-test.ts --staged",
|
|
38
|
+
"test:infrastructure": "node --import tsx/esm lint-scripts/smart-test.ts --infrastructure",
|
|
39
|
+
"test:all": "node --import tsx/esm lint-scripts/smart-test.ts --all",
|
|
40
|
+
"test:coverage": "vitest run --coverage",
|
|
41
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
42
|
+
"test:ui": "vitest run --ui",
|
|
43
|
+
"test:e2e": "playwright test",
|
|
44
|
+
"test:e2e:ui": "playwright test --ui",
|
|
45
|
+
"test:e2e:debug": "playwright test --debug",
|
|
46
|
+
"test:track": "node --import tsx/esm lint-scripts/test-tracker.ts",
|
|
47
|
+
"test:history": "node --import tsx/esm lint-scripts/test-history.ts",
|
|
48
|
+
"test:history:list": "node --import tsx/esm lint-scripts/test-history.ts list",
|
|
49
|
+
"test:history:show": "node --import tsx/esm lint-scripts/test-history.ts show",
|
|
50
|
+
"test:history:compare": "node --import tsx/esm lint-scripts/test-history.ts compare",
|
|
51
|
+
"test:history:failed": "node --import tsx/esm lint-scripts/test-history.ts failed",
|
|
52
|
+
"test:full": "npm run test:all && npm run test:integration && npm run test:e2e",
|
|
53
|
+
"coverage": "vitest --coverage",
|
|
54
|
+
"lint": "eslint .",
|
|
55
|
+
"lint:template": "cd template && npx eslint src/ --max-warnings=0",
|
|
56
|
+
"format": "prettier --write .",
|
|
57
|
+
"validate:all": "node --import tsx/esm lint-scripts/validate-all.ts",
|
|
58
|
+
"validate:watch": "node --import tsx/esm lint-scripts/watch-validator.ts",
|
|
59
|
+
"validate:vite-routes": "node --import tsx/esm lint-scripts/validate-vite-routes.ts",
|
|
60
|
+
"validate:modules": "npx tsx src/server/core/module-loader.ts",
|
|
61
|
+
"check:refs": "node --import tsx/esm lint-scripts/check-refs.ts",
|
|
62
|
+
"create:module": "node --import tsx/esm scripts/create-template.ts",
|
|
63
|
+
"postinstall": "patch-package",
|
|
64
|
+
"prepare": "husky",
|
|
65
|
+
"db:generate": "drizzle-kit generate",
|
|
66
|
+
"db:migrate": "drizzle-kit migrate",
|
|
67
|
+
"db:push": "drizzle-kit push",
|
|
68
|
+
"db:studio": "drizzle-kit studio",
|
|
69
|
+
"framework:init": "node --import tsx/esm lint-scripts/framework/init-baseline.ts",
|
|
70
|
+
"framework:update": "node --import tsx/esm lint-scripts/framework/update-baseline.ts",
|
|
71
|
+
"framework:check": "node --import tsx/esm lint-scripts/framework/check-modify.ts",
|
|
72
|
+
"dev:context": "node --import tsx/esm lint-scripts/dev-context-analyzer.ts",
|
|
73
|
+
"dev:guide": "node --import tsx/esm lint-scripts/dev-guide-generator.ts",
|
|
74
|
+
"ai:context": "node --import tsx/esm lint-scripts/ai-context-generator.ts",
|
|
75
|
+
"validate:template": "npm run typecheck:template && npm run lint:template",
|
|
76
|
+
"test:template": "cd template && npx vitest run"
|
|
77
|
+
},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"@hono/node-server": "^1.14.4",
|
|
80
|
+
"@hono/zod-openapi": "1.2.2",
|
|
81
|
+
"@hono/zod-validator": "0.7.6",
|
|
82
|
+
"@inquirer/prompts": "^8.4.2",
|
|
83
|
+
"@libsql/client": "^0.17.0",
|
|
84
|
+
"chalk": "^5.6.2",
|
|
85
|
+
"commander": "^14.0.3",
|
|
86
|
+
"dotenv": "^16.5.0",
|
|
87
|
+
"drizzle-orm": "^0.45.1",
|
|
88
|
+
"fs-extra": "^11.3.5",
|
|
89
|
+
"hono": "^4.12.16",
|
|
90
|
+
"jsonwebtoken": "^9.0.3",
|
|
91
|
+
"lucide-react": "^0.576.0",
|
|
92
|
+
"ora": "^9.4.0",
|
|
93
|
+
"pino": "^9.7.0",
|
|
94
|
+
"pino-pretty": "^13.0.0",
|
|
95
|
+
"react": "^18.3.1",
|
|
96
|
+
"react-dom": "^18.3.1",
|
|
97
|
+
"react-router-dom": "^7.13.1",
|
|
98
|
+
"ws": "^8.18.3",
|
|
99
|
+
"zod": "^4.4.3",
|
|
100
|
+
"zustand": "^5.0.2"
|
|
101
|
+
},
|
|
102
|
+
"devDependencies": {
|
|
103
|
+
"@cloudflare/workers-types": "^4.20260503.1",
|
|
104
|
+
"@commitlint/cli": "^20.4.3",
|
|
105
|
+
"@commitlint/config-conventional": "^20.4.3",
|
|
106
|
+
"@eslint/js": "^9.39.4",
|
|
107
|
+
"@hono/vite-dev-server": "^0.23.0",
|
|
108
|
+
"@playwright/test": "^1.50.0",
|
|
109
|
+
"@tailwindcss/postcss": "^4.2.1",
|
|
110
|
+
"@testing-library/dom": "^10.4.1",
|
|
111
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
112
|
+
"@testing-library/react": "^16.3.2",
|
|
113
|
+
"@types/fs-extra": "^11.0.4",
|
|
114
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
115
|
+
"@types/node": "^22.13.10",
|
|
116
|
+
"@types/react": "^18.3.0",
|
|
117
|
+
"@types/react-dom": "^18.3.0",
|
|
118
|
+
"@types/ws": "^8.18.0",
|
|
119
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
120
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
121
|
+
"@vitest/ui": "^4.0.16",
|
|
122
|
+
"autoprefixer": "^10.4.27",
|
|
123
|
+
"bun-types": "^1.3.10",
|
|
124
|
+
"drizzle-kit": "^0.31.9",
|
|
125
|
+
"eslint": "^9.21.0",
|
|
126
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
127
|
+
"eslint-plugin-react-refresh": "^0.4.19",
|
|
128
|
+
"eventsource": "^4.1.0",
|
|
129
|
+
"glob": "^13.0.6",
|
|
130
|
+
"globals": "^16.0.0",
|
|
131
|
+
"husky": "^9.1.7",
|
|
132
|
+
"jsdom": "^26.0.3",
|
|
133
|
+
"lint-staged": "^15.5.0",
|
|
134
|
+
"minimatch": "^10.2.4",
|
|
135
|
+
"patch-package": "^8.0.1",
|
|
136
|
+
"playwright": "^1.50.0",
|
|
137
|
+
"postcss": "^8.5.6",
|
|
138
|
+
"prettier": "^3.5.3",
|
|
139
|
+
"tailwindcss": "^4.2.1",
|
|
140
|
+
"ts-import": "^5.0.0-beta.1",
|
|
141
|
+
"tsup": "^8.5.0",
|
|
142
|
+
"tsx": "^4.21.0",
|
|
143
|
+
"typescript": "^5.8.3",
|
|
144
|
+
"typescript-eslint": "^8.25.0",
|
|
145
|
+
"vite": "^6.2.3",
|
|
146
|
+
"vitest": "^4.0.16",
|
|
147
|
+
"wrangler": "^4.75.0"
|
|
148
|
+
},
|
|
149
|
+
"lint-staged": {
|
|
150
|
+
"*.{ts,tsx,js,jsx}": [
|
|
151
|
+
"prettier --write",
|
|
152
|
+
"eslint --fix",
|
|
153
|
+
"eslint --max-warnings=0 --no-warn-ignored"
|
|
154
|
+
],
|
|
155
|
+
"*.{json,md,css}": [
|
|
156
|
+
"prettier --write"
|
|
157
|
+
],
|
|
158
|
+
"src/server/**/*routes*.ts": [
|
|
159
|
+
"npm run validate:all"
|
|
160
|
+
],
|
|
161
|
+
"src/client/**/*.{ts,tsx}": [
|
|
162
|
+
"npm run validate:all"
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
"engines": {
|
|
166
|
+
"node": ">=18.0.0"
|
|
167
|
+
},
|
|
168
|
+
"overrides": {
|
|
169
|
+
"esbuild": "^0.25.0"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Writing Hookify Rules
|
|
3
|
+
description: This skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Writing Hookify Rules
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Hookify rules are markdown files with YAML frontmatter that define patterns to watch for and messages to show when those patterns match. Rules are stored in `.claude/hookify.{rule-name}.local.md` files.
|
|
12
|
+
|
|
13
|
+
## Rule File Format
|
|
14
|
+
|
|
15
|
+
### Basic Structure
|
|
16
|
+
|
|
17
|
+
```markdown
|
|
18
|
+
---
|
|
19
|
+
name: rule-identifier
|
|
20
|
+
enabled: true
|
|
21
|
+
event: bash|file|stop|prompt|all
|
|
22
|
+
pattern: regex-pattern-here
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Message to show Claude when this rule triggers.
|
|
26
|
+
Can include markdown formatting, warnings, suggestions, etc.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Frontmatter Fields
|
|
30
|
+
|
|
31
|
+
**name** (required): Unique identifier for the rule
|
|
32
|
+
|
|
33
|
+
- Use kebab-case: `warn-dangerous-rm`, `block-console-log`
|
|
34
|
+
- Be descriptive and action-oriented
|
|
35
|
+
- Start with verb: warn, prevent, block, require, check
|
|
36
|
+
|
|
37
|
+
**enabled** (required): Boolean to activate/deactivate
|
|
38
|
+
|
|
39
|
+
- `true`: Rule is active
|
|
40
|
+
- `false`: Rule is disabled (won't trigger)
|
|
41
|
+
- Can toggle without deleting rule
|
|
42
|
+
|
|
43
|
+
**event** (required): Which hook event to trigger on
|
|
44
|
+
|
|
45
|
+
- `bash`: Bash tool commands
|
|
46
|
+
- `file`: Edit, Write, MultiEdit tools
|
|
47
|
+
- `stop`: When agent wants to stop
|
|
48
|
+
- `prompt`: When user submits a prompt
|
|
49
|
+
- `all`: All events
|
|
50
|
+
|
|
51
|
+
**action** (optional): What to do when rule matches
|
|
52
|
+
|
|
53
|
+
- `warn`: Show message but allow operation (default)
|
|
54
|
+
- `block`: Prevent operation (PreToolUse) or stop session (Stop events)
|
|
55
|
+
- If omitted, defaults to `warn`
|
|
56
|
+
|
|
57
|
+
**pattern** (simple format): Regex pattern to match
|
|
58
|
+
|
|
59
|
+
- Used for simple single-condition rules
|
|
60
|
+
- Matches against command (bash) or new_text (file)
|
|
61
|
+
- Python regex syntax
|
|
62
|
+
|
|
63
|
+
**Example:**
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
event: bash
|
|
67
|
+
pattern: rm\s+-rf
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Advanced Format (Multiple Conditions)
|
|
71
|
+
|
|
72
|
+
For complex rules with multiple conditions:
|
|
73
|
+
|
|
74
|
+
```markdown
|
|
75
|
+
---
|
|
76
|
+
name: warn-env-file-edits
|
|
77
|
+
enabled: true
|
|
78
|
+
event: file
|
|
79
|
+
conditions:
|
|
80
|
+
- field: file_path
|
|
81
|
+
operator: regex_match
|
|
82
|
+
pattern: \.env$
|
|
83
|
+
- field: new_text
|
|
84
|
+
operator: contains
|
|
85
|
+
pattern: API_KEY
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
You're adding an API key to a .env file. Ensure this file is in .gitignore!
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Condition fields:**
|
|
92
|
+
|
|
93
|
+
- `field`: Which field to check
|
|
94
|
+
- For bash: `command`
|
|
95
|
+
- For file: `file_path`, `new_text`, `old_text`, `content`
|
|
96
|
+
- `operator`: How to match
|
|
97
|
+
- `regex_match`: Regex pattern matching
|
|
98
|
+
- `contains`: Substring check
|
|
99
|
+
- `equals`: Exact match
|
|
100
|
+
- `not_contains`: Substring must NOT be present
|
|
101
|
+
- `starts_with`: Prefix check
|
|
102
|
+
- `ends_with`: Suffix check
|
|
103
|
+
- `pattern`: Pattern or string to match
|
|
104
|
+
|
|
105
|
+
**All conditions must match for rule to trigger.**
|
|
106
|
+
|
|
107
|
+
## Message Body
|
|
108
|
+
|
|
109
|
+
The markdown content after frontmatter is shown to Claude when the rule triggers.
|
|
110
|
+
|
|
111
|
+
**Good messages:**
|
|
112
|
+
|
|
113
|
+
- Explain what was detected
|
|
114
|
+
- Explain why it's problematic
|
|
115
|
+
- Suggest alternatives or best practices
|
|
116
|
+
- Use formatting for clarity (bold, lists, etc.)
|
|
117
|
+
|
|
118
|
+
**Example:**
|
|
119
|
+
|
|
120
|
+
```markdown
|
|
121
|
+
⚠️ **Console.log detected!**
|
|
122
|
+
|
|
123
|
+
You're adding console.log to production code.
|
|
124
|
+
|
|
125
|
+
**Why this matters:**
|
|
126
|
+
|
|
127
|
+
- Debug logs shouldn't ship to production
|
|
128
|
+
- Console.log can expose sensitive data
|
|
129
|
+
- Impacts browser performance
|
|
130
|
+
|
|
131
|
+
**Alternatives:**
|
|
132
|
+
|
|
133
|
+
- Use a proper logging library
|
|
134
|
+
- Remove before committing
|
|
135
|
+
- Use conditional debug builds
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Event Type Guide
|
|
139
|
+
|
|
140
|
+
### bash Events
|
|
141
|
+
|
|
142
|
+
Match Bash command patterns:
|
|
143
|
+
|
|
144
|
+
```markdown
|
|
145
|
+
---
|
|
146
|
+
event: bash
|
|
147
|
+
pattern: sudo\s+|rm\s+-rf|chmod\s+777
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
Dangerous command detected!
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Common patterns:**
|
|
154
|
+
|
|
155
|
+
- Dangerous commands: `rm\s+-rf`, `dd\s+if=`, `mkfs`
|
|
156
|
+
- Privilege escalation: `sudo\s+`, `su\s+`
|
|
157
|
+
- Permission issues: `chmod\s+777`, `chown\s+root`
|
|
158
|
+
|
|
159
|
+
### file Events
|
|
160
|
+
|
|
161
|
+
Match Edit/Write/MultiEdit operations:
|
|
162
|
+
|
|
163
|
+
```markdown
|
|
164
|
+
---
|
|
165
|
+
event: file
|
|
166
|
+
pattern: console\.log\(|eval\(|innerHTML\s*=
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
Potentially problematic code pattern detected!
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Match on different fields:**
|
|
173
|
+
|
|
174
|
+
```markdown
|
|
175
|
+
---
|
|
176
|
+
event: file
|
|
177
|
+
conditions:
|
|
178
|
+
- field: file_path
|
|
179
|
+
operator: regex_match
|
|
180
|
+
pattern: \.tsx?$
|
|
181
|
+
- field: new_text
|
|
182
|
+
operator: regex_match
|
|
183
|
+
pattern: console\.log\(
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
Console.log in TypeScript file!
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Common patterns:**
|
|
190
|
+
|
|
191
|
+
- Debug code: `console\.log\(`, `debugger`, `print\(`
|
|
192
|
+
- Security risks: `eval\(`, `innerHTML\s*=`, `dangerouslySetInnerHTML`
|
|
193
|
+
- Sensitive files: `\.env$`, `credentials`, `\.pem$`
|
|
194
|
+
- Generated files: `node_modules/`, `dist/`, `build/`
|
|
195
|
+
|
|
196
|
+
### stop Events
|
|
197
|
+
|
|
198
|
+
Match when agent wants to stop (completion checks):
|
|
199
|
+
|
|
200
|
+
```markdown
|
|
201
|
+
---
|
|
202
|
+
event: stop
|
|
203
|
+
pattern: .*
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
Before stopping, verify:
|
|
207
|
+
|
|
208
|
+
- [ ] Tests were run
|
|
209
|
+
- [ ] Build succeeded
|
|
210
|
+
- [ ] Documentation updated
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Use for:**
|
|
214
|
+
|
|
215
|
+
- Reminders about required steps
|
|
216
|
+
- Completion checklists
|
|
217
|
+
- Process enforcement
|
|
218
|
+
|
|
219
|
+
### prompt Events
|
|
220
|
+
|
|
221
|
+
Match user prompt content (advanced):
|
|
222
|
+
|
|
223
|
+
```markdown
|
|
224
|
+
---
|
|
225
|
+
event: prompt
|
|
226
|
+
conditions:
|
|
227
|
+
- field: user_prompt
|
|
228
|
+
operator: contains
|
|
229
|
+
pattern: deploy to production
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
Production deployment checklist:
|
|
233
|
+
|
|
234
|
+
- [ ] Tests passing?
|
|
235
|
+
- [ ] Reviewed by team?
|
|
236
|
+
- [ ] Monitoring ready?
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Pattern Writing Tips
|
|
240
|
+
|
|
241
|
+
### Regex Basics
|
|
242
|
+
|
|
243
|
+
**Literal characters:** Most characters match themselves
|
|
244
|
+
|
|
245
|
+
- `rm` matches "rm"
|
|
246
|
+
- `console.log` matches "console.log"
|
|
247
|
+
|
|
248
|
+
**Special characters need escaping:**
|
|
249
|
+
|
|
250
|
+
- `.` (any char) → `\.` (literal dot)
|
|
251
|
+
- `(` `)` → `\(` `\)` (literal parens)
|
|
252
|
+
- `[` `]` → `\[` `\]` (literal brackets)
|
|
253
|
+
|
|
254
|
+
**Common metacharacters:**
|
|
255
|
+
|
|
256
|
+
- `\s` - whitespace (space, tab, newline)
|
|
257
|
+
- `\d` - digit (0-9)
|
|
258
|
+
- `\w` - word character (a-z, A-Z, 0-9, \_)
|
|
259
|
+
- `.` - any character
|
|
260
|
+
- `+` - one or more
|
|
261
|
+
- `*` - zero or more
|
|
262
|
+
- `?` - zero or one
|
|
263
|
+
- `|` - OR
|
|
264
|
+
|
|
265
|
+
**Examples:**
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
rm\s+-rf Matches: rm -rf, rm -rf
|
|
269
|
+
console\.log\( Matches: console.log(
|
|
270
|
+
(eval|exec)\( Matches: eval( or exec(
|
|
271
|
+
chmod\s+777 Matches: chmod 777, chmod 777
|
|
272
|
+
API_KEY\s*= Matches: API_KEY=, API_KEY =
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Testing Patterns
|
|
276
|
+
|
|
277
|
+
Test regex patterns before using:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
python3 -c "import re; print(re.search(r'your_pattern', 'test text'))"
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Or use online regex testers (regex101.com with Python flavor).
|
|
284
|
+
|
|
285
|
+
### Common Pitfalls
|
|
286
|
+
|
|
287
|
+
**Too broad:**
|
|
288
|
+
|
|
289
|
+
```yaml
|
|
290
|
+
pattern: log # Matches "log", "login", "dialog", "catalog"
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Better: `console\.log\(|logger\.`
|
|
294
|
+
|
|
295
|
+
**Too specific:**
|
|
296
|
+
|
|
297
|
+
```yaml
|
|
298
|
+
pattern: rm -rf /tmp # Only matches exact path
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Better: `rm\s+-rf`
|
|
302
|
+
|
|
303
|
+
**Escaping issues:**
|
|
304
|
+
|
|
305
|
+
- YAML quoted strings: `"pattern"` requires double backslashes `\\s`
|
|
306
|
+
- YAML unquoted: `pattern: \s` works as-is
|
|
307
|
+
- **Recommendation**: Use unquoted patterns in YAML
|
|
308
|
+
|
|
309
|
+
## File Organization
|
|
310
|
+
|
|
311
|
+
**Location:** All rules in `.claude/` directory
|
|
312
|
+
**Naming:** `.claude/hookify.{descriptive-name}.local.md`
|
|
313
|
+
**Gitignore:** Add `.claude/*.local.md` to `.gitignore`
|
|
314
|
+
|
|
315
|
+
**Good names:**
|
|
316
|
+
|
|
317
|
+
- `hookify.dangerous-rm.local.md`
|
|
318
|
+
- `hookify.console-log.local.md`
|
|
319
|
+
- `hookify.require-tests.local.md`
|
|
320
|
+
- `hookify.sensitive-files.local.md`
|
|
321
|
+
|
|
322
|
+
**Bad names:**
|
|
323
|
+
|
|
324
|
+
- `hookify.rule1.local.md` (not descriptive)
|
|
325
|
+
- `hookify.md` (missing .local)
|
|
326
|
+
- `danger.local.md` (missing hookify prefix)
|
|
327
|
+
|
|
328
|
+
## Workflow
|
|
329
|
+
|
|
330
|
+
### Creating a Rule
|
|
331
|
+
|
|
332
|
+
1. Identify unwanted behavior
|
|
333
|
+
2. Determine which tool is involved (Bash, Edit, etc.)
|
|
334
|
+
3. Choose event type (bash, file, stop, etc.)
|
|
335
|
+
4. Write regex pattern
|
|
336
|
+
5. Create `.claude/hookify.{name}.local.md` file in project root
|
|
337
|
+
6. Test immediately - rules are read dynamically on next tool use
|
|
338
|
+
|
|
339
|
+
### Refining a Rule
|
|
340
|
+
|
|
341
|
+
1. Edit the `.local.md` file
|
|
342
|
+
2. Adjust pattern or message
|
|
343
|
+
3. Test immediately - changes take effect on next tool use
|
|
344
|
+
|
|
345
|
+
### Disabling a Rule
|
|
346
|
+
|
|
347
|
+
**Temporary:** Set `enabled: false` in frontmatter
|
|
348
|
+
**Permanent:** Delete the `.local.md` file
|
|
349
|
+
|
|
350
|
+
## Examples
|
|
351
|
+
|
|
352
|
+
See `${CLAUDE_PLUGIN_ROOT}/examples/` for complete examples:
|
|
353
|
+
|
|
354
|
+
- `dangerous-rm.local.md` - Block dangerous rm commands
|
|
355
|
+
- `console-log-warning.local.md` - Warn about console.log
|
|
356
|
+
- `sensitive-files-warning.local.md` - Warn about editing .env files
|
|
357
|
+
|
|
358
|
+
## Quick Reference
|
|
359
|
+
|
|
360
|
+
**Minimum viable rule:**
|
|
361
|
+
|
|
362
|
+
```markdown
|
|
363
|
+
---
|
|
364
|
+
name: my-rule
|
|
365
|
+
enabled: true
|
|
366
|
+
event: bash
|
|
367
|
+
pattern: dangerous_command
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
Warning message here
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Rule with conditions:**
|
|
374
|
+
|
|
375
|
+
```markdown
|
|
376
|
+
---
|
|
377
|
+
name: my-rule
|
|
378
|
+
enabled: true
|
|
379
|
+
event: file
|
|
380
|
+
conditions:
|
|
381
|
+
- field: file_path
|
|
382
|
+
operator: regex_match
|
|
383
|
+
pattern: \.ts$
|
|
384
|
+
- field: new_text
|
|
385
|
+
operator: contains
|
|
386
|
+
pattern: any
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
Warning message
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
**Event types:**
|
|
393
|
+
|
|
394
|
+
- `bash` - Bash commands
|
|
395
|
+
- `file` - File edits
|
|
396
|
+
- `stop` - Completion checks
|
|
397
|
+
- `prompt` - User input
|
|
398
|
+
- `all` - All events
|
|
399
|
+
|
|
400
|
+
**Field options:**
|
|
401
|
+
|
|
402
|
+
- Bash: `command`
|
|
403
|
+
- File: `file_path`, `new_text`, `old_text`, `content`
|
|
404
|
+
- Prompt: `user_prompt`
|
|
405
|
+
|
|
406
|
+
**Operators:**
|
|
407
|
+
|
|
408
|
+
- `regex_match`, `contains`, `equals`, `not_contains`, `starts_with`, `ends_with`
|