From 3f7887eba659366855b75af1053151902f90d341 Mon Sep 17 00:00:00 2001 From: jramos Date: Fri, 3 Apr 2026 15:29:05 -0600 Subject: [PATCH] added hooks --- .../hooks/check-component-conventions.kiro.hook | 16 ++++++++++++++++ .kiro/hooks/jsdoc-route-docs.kiro.hook | 16 ++++++++++++++++ .kiro/hooks/sqlite3-safety-check.kiro.hook | 16 ++++++++++++++++ .kiro/hooks/verify-migration-pattern.kiro.hook | 16 ++++++++++++++++ .kiro/hooks/verify-new-migration.kiro.hook | 16 ++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 .kiro/hooks/check-component-conventions.kiro.hook create mode 100644 .kiro/hooks/jsdoc-route-docs.kiro.hook create mode 100644 .kiro/hooks/sqlite3-safety-check.kiro.hook create mode 100644 .kiro/hooks/verify-migration-pattern.kiro.hook create mode 100644 .kiro/hooks/verify-new-migration.kiro.hook diff --git a/.kiro/hooks/check-component-conventions.kiro.hook b/.kiro/hooks/check-component-conventions.kiro.hook new file mode 100644 index 0000000..47d62ce --- /dev/null +++ b/.kiro/hooks/check-component-conventions.kiro.hook @@ -0,0 +1,16 @@ +{ + "enabled": true, + "name": "Check Component Conventions", + "description": "On save of files in frontend/src/components/, verifies the component follows project conventions and flags deviations as inline comments.", + "version": "1", + "when": { + "type": "fileEdited", + "patterns": [ + "frontend/src/components/**/*.js" + ] + }, + "then": { + "type": "askAgent", + "prompt": "Review the saved component file and verify it follows these project conventions:\n\n1. Functional component with hooks (no class components)\n2. Uses Lucide icons for iconography (not raw SVGs or other icon libraries)\n3. Uses inline styles or existing CSS classes from App.css (no CSS modules, no styled-components)\n4. Fetches data with fetch() using relative API paths and credentials: 'include' (no axios, no absolute URLs)\n5. Handles loading and error states when fetching data\n\nFor any deviations found, add inline comments in the code flagging the issue, e.g. // ⚠️ CONVENTION: Use lucide-react icons instead of raw SVGs\n\nOnly flag actual deviations. Do not modify working logic or refactor the component." + } +} \ No newline at end of file diff --git a/.kiro/hooks/jsdoc-route-docs.kiro.hook b/.kiro/hooks/jsdoc-route-docs.kiro.hook new file mode 100644 index 0000000..466d759 --- /dev/null +++ b/.kiro/hooks/jsdoc-route-docs.kiro.hook @@ -0,0 +1,16 @@ +{ + "enabled": true, + "name": "JSDoc Route Documentation", + "description": "On save of files in backend/routes/, ensures every exported route handler has a JSDoc comment documenting the HTTP method, path, query parameters, request body shape, and response shape. Uses the existing documentation style in the file. Does not add comments to internal helper functions.", + "version": "1", + "when": { + "type": "fileEdited", + "patterns": [ + "backend/routes/*.js" + ] + }, + "then": { + "type": "askAgent", + "prompt": "Review the saved route file and ensure every exported route handler (e.g., router.get, router.post, router.put, router.patch, router.delete) has a JSDoc comment directly above it documenting: the HTTP method, the route path, any query parameters, the request body shape (if applicable), and the response shape. Match the existing documentation style already used in the file. Do NOT add JSDoc comments to internal helper functions that are not route handlers. Only add missing documentation — do not modify or remove existing JSDoc comments that are already correct." + } +} \ No newline at end of file diff --git a/.kiro/hooks/sqlite3-safety-check.kiro.hook b/.kiro/hooks/sqlite3-safety-check.kiro.hook new file mode 100644 index 0000000..13f4d5b --- /dev/null +++ b/.kiro/hooks/sqlite3-safety-check.kiro.hook @@ -0,0 +1,16 @@ +{ + "enabled": true, + "name": "SQLite3 Safety Check", + "description": "On save of files containing db.run, db.get, or db.all, verifies all sqlite3 calls use parameterized queries (? placeholders) instead of string concatenation, handle the error parameter first in every callback, and use hardcoded table/column names. Flags violations as inline comments prefixed with \"// FIXME:\".", + "version": "1", + "when": { + "type": "fileEdited", + "patterns": [ + "backend/**/*.js" + ] + }, + "then": { + "type": "askAgent", + "prompt": "The saved file may contain sqlite3 calls (db.run, db.get, or db.all). Scan the file and verify all sqlite3 calls follow these rules:\n\n1. Parameterized queries only: All SQL queries must use ? placeholders for dynamic values. Never use string concatenation or template literals to inject values into SQL strings.\n2. Error-first callbacks: Every callback passed to db.run, db.get, or db.all must handle the error parameter first (e.g., `if (err) { ... }`).\n3. Hardcoded table/column names: All table and column names in SQL strings must be hardcoded string literals, never sourced from variables or parameters.\n\nIf the file does not contain any db.run, db.get, or db.all calls, skip the check silently.\n\nFor any violations found, add an inline comment on the offending line prefixed with \"// FIXME:\" describing the specific issue. Do not modify any other code." + } +} \ No newline at end of file diff --git a/.kiro/hooks/verify-migration-pattern.kiro.hook b/.kiro/hooks/verify-migration-pattern.kiro.hook new file mode 100644 index 0000000..6e2db34 --- /dev/null +++ b/.kiro/hooks/verify-migration-pattern.kiro.hook @@ -0,0 +1,16 @@ +{ + "enabled": true, + "name": "Verify Migration Pattern", + "description": "On save or create of migration files (migrate*.js), verifies the migration follows existing project patterns: uses CREATE TABLE IF NOT EXISTS, includes explicit column types, adds appropriate indexes, and wraps multiple statements in transactions. Compares against existing migrations for style consistency.", + "version": "1", + "when": { + "type": "fileEdited", + "patterns": [ + "**/migrate*.js" + ] + }, + "then": { + "type": "askAgent", + "prompt": "A migration file was just saved. Review the edited file and verify it follows the existing migration pattern used in this project. Check the existing migrations in backend/migrations/ for reference, then verify the edited file:\n\n1. Uses CREATE TABLE IF NOT EXISTS (not just CREATE TABLE)\n2. Includes all columns with explicit SQLite types (TEXT, INTEGER, REAL, etc.)\n3. Adds appropriate indexes for foreign keys and frequently queried columns\n4. Wraps operations in a serialized transaction (db.serialize + db.run(\"BEGIN TRANSACTION\") / COMMIT) if there are multiple statements\n5. Follows the same callback-based db.run() style as existing migrations\n6. Includes proper error handling\n\nCompare the file against the existing migrations in backend/migrations/ for style consistency. Report any deviations or issues found." + } +} \ No newline at end of file diff --git a/.kiro/hooks/verify-new-migration.kiro.hook b/.kiro/hooks/verify-new-migration.kiro.hook new file mode 100644 index 0000000..5d83e7c --- /dev/null +++ b/.kiro/hooks/verify-new-migration.kiro.hook @@ -0,0 +1,16 @@ +{ + "enabled": true, + "name": "Verify New Migration", + "description": "On creation of new migration files (migrate*.js), verifies the migration follows existing project patterns: uses CREATE TABLE IF NOT EXISTS, includes explicit column types, adds appropriate indexes, and wraps multiple statements in transactions.", + "version": "1", + "when": { + "type": "fileCreated", + "patterns": [ + "**/migrate*.js" + ] + }, + "then": { + "type": "askAgent", + "prompt": "A new migration file was just created. Review the file and verify it follows the existing migration pattern used in this project. Check the existing migrations in backend/migrations/ for reference, then verify the new file:\n\n1. Uses CREATE TABLE IF NOT EXISTS (not just CREATE TABLE)\n2. Includes all columns with explicit SQLite types (TEXT, INTEGER, REAL, etc.)\n3. Adds appropriate indexes for foreign keys and frequently queried columns\n4. Wraps operations in a serialized transaction (db.serialize + db.run(\"BEGIN TRANSACTION\") / COMMIT) if there are multiple statements\n5. Follows the same callback-based db.run() style as existing migrations\n6. Includes proper error handling\n\nCompare the file against the existing migrations in backend/migrations/ for style consistency. Report any deviations or issues found." + } +} \ No newline at end of file