builder-doctor 1.0.2 → 1.0.3
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 +37 -1
- package/dist/index.js +85 -68
- package/dist/index.js.map +1 -1
- package/dist/network.d.ts +23 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +155 -0
- package/dist/network.js.map +1 -0
- package/dist/rule-parse.d.ts +43 -0
- package/dist/rule-parse.d.ts.map +1 -0
- package/dist/rule-parse.js +188 -0
- package/dist/rule-parse.js.map +1 -0
- package/dist/rules.d.ts +5 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +296 -0
- package/dist/rules.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,4 +17,40 @@ npx builder-doctor
|
|
|
17
17
|
or for additional details (like responses and headers):
|
|
18
18
|
```bash
|
|
19
19
|
npx builder-doctor --verbose
|
|
20
|
-
```
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Network checks
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx builder-doctor network
|
|
26
|
+
```
|
|
27
|
+
The tool performs the following diagnostic checks for a valid http or ping response as a way to test network connectivity to:
|
|
28
|
+
- firestore.googleapis.com
|
|
29
|
+
- firebasestorage.googleapis.com
|
|
30
|
+
- builder.io
|
|
31
|
+
- ai.builder.io
|
|
32
|
+
- builder.io app
|
|
33
|
+
- cdn.builder.io
|
|
34
|
+
- *.builder.codes
|
|
35
|
+
- *.builder.my
|
|
36
|
+
- 34.136.119.149
|
|
37
|
+
|
|
38
|
+
The tool cannot verify connectivity to (but you should):
|
|
39
|
+
- *.fly.dev
|
|
40
|
+
|
|
41
|
+
## Rules checks
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx builder-doctor rules
|
|
45
|
+
```
|
|
46
|
+
The tool analyses your .builderrules, agents.md and rules in .builder/rules or .cursor/rules. Recommendations are made to:
|
|
47
|
+
- Find where there are too many rules being applied at once causing the AI to ignore some rules.
|
|
48
|
+
- Common missing front matter like `description` where needed
|
|
49
|
+
- Overuse of `alwaysApply`
|
|
50
|
+
- Common incorrect namings of agents.md and .builderrules
|
|
51
|
+
|
|
52
|
+
## ToDo
|
|
53
|
+
- Verify if frontmatter like alwaysApply is respected without reference in agents.md
|
|
54
|
+
- Verify if globs is respected without reference
|
|
55
|
+
- Verify if rules are found from current working directory or root of project
|
|
56
|
+
|
package/dist/index.js
CHANGED
|
@@ -1,78 +1,95 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const
|
|
4
|
+
const rules_1 = require("./rules");
|
|
5
|
+
const network_1 = require("./network");
|
|
5
6
|
const args = process.argv.slice(2);
|
|
6
7
|
const verbose = args.includes("--verbose");
|
|
8
|
+
const rules = args.includes("rules");
|
|
9
|
+
const network = args.includes("network");
|
|
10
|
+
const all = !rules && !network;
|
|
7
11
|
async function main() {
|
|
8
12
|
try {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
13
|
+
if (all || network) {
|
|
14
|
+
console.log(`Checking connectivity to Builder.io services...`);
|
|
15
|
+
await (0, network_1.check)({
|
|
16
|
+
host: "firestore.googleapis.com",
|
|
17
|
+
url: "https://firestore.googleapis.com/",
|
|
18
|
+
verbose,
|
|
19
|
+
expectedStatus: 404,
|
|
20
|
+
expectedContent: "<span id=logo aria-label=Google>",
|
|
21
|
+
});
|
|
22
|
+
await (0, network_1.check)({
|
|
23
|
+
host: "firebasestorage.googleapis.com",
|
|
24
|
+
url: "https://firebasestorage.googleapis.com/",
|
|
25
|
+
verbose,
|
|
26
|
+
expectedStatus: 404,
|
|
27
|
+
expectedContent: "<span id=logo aria-label=Google>",
|
|
28
|
+
});
|
|
29
|
+
await (0, network_1.check)({
|
|
30
|
+
host: "builder.io",
|
|
31
|
+
url: "https://www.builder.io/",
|
|
32
|
+
verbose,
|
|
33
|
+
expectedStatus: 200,
|
|
34
|
+
expectedContent: "<body>",
|
|
35
|
+
});
|
|
36
|
+
await (0, network_1.check)({
|
|
37
|
+
host: "builder.io app",
|
|
38
|
+
url: "https://builder.io/content",
|
|
39
|
+
verbose,
|
|
40
|
+
expectedStatus: 200,
|
|
41
|
+
expectedContent: "<body>",
|
|
42
|
+
});
|
|
43
|
+
await (0, network_1.check)({
|
|
44
|
+
host: "cdn.builder.io",
|
|
45
|
+
url: "https://cdn.builder.io/static/media/builder-logo.bff0faae.png",
|
|
46
|
+
verbose,
|
|
47
|
+
expectedStatus: 200,
|
|
48
|
+
expectedHeader: "content-type",
|
|
49
|
+
expectedHeaderValue: "image/png",
|
|
50
|
+
});
|
|
51
|
+
await (0, network_1.check)({
|
|
52
|
+
host: "*.builder.codes",
|
|
53
|
+
url: "https://stuff.builder.codes/",
|
|
54
|
+
verbose,
|
|
55
|
+
expectedStatus: 404,
|
|
56
|
+
expectedHeader: "server",
|
|
57
|
+
expectedHeaderValue: "Google Frontend",
|
|
58
|
+
});
|
|
59
|
+
await (0, network_1.check)({
|
|
60
|
+
host: "*.builder.my",
|
|
61
|
+
url: "https://www.builder.my/",
|
|
62
|
+
verbose,
|
|
63
|
+
expectedStatus: 200,
|
|
64
|
+
expectedHeader: "x-powered-by",
|
|
65
|
+
expectedHeaderValue: "Next.js",
|
|
66
|
+
});
|
|
67
|
+
await (0, network_1.check)({
|
|
68
|
+
host: "*.fly.dev",
|
|
69
|
+
url: "https://status.flyio.net/",
|
|
70
|
+
verbose,
|
|
71
|
+
expectedStatus: 200,
|
|
72
|
+
message: " (Unknown status)",
|
|
73
|
+
});
|
|
74
|
+
await (0, network_1.check)({
|
|
75
|
+
host: "ai.builder.io",
|
|
76
|
+
url: "https://ai.builder.io/",
|
|
77
|
+
verbose,
|
|
78
|
+
expectedStatus: 200,
|
|
79
|
+
});
|
|
80
|
+
await (0, network_1.check)({
|
|
81
|
+
host: "34.136.119.149",
|
|
82
|
+
verbose,
|
|
83
|
+
message: " (ping)",
|
|
84
|
+
additionalErrorInfo: "This is the Static IP address that Builder.io uses",
|
|
85
|
+
ping: true,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (all || rules) {
|
|
89
|
+
await (0, rules_1.checkRules)({
|
|
90
|
+
verbose,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
76
93
|
}
|
|
77
94
|
catch (error) {
|
|
78
95
|
console.error("An error occurred:", error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,mCAAqC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts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C,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IncomingHttpHeaders } from "http2";
|
|
2
|
+
export interface Response {
|
|
3
|
+
statusCode?: number;
|
|
4
|
+
statusMessage?: string;
|
|
5
|
+
body: string;
|
|
6
|
+
headers: IncomingHttpHeaders;
|
|
7
|
+
}
|
|
8
|
+
interface CheckOptions {
|
|
9
|
+
host: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
verbose: boolean;
|
|
12
|
+
expectedStatus?: number;
|
|
13
|
+
expectedContent?: string;
|
|
14
|
+
expectedHeader?: string;
|
|
15
|
+
expectedHeaderValue?: string;
|
|
16
|
+
message?: string;
|
|
17
|
+
additionalErrorInfo?: string;
|
|
18
|
+
ping?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function get(url: string): Promise<Response>;
|
|
21
|
+
export declare function check(options: CheckOptions): Promise<void>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAM5C,MAAM,WAAW,QAAQ;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0BxD;AAWD,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAmChE"}
|
package/dist/network.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.get = get;
|
|
37
|
+
exports.check = check;
|
|
38
|
+
const https = __importStar(require("https"));
|
|
39
|
+
const http = __importStar(require("http"));
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
const util_1 = require("util");
|
|
42
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
43
|
+
async function get(url) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const parsedUrl = new URL(url);
|
|
46
|
+
const client = parsedUrl.protocol === "https:" ? https : http;
|
|
47
|
+
client
|
|
48
|
+
.get(url, (res) => {
|
|
49
|
+
let data = "";
|
|
50
|
+
res.on("data", (chunk) => {
|
|
51
|
+
data += chunk;
|
|
52
|
+
});
|
|
53
|
+
res.on("end", () => {
|
|
54
|
+
resolve({
|
|
55
|
+
statusCode: res.statusCode || 0,
|
|
56
|
+
body: data,
|
|
57
|
+
statusMessage: res.statusMessage || "",
|
|
58
|
+
headers: res.headers,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
})
|
|
62
|
+
.on("error", (err) => {
|
|
63
|
+
reject(err);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const red = "\x1b[31m";
|
|
68
|
+
const green = "\x1b[32m";
|
|
69
|
+
const reset = "\x1b[0m";
|
|
70
|
+
async function check(options) {
|
|
71
|
+
let result = { reason: "", details: "" };
|
|
72
|
+
try {
|
|
73
|
+
if (options.ping) {
|
|
74
|
+
result = await checkPing(options);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
result = await checkHttp(options);
|
|
78
|
+
}
|
|
79
|
+
if (result.reason == "") {
|
|
80
|
+
console.log(`${green}✓${reset} ${options.host}${options.message ?? ""}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
let msg = `${err}`;
|
|
85
|
+
// Eg turn off Wifi
|
|
86
|
+
if (msg.includes(`Error: getaddrinfo`)) {
|
|
87
|
+
result.reason = `You may not have internet connectivity or the domain ${options.host} is not accessible.`;
|
|
88
|
+
}
|
|
89
|
+
// Not a known error then report back the actual error
|
|
90
|
+
if (result.reason == "") {
|
|
91
|
+
result.reason = msg;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (result.reason !== "") {
|
|
95
|
+
console.log(`${red}✗ ${options.host} ${red}Failed${reset}: ${result.reason}`);
|
|
96
|
+
if (options.additionalErrorInfo) {
|
|
97
|
+
console.log(options.additionalErrorInfo);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (result.details !== "") {
|
|
101
|
+
console.log(result.details);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function checkHttp(options) {
|
|
105
|
+
let reason = "";
|
|
106
|
+
let details = "";
|
|
107
|
+
if (!options.url)
|
|
108
|
+
throw new Error("URL is required for HTTP checks");
|
|
109
|
+
const response = await get(options.url);
|
|
110
|
+
if (response.statusCode !== options.expectedStatus) {
|
|
111
|
+
reason = `The domain ${options.host} appears to be blocked. An unexpected status code was reported ${response.statusCode}. Check your network settings (eg VPN connection, network status, Wifi).`;
|
|
112
|
+
}
|
|
113
|
+
else if (options.expectedContent &&
|
|
114
|
+
response.body.indexOf(options.expectedContent) === -1) {
|
|
115
|
+
reason = `The domain ${options.host} appears to be blocked. An unexpected response was found. Check your network settings (eg VPN connection, network status, Wifi).`;
|
|
116
|
+
if (options.verbose) {
|
|
117
|
+
details = "Body" + response.body;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (options.expectedHeader &&
|
|
121
|
+
response.headers[options.expectedHeader] !== options.expectedHeaderValue) {
|
|
122
|
+
reason = `The domain ${options.host} appears to be blocked. An unexpected response header for "${options.expectedHeader}" was found. Check your network settings (eg VPN connection, network status, Wifi).`;
|
|
123
|
+
if (options.verbose) {
|
|
124
|
+
details = `Headers: ${JSON.stringify(response.headers)}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return { reason, details };
|
|
128
|
+
}
|
|
129
|
+
function checkPing(options) {
|
|
130
|
+
return new Promise(async (resolve) => {
|
|
131
|
+
try {
|
|
132
|
+
const isWindows = process.platform === "win32";
|
|
133
|
+
const pingCommand = isWindows
|
|
134
|
+
? `ping -n 1 ${options.host}`
|
|
135
|
+
: `ping -c 1 ${options.host}`;
|
|
136
|
+
const { stdout, stderr } = await execAsync(pingCommand);
|
|
137
|
+
if (stderr) {
|
|
138
|
+
resolve({
|
|
139
|
+
reason: `Ping to ${options.host} failed: ${stderr}`,
|
|
140
|
+
details: "",
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
resolve({ reason: "", details: "" });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
resolve({
|
|
149
|
+
reason: `Unable to ping ${options.host}. The host may be unreachable or blocking ICMP requests. ${error}`,
|
|
150
|
+
details: options.verbose ? `${error}` : "",
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,kBA0BC;AAWD,sBAmCC;AApGD,6CAA+B;AAC/B,2CAA6B;AAE7B,iDAAqC;AACrC,+BAAiC;AAEjC,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAsB3B,KAAK,UAAU,GAAG,CAAC,GAAW;IACnC,OAAO,IAAI,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SAAS;gBAC3B,CAAC,CAAC,aAAa,OAAO,CAAC,IAAI,EAAE;gBAC7B,CAAC,CAAC,aAAa,OAAO,CAAC,IAAI,EAAE,CAAC;YAEhC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,CAAC;YAExD,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,CAAC;oBACN,MAAM,EAAE,WAAW,OAAO,CAAC,IAAI,YAAY,MAAM,EAAE;oBACnD,OAAO,EAAE,EAAE;iBACZ,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC;gBACN,MAAM,EAAE,kBAAkB,OAAO,CAAC,IAAI,4DAA4D,KAAK,EAAE;gBACzG,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE;aAC3C,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface RuleFile {
|
|
2
|
+
filename: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
globs?: string;
|
|
5
|
+
alwaysApply?: boolean;
|
|
6
|
+
body: string;
|
|
7
|
+
lines: number;
|
|
8
|
+
}
|
|
9
|
+
export interface MdcFrontmatterData {
|
|
10
|
+
description?: string;
|
|
11
|
+
glob?: string;
|
|
12
|
+
type: "agent-mode" | "always";
|
|
13
|
+
}
|
|
14
|
+
export interface MdcParseResult {
|
|
15
|
+
frontmatter: MdcFrontmatterData;
|
|
16
|
+
body: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Detects if a file is an MDC file based on filename and content
|
|
20
|
+
* @param fileName - The name or path of the file
|
|
21
|
+
* @param content - The content of the file
|
|
22
|
+
* @returns true if the file appears to be an MDC file
|
|
23
|
+
*/
|
|
24
|
+
export declare function isMdcFile(fileName: string | undefined, content: string | undefined): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Parses .mdc file content with frontmatter format.
|
|
27
|
+
* Expected format:
|
|
28
|
+
* ```
|
|
29
|
+
* ---
|
|
30
|
+
* description: Some description
|
|
31
|
+
* globs: *.ts,*.js
|
|
32
|
+
* alwaysApply: true
|
|
33
|
+
* ---
|
|
34
|
+
* Main content body here
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param fileContent - The raw file content to parse
|
|
38
|
+
* @returns Parsed frontmatter data and body content
|
|
39
|
+
* @throws Error if the file format is invalid
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseMdcFile(fileContent: string): MdcParseResult;
|
|
42
|
+
export declare function parseCursorRules(absolutePath: string): RuleFile;
|
|
43
|
+
//# sourceMappingURL=rule-parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-parse.d.ts","sourceRoot":"","sources":["../src/rule-parse.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,kBAAkB,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,OAAO,CAeT;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CA8HhE;AAKD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CA8B/D"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMdcFile = isMdcFile;
|
|
4
|
+
exports.parseMdcFile = parseMdcFile;
|
|
5
|
+
exports.parseCursorRules = parseCursorRules;
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
/**
|
|
8
|
+
* Detects if a file is an MDC file based on filename and content
|
|
9
|
+
* @param fileName - The name or path of the file
|
|
10
|
+
* @param content - The content of the file
|
|
11
|
+
* @returns true if the file appears to be an MDC file
|
|
12
|
+
*/
|
|
13
|
+
function isMdcFile(fileName, content) {
|
|
14
|
+
if (!fileName || !content) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
// Check file extension
|
|
18
|
+
const hasCorrectExtension = fileName.toLowerCase().endsWith(".mdc");
|
|
19
|
+
// Check content structure - should have frontmatter delimiters
|
|
20
|
+
const hasValidStructure = typeof content === "string" &&
|
|
21
|
+
content.trim().startsWith("---") &&
|
|
22
|
+
content.indexOf("---", 3) > 3; // Second --- should exist after the first one
|
|
23
|
+
return hasCorrectExtension && hasValidStructure;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parses .mdc file content with frontmatter format.
|
|
27
|
+
* Expected format:
|
|
28
|
+
* ```
|
|
29
|
+
* ---
|
|
30
|
+
* description: Some description
|
|
31
|
+
* globs: *.ts,*.js
|
|
32
|
+
* alwaysApply: true
|
|
33
|
+
* ---
|
|
34
|
+
* Main content body here
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param fileContent - The raw file content to parse
|
|
38
|
+
* @returns Parsed frontmatter data and body content
|
|
39
|
+
* @throws Error if the file format is invalid
|
|
40
|
+
*/
|
|
41
|
+
function parseMdcFile(fileContent) {
|
|
42
|
+
// Handle invalid input gracefully
|
|
43
|
+
if (!fileContent || typeof fileContent !== "string") {
|
|
44
|
+
return {
|
|
45
|
+
frontmatter: {
|
|
46
|
+
description: "",
|
|
47
|
+
glob: "",
|
|
48
|
+
type: "agent-mode",
|
|
49
|
+
},
|
|
50
|
+
body: "",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
// Preprocess content by converting JSON string representation and replacing \\n with \n
|
|
55
|
+
// This matches the original logic exactly
|
|
56
|
+
const preprocessedContent = JSON.stringify(fileContent).replace(/\\n/g, "\n");
|
|
57
|
+
// Split by frontmatter delimiters
|
|
58
|
+
const parts = preprocessedContent.split("---");
|
|
59
|
+
// Handle missing frontmatter delimiters gracefully
|
|
60
|
+
if (parts.length < 3) {
|
|
61
|
+
return {
|
|
62
|
+
frontmatter: {
|
|
63
|
+
description: "",
|
|
64
|
+
glob: "",
|
|
65
|
+
type: "agent-mode",
|
|
66
|
+
},
|
|
67
|
+
body: fileContent.trim(),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Extract frontmatter and body, filtering out empty parts - this matches the original logic
|
|
71
|
+
const filteredParts = parts.map((s) => s.trim()).filter(Boolean);
|
|
72
|
+
// Handle insufficient parts gracefully
|
|
73
|
+
if (filteredParts.length < 2) {
|
|
74
|
+
return {
|
|
75
|
+
frontmatter: {
|
|
76
|
+
description: "",
|
|
77
|
+
glob: "",
|
|
78
|
+
type: "agent-mode",
|
|
79
|
+
},
|
|
80
|
+
body: "",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// The original logic assumes filtered parts [0] is the quote, [1] is frontmatter, [2] is body
|
|
84
|
+
// We need to handle this correctly based on the actual structure
|
|
85
|
+
let frontmatterContent = "";
|
|
86
|
+
let body = "";
|
|
87
|
+
if (filteredParts.length >= 3) {
|
|
88
|
+
// Standard case: ['"', 'frontmatter', 'body...', 'more body...']
|
|
89
|
+
frontmatterContent = filteredParts[1];
|
|
90
|
+
// Join all remaining parts in case body contains additional ---
|
|
91
|
+
body = filteredParts.slice(2).join(" --- ");
|
|
92
|
+
// Remove trailing quote from body if present
|
|
93
|
+
if (body.endsWith('"')) {
|
|
94
|
+
body = body.slice(0, -1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (filteredParts.length === 2) {
|
|
98
|
+
// Edge case: just frontmatter and body combined
|
|
99
|
+
frontmatterContent = filteredParts[0];
|
|
100
|
+
body = filteredParts[1];
|
|
101
|
+
if (body.endsWith('"')) {
|
|
102
|
+
body = body.slice(0, -1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
body = body.trim();
|
|
106
|
+
// Parse frontmatter
|
|
107
|
+
const frontmatterLines = frontmatterContent
|
|
108
|
+
.split("\n")
|
|
109
|
+
.filter((line) => line.trim());
|
|
110
|
+
let description = "";
|
|
111
|
+
let glob = "";
|
|
112
|
+
let type = "agent-mode";
|
|
113
|
+
for (const line of frontmatterLines) {
|
|
114
|
+
const colonIndex = line.indexOf(":");
|
|
115
|
+
if (colonIndex === -1)
|
|
116
|
+
continue;
|
|
117
|
+
const key = line.substring(0, colonIndex).trim();
|
|
118
|
+
const value = line.substring(colonIndex + 1).trim();
|
|
119
|
+
switch (key) {
|
|
120
|
+
case "description":
|
|
121
|
+
description = value || "";
|
|
122
|
+
break;
|
|
123
|
+
case "globs":
|
|
124
|
+
glob = value || "";
|
|
125
|
+
break;
|
|
126
|
+
case "alwaysApply":
|
|
127
|
+
type = value === "true" ? "always" : "agent-mode";
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
frontmatter: {
|
|
133
|
+
description,
|
|
134
|
+
glob,
|
|
135
|
+
type,
|
|
136
|
+
},
|
|
137
|
+
body,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
// If any error occurs during parsing, return graceful defaults
|
|
142
|
+
return {
|
|
143
|
+
frontmatter: {
|
|
144
|
+
description: "",
|
|
145
|
+
glob: "",
|
|
146
|
+
type: "agent-mode",
|
|
147
|
+
},
|
|
148
|
+
body: fileContent.trim(),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function countNonEmptyLines(content) {
|
|
153
|
+
return content.split("\n").filter((line) => line.trim().length > 0).length;
|
|
154
|
+
}
|
|
155
|
+
function parseCursorRules(absolutePath) {
|
|
156
|
+
let exists = false;
|
|
157
|
+
try {
|
|
158
|
+
const stat = (0, fs_1.statSync)(absolutePath);
|
|
159
|
+
exists = stat.isFile();
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
exists = false;
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
if (exists) {
|
|
166
|
+
const fileContent = (0, fs_1.readFileSync)(absolutePath, "utf-8");
|
|
167
|
+
const lines = countNonEmptyLines(fileContent);
|
|
168
|
+
const result = parseMdcFile(fileContent);
|
|
169
|
+
return {
|
|
170
|
+
filename: absolutePath,
|
|
171
|
+
description: result.frontmatter.description,
|
|
172
|
+
globs: result.frontmatter.glob,
|
|
173
|
+
alwaysApply: result.frontmatter.type
|
|
174
|
+
? result.frontmatter.type === "always"
|
|
175
|
+
: undefined,
|
|
176
|
+
lines,
|
|
177
|
+
body: fileContent,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
throw new Error(`File not found at path: ${absolutePath}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
throw new Error(`Error parsing MDC file at ${absolutePath}: ${error}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=rule-parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|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AAC,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ;oBACtC,CAAC,CAAC,SAAS;gBACb,KAAK;gBACL,IAAI,EAAE,WAAW;aAClB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,YAAY,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,YAAY,KAAK,KAAK,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC"}
|
package/dist/rules.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;CAClB;AASD,wBAAsB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAWrE"}
|
package/dist/rules.js
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkRules = checkRules;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const rule_parse_1 = require("./rule-parse");
|
|
7
|
+
const MAX_LINES = 500; // Maximum acceptable lines in rules
|
|
8
|
+
const WARN_LINES = 150; // Lines at which to warn
|
|
9
|
+
const MAX_TOTAL_LINES = 500; // Maximum total lines in all rules
|
|
10
|
+
async function checkRules(options) {
|
|
11
|
+
const rulesResult = {
|
|
12
|
+
hasAgentsMd: hasAgentsMd(),
|
|
13
|
+
hasBuilderRulesFile: hasBuilderRulesFile(),
|
|
14
|
+
rules: await getRuleFiles(),
|
|
15
|
+
rootRuleFile: getRootRuleFile(),
|
|
16
|
+
};
|
|
17
|
+
if (options.verbose) {
|
|
18
|
+
console.log("Rules Check Result:", JSON.stringify(rulesResult, null, 2));
|
|
19
|
+
}
|
|
20
|
+
commentOn(rulesResult);
|
|
21
|
+
}
|
|
22
|
+
function commentOn(result) {
|
|
23
|
+
const problems = [];
|
|
24
|
+
const warnings = [];
|
|
25
|
+
const infos = [];
|
|
26
|
+
if (!result.hasAgentsMd && !result.hasBuilderRulesFile) {
|
|
27
|
+
if ((0, fs_1.existsSync)("agent.md")) {
|
|
28
|
+
problem("Found agent.md file. Did you mean agents.md?");
|
|
29
|
+
}
|
|
30
|
+
if ((0, fs_1.existsSync)("builderrules")) {
|
|
31
|
+
problem("Found builderrules file. Did you mean .builderrules?");
|
|
32
|
+
}
|
|
33
|
+
if ((0, fs_1.existsSync)(".builderules")) {
|
|
34
|
+
problem("Found .builderules file. Did you mean .builderrules?");
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!result.rootRuleFile) {
|
|
39
|
+
problems.push("Error with rules file.");
|
|
40
|
+
outputMessages(problems, warnings, infos);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const rootFileLines = result.rootRuleFile.lines || 0;
|
|
44
|
+
let lines = rootFileLines;
|
|
45
|
+
let alwaysCount = 0;
|
|
46
|
+
let alwaysList = [];
|
|
47
|
+
for (const r of result.rules) {
|
|
48
|
+
if (r.alwaysApply) {
|
|
49
|
+
alwaysCount++;
|
|
50
|
+
alwaysList.push((0, path_1.basename)(r.filename));
|
|
51
|
+
lines += r.lines;
|
|
52
|
+
}
|
|
53
|
+
const hasCorrectExtension = r.filename.toLowerCase().endsWith(".mdc");
|
|
54
|
+
if (!hasCorrectExtension) {
|
|
55
|
+
warnings.push(`${(0, path_1.basename)(r.filename)} does not have a .mdc file extension. Is this file intended to be in the rules folder?`);
|
|
56
|
+
}
|
|
57
|
+
if (!r.alwaysApply) {
|
|
58
|
+
if (hasCorrectExtension &&
|
|
59
|
+
(!r.description || r.description.trim().length === 0)) {
|
|
60
|
+
warnings.push(`${(0, path_1.basename)(r.filename)} is missing a description in the frontmatter. Consider adding a description so that this rule can conditionally apply.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (r.alwaysApply && !r.globs) {
|
|
64
|
+
infos.push(`${(0, path_1.basename)(r.filename)} is marked as alwaysApply but is missing globs in the frontmatter. Consider adding globs to specify which files this rule should apply to, or removing alwaysApply.`);
|
|
65
|
+
}
|
|
66
|
+
if (r.lines > MAX_LINES && hasCorrectExtension) {
|
|
67
|
+
problems.push(`${(0, path_1.basename)(r.filename)} has ${r.lines} lines. Reduce to below ${MAX_LINES} lines to avoid the AI ignoring some rules.`);
|
|
68
|
+
}
|
|
69
|
+
else if (r.lines > WARN_LINES && hasCorrectExtension) {
|
|
70
|
+
warnings.push(`${(0, path_1.basename)(r.filename)} has ${r.lines} lines. Consider reducing below ${WARN_LINES} to avoid the AI ignoring some rules.`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (alwaysCount > 5) {
|
|
74
|
+
warnings.push(`You have ${alwaysCount} rules files marked as alwaysApply. This is the same as adding to ${result.rootRuleFile.filename} but with unsorted precendence. Consider limiting use of alwaysApply.`);
|
|
75
|
+
}
|
|
76
|
+
if (rootFileLines > MAX_LINES) {
|
|
77
|
+
problems.push(`${result.rootRuleFile.filename} has ${rootFileLines} lines. Consider reducing below ${MAX_LINES} to avoid the AI ignoring some rules.`);
|
|
78
|
+
}
|
|
79
|
+
if (lines > MAX_TOTAL_LINES) {
|
|
80
|
+
if (alwaysCount > 0) {
|
|
81
|
+
problems.push(`Your rules files have a total of ${lines} lines that are always applied. Consider removing alwaysApply from ${alwaysList.join(", ")} to reduce the line count below ${MAX_TOTAL_LINES} lines to avoid the AI ignoring some rules.`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
problems.push(`Your rules files have a total of ${lines} lines that are always applied. Consider reducing this below ${MAX_TOTAL_LINES} lines to avoid the AI ignoring some rules.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (problems.length === 0 && warnings.length === 0 && infos.length === 0) {
|
|
88
|
+
console.log(`${green}✓${reset} ${result.rootRuleFile.filename} (${result.rules.length} rules files. ${lines} lines).`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
console.log();
|
|
92
|
+
console.log(`The following recommendations were found with your rules (${result.rootRuleFile.filename}):`);
|
|
93
|
+
outputMessages(problems, warnings, infos);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function outputMessages(problems, warnings, infos) {
|
|
97
|
+
problems.forEach((msg) => console.log(`${red}✗${reset} ${msg}`));
|
|
98
|
+
warnings.forEach((msg) => console.log(`${orange}⚠${reset} ${msg}`));
|
|
99
|
+
infos.forEach((msg) => console.log(`${blue}ℹ${reset} ${msg}`));
|
|
100
|
+
}
|
|
101
|
+
function problem(message) {
|
|
102
|
+
console.log(`${red}✗${reset} ${message}`);
|
|
103
|
+
}
|
|
104
|
+
function warn(message) {
|
|
105
|
+
console.log(`${orange}⚠${reset} ${message}`);
|
|
106
|
+
}
|
|
107
|
+
function info(message) {
|
|
108
|
+
console.log(`${blue}ℹ${reset} ${message}`);
|
|
109
|
+
}
|
|
110
|
+
function hasAgentsMd() {
|
|
111
|
+
return (0, fs_1.existsSync)("agents.md");
|
|
112
|
+
}
|
|
113
|
+
function hasBuilderRulesFile() {
|
|
114
|
+
return (0, fs_1.existsSync)(".builderrules");
|
|
115
|
+
}
|
|
116
|
+
const IGNORE_FILES = [".gitignore", ".builderignore"];
|
|
117
|
+
const IGNORE_PATTERNS = [
|
|
118
|
+
"**/*.snap",
|
|
119
|
+
"**/*.liquid",
|
|
120
|
+
"**/.git",
|
|
121
|
+
"**/dist",
|
|
122
|
+
"**/*.pyc",
|
|
123
|
+
"**/.DS_Store",
|
|
124
|
+
"**/.vscode",
|
|
125
|
+
"**/__pycache__",
|
|
126
|
+
"**/coverage",
|
|
127
|
+
"**/.next",
|
|
128
|
+
"**/coverage",
|
|
129
|
+
"**/example",
|
|
130
|
+
"**/__snapshots__",
|
|
131
|
+
"**/.gradle",
|
|
132
|
+
"**/xcuserdata",
|
|
133
|
+
"**/.build",
|
|
134
|
+
"**/*.zip",
|
|
135
|
+
// Private keys and certificates
|
|
136
|
+
"**/*.pem",
|
|
137
|
+
"**/*.key",
|
|
138
|
+
"**/*.p12",
|
|
139
|
+
"**/*.pfx",
|
|
140
|
+
"**/*.cer",
|
|
141
|
+
"**/*.crt",
|
|
142
|
+
"**/*.der",
|
|
143
|
+
"**/*.p7b",
|
|
144
|
+
"**/*.p7c",
|
|
145
|
+
"**/*.jks",
|
|
146
|
+
"**/*.keystore",
|
|
147
|
+
// SSH keys
|
|
148
|
+
"**/id_rsa",
|
|
149
|
+
"**/id_rsa.*",
|
|
150
|
+
"**/id_dsa",
|
|
151
|
+
"**/id_dsa.*",
|
|
152
|
+
"**/id_ecdsa",
|
|
153
|
+
"**/id_ecdsa.*",
|
|
154
|
+
"**/id_ed25519",
|
|
155
|
+
"**/id_ed25519.*",
|
|
156
|
+
"**/.ssh/**",
|
|
157
|
+
"**/known_hosts",
|
|
158
|
+
"**/authorized_keys",
|
|
159
|
+
// Cloud provider credentials
|
|
160
|
+
"**/.aws/**",
|
|
161
|
+
"**/credentials",
|
|
162
|
+
"**/.gcp/**",
|
|
163
|
+
"**/.azure/**",
|
|
164
|
+
"**/gcloud/**",
|
|
165
|
+
"**/google-credentials.json",
|
|
166
|
+
"**/gcp-key.json",
|
|
167
|
+
"**/service-account*.json",
|
|
168
|
+
// API keys and tokens
|
|
169
|
+
"**/.pypirc",
|
|
170
|
+
"**/.dockercfg",
|
|
171
|
+
"**/.docker/config.json",
|
|
172
|
+
"**/token.json",
|
|
173
|
+
"**/tokens.json",
|
|
174
|
+
"**/secrets.json",
|
|
175
|
+
"**/secret.json",
|
|
176
|
+
"**/api-keys.json",
|
|
177
|
+
"**/apikeys.json",
|
|
178
|
+
// Database files and dumps
|
|
179
|
+
"**/*.sql",
|
|
180
|
+
"**/*.sqlite",
|
|
181
|
+
"**/*.sqlite3",
|
|
182
|
+
"**/*.db",
|
|
183
|
+
"**/*.dump",
|
|
184
|
+
"**/*.bak",
|
|
185
|
+
// Password files
|
|
186
|
+
"**/passwd",
|
|
187
|
+
"**/password",
|
|
188
|
+
"**/passwords",
|
|
189
|
+
"**/.htpasswd",
|
|
190
|
+
"**/shadow",
|
|
191
|
+
// Git credentials
|
|
192
|
+
"**/.git-credentials",
|
|
193
|
+
"**/.gitconfig",
|
|
194
|
+
"**/.netrc",
|
|
195
|
+
// Kubernetes secrets
|
|
196
|
+
"**/kubeconfig",
|
|
197
|
+
"**/.kube/**",
|
|
198
|
+
"**/k8s-secrets.yaml",
|
|
199
|
+
"**/k8s-secrets.yml",
|
|
200
|
+
// Terraform state
|
|
201
|
+
"**/*.tfstate",
|
|
202
|
+
"**/*.tfstate.*",
|
|
203
|
+
"**/.terraform/**",
|
|
204
|
+
// Other sensitive files
|
|
205
|
+
"**/.history",
|
|
206
|
+
"**/.bash_history",
|
|
207
|
+
"**/.zsh_history",
|
|
208
|
+
"**/wallet.dat",
|
|
209
|
+
"**/.gnupg/**",
|
|
210
|
+
"**/private.xml",
|
|
211
|
+
"**/signing.properties",
|
|
212
|
+
"**/*.ovpn",
|
|
213
|
+
"**/wp-config.php",
|
|
214
|
+
"**/config.inc.php",
|
|
215
|
+
"**/local_settings.py",
|
|
216
|
+
"**/database.yml",
|
|
217
|
+
"**/secrets.yml",
|
|
218
|
+
"**/.tox/**",
|
|
219
|
+
"**/firebase-adminsdk*.json",
|
|
220
|
+
"**/firebaseConfig.json",
|
|
221
|
+
"**/google-services.json",
|
|
222
|
+
"**/GoogleService-Info.plist",
|
|
223
|
+
];
|
|
224
|
+
async function getRuleFiles() {
|
|
225
|
+
const currentDir = process.cwd();
|
|
226
|
+
const rulesFolders = [".cursor/rules", ".builder/rules"];
|
|
227
|
+
const rulesFiles = [
|
|
228
|
+
".cursorrules",
|
|
229
|
+
".builderrules",
|
|
230
|
+
".windsurfrules",
|
|
231
|
+
".github/copilot-instructions.md",
|
|
232
|
+
];
|
|
233
|
+
let files = [];
|
|
234
|
+
try {
|
|
235
|
+
for (const rulesFolder of rulesFolders) {
|
|
236
|
+
const projectRulesDir = (0, path_1.join)(currentDir, rulesFolder);
|
|
237
|
+
if ((0, fs_1.existsSync)(projectRulesDir)) {
|
|
238
|
+
files = [
|
|
239
|
+
...findRulesFilesRecursively(projectRulesDir, projectRulesDir),
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return files;
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
console.debug(`Error reading ${currentDir}:`, error);
|
|
247
|
+
}
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
function findRulesFilesRecursively(dir, rulesFolderRoot, ruleRelativePath = "") {
|
|
251
|
+
try {
|
|
252
|
+
if (!(0, fs_1.existsSync)(dir)) {
|
|
253
|
+
return [];
|
|
254
|
+
}
|
|
255
|
+
const entries = (0, fs_1.readdirSync)(dir);
|
|
256
|
+
let rules = [];
|
|
257
|
+
for (const entry of entries) {
|
|
258
|
+
const entryPath = (0, path_1.join)(dir, entry);
|
|
259
|
+
const stat = (0, fs_1.statSync)(entryPath);
|
|
260
|
+
if (!stat)
|
|
261
|
+
continue;
|
|
262
|
+
if (stat.isDirectory()) {
|
|
263
|
+
const newRulePath = ruleRelativePath
|
|
264
|
+
? `${ruleRelativePath}/${entry}`
|
|
265
|
+
: entry;
|
|
266
|
+
rules = [
|
|
267
|
+
...findRulesFilesRecursively(entryPath, rulesFolderRoot, newRulePath),
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
rules.push((0, rule_parse_1.parseCursorRules)(entryPath));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return rules;
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
// ignore directory read errors
|
|
278
|
+
console.warn(`ignoring error reading rules from ${dir}:`, error);
|
|
279
|
+
return [];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function getRootRuleFile() {
|
|
283
|
+
if (hasAgentsMd()) {
|
|
284
|
+
return (0, rule_parse_1.parseCursorRules)("agents.md");
|
|
285
|
+
}
|
|
286
|
+
else if (hasBuilderRulesFile()) {
|
|
287
|
+
return (0, rule_parse_1.parseCursorRules)(".builderrules");
|
|
288
|
+
}
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
const red = "\x1b[31m";
|
|
292
|
+
const orange = "\x1b[33m";
|
|
293
|
+
const blue = "\x1b[34m";
|
|
294
|
+
const green = "\x1b[32m";
|
|
295
|
+
const reset = "\x1b[0m";
|
|
296
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":";;AAmBA,gCAWC;AA9BD,2BAAuD;AACvD,+BAAsC;AACtC,6CAA0E;AAE1E,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,oCAAoC;AAC3D,MAAM,UAAU,GAAG,GAAG,CAAC,CAAC,yBAAyB;AACjD,MAAM,eAAe,GAAG,GAAG,CAAC,CAAC,mCAAmC;AAazD,KAAK,UAAU,UAAU,CAAC,OAAqB;IACpD,MAAM,WAAW,GAAgB;QAC/B,WAAW,EAAE,WAAW,EAAE;QAC1B,mBAAmB,EAAE,mBAAmB,EAAE;QAC1C,KAAK,EAAE,MAAM,YAAY,EAAE;QAC3B,YAAY,EAAE,eAAe,EAAE;KAChC,CAAC;IACF,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,SAAS,CAAC,WAAW,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,SAAS,CAAC,MAAmB;IACpC,M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