@junerver/ignore-agent 1.0.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.
Files changed (2) hide show
  1. package/bin/cli.js +54 -0
  2. package/package.json +11 -0
package/bin/cli.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, statSync } from "node:fs";
4
+ import { join, resolve, dirname } from "node:path";
5
+
6
+ const ENTRIES = ["AGENTS.md", "CLAUDE.md", ".claude/"];
7
+ const SEPARATOR = "# === ignore-agent ===";
8
+
9
+ function findGitRoot(start) {
10
+ let dir = resolve(start);
11
+ while (true) {
12
+ const candidate = join(dir, ".git");
13
+ if (existsSync(candidate)) {
14
+ const st = statSync(candidate);
15
+ if (st.isDirectory()) return dir;
16
+ }
17
+ const parent = dirname(dir);
18
+ if (parent === dir) return null;
19
+ dir = parent;
20
+ }
21
+ }
22
+
23
+ function main() {
24
+ const cwd = process.cwd();
25
+ const root = findGitRoot(cwd);
26
+
27
+ if (!root) {
28
+ console.error("✖ Not inside a git repository.");
29
+ process.exit(1);
30
+ }
31
+
32
+ const infoDir = join(root, ".git", "info");
33
+ const excludePath = join(infoDir, "exclude");
34
+
35
+ if (!existsSync(infoDir)) mkdirSync(infoDir, { recursive: true });
36
+
37
+ let content = "";
38
+ if (existsSync(excludePath)) content = readFileSync(excludePath, "utf8");
39
+
40
+ if (content.includes(SEPARATOR)) {
41
+ console.log("✔ Already configured – skipping.");
42
+ return;
43
+ }
44
+
45
+ const block =
46
+ `\n${SEPARATOR}\n` +
47
+ ENTRIES.map((e) => e).join("\n") +
48
+ `\n${SEPARATOR}\n`;
49
+
50
+ writeFileSync(excludePath, content + block, "utf8");
51
+ console.log(`✔ Injected ${ENTRIES.length} entries into ${excludePath}`);
52
+ }
53
+
54
+ main();
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@junerver/ignore-agent",
3
+ "version": "1.0.0",
4
+ "description": "Inject AGENTS.md, CLAUDE.md and .claude/ into .git/info/exclude",
5
+ "bin": {
6
+ "ignore-agent": "./bin/cli.js"
7
+ },
8
+ "type": "module",
9
+ "keywords": ["git", "ignore", "agent", "cli"],
10
+ "license": "MIT"
11
+ }