pilotignore 0.1.1 → 0.1.2
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/bin/cli.js +28 -4
- package/package.json +8 -1
- package/templates/{pilotignore.js → pilotignore.cjs} +15 -5
- package/templates/pilotignore.json +3 -3
- package/assets/copilot-cli.png +0 -0
- package/assets/copilot-vscode.png +0 -0
- package/assets/logo.svg +0 -8
- package/tests/README.md +0 -1
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ project-root/
|
|
|
91
91
|
│ └── pilotignore.json <-- Tells Copilot to run the firewall from node_modules
|
|
92
92
|
├── .copilot/
|
|
93
93
|
│ └── logs/
|
|
94
|
-
│ └── pilotignore.log <-- Action logs accumulate here (
|
|
94
|
+
│ └── pilotignore.log <-- Action logs accumulate here (automatically added to your .gitignore!)
|
|
95
95
|
├── .pilotignore <-- Add your sensitive files/folders to this blocklist
|
|
96
96
|
└── package.json <-- pilotignore is installed as a devDependency
|
|
97
97
|
|
package/bin/cli.js
CHANGED
|
@@ -34,10 +34,10 @@ async function init() {
|
|
|
34
34
|
|
|
35
35
|
// 3. Copy the actual firewall script
|
|
36
36
|
await fs.copyFile(
|
|
37
|
-
path.join(templatesDir, "pilotignore.
|
|
38
|
-
path.join(githubHooksDir, "pilotignore.
|
|
37
|
+
path.join(templatesDir, "pilotignore.cjs"),
|
|
38
|
+
path.join(githubHooksDir, "pilotignore.cjs"),
|
|
39
39
|
);
|
|
40
|
-
console.log("✅ Copied: .github/hooks/pilotignore.
|
|
40
|
+
console.log("✅ Copied: .github/hooks/pilotignore.cjs");
|
|
41
41
|
|
|
42
42
|
// 4. Create .pilotignore only if it doesn't exist
|
|
43
43
|
const targetPilotignore = path.join(targetDir, ".pilotignore");
|
|
@@ -49,7 +49,31 @@ async function init() {
|
|
|
49
49
|
path.join(templatesDir, "default.pilotignore"),
|
|
50
50
|
targetPilotignore,
|
|
51
51
|
);
|
|
52
|
-
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 5. Add .copilot/ to .gitignore if not already ignored
|
|
55
|
+
const targetGitignore = path.join(targetDir, ".gitignore");
|
|
56
|
+
try {
|
|
57
|
+
let gitignoreContent = "";
|
|
58
|
+
try {
|
|
59
|
+
gitignoreContent = await fs.readFile(targetGitignore, "utf8");
|
|
60
|
+
} catch {
|
|
61
|
+
// .gitignore doesn't exist yet, we will create it
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!gitignoreContent.includes(".copilot")) {
|
|
65
|
+
const separator = gitignoreContent && !gitignoreContent.endsWith("\n") ? "\n" : "";
|
|
66
|
+
await fs.writeFile(
|
|
67
|
+
targetGitignore,
|
|
68
|
+
gitignoreContent + separator + "\n# pilotignore logs\n.copilot/\n",
|
|
69
|
+
"utf8"
|
|
70
|
+
);
|
|
71
|
+
console.log("✅ Added .copilot/ to .gitignore");
|
|
72
|
+
} else {
|
|
73
|
+
console.log("ℹ️ .copilot/ already in .gitignore, skipping.");
|
|
74
|
+
}
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.log("ℹ️ Could not update .gitignore: " + err.message);
|
|
53
77
|
}
|
|
54
78
|
|
|
55
79
|
console.log("\n🚀 pilotignore initialization complete!");
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pilotignore",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Prevent Copilot from reading your secrets using .pilotignore. Works like .gitignore but for GitHub Copilot.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/cli.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"pilotignore": "./bin/cli.js"
|
|
9
9
|
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "node --test tests/"
|
|
12
|
+
},
|
|
10
13
|
"keywords": [
|
|
11
14
|
"copilot",
|
|
12
15
|
"github",
|
|
@@ -19,6 +22,10 @@
|
|
|
19
22
|
"pre-tool-use",
|
|
20
23
|
"copilot-hooks"
|
|
21
24
|
],
|
|
25
|
+
"files": [
|
|
26
|
+
"bin",
|
|
27
|
+
"templates"
|
|
28
|
+
],
|
|
22
29
|
"author": "Valtteri Kerttula",
|
|
23
30
|
"license": "MIT"
|
|
24
31
|
}
|
|
@@ -109,12 +109,22 @@ process.stdin.on("end", () => {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
const isBlocked = candidates.some((candidate) => {
|
|
112
|
-
|
|
112
|
+
const absolutePath = path.resolve(currentCwd, candidate);
|
|
113
|
+
const relative = path.relative(currentCwd, absolutePath).replace(/\\/g, "/");
|
|
114
|
+
|
|
115
|
+
return ignoreRules.some((rule) => {
|
|
116
|
+
const cleanRule = rule.endsWith("/") ? rule.slice(0, -1) : rule;
|
|
117
|
+
|
|
118
|
+
const relLower = relative.toLowerCase();
|
|
119
|
+
const ruleLower = cleanRule.toLowerCase();
|
|
120
|
+
|
|
121
|
+
if (relLower === ruleLower) return true;
|
|
122
|
+
if (relLower.startsWith(ruleLower + "/")) return true;
|
|
123
|
+
if (relLower.endsWith("/" + ruleLower)) return true;
|
|
124
|
+
if (relLower.includes("/" + ruleLower + "/")) return true;
|
|
125
|
+
|
|
113
126
|
return false;
|
|
114
|
-
|
|
115
|
-
return ignoreRules.some(
|
|
116
|
-
(rule) => relative.endsWith(rule) || relative === rule,
|
|
117
|
-
);
|
|
127
|
+
});
|
|
118
128
|
});
|
|
119
129
|
|
|
120
130
|
if (isBlocked) {
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"preToolUse": [
|
|
5
5
|
{
|
|
6
6
|
"type": "command",
|
|
7
|
-
"bash": "node .github/hooks/pilotignore.
|
|
8
|
-
"powershell": "node .github\\hooks\\pilotignore.
|
|
9
|
-
"windows": "node .github\\hooks\\pilotignore.
|
|
7
|
+
"bash": "node .github/hooks/pilotignore.cjs",
|
|
8
|
+
"powershell": "node .github\\hooks\\pilotignore.cjs",
|
|
9
|
+
"windows": "node .github\\hooks\\pilotignore.cjs",
|
|
10
10
|
"cwd": ".",
|
|
11
11
|
"timeoutSec": 5
|
|
12
12
|
}
|
package/assets/copilot-cli.png
DELETED
|
Binary file
|
|
Binary file
|
package/assets/logo.svg
DELETED
package/tests/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Coming
|