@clipboard-health/ai-rules 0.3.3 → 1.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 CHANGED
@@ -56,11 +56,11 @@ npm install --save-dev @clipboard-health/ai-rules
56
56
  4. Commit the generated files:
57
57
 
58
58
  ```bash
59
- git add AGENTS.md CLAUDE.md
59
+ git add .
60
60
  git commit -m "feat: add AI coding rules"
61
61
  ```
62
62
 
63
- 5. Bonus: For repo-specific rules, create an `OVERLAY.md` file. The generated files instruct agents to read this file if it exists for additional rules.
63
+ 5. Bonus: For repo-specific rules, create an `OVERLAY.md` file. The `sync` script appends its contents in each generated file to load the contents into AI agent context.
64
64
 
65
65
  ### Updating Rules
66
66
 
@@ -74,10 +74,10 @@ npm update @clipboard-health/ai-rules
74
74
  npm install
75
75
 
76
76
  # Review the changes
77
- git diff AGENTS.md CLAUDE.md
77
+ git diff .
78
78
 
79
79
  # Commit the updates
80
- git add AGENTS.md CLAUDE.md
80
+ git add .
81
81
  git commit -m "chore: update AI coding rules"
82
82
  ```
83
83
 
package/backend/AGENTS.md CHANGED
@@ -170,8 +170,13 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
170
170
  - Avoid magic strings and numbers; define constants.
171
171
  - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
172
172
  - When declaring functions, use the `function` keyword, not `const`.
173
+ - Files should read from top to bottom: `export`ed items live on top and the internal functions and methods they call go below them.
173
174
  - Prefer data immutability.
174
175
 
176
+ # Commit messages
177
+
178
+ - Follow the Conventional Commits 1.0 spec for commit messages and in pull request titles.
179
+
175
180
  <!-- Source: .ruler/common/errorHandlingAndValidation.md -->
176
181
 
177
182
  # Error handling and validation
@@ -185,15 +190,6 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
185
190
  - Implement proper error logging and user-friendly error messages.
186
191
  - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
187
192
 
188
- <!-- Source: .ruler/common/keyConventions.md -->
189
-
190
- # Key conventions
191
-
192
- - You are familiar with the latest features and best practices.
193
- - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
194
- - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
195
- - If there might not be a correct answer or do not know the answer, say so instead of guessing.
196
-
197
193
  <!-- Source: .ruler/common/testing.md -->
198
194
 
199
195
  # Testing
@@ -223,9 +219,3 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
223
219
  - Leverage `readonly` properties for function parameter immutability.
224
220
  - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
225
221
  - Implement exhaustiveness checking using `never`.
226
-
227
- <!-- Source: .ruler/common/zOverlay.md -->
228
-
229
- # Overlay
230
-
231
- - If an ./OVERLAY.md file exists, read it for additional rules.
package/backend/CLAUDE.md CHANGED
@@ -168,8 +168,13 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
168
168
  - Avoid magic strings and numbers; define constants.
169
169
  - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
170
170
  - When declaring functions, use the `function` keyword, not `const`.
171
+ - Files should read from top to bottom: `export`ed items live on top and the internal functions and methods they call go below them.
171
172
  - Prefer data immutability.
172
173
 
174
+ # Commit messages
175
+
176
+ - Follow the Conventional Commits 1.0 spec for commit messages and in pull request titles.
177
+
173
178
  <!-- Source: .ruler/common/errorHandlingAndValidation.md -->
174
179
 
175
180
  # Error handling and validation
@@ -183,15 +188,6 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
183
188
  - Implement proper error logging and user-friendly error messages.
184
189
  - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
185
190
 
186
- <!-- Source: .ruler/common/keyConventions.md -->
187
-
188
- # Key conventions
189
-
190
- - You are familiar with the latest features and best practices.
191
- - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
192
- - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
193
- - If there might not be a correct answer or do not know the answer, say so instead of guessing.
194
-
195
191
  <!-- Source: .ruler/common/testing.md -->
196
192
 
197
193
  # Testing
@@ -221,9 +217,3 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
221
217
  - Leverage `readonly` properties for function parameter immutability.
222
218
  - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
223
219
  - Implement exhaustiveness checking using `never`.
224
-
225
- <!-- Source: .ruler/common/zOverlay.md -->
226
-
227
- # Overlay
228
-
229
- - If an ./OVERLAY.md file exists, read it for additional rules.
package/common/AGENTS.md CHANGED
@@ -12,8 +12,13 @@
12
12
  - Avoid magic strings and numbers; define constants.
13
13
  - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
14
14
  - When declaring functions, use the `function` keyword, not `const`.
15
+ - Files should read from top to bottom: `export`ed items live on top and the internal functions and methods they call go below them.
15
16
  - Prefer data immutability.
16
17
 
18
+ # Commit messages
19
+
20
+ - Follow the Conventional Commits 1.0 spec for commit messages and in pull request titles.
21
+
17
22
  <!-- Source: .ruler/common/errorHandlingAndValidation.md -->
18
23
 
19
24
  # Error handling and validation
@@ -27,15 +32,6 @@
27
32
  - Implement proper error logging and user-friendly error messages.
28
33
  - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
29
34
 
30
- <!-- Source: .ruler/common/keyConventions.md -->
31
-
32
- # Key conventions
33
-
34
- - You are familiar with the latest features and best practices.
35
- - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
36
- - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
37
- - If there might not be a correct answer or do not know the answer, say so instead of guessing.
38
-
39
35
  <!-- Source: .ruler/common/testing.md -->
40
36
 
41
37
  # Testing
@@ -65,9 +61,3 @@
65
61
  - Leverage `readonly` properties for function parameter immutability.
66
62
  - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
67
63
  - Implement exhaustiveness checking using `never`.
68
-
69
- <!-- Source: .ruler/common/zOverlay.md -->
70
-
71
- # Overlay
72
-
73
- - If an ./OVERLAY.md file exists, read it for additional rules.
package/common/CLAUDE.md CHANGED
@@ -10,8 +10,13 @@
10
10
  - Avoid magic strings and numbers; define constants.
11
11
  - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
12
12
  - When declaring functions, use the `function` keyword, not `const`.
13
+ - Files should read from top to bottom: `export`ed items live on top and the internal functions and methods they call go below them.
13
14
  - Prefer data immutability.
14
15
 
16
+ # Commit messages
17
+
18
+ - Follow the Conventional Commits 1.0 spec for commit messages and in pull request titles.
19
+
15
20
  <!-- Source: .ruler/common/errorHandlingAndValidation.md -->
16
21
 
17
22
  # Error handling and validation
@@ -25,15 +30,6 @@
25
30
  - Implement proper error logging and user-friendly error messages.
26
31
  - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
27
32
 
28
- <!-- Source: .ruler/common/keyConventions.md -->
29
-
30
- # Key conventions
31
-
32
- - You are familiar with the latest features and best practices.
33
- - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
34
- - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
35
- - If there might not be a correct answer or do not know the answer, say so instead of guessing.
36
-
37
33
  <!-- Source: .ruler/common/testing.md -->
38
34
 
39
35
  # Testing
@@ -63,9 +59,3 @@
63
59
  - Leverage `readonly` properties for function parameter immutability.
64
60
  - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
65
61
  - Implement exhaustiveness checking using `never`.
66
-
67
- <!-- Source: .ruler/common/zOverlay.md -->
68
-
69
- # Overlay
70
-
71
- - If an ./OVERLAY.md file exists, read it for additional rules.
@@ -12,8 +12,13 @@
12
12
  - Avoid magic strings and numbers; define constants.
13
13
  - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
14
14
  - When declaring functions, use the `function` keyword, not `const`.
15
+ - Files should read from top to bottom: `export`ed items live on top and the internal functions and methods they call go below them.
15
16
  - Prefer data immutability.
16
17
 
18
+ # Commit messages
19
+
20
+ - Follow the Conventional Commits 1.0 spec for commit messages and in pull request titles.
21
+
17
22
  <!-- Source: .ruler/common/errorHandlingAndValidation.md -->
18
23
 
19
24
  # Error handling and validation
@@ -27,15 +32,6 @@
27
32
  - Implement proper error logging and user-friendly error messages.
28
33
  - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
29
34
 
30
- <!-- Source: .ruler/common/keyConventions.md -->
31
-
32
- # Key conventions
33
-
34
- - You are familiar with the latest features and best practices.
35
- - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
36
- - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
37
- - If there might not be a correct answer or do not know the answer, say so instead of guessing.
38
-
39
35
  <!-- Source: .ruler/common/testing.md -->
40
36
 
41
37
  # Testing
@@ -66,12 +62,6 @@
66
62
  - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
67
63
  - Implement exhaustiveness checking using `never`.
68
64
 
69
- <!-- Source: .ruler/common/zOverlay.md -->
70
-
71
- # Overlay
72
-
73
- - If an ./OVERLAY.md file exists, read it for additional rules.
74
-
75
65
  <!-- Source: .ruler/frontend/custom-hooks.md -->
76
66
 
77
67
  # Custom Hook Standards
@@ -10,8 +10,13 @@
10
10
  - Avoid magic strings and numbers; define constants.
11
11
  - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
12
12
  - When declaring functions, use the `function` keyword, not `const`.
13
+ - Files should read from top to bottom: `export`ed items live on top and the internal functions and methods they call go below them.
13
14
  - Prefer data immutability.
14
15
 
16
+ # Commit messages
17
+
18
+ - Follow the Conventional Commits 1.0 spec for commit messages and in pull request titles.
19
+
15
20
  <!-- Source: .ruler/common/errorHandlingAndValidation.md -->
16
21
 
17
22
  # Error handling and validation
@@ -25,15 +30,6 @@
25
30
  - Implement proper error logging and user-friendly error messages.
26
31
  - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
27
32
 
28
- <!-- Source: .ruler/common/keyConventions.md -->
29
-
30
- # Key conventions
31
-
32
- - You are familiar with the latest features and best practices.
33
- - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
34
- - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
35
- - If there might not be a correct answer or do not know the answer, say so instead of guessing.
36
-
37
33
  <!-- Source: .ruler/common/testing.md -->
38
34
 
39
35
  # Testing
@@ -64,12 +60,6 @@
64
60
  - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
65
61
  - Implement exhaustiveness checking using `never`.
66
62
 
67
- <!-- Source: .ruler/common/zOverlay.md -->
68
-
69
- # Overlay
70
-
71
- - If an ./OVERLAY.md file exists, read it for additional rules.
72
-
73
63
  <!-- Source: .ruler/frontend/custom-hooks.md -->
74
64
 
75
65
  # Custom Hook Standards
@@ -170,8 +170,13 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
170
170
  - Avoid magic strings and numbers; define constants.
171
171
  - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
172
172
  - When declaring functions, use the `function` keyword, not `const`.
173
+ - Files should read from top to bottom: `export`ed items live on top and the internal functions and methods they call go below them.
173
174
  - Prefer data immutability.
174
175
 
176
+ # Commit messages
177
+
178
+ - Follow the Conventional Commits 1.0 spec for commit messages and in pull request titles.
179
+
175
180
  <!-- Source: .ruler/common/errorHandlingAndValidation.md -->
176
181
 
177
182
  # Error handling and validation
@@ -185,15 +190,6 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
185
190
  - Implement proper error logging and user-friendly error messages.
186
191
  - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
187
192
 
188
- <!-- Source: .ruler/common/keyConventions.md -->
189
-
190
- # Key conventions
191
-
192
- - You are familiar with the latest features and best practices.
193
- - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
194
- - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
195
- - If there might not be a correct answer or do not know the answer, say so instead of guessing.
196
-
197
193
  <!-- Source: .ruler/common/testing.md -->
198
194
 
199
195
  # Testing
@@ -224,12 +220,6 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
224
220
  - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
225
221
  - Implement exhaustiveness checking using `never`.
226
222
 
227
- <!-- Source: .ruler/common/zOverlay.md -->
228
-
229
- # Overlay
230
-
231
- - If an ./OVERLAY.md file exists, read it for additional rules.
232
-
233
223
  <!-- Source: .ruler/frontend/custom-hooks.md -->
234
224
 
235
225
  # Custom Hook Standards
@@ -168,8 +168,13 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
168
168
  - Avoid magic strings and numbers; define constants.
169
169
  - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
170
170
  - When declaring functions, use the `function` keyword, not `const`.
171
+ - Files should read from top to bottom: `export`ed items live on top and the internal functions and methods they call go below them.
171
172
  - Prefer data immutability.
172
173
 
174
+ # Commit messages
175
+
176
+ - Follow the Conventional Commits 1.0 spec for commit messages and in pull request titles.
177
+
173
178
  <!-- Source: .ruler/common/errorHandlingAndValidation.md -->
174
179
 
175
180
  # Error handling and validation
@@ -183,15 +188,6 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
183
188
  - Implement proper error logging and user-friendly error messages.
184
189
  - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
185
190
 
186
- <!-- Source: .ruler/common/keyConventions.md -->
187
-
188
- # Key conventions
189
-
190
- - You are familiar with the latest features and best practices.
191
- - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
192
- - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
193
- - If there might not be a correct answer or do not know the answer, say so instead of guessing.
194
-
195
191
  <!-- Source: .ruler/common/testing.md -->
196
192
 
197
193
  # Testing
@@ -222,12 +218,6 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
222
218
  - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
223
219
  - Implement exhaustiveness checking using `never`.
224
220
 
225
- <!-- Source: .ruler/common/zOverlay.md -->
226
-
227
- # Overlay
228
-
229
- - If an ./OVERLAY.md file exists, read it for additional rules.
230
-
231
221
  <!-- Source: .ruler/frontend/custom-hooks.md -->
232
222
 
233
223
  # Custom Hook Standards
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@clipboard-health/ai-rules",
3
3
  "description": "Pre-built AI agent rules for consistent coding standards.",
4
- "version": "0.3.3",
4
+ "version": "1.1.0",
5
5
  "bugs": "https://github.com/ClipboardHealth/core-utils/issues",
6
6
  "devDependencies": {
7
7
  "@intellectronica/ruler": "0.3.10"
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.PROFILES = exports.PATHS = void 0;
4
- const node_path_1 = require("node:path");
5
- const packageRoot = (0, node_path_1.join)(__dirname, "..");
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const packageRoot = node_path_1.default.join(__dirname, "..");
6
9
  exports.PATHS = {
7
10
  packageRoot,
8
- outputDirectory: (0, node_path_1.join)(packageRoot, "..", "..", "dist", "packages", "ai-rules"),
11
+ outputDirectory: node_path_1.default.join(packageRoot, "..", "..", "dist", "packages", "ai-rules"),
9
12
  };
10
13
  exports.PROFILES = {
11
14
  frontend: ["common", "frontend"],
package/scripts/sync.js CHANGED
@@ -1,15 +1,36 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable unicorn/no-process-exit */
4
- /* eslint-disable n/no-process-exit */
6
+ /* eslint-disable unicorn/no-process-exit, n/no-process-exit */
7
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
5
8
  const promises_1 = require("node:fs/promises");
6
- const node_path_1 = require("node:path");
9
+ const node_path_1 = __importDefault(require("node:path"));
7
10
  const constants_1 = require("./constants");
8
11
  const toErrorMessage_1 = require("./toErrorMessage");
9
12
  const PATHS = {
10
- projectRoot: (0, node_path_1.join)(__dirname, "../../../.."),
11
- rules: (0, node_path_1.join)(__dirname, ".."),
13
+ projectRoot: node_path_1.default.join(__dirname, "../../../.."),
14
+ rules: node_path_1.default.join(__dirname, ".."),
12
15
  };
16
+ async function sync() {
17
+ try {
18
+ const profile = getProfileFromArguments();
19
+ // Force copy files; rely on `git` if it overwrites files.
20
+ await (0, promises_1.cp)(node_path_1.default.join(PATHS.rules, profile), PATHS.projectRoot, { force: true, recursive: true });
21
+ console.log(`✅ @clipboard-health/ai-rules synced ${profile}`);
22
+ // Append OVERLAY.md content if it exists
23
+ await appendOverlayToFiles({
24
+ filesToUpdate: ["CLAUDE.md", "AGENTS.md"],
25
+ projectRoot: PATHS.projectRoot,
26
+ });
27
+ }
28
+ catch (error) {
29
+ // Log error but exit gracefully to avoid breaking installs
30
+ console.error(`⚠️ @clipboard-health/ai-rules sync failed: ${(0, toErrorMessage_1.toErrorMessage)(error)}`);
31
+ process.exit(0);
32
+ }
33
+ }
13
34
  function getProfileFromArguments() {
14
35
  const profile = process.argv[2];
15
36
  if (!profile || !(profile in constants_1.PROFILES)) {
@@ -20,20 +41,39 @@ function getProfileFromArguments() {
20
41
  }
21
42
  return profile;
22
43
  }
23
- async function sync() {
44
+ /**
45
+ * Appends OVERLAY.md content to specified files if OVERLAY.md exists.
46
+ */
47
+ async function appendOverlayToFiles(params) {
48
+ const { filesToUpdate, projectRoot } = params;
49
+ const overlayPath = node_path_1.default.join(projectRoot, "OVERLAY.md");
50
+ const overlayContent = await readOverlayContent(overlayPath);
51
+ if (!overlayContent) {
52
+ // OVERLAY.md doesn't exist or can't be read, nothing to append
53
+ return;
54
+ }
55
+ // Append to each file
56
+ await Promise.all(filesToUpdate.map(async (file) => {
57
+ const filePath = node_path_1.default.join(projectRoot, file);
58
+ try {
59
+ const currentContent = await (0, promises_1.readFile)(filePath, "utf8");
60
+ const updatedContent = `${currentContent}\n<!-- Source: ./OVERLAY.md -->\n\n${overlayContent}`;
61
+ await (0, promises_1.writeFile)(filePath, updatedContent, "utf8");
62
+ }
63
+ catch (error) {
64
+ console.warn(`⚠️ Could not append overlay to ${file}: ${(0, toErrorMessage_1.toErrorMessage)(error)}`);
65
+ }
66
+ }));
67
+ console.log(`📎 Appended OVERLAY.md to ${filesToUpdate.join(", ")}`);
68
+ }
69
+ async function readOverlayContent(overlayPath) {
24
70
  try {
25
- const profile = getProfileFromArguments();
26
- // Force copy files; rely on `git` if it overwrites files.
27
- await (0, promises_1.cp)((0, node_path_1.join)(PATHS.rules, profile), PATHS.projectRoot, { recursive: true, force: true });
28
- console.log(`✅ @clipboard-health/ai-rules synced ${profile}`);
71
+ return await (0, promises_1.readFile)(overlayPath, "utf8");
29
72
  }
30
- catch (error) {
31
- // Log error but exit gracefully to avoid breaking installs
32
- console.error(`⚠️ @clipboard-health/ai-rules sync failed: ${(0, toErrorMessage_1.toErrorMessage)(error)}`);
33
- process.exit(0);
73
+ catch {
74
+ return undefined;
34
75
  }
35
76
  }
36
77
  // eslint-disable-next-line unicorn/prefer-top-level-await
37
78
  void sync();
38
- /* eslint-enable n/no-process-exit */
39
- /* eslint-enable unicorn/no-process-exit */
79
+ /* eslint-enable unicorn/no-process-exit, n/no-process-exit */