@clipboard-health/ai-rules 1.0.0 → 1.1.1
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 +1 -1
- package/backend/AGENTS.md +5 -7
- package/backend/CLAUDE.md +5 -7
- package/common/AGENTS.md +5 -7
- package/common/CLAUDE.md +5 -7
- package/frontend/AGENTS.md +5 -7
- package/frontend/CLAUDE.md +5 -7
- package/fullstack/AGENTS.md +5 -7
- package/fullstack/CLAUDE.md +5 -7
- package/package.json +1 -1
- package/scripts/sync.js +47 -10
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ npm install --save-dev @clipboard-health/ai-rules
|
|
|
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
|
|
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
|
|
package/backend/AGENTS.md
CHANGED
|
@@ -170,8 +170,12 @@ 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.
|
|
175
179
|
|
|
176
180
|
<!-- Source: .ruler/common/errorHandlingAndValidation.md -->
|
|
177
181
|
|
|
@@ -215,9 +219,3 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
|
|
|
215
219
|
- Leverage `readonly` properties for function parameter immutability.
|
|
216
220
|
- Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
|
|
217
221
|
- Implement exhaustiveness checking using `never`.
|
|
218
|
-
|
|
219
|
-
<!-- Source: .ruler/common/zOverlay.md -->
|
|
220
|
-
|
|
221
|
-
# Overlay
|
|
222
|
-
|
|
223
|
-
- If an ./OVERLAY.md file exists, read it for additional rules.
|
package/backend/CLAUDE.md
CHANGED
|
@@ -168,8 +168,12 @@ 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.
|
|
173
177
|
|
|
174
178
|
<!-- Source: .ruler/common/errorHandlingAndValidation.md -->
|
|
175
179
|
|
|
@@ -213,9 +217,3 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
|
|
|
213
217
|
- Leverage `readonly` properties for function parameter immutability.
|
|
214
218
|
- Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
|
|
215
219
|
- Implement exhaustiveness checking using `never`.
|
|
216
|
-
|
|
217
|
-
<!-- Source: .ruler/common/zOverlay.md -->
|
|
218
|
-
|
|
219
|
-
# Overlay
|
|
220
|
-
|
|
221
|
-
- If an ./OVERLAY.md file exists, read it for additional rules.
|
package/common/AGENTS.md
CHANGED
|
@@ -12,8 +12,12 @@
|
|
|
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.
|
|
17
21
|
|
|
18
22
|
<!-- Source: .ruler/common/errorHandlingAndValidation.md -->
|
|
19
23
|
|
|
@@ -57,9 +61,3 @@
|
|
|
57
61
|
- Leverage `readonly` properties for function parameter immutability.
|
|
58
62
|
- Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
|
|
59
63
|
- Implement exhaustiveness checking using `never`.
|
|
60
|
-
|
|
61
|
-
<!-- Source: .ruler/common/zOverlay.md -->
|
|
62
|
-
|
|
63
|
-
# Overlay
|
|
64
|
-
|
|
65
|
-
- If an ./OVERLAY.md file exists, read it for additional rules.
|
package/common/CLAUDE.md
CHANGED
|
@@ -10,8 +10,12 @@
|
|
|
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.
|
|
15
19
|
|
|
16
20
|
<!-- Source: .ruler/common/errorHandlingAndValidation.md -->
|
|
17
21
|
|
|
@@ -55,9 +59,3 @@
|
|
|
55
59
|
- Leverage `readonly` properties for function parameter immutability.
|
|
56
60
|
- Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
|
|
57
61
|
- Implement exhaustiveness checking using `never`.
|
|
58
|
-
|
|
59
|
-
<!-- Source: .ruler/common/zOverlay.md -->
|
|
60
|
-
|
|
61
|
-
# Overlay
|
|
62
|
-
|
|
63
|
-
- If an ./OVERLAY.md file exists, read it for additional rules.
|
package/frontend/AGENTS.md
CHANGED
|
@@ -12,8 +12,12 @@
|
|
|
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.
|
|
17
21
|
|
|
18
22
|
<!-- Source: .ruler/common/errorHandlingAndValidation.md -->
|
|
19
23
|
|
|
@@ -58,12 +62,6 @@
|
|
|
58
62
|
- Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
|
|
59
63
|
- Implement exhaustiveness checking using `never`.
|
|
60
64
|
|
|
61
|
-
<!-- Source: .ruler/common/zOverlay.md -->
|
|
62
|
-
|
|
63
|
-
# Overlay
|
|
64
|
-
|
|
65
|
-
- If an ./OVERLAY.md file exists, read it for additional rules.
|
|
66
|
-
|
|
67
65
|
<!-- Source: .ruler/frontend/custom-hooks.md -->
|
|
68
66
|
|
|
69
67
|
# Custom Hook Standards
|
package/frontend/CLAUDE.md
CHANGED
|
@@ -10,8 +10,12 @@
|
|
|
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.
|
|
15
19
|
|
|
16
20
|
<!-- Source: .ruler/common/errorHandlingAndValidation.md -->
|
|
17
21
|
|
|
@@ -56,12 +60,6 @@
|
|
|
56
60
|
- Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
|
|
57
61
|
- Implement exhaustiveness checking using `never`.
|
|
58
62
|
|
|
59
|
-
<!-- Source: .ruler/common/zOverlay.md -->
|
|
60
|
-
|
|
61
|
-
# Overlay
|
|
62
|
-
|
|
63
|
-
- If an ./OVERLAY.md file exists, read it for additional rules.
|
|
64
|
-
|
|
65
63
|
<!-- Source: .ruler/frontend/custom-hooks.md -->
|
|
66
64
|
|
|
67
65
|
# Custom Hook Standards
|
package/fullstack/AGENTS.md
CHANGED
|
@@ -170,8 +170,12 @@ 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.
|
|
175
179
|
|
|
176
180
|
<!-- Source: .ruler/common/errorHandlingAndValidation.md -->
|
|
177
181
|
|
|
@@ -216,12 +220,6 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
|
|
|
216
220
|
- Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
|
|
217
221
|
- Implement exhaustiveness checking using `never`.
|
|
218
222
|
|
|
219
|
-
<!-- Source: .ruler/common/zOverlay.md -->
|
|
220
|
-
|
|
221
|
-
# Overlay
|
|
222
|
-
|
|
223
|
-
- If an ./OVERLAY.md file exists, read it for additional rules.
|
|
224
|
-
|
|
225
223
|
<!-- Source: .ruler/frontend/custom-hooks.md -->
|
|
226
224
|
|
|
227
225
|
# Custom Hook Standards
|
package/fullstack/CLAUDE.md
CHANGED
|
@@ -168,8 +168,12 @@ 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.
|
|
173
177
|
|
|
174
178
|
<!-- Source: .ruler/common/errorHandlingAndValidation.md -->
|
|
175
179
|
|
|
@@ -214,12 +218,6 @@ Send notifications through [Knock](https://docs.knock.app) using the `@clipboard
|
|
|
214
218
|
- Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
|
|
215
219
|
- Implement exhaustiveness checking using `never`.
|
|
216
220
|
|
|
217
|
-
<!-- Source: .ruler/common/zOverlay.md -->
|
|
218
|
-
|
|
219
|
-
# Overlay
|
|
220
|
-
|
|
221
|
-
- If an ./OVERLAY.md file exists, read it for additional rules.
|
|
222
|
-
|
|
223
221
|
<!-- Source: .ruler/frontend/custom-hooks.md -->
|
|
224
222
|
|
|
225
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": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"bugs": "https://github.com/ClipboardHealth/core-utils/issues",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@intellectronica/ruler": "0.3.10"
|
package/scripts/sync.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
/* eslint-disable unicorn/no-process-exit, n/no-process-exit */
|
|
7
|
-
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
8
7
|
const promises_1 = require("node:fs/promises");
|
|
9
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
9
|
const constants_1 = require("./constants");
|
|
@@ -13,6 +12,24 @@ const PATHS = {
|
|
|
13
12
|
projectRoot: node_path_1.default.join(__dirname, "../../../.."),
|
|
14
13
|
rules: node_path_1.default.join(__dirname, ".."),
|
|
15
14
|
};
|
|
15
|
+
async function sync() {
|
|
16
|
+
try {
|
|
17
|
+
const profile = getProfileFromArguments();
|
|
18
|
+
// Force copy files; rely on `git` if it overwrites files.
|
|
19
|
+
await (0, promises_1.cp)(node_path_1.default.join(PATHS.rules, profile), PATHS.projectRoot, { force: true, recursive: true });
|
|
20
|
+
console.log(`✅ @clipboard-health/ai-rules synced ${profile}`);
|
|
21
|
+
// Append OVERLAY.md content if it exists
|
|
22
|
+
await appendOverlayToFiles({
|
|
23
|
+
filesToUpdate: ["CLAUDE.md", "AGENTS.md"],
|
|
24
|
+
projectRoot: PATHS.projectRoot,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// Log error but exit gracefully to avoid breaking installs
|
|
29
|
+
console.error(`⚠️ @clipboard-health/ai-rules sync failed: ${(0, toErrorMessage_1.toErrorMessage)(error)}`);
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
16
33
|
function getProfileFromArguments() {
|
|
17
34
|
const profile = process.argv[2];
|
|
18
35
|
if (!profile || !(profile in constants_1.PROFILES)) {
|
|
@@ -23,17 +40,37 @@ function getProfileFromArguments() {
|
|
|
23
40
|
}
|
|
24
41
|
return profile;
|
|
25
42
|
}
|
|
26
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Appends OVERLAY.md content to specified files if OVERLAY.md exists.
|
|
45
|
+
*/
|
|
46
|
+
async function appendOverlayToFiles(params) {
|
|
47
|
+
const { filesToUpdate, projectRoot } = params;
|
|
48
|
+
const overlayPath = node_path_1.default.join(projectRoot, "OVERLAY.md");
|
|
49
|
+
const overlayContent = await readOverlayContent(overlayPath);
|
|
50
|
+
if (!overlayContent) {
|
|
51
|
+
// OVERLAY.md doesn't exist or can't be read, nothing to append
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Append to each file
|
|
55
|
+
await Promise.all(filesToUpdate.map(async (file) => {
|
|
56
|
+
const filePath = node_path_1.default.join(projectRoot, file);
|
|
57
|
+
try {
|
|
58
|
+
const currentContent = await (0, promises_1.readFile)(filePath, "utf8");
|
|
59
|
+
const updatedContent = `${currentContent}\n<!-- Source: ./OVERLAY.md -->\n\n${overlayContent}`;
|
|
60
|
+
await (0, promises_1.writeFile)(filePath, updatedContent, "utf8");
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.warn(`⚠️ Could not append overlay to ${file}: ${(0, toErrorMessage_1.toErrorMessage)(error)}`);
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
console.log(`📎 Appended OVERLAY.md to ${filesToUpdate.join(", ")}`);
|
|
67
|
+
}
|
|
68
|
+
async function readOverlayContent(overlayPath) {
|
|
27
69
|
try {
|
|
28
|
-
|
|
29
|
-
// Force copy files; rely on `git` if it overwrites files.
|
|
30
|
-
await (0, promises_1.cp)(node_path_1.default.join(PATHS.rules, profile), PATHS.projectRoot, { force: true, recursive: true });
|
|
31
|
-
console.log(`✅ @clipboard-health/ai-rules synced ${profile}`);
|
|
70
|
+
return await (0, promises_1.readFile)(overlayPath, "utf8");
|
|
32
71
|
}
|
|
33
|
-
catch
|
|
34
|
-
|
|
35
|
-
console.error(`⚠️ @clipboard-health/ai-rules sync failed: ${(0, toErrorMessage_1.toErrorMessage)(error)}`);
|
|
36
|
-
process.exit(0);
|
|
72
|
+
catch {
|
|
73
|
+
return undefined;
|
|
37
74
|
}
|
|
38
75
|
}
|
|
39
76
|
// eslint-disable-next-line unicorn/prefer-top-level-await
|