aiignore-cli 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.
- package/LICENSE +190 -0
- package/README.ko.md +104 -0
- package/README.md +104 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +930 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 yjcho9317
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.ko.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# aiignore
|
|
2
|
+
|
|
3
|
+
AI 코딩 도구로부터 민감 파일을 보호하는 CLI.
|
|
4
|
+
|
|
5
|
+
AI 도구마다 ignore 방식이 다르다 — `.cursorignore`, `.geminiignore`, `.codeiumignore`, `.claude/settings.json`, `.aiignore` — 포맷도 다르고 알려지지 않은 우회 버그도 있다. `aiignore`는 프로젝트를 스캔하고, 사용 중인 도구를 감지하고, 각 도구에 맞는 설정 파일을 자동 생성한다.
|
|
6
|
+
|
|
7
|
+
## 빠른 시작
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx aiignore init
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
또는 전역 설치:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g aiignore
|
|
17
|
+
aiignore init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Node.js 18 이상.
|
|
21
|
+
|
|
22
|
+
## 왜 직접 안 만들고?
|
|
23
|
+
|
|
24
|
+
만들 수 있다. `.cursorignore` 하나 쓰는 데 30초면 된다. 그런데:
|
|
25
|
+
|
|
26
|
+
- Cursor는 `.cursorignore`, Claude Code는 `settings.json` deny 규칙, Gemini CLI는 `.geminiignore`, JetBrains는 `.aiignore`, Windsurf는 아직 `.codeiumignore`를 쓴다는 걸 알고 있는가?
|
|
27
|
+
- Cursor의 ignore가 "best-effort"이고 CVE가 2개 있다는 것, Gemini의 부정 패턴이 깨져있다는 것, Copilot은 ignore 파일 자체가 없다는 걸 알고 있는가?
|
|
28
|
+
- 새 프로젝트 세팅할 때마다 각 도구의 포맷을 찾아볼 생각인가?
|
|
29
|
+
|
|
30
|
+
`aiignore`가 조사를 대신 해준다. 각 도구의 보안 현황 데이터가 진짜 가치고, CLI는 그걸 적용하는 수단이다.
|
|
31
|
+
|
|
32
|
+
## 명령어
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
aiignore # aiignore init과 동일
|
|
36
|
+
aiignore init # 자동 감지 후 생성
|
|
37
|
+
aiignore init --all # 감지 건너뛰고 전체 도구 대상
|
|
38
|
+
aiignore init --only cursor # 특정 도구만
|
|
39
|
+
aiignore init --only cursor,gemini # 여러 도구 지정 (쉼표 구분)
|
|
40
|
+
aiignore init --append # 기존 파일에 누락 패턴만 추가
|
|
41
|
+
aiignore init --dry-run # 미리보기 (파일 생성 안 함)
|
|
42
|
+
aiignore init --force # 기존 파일 덮어쓰기
|
|
43
|
+
aiignore init -q # 무출력 모드
|
|
44
|
+
|
|
45
|
+
aiignore verify # 보호 상태 테이블
|
|
46
|
+
aiignore verify --ci # 미보호 시 exit 1
|
|
47
|
+
aiignore verify --strict # unreliable 이상이면 exit 1
|
|
48
|
+
aiignore verify --json # JSON 출력
|
|
49
|
+
|
|
50
|
+
aiignore list # 지원 도구 및 별칭 목록
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 지원 도구
|
|
54
|
+
|
|
55
|
+
| 도구 | 생성 파일 | 신뢰도 | 주요 이슈 |
|
|
56
|
+
|------|----------|--------|----------|
|
|
57
|
+
| Cursor | `.cursorignore` | 낮음 | "best-effort", Agent 우회, `@` 참조 우회 |
|
|
58
|
+
| Claude Code | `.claude/settings.json` | 중간 | `Read()` deny가 Bash cat도 차단 (테스트 확인) |
|
|
59
|
+
| Copilot | 가이드 문서만 | 없음 | 개인 개발자용 ignore 파일 없음 |
|
|
60
|
+
| Gemini CLI | `.geminiignore` | 낮음 | 부정 패턴 깨짐, `.env`/`.pem` 자체 차단 정책 있음 |
|
|
61
|
+
| JetBrains AI | `.aiignore` | 높음 | 가장 안정적. 민감 파일명은 AI가 자체 REDACT |
|
|
62
|
+
| Windsurf | `.codeiumignore` | 중간 | 부정 패턴이 `.gitignore` 무시 불가 |
|
|
63
|
+
|
|
64
|
+
## 보호 대상
|
|
65
|
+
|
|
66
|
+
기본 패턴 + `.gitignore`의 보안 관련 항목을 자동 병합:
|
|
67
|
+
|
|
68
|
+
| 분류 | 패턴 |
|
|
69
|
+
|------|------|
|
|
70
|
+
| 환경변수 | `.env`, `.env.*`, `.env.local` |
|
|
71
|
+
| 인증정보 | `credentials.json`, `service-account*.json`, `*secret*`, `token.json` |
|
|
72
|
+
| 키 | `*.pem`, `*.key`, `*.p12`, `*.pfx`, `*.jks` |
|
|
73
|
+
| SSH | `.ssh/`, `id_rsa*`, `id_ed25519*`, `id_ecdsa*` |
|
|
74
|
+
| 클라우드 | `.aws/`, `.gcp/`, `.azure/`, `gcloud/` |
|
|
75
|
+
| 앱 시크릿 | `config/secrets.yml`, `config/master.key`, `vault.json` |
|
|
76
|
+
| 데이터베이스 | `*.sqlite`, `*.db`, `dump.sql` |
|
|
77
|
+
| 인증서 | `*.crt`, `*.cer`, `*.ca-bundle` |
|
|
78
|
+
|
|
79
|
+
## 도구 별칭
|
|
80
|
+
|
|
81
|
+
`--only` 옵션에서 사용 가능 (쉼표로 여러 개 지정):
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
cursor -> Cursor
|
|
85
|
+
claude / claude-code -> Claude Code
|
|
86
|
+
copilot -> GitHub Copilot
|
|
87
|
+
gemini / gemini-cli -> Gemini CLI
|
|
88
|
+
jetbrains / jb -> JetBrains AI
|
|
89
|
+
windsurf / codeium -> Windsurf/Codeium
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`aiignore list`로 전체 목록 확인 가능.
|
|
93
|
+
|
|
94
|
+
## 한계
|
|
95
|
+
|
|
96
|
+
어떤 AI 도구도 파일 접근을 100% 차단하지 못한다. 모든 도구의 공통 약점: Agent/터미널 모드에서 셸 명령으로 ignore 파일을 우회할 수 있다. Copilot은 개인 개발자용 ignore 자체가 없다.
|
|
97
|
+
|
|
98
|
+
이 도구는 방어의 한 레이어다. 프로덕션 시크릿은 시크릿 매니저, pre-commit hook(`gitleaks`, `trufflehog`), 프로젝트 디렉토리 외부 보관을 병행해야 한다.
|
|
99
|
+
|
|
100
|
+
도구별 상세 내용(CVE, 버그, 테스트 결과)은 [AI Coding Tool Security Reference](docs/test-report.md) 참고.
|
|
101
|
+
|
|
102
|
+
## 라이선스
|
|
103
|
+
|
|
104
|
+
Apache-2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# aiignore
|
|
2
|
+
|
|
3
|
+
One command to protect your secrets from all AI coding tools.
|
|
4
|
+
|
|
5
|
+
Every AI tool has a different ignore mechanism — `.cursorignore`, `.geminiignore`, `.codeiumignore`, `.claude/settings.json`, `.aiignore` — each with its own quirks and undocumented bypass bugs. `aiignore` scans your project, detects which tools you use, and generates the right config for each one.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx aiignore init
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or install globally:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g aiignore
|
|
17
|
+
aiignore init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Requires Node.js 18+.
|
|
21
|
+
|
|
22
|
+
## Why not just create the files manually?
|
|
23
|
+
|
|
24
|
+
You could. A `.cursorignore` takes 30 seconds to write. But:
|
|
25
|
+
|
|
26
|
+
- Do you know that Cursor also needs `.cursorignore`, Claude Code needs `settings.json` deny rules, Gemini CLI needs `.geminiignore`, JetBrains needs `.aiignore`, and Windsurf still uses `.codeiumignore`?
|
|
27
|
+
- Do you know that Cursor's ignore is "best-effort" with 2 known CVEs, that Gemini's negation patterns are broken, or that Copilot has no ignore file at all?
|
|
28
|
+
- Do you want to research each tool's format every time you set up a new project?
|
|
29
|
+
|
|
30
|
+
`aiignore` does the research for you. The security data behind each tool is the real value — the CLI just applies it.
|
|
31
|
+
|
|
32
|
+
## Commands
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
aiignore # same as aiignore init
|
|
36
|
+
aiignore init # auto-detect and generate
|
|
37
|
+
aiignore init --all # all tools, skip detection
|
|
38
|
+
aiignore init --only cursor # single tool
|
|
39
|
+
aiignore init --only cursor,gemini # multiple tools (comma-separated)
|
|
40
|
+
aiignore init --append # add missing patterns to existing files
|
|
41
|
+
aiignore init --dry-run # preview only
|
|
42
|
+
aiignore init --force # overwrite existing files
|
|
43
|
+
aiignore init -q # quiet mode (no output)
|
|
44
|
+
|
|
45
|
+
aiignore verify # protection status table
|
|
46
|
+
aiignore verify --ci # exit 1 if unprotected
|
|
47
|
+
aiignore verify --strict # exit 1 if any tool is unreliable
|
|
48
|
+
aiignore verify --json # machine-readable output
|
|
49
|
+
|
|
50
|
+
aiignore list # show supported tools and aliases
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Tool Support
|
|
54
|
+
|
|
55
|
+
| Tool | File Generated | Reliability | Key Issue |
|
|
56
|
+
|------|---------------|-------------|-----------|
|
|
57
|
+
| Cursor | `.cursorignore` | Low | "best-effort", agent bypass, `@` reference bypass |
|
|
58
|
+
| Claude Code | `.claude/settings.json` | Medium | `Read()` deny covers Bash too (tested) |
|
|
59
|
+
| Copilot | guide only | None | no ignore file exists for individual devs |
|
|
60
|
+
| Gemini CLI | `.geminiignore` | Low | negation patterns broken, self-blocks `.env`/`.pem` |
|
|
61
|
+
| JetBrains AI | `.aiignore` | High | most reliable; AI redacts sensitive filenames |
|
|
62
|
+
| Windsurf | `.codeiumignore` | Medium | negation can't override `.gitignore` |
|
|
63
|
+
|
|
64
|
+
## What Gets Protected
|
|
65
|
+
|
|
66
|
+
Patterns are sourced from built-in defaults + security-related entries in your `.gitignore`:
|
|
67
|
+
|
|
68
|
+
| Category | Patterns |
|
|
69
|
+
|----------|----------|
|
|
70
|
+
| Environment | `.env`, `.env.*`, `.env.local` |
|
|
71
|
+
| Credentials | `credentials.json`, `service-account*.json`, `*secret*`, `token.json` |
|
|
72
|
+
| Keys | `*.pem`, `*.key`, `*.p12`, `*.pfx`, `*.jks` |
|
|
73
|
+
| SSH | `.ssh/`, `id_rsa*`, `id_ed25519*`, `id_ecdsa*` |
|
|
74
|
+
| Cloud | `.aws/`, `.gcp/`, `.azure/`, `gcloud/` |
|
|
75
|
+
| App Secrets | `config/secrets.yml`, `config/master.key`, `vault.json` |
|
|
76
|
+
| Database | `*.sqlite`, `*.db`, `dump.sql` |
|
|
77
|
+
| Certificates | `*.crt`, `*.cer`, `*.ca-bundle` |
|
|
78
|
+
|
|
79
|
+
## Tool Aliases
|
|
80
|
+
|
|
81
|
+
`--only` accepts these names (comma-separated):
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
cursor -> Cursor
|
|
85
|
+
claude / claude-code -> Claude Code
|
|
86
|
+
copilot -> GitHub Copilot
|
|
87
|
+
gemini / gemini-cli -> Gemini CLI
|
|
88
|
+
jetbrains / jb -> JetBrains AI
|
|
89
|
+
windsurf / codeium -> Windsurf/Codeium
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Run `aiignore list` to see all tools and aliases.
|
|
93
|
+
|
|
94
|
+
## Limitations
|
|
95
|
+
|
|
96
|
+
No AI tool guarantees 100% file exclusion. All tools share a common weakness: agent/terminal modes can bypass ignore files by running shell commands directly. Copilot has no ignore mechanism at all for individual developers.
|
|
97
|
+
|
|
98
|
+
This tool is one layer of defense. For production secrets, also use a secrets manager, pre-commit hooks (`gitleaks`, `trufflehog`), and keep secrets out of your project directory entirely.
|
|
99
|
+
|
|
100
|
+
For per-tool details (CVEs, known bugs, tested behavior), see [AI Coding Tool Security Reference](docs/test-report.md).
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,930 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/commands/init.ts
|
|
7
|
+
import ora from "ora";
|
|
8
|
+
import chalk2 from "chalk";
|
|
9
|
+
|
|
10
|
+
// src/scanners/secret-detector.ts
|
|
11
|
+
import fg from "fast-glob";
|
|
12
|
+
import fs from "fs";
|
|
13
|
+
import path from "path";
|
|
14
|
+
|
|
15
|
+
// src/data/default-patterns.ts
|
|
16
|
+
var DEFAULT_PATTERNS = {
|
|
17
|
+
secrets: [
|
|
18
|
+
".env",
|
|
19
|
+
".env.*",
|
|
20
|
+
".env.local",
|
|
21
|
+
".env.*.local"
|
|
22
|
+
],
|
|
23
|
+
credentials: [
|
|
24
|
+
"credentials.json",
|
|
25
|
+
"service-account*.json",
|
|
26
|
+
"*secret*",
|
|
27
|
+
"*credential*",
|
|
28
|
+
"token.json"
|
|
29
|
+
],
|
|
30
|
+
keys: [
|
|
31
|
+
"*.pem",
|
|
32
|
+
"*.key",
|
|
33
|
+
"*.p12",
|
|
34
|
+
"*.pfx",
|
|
35
|
+
"*.jks",
|
|
36
|
+
"*.keystore"
|
|
37
|
+
],
|
|
38
|
+
ssh: [
|
|
39
|
+
".ssh/",
|
|
40
|
+
"id_rsa*",
|
|
41
|
+
"id_ed25519*",
|
|
42
|
+
"id_ecdsa*",
|
|
43
|
+
"known_hosts"
|
|
44
|
+
],
|
|
45
|
+
cloud: [
|
|
46
|
+
".aws/",
|
|
47
|
+
".gcp/",
|
|
48
|
+
".azure/",
|
|
49
|
+
"gcloud/"
|
|
50
|
+
],
|
|
51
|
+
app: [
|
|
52
|
+
"config/secrets.yml",
|
|
53
|
+
"config/master.key",
|
|
54
|
+
".secret",
|
|
55
|
+
"vault.json",
|
|
56
|
+
"*.secrets"
|
|
57
|
+
],
|
|
58
|
+
database: [
|
|
59
|
+
"*.sqlite",
|
|
60
|
+
"*.db",
|
|
61
|
+
"dump.sql",
|
|
62
|
+
"*.dump"
|
|
63
|
+
],
|
|
64
|
+
certs: [
|
|
65
|
+
"*.crt",
|
|
66
|
+
"*.cer",
|
|
67
|
+
"*.ca-bundle"
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
function getAllPatterns() {
|
|
71
|
+
return Object.values(DEFAULT_PATTERNS).flat();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/scanners/secret-detector.ts
|
|
75
|
+
async function scanForSecrets(projectDir) {
|
|
76
|
+
const defaultPatterns = getAllPatterns();
|
|
77
|
+
const foundFiles = [];
|
|
78
|
+
for (const pattern of defaultPatterns) {
|
|
79
|
+
const matches = await fg(pattern, {
|
|
80
|
+
cwd: projectDir,
|
|
81
|
+
dot: true,
|
|
82
|
+
onlyFiles: true,
|
|
83
|
+
ignore: ["node_modules/**", ".git/**"],
|
|
84
|
+
suppressErrors: true
|
|
85
|
+
});
|
|
86
|
+
foundFiles.push(...matches);
|
|
87
|
+
}
|
|
88
|
+
const gitignorePatterns = readGitignorePatterns(projectDir);
|
|
89
|
+
const allPatterns = [.../* @__PURE__ */ new Set([...defaultPatterns, ...gitignorePatterns])];
|
|
90
|
+
return {
|
|
91
|
+
foundFiles: [...new Set(foundFiles)],
|
|
92
|
+
patterns: allPatterns
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function readGitignorePatterns(projectDir) {
|
|
96
|
+
const gitignorePath = path.join(projectDir, ".gitignore");
|
|
97
|
+
if (!fs.existsSync(gitignorePath)) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const content = fs.readFileSync(gitignorePath, "utf-8");
|
|
101
|
+
const securityRelated = [];
|
|
102
|
+
for (const line of content.split("\n")) {
|
|
103
|
+
const trimmed = line.trim();
|
|
104
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
105
|
+
if (isSecurityPattern(trimmed)) {
|
|
106
|
+
securityRelated.push(trimmed);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return securityRelated;
|
|
110
|
+
}
|
|
111
|
+
function isSecurityPattern(pattern) {
|
|
112
|
+
const securityKeywords = [
|
|
113
|
+
".env",
|
|
114
|
+
".pem",
|
|
115
|
+
".key",
|
|
116
|
+
".p12",
|
|
117
|
+
".pfx",
|
|
118
|
+
".jks",
|
|
119
|
+
"secret",
|
|
120
|
+
"credential",
|
|
121
|
+
"token",
|
|
122
|
+
"password",
|
|
123
|
+
".ssh",
|
|
124
|
+
".aws",
|
|
125
|
+
".gcp",
|
|
126
|
+
".azure",
|
|
127
|
+
"id_rsa",
|
|
128
|
+
"id_ed25519",
|
|
129
|
+
"id_ecdsa",
|
|
130
|
+
"vault",
|
|
131
|
+
"master.key",
|
|
132
|
+
".keystore"
|
|
133
|
+
];
|
|
134
|
+
const lower = pattern.toLowerCase();
|
|
135
|
+
return securityKeywords.some((kw) => lower.includes(kw));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/scanners/tool-detector.ts
|
|
139
|
+
import fs2 from "fs";
|
|
140
|
+
import path2 from "path";
|
|
141
|
+
var TOOL_SIGNALS = {
|
|
142
|
+
cursor: {
|
|
143
|
+
name: "Cursor",
|
|
144
|
+
paths: [".cursor/", ".cursorignore", ".cursorrules"]
|
|
145
|
+
},
|
|
146
|
+
claudeCode: {
|
|
147
|
+
name: "Claude Code",
|
|
148
|
+
paths: [".claude/", ".claude/settings.json", "CLAUDE.md"]
|
|
149
|
+
},
|
|
150
|
+
copilot: {
|
|
151
|
+
name: "GitHub Copilot",
|
|
152
|
+
paths: [".github/copilot-instructions.md"]
|
|
153
|
+
},
|
|
154
|
+
geminiCli: {
|
|
155
|
+
name: "Gemini CLI",
|
|
156
|
+
paths: [".geminiignore", ".gemini/"]
|
|
157
|
+
},
|
|
158
|
+
jetbrains: {
|
|
159
|
+
name: "JetBrains AI",
|
|
160
|
+
paths: [".idea/", ".aiignore", ".aiexclude"]
|
|
161
|
+
},
|
|
162
|
+
windsurf: {
|
|
163
|
+
name: "Windsurf/Codeium",
|
|
164
|
+
paths: [".codeiumignore", ".windsurf/"]
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
function detectTools(projectDir) {
|
|
168
|
+
const results = [];
|
|
169
|
+
for (const [id, config] of Object.entries(TOOL_SIGNALS)) {
|
|
170
|
+
const foundSignals = [];
|
|
171
|
+
for (const signalPath of config.paths) {
|
|
172
|
+
const fullPath = path2.join(projectDir, signalPath);
|
|
173
|
+
if (fs2.existsSync(fullPath)) {
|
|
174
|
+
foundSignals.push(signalPath);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
results.push({
|
|
178
|
+
name: config.name,
|
|
179
|
+
id,
|
|
180
|
+
detected: foundSignals.length > 0,
|
|
181
|
+
signals: foundSignals
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return results;
|
|
185
|
+
}
|
|
186
|
+
var ALL_TOOL_IDS = Object.keys(TOOL_SIGNALS);
|
|
187
|
+
|
|
188
|
+
// src/generators/cursorignore.ts
|
|
189
|
+
import fs3 from "fs";
|
|
190
|
+
import path3 from "path";
|
|
191
|
+
function generateCursorignore(projectDir, patterns, mode) {
|
|
192
|
+
const filePath = path3.join(projectDir, ".cursorignore");
|
|
193
|
+
const exists = fs3.existsSync(filePath);
|
|
194
|
+
if (exists && mode === "default") {
|
|
195
|
+
return skipResult("cursor", "Cursor", ".cursorignore");
|
|
196
|
+
}
|
|
197
|
+
if (exists && mode === "append") {
|
|
198
|
+
const added = appendPatterns(filePath, patterns);
|
|
199
|
+
return {
|
|
200
|
+
toolId: "cursor",
|
|
201
|
+
toolName: "Cursor",
|
|
202
|
+
filePath: ".cursorignore",
|
|
203
|
+
created: added > 0,
|
|
204
|
+
skipped: added === 0,
|
|
205
|
+
message: added > 0 ? `${added} pattern(s) added` : "No new patterns to add"
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const content = buildIgnoreFile("Cursor", ".cursorignore", patterns, [
|
|
209
|
+
'NOTE: Cursor treats .cursorignore as "best-effort" \u2014 not guaranteed.',
|
|
210
|
+
"CVE-2025-59944: case-sensitivity bypass known.",
|
|
211
|
+
"CVE-2025-64110: agent rewrite bypass known."
|
|
212
|
+
]);
|
|
213
|
+
fs3.writeFileSync(filePath, content, "utf-8");
|
|
214
|
+
return {
|
|
215
|
+
toolId: "cursor",
|
|
216
|
+
toolName: "Cursor",
|
|
217
|
+
filePath: ".cursorignore",
|
|
218
|
+
created: true,
|
|
219
|
+
skipped: false,
|
|
220
|
+
message: '"best-effort" \u2014 not guaranteed'
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function buildIgnoreFile(toolName, fileName, patterns, warnings = []) {
|
|
224
|
+
const lines = [
|
|
225
|
+
`# ${fileName}`,
|
|
226
|
+
`# Generated by aiignore \u2014 https://github.com/yjcho9317/aiignore`,
|
|
227
|
+
`# Protects sensitive files from ${toolName}`,
|
|
228
|
+
"#"
|
|
229
|
+
];
|
|
230
|
+
if (warnings.length > 0) {
|
|
231
|
+
for (const warn of warnings) {
|
|
232
|
+
lines.push(`# WARNING: ${warn}`);
|
|
233
|
+
}
|
|
234
|
+
lines.push("#");
|
|
235
|
+
}
|
|
236
|
+
lines.push("");
|
|
237
|
+
lines.push("# Secrets & Environment");
|
|
238
|
+
lines.push(...patterns.filter((p) => p.includes(".env") || p.includes("secret") || p.includes("credential") || p.includes("token")));
|
|
239
|
+
lines.push("");
|
|
240
|
+
lines.push("# Keys & Certificates");
|
|
241
|
+
lines.push(...patterns.filter(
|
|
242
|
+
(p) => p.includes(".pem") || p.includes(".key") || p.includes(".p12") || p.includes(".pfx") || p.includes(".jks") || p.includes(".keystore") || p.includes(".crt") || p.includes(".cer") || p.includes(".ca-bundle")
|
|
243
|
+
));
|
|
244
|
+
lines.push("");
|
|
245
|
+
lines.push("# SSH");
|
|
246
|
+
lines.push(...patterns.filter(
|
|
247
|
+
(p) => p.includes("ssh") || p.includes("id_rsa") || p.includes("id_ed25519") || p.includes("id_ecdsa") || p.includes("known_hosts")
|
|
248
|
+
));
|
|
249
|
+
lines.push("");
|
|
250
|
+
lines.push("# Cloud Providers");
|
|
251
|
+
lines.push(...patterns.filter(
|
|
252
|
+
(p) => p.includes(".aws") || p.includes(".gcp") || p.includes(".azure") || p.includes("gcloud")
|
|
253
|
+
));
|
|
254
|
+
lines.push("");
|
|
255
|
+
lines.push("# Application Secrets & Database");
|
|
256
|
+
lines.push(...patterns.filter(
|
|
257
|
+
(p) => p.includes("vault") || p.includes("master.key") || p.includes(".secret") || p.includes(".sqlite") || p.includes(".db") || p.includes("dump.sql") || p.includes(".dump") || p.includes("secrets.yml")
|
|
258
|
+
));
|
|
259
|
+
lines.push("");
|
|
260
|
+
return lines.join("\n");
|
|
261
|
+
}
|
|
262
|
+
function appendPatterns(filePath, patterns) {
|
|
263
|
+
const existing = fs3.readFileSync(filePath, "utf-8");
|
|
264
|
+
const newPatterns = patterns.filter((p) => !existing.includes(p));
|
|
265
|
+
if (newPatterns.length === 0) return 0;
|
|
266
|
+
const addition = "\n# Added by aiignore\n" + newPatterns.join("\n") + "\n";
|
|
267
|
+
fs3.appendFileSync(filePath, addition, "utf-8");
|
|
268
|
+
return newPatterns.length;
|
|
269
|
+
}
|
|
270
|
+
function skipResult(toolId, toolName, filePath) {
|
|
271
|
+
return {
|
|
272
|
+
toolId,
|
|
273
|
+
toolName,
|
|
274
|
+
filePath,
|
|
275
|
+
created: false,
|
|
276
|
+
skipped: true,
|
|
277
|
+
message: "Already exists (use --force to overwrite or --append to add patterns)"
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/generators/claude-settings.ts
|
|
282
|
+
import fs4 from "fs";
|
|
283
|
+
import path4 from "path";
|
|
284
|
+
|
|
285
|
+
// src/utils/logger.ts
|
|
286
|
+
import chalk from "chalk";
|
|
287
|
+
var logger = {
|
|
288
|
+
info(msg) {
|
|
289
|
+
console.log(chalk.blue("i"), msg);
|
|
290
|
+
},
|
|
291
|
+
success(msg) {
|
|
292
|
+
console.log(chalk.green("+"), msg);
|
|
293
|
+
},
|
|
294
|
+
warn(msg) {
|
|
295
|
+
console.log(chalk.yellow("!"), msg);
|
|
296
|
+
},
|
|
297
|
+
error(msg) {
|
|
298
|
+
console.log(chalk.red("x"), msg);
|
|
299
|
+
},
|
|
300
|
+
dim(msg) {
|
|
301
|
+
console.log(chalk.dim(msg));
|
|
302
|
+
},
|
|
303
|
+
heading(msg) {
|
|
304
|
+
console.log();
|
|
305
|
+
console.log(chalk.bold(msg));
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// src/generators/claude-settings.ts
|
|
310
|
+
function generateClaudeSettings(projectDir, patterns, mode) {
|
|
311
|
+
const settingsDir = path4.join(projectDir, ".claude");
|
|
312
|
+
const settingsPath = path4.join(settingsDir, "settings.json");
|
|
313
|
+
let existing = {};
|
|
314
|
+
if (fs4.existsSync(settingsPath)) {
|
|
315
|
+
try {
|
|
316
|
+
existing = JSON.parse(fs4.readFileSync(settingsPath, "utf-8"));
|
|
317
|
+
} catch {
|
|
318
|
+
logger.warn("Existing .claude/settings.json has invalid JSON \u2014 creating new");
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const existingPerms = existing.permissions ?? {};
|
|
322
|
+
const existingDeny = existingPerms.deny ?? [];
|
|
323
|
+
const aiignorePatterns = new Set(patterns.map((p) => `Read(${p})`));
|
|
324
|
+
const userDeny = mode === "force" ? existingDeny.filter((d) => !isAiignorePattern(d)) : existingDeny;
|
|
325
|
+
const newDeny = [.../* @__PURE__ */ new Set([
|
|
326
|
+
...userDeny,
|
|
327
|
+
...aiignorePatterns
|
|
328
|
+
])];
|
|
329
|
+
if (mode === "append" && newDeny.length === existingDeny.length) {
|
|
330
|
+
return {
|
|
331
|
+
toolId: "claudeCode",
|
|
332
|
+
toolName: "Claude Code",
|
|
333
|
+
filePath: ".claude/settings.json",
|
|
334
|
+
created: false,
|
|
335
|
+
skipped: true,
|
|
336
|
+
message: "No new patterns to add"
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
const merged = {
|
|
340
|
+
...existing,
|
|
341
|
+
permissions: {
|
|
342
|
+
...existingPerms,
|
|
343
|
+
deny: newDeny
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
if (!fs4.existsSync(settingsDir)) {
|
|
347
|
+
fs4.mkdirSync(settingsDir, { recursive: true });
|
|
348
|
+
}
|
|
349
|
+
fs4.writeFileSync(settingsPath, JSON.stringify(merged, null, 2) + "\n", "utf-8");
|
|
350
|
+
return {
|
|
351
|
+
toolId: "claudeCode",
|
|
352
|
+
toolName: "Claude Code",
|
|
353
|
+
filePath: ".claude/settings.json",
|
|
354
|
+
created: true,
|
|
355
|
+
skipped: false,
|
|
356
|
+
message: "Deny patterns added \u2014 hooks recommended for stronger protection"
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function isAiignorePattern(pattern) {
|
|
360
|
+
return pattern.startsWith("Read(") || pattern.startsWith("Bash(cat:") || pattern.startsWith("Bash(cat ");
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// src/generators/copilot-guide.ts
|
|
364
|
+
import fs5 from "fs";
|
|
365
|
+
import path5 from "path";
|
|
366
|
+
var GUIDE_CONTENT = `# Copilot Security Guide
|
|
367
|
+
|
|
368
|
+
> Generated by [aiignore](https://github.com/yjcho9317/aiignore)
|
|
369
|
+
|
|
370
|
+
## No File-Level Protection Available
|
|
371
|
+
|
|
372
|
+
GitHub Copilot does **not** have a \`.copilotignore\` file or any file-level
|
|
373
|
+
ignore mechanism for individual developers.
|
|
374
|
+
|
|
375
|
+
### What exists (but doesn't help individual devs):
|
|
376
|
+
|
|
377
|
+
- **Content Exclusion**: Organization/Enterprise only setting
|
|
378
|
+
- Configured by org admins in GitHub Settings
|
|
379
|
+
- Not available for personal accounts or free plans
|
|
380
|
+
- Does NOT work in Agent mode, Edit mode, or Copilot CLI
|
|
381
|
+
|
|
382
|
+
### Recommended alternatives:
|
|
383
|
+
|
|
384
|
+
1. **Keep secrets outside your project directory**
|
|
385
|
+
- Use environment variables from your shell profile
|
|
386
|
+
- Use a secrets manager (1Password CLI, Vault, etc.)
|
|
387
|
+
|
|
388
|
+
2. **Use .gitignore** (partial protection)
|
|
389
|
+
- Copilot may still read gitignored files for context
|
|
390
|
+
- But it reduces the chance of secrets in suggestions
|
|
391
|
+
|
|
392
|
+
3. **If you have Business/Enterprise plan**:
|
|
393
|
+
- Ask your org admin to configure Content Exclusion
|
|
394
|
+
- Settings -> Copilot -> Content exclusion -> Add paths
|
|
395
|
+
|
|
396
|
+
### References:
|
|
397
|
+
- [GitHub Docs: Content Exclusion](https://docs.github.com/en/copilot/managing-copilot/configuring-content-exclusions)
|
|
398
|
+
`;
|
|
399
|
+
function generateCopilotGuide(projectDir, _patterns, mode) {
|
|
400
|
+
const dirPath = path5.join(projectDir, ".github");
|
|
401
|
+
const filePath = path5.join(dirPath, "copilot-security-guide.md");
|
|
402
|
+
if (fs5.existsSync(filePath) && mode !== "force") {
|
|
403
|
+
return {
|
|
404
|
+
toolId: "copilot",
|
|
405
|
+
toolName: "GitHub Copilot",
|
|
406
|
+
filePath: ".github/copilot-security-guide.md",
|
|
407
|
+
created: false,
|
|
408
|
+
skipped: true,
|
|
409
|
+
message: "Already exists (use --force to overwrite)"
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
if (!fs5.existsSync(dirPath)) {
|
|
413
|
+
fs5.mkdirSync(dirPath, { recursive: true });
|
|
414
|
+
}
|
|
415
|
+
fs5.writeFileSync(filePath, GUIDE_CONTENT, "utf-8");
|
|
416
|
+
return {
|
|
417
|
+
toolId: "copilot",
|
|
418
|
+
toolName: "GitHub Copilot",
|
|
419
|
+
filePath: ".github/copilot-security-guide.md",
|
|
420
|
+
created: true,
|
|
421
|
+
skipped: false,
|
|
422
|
+
message: "No file-level protection \u2014 guide created instead"
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/generators/geminiignore.ts
|
|
427
|
+
import fs6 from "fs";
|
|
428
|
+
import path6 from "path";
|
|
429
|
+
function generateGeminiignore(projectDir, patterns, mode) {
|
|
430
|
+
const filePath = path6.join(projectDir, ".geminiignore");
|
|
431
|
+
const exists = fs6.existsSync(filePath);
|
|
432
|
+
if (exists && mode === "default") {
|
|
433
|
+
return skipResult("geminiCli", "Gemini CLI", ".geminiignore");
|
|
434
|
+
}
|
|
435
|
+
if (exists && mode === "append") {
|
|
436
|
+
const added = appendPatterns(filePath, patterns);
|
|
437
|
+
return {
|
|
438
|
+
toolId: "geminiCli",
|
|
439
|
+
toolName: "Gemini CLI",
|
|
440
|
+
filePath: ".geminiignore",
|
|
441
|
+
created: added > 0,
|
|
442
|
+
skipped: added === 0,
|
|
443
|
+
message: added > 0 ? `${added} pattern(s) added` : "No new patterns to add"
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
const content = buildIgnoreFile("Gemini CLI", ".geminiignore", patterns, [
|
|
447
|
+
"NOTE: Negation patterns (!) are broken in Gemini CLI.",
|
|
448
|
+
"list_dir may ignore .geminiignore in Antigravity mode."
|
|
449
|
+
]);
|
|
450
|
+
fs6.writeFileSync(filePath, content, "utf-8");
|
|
451
|
+
return {
|
|
452
|
+
toolId: "geminiCli",
|
|
453
|
+
toolName: "Gemini CLI",
|
|
454
|
+
filePath: ".geminiignore",
|
|
455
|
+
created: true,
|
|
456
|
+
skipped: false,
|
|
457
|
+
message: "Negation patterns broken"
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// src/generators/codeiumignore.ts
|
|
462
|
+
import fs7 from "fs";
|
|
463
|
+
import path7 from "path";
|
|
464
|
+
function generateCodeiumignore(projectDir, patterns, mode) {
|
|
465
|
+
const filePath = path7.join(projectDir, ".codeiumignore");
|
|
466
|
+
const exists = fs7.existsSync(filePath);
|
|
467
|
+
if (exists && mode === "default") {
|
|
468
|
+
return skipResult("windsurf", "Windsurf/Codeium", ".codeiumignore");
|
|
469
|
+
}
|
|
470
|
+
if (exists && mode === "append") {
|
|
471
|
+
const added = appendPatterns(filePath, patterns);
|
|
472
|
+
return {
|
|
473
|
+
toolId: "windsurf",
|
|
474
|
+
toolName: "Windsurf/Codeium",
|
|
475
|
+
filePath: ".codeiumignore",
|
|
476
|
+
created: added > 0,
|
|
477
|
+
skipped: added === 0,
|
|
478
|
+
message: added > 0 ? `${added} pattern(s) added` : "No new patterns to add"
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
const content = buildIgnoreFile("Windsurf/Codeium", ".codeiumignore", patterns, [
|
|
482
|
+
"NOTE: Negation (!) cannot override .gitignore exclusions (Issue #133).",
|
|
483
|
+
"Still uses .codeiumignore (not .windsurfignore)."
|
|
484
|
+
]);
|
|
485
|
+
fs7.writeFileSync(filePath, content, "utf-8");
|
|
486
|
+
return {
|
|
487
|
+
toolId: "windsurf",
|
|
488
|
+
toolName: "Windsurf/Codeium",
|
|
489
|
+
filePath: ".codeiumignore",
|
|
490
|
+
created: true,
|
|
491
|
+
skipped: false,
|
|
492
|
+
message: "Negation cannot override .gitignore"
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// src/generators/aiignore-jb.ts
|
|
497
|
+
import fs8 from "fs";
|
|
498
|
+
import path8 from "path";
|
|
499
|
+
function generateAiignoreJB(projectDir, patterns, mode) {
|
|
500
|
+
const filePath = path8.join(projectDir, ".aiignore");
|
|
501
|
+
const exists = fs8.existsSync(filePath);
|
|
502
|
+
if (exists && mode === "default") {
|
|
503
|
+
return skipResult("jetbrains", "JetBrains AI", ".aiignore");
|
|
504
|
+
}
|
|
505
|
+
if (exists && mode === "append") {
|
|
506
|
+
const added = appendPatterns(filePath, patterns);
|
|
507
|
+
return {
|
|
508
|
+
toolId: "jetbrains",
|
|
509
|
+
toolName: "JetBrains AI",
|
|
510
|
+
filePath: ".aiignore",
|
|
511
|
+
created: added > 0,
|
|
512
|
+
skipped: added === 0,
|
|
513
|
+
message: added > 0 ? `${added} pattern(s) added` : "No new patterns to add"
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
const content = buildIgnoreFile("JetBrains AI", ".aiignore", patterns, [
|
|
517
|
+
"JetBrains native format. Also supports .aiexclude for compatibility."
|
|
518
|
+
]);
|
|
519
|
+
fs8.writeFileSync(filePath, content, "utf-8");
|
|
520
|
+
return {
|
|
521
|
+
toolId: "jetbrains",
|
|
522
|
+
toolName: "JetBrains AI",
|
|
523
|
+
filePath: ".aiignore",
|
|
524
|
+
created: true,
|
|
525
|
+
skipped: false,
|
|
526
|
+
message: "Most reliable ignore mechanism"
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// src/generators/index.ts
|
|
531
|
+
var generators = {
|
|
532
|
+
cursor: generateCursorignore,
|
|
533
|
+
claudeCode: generateClaudeSettings,
|
|
534
|
+
copilot: generateCopilotGuide,
|
|
535
|
+
geminiCli: generateGeminiignore,
|
|
536
|
+
jetbrains: generateAiignoreJB,
|
|
537
|
+
windsurf: generateCodeiumignore
|
|
538
|
+
};
|
|
539
|
+
function runGenerators(projectDir, patterns, toolIds, mode) {
|
|
540
|
+
const results = [];
|
|
541
|
+
for (const toolId of toolIds) {
|
|
542
|
+
const generator = generators[toolId];
|
|
543
|
+
if (generator) {
|
|
544
|
+
results.push(generator(projectDir, patterns, mode));
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return results;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// src/data/tool-status.ts
|
|
551
|
+
var TOOL_STATUS = {
|
|
552
|
+
cursor: {
|
|
553
|
+
tool: "Cursor",
|
|
554
|
+
ignoreFile: ".cursorignore",
|
|
555
|
+
reliability: "low",
|
|
556
|
+
knownLimitations: [
|
|
557
|
+
'"best-effort" \u2014 not guaranteed (official docs)',
|
|
558
|
+
"CVE-2025-59944: case-sensitivity bypass",
|
|
559
|
+
"CVE-2025-64110: agent rewrite bypass",
|
|
560
|
+
"Agent mode can bypass via terminal commands",
|
|
561
|
+
"@file reference ignores .cursorignore (user can attach protected files)"
|
|
562
|
+
],
|
|
563
|
+
recommendedApproach: ".cursorignore file with gitignore syntax",
|
|
564
|
+
source: "https://docs.cursor.com/context/ignore-files"
|
|
565
|
+
},
|
|
566
|
+
claudeCode: {
|
|
567
|
+
tool: "Claude Code",
|
|
568
|
+
ignoreFile: ".claude/settings.json",
|
|
569
|
+
reliability: "medium",
|
|
570
|
+
knownLimitations: [
|
|
571
|
+
"permissions.deny has enforcement bugs (#6699, #6631, #8961)",
|
|
572
|
+
"Read() deny also blocks Bash cat (tested) \u2014 separate Bash deny not needed",
|
|
573
|
+
".claudeignore exists but only blocks Read tool"
|
|
574
|
+
],
|
|
575
|
+
recommendedApproach: "settings.json deny patterns + PreToolUse hooks",
|
|
576
|
+
source: "https://code.claude.com/docs/en/settings"
|
|
577
|
+
},
|
|
578
|
+
copilot: {
|
|
579
|
+
tool: "GitHub Copilot",
|
|
580
|
+
ignoreFile: "none",
|
|
581
|
+
reliability: "none",
|
|
582
|
+
knownLimitations: [
|
|
583
|
+
".copilotignore does NOT exist",
|
|
584
|
+
"Content Exclusion is Business/Enterprise only",
|
|
585
|
+
"Not supported in Agent, Edit, or CLI modes",
|
|
586
|
+
"Individual developers have NO file-level protection"
|
|
587
|
+
],
|
|
588
|
+
recommendedApproach: "No file-level protection available for individual developers",
|
|
589
|
+
source: "https://docs.github.com/en/copilot/managing-copilot/configuring-content-exclusions"
|
|
590
|
+
},
|
|
591
|
+
geminiCli: {
|
|
592
|
+
tool: "Gemini CLI",
|
|
593
|
+
ignoreFile: ".geminiignore",
|
|
594
|
+
reliability: "low",
|
|
595
|
+
knownLimitations: [
|
|
596
|
+
"Negation patterns (!) are broken",
|
|
597
|
+
"list_dir ignores .geminiignore in Antigravity mode",
|
|
598
|
+
".aiignore/.aiexclude NOT supported (only Gemini Code Assist IDE)",
|
|
599
|
+
"Gemini CLI self-blocks .env, .pem, .env.local regardless of .geminiignore (built-in policy)"
|
|
600
|
+
],
|
|
601
|
+
recommendedApproach: ".geminiignore file with gitignore syntax (avoid negation)",
|
|
602
|
+
source: "https://github.com/google-gemini/gemini-cli"
|
|
603
|
+
},
|
|
604
|
+
jetbrains: {
|
|
605
|
+
tool: "JetBrains AI",
|
|
606
|
+
ignoreFile: ".aiignore",
|
|
607
|
+
reliability: "high",
|
|
608
|
+
knownLimitations: [
|
|
609
|
+
"Not 100% guaranteed (YouTrack LLM-17544)",
|
|
610
|
+
"Claude Agent inside JetBrains may ignore .aiignore (LLM-20693)",
|
|
611
|
+
"Sensitive-looking content (.env, .pem) may show REDACT instead of full block (AI policy overlap)"
|
|
612
|
+
],
|
|
613
|
+
recommendedApproach: ".aiignore file (native) with gitignore syntax",
|
|
614
|
+
source: "https://www.jetbrains.com/help/ai-assistant/disable-ai-assistant.html"
|
|
615
|
+
},
|
|
616
|
+
windsurf: {
|
|
617
|
+
tool: "Windsurf/Codeium",
|
|
618
|
+
ignoreFile: ".codeiumignore",
|
|
619
|
+
reliability: "medium",
|
|
620
|
+
knownLimitations: [
|
|
621
|
+
"Negation (!) cannot override .gitignore exclusions (Issue #133)",
|
|
622
|
+
'"Allow Cascade to access .gitignore files" toggle does not work (Issue #225)',
|
|
623
|
+
"Autocomplete blocking is indirect (via indexing), not explicitly documented",
|
|
624
|
+
"Still uses .codeiumignore (not .windsurfignore)"
|
|
625
|
+
],
|
|
626
|
+
recommendedApproach: ".codeiumignore file with gitignore syntax (avoid negation)",
|
|
627
|
+
source: "https://docs.windsurf.com/context-awareness/windsurf-ignore"
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
// src/utils/aliases.ts
|
|
632
|
+
var TOOL_ALIASES = {
|
|
633
|
+
cursor: "cursor",
|
|
634
|
+
claude: "claudeCode",
|
|
635
|
+
"claude-code": "claudeCode",
|
|
636
|
+
claudecode: "claudeCode",
|
|
637
|
+
copilot: "copilot",
|
|
638
|
+
gemini: "geminiCli",
|
|
639
|
+
"gemini-cli": "geminiCli",
|
|
640
|
+
jetbrains: "jetbrains",
|
|
641
|
+
jb: "jetbrains",
|
|
642
|
+
windsurf: "windsurf",
|
|
643
|
+
codeium: "windsurf"
|
|
644
|
+
};
|
|
645
|
+
function resolveToolId(input) {
|
|
646
|
+
return TOOL_ALIASES[input.toLowerCase()];
|
|
647
|
+
}
|
|
648
|
+
function resolveToolIds(input) {
|
|
649
|
+
const parts = input.split(",").map((s) => s.trim()).filter(Boolean);
|
|
650
|
+
const ids = [];
|
|
651
|
+
const invalid = [];
|
|
652
|
+
for (const part of parts) {
|
|
653
|
+
const resolved = resolveToolId(part);
|
|
654
|
+
if (resolved) {
|
|
655
|
+
ids.push(resolved);
|
|
656
|
+
} else {
|
|
657
|
+
invalid.push(part);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
return { ids: [...new Set(ids)], invalid };
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// src/commands/init.ts
|
|
664
|
+
async function initCommand(options) {
|
|
665
|
+
const projectDir = process.cwd();
|
|
666
|
+
const log = options.quiet ? { dim: noop, info: noop, warn: noop, success: noop, heading: noop } : logger;
|
|
667
|
+
const spinner = options.quiet ? null : ora("Scanning project for sensitive files...").start();
|
|
668
|
+
const scanResult = await scanForSecrets(projectDir);
|
|
669
|
+
spinner?.succeed(
|
|
670
|
+
`Found ${scanResult.foundFiles.length} sensitive file(s), ${scanResult.patterns.length} patterns`
|
|
671
|
+
);
|
|
672
|
+
if (scanResult.foundFiles.length > 0 && !options.quiet) {
|
|
673
|
+
logger.dim(" Found: " + scanResult.foundFiles.slice(0, 5).join(", ") + (scanResult.foundFiles.length > 5 ? ` (+${scanResult.foundFiles.length - 5} more)` : ""));
|
|
674
|
+
}
|
|
675
|
+
const spinnerTools = options.quiet ? null : ora("Detecting AI coding tools...").start();
|
|
676
|
+
const detectedTools = detectTools(projectDir);
|
|
677
|
+
const activeTools = detectedTools.filter((t) => t.detected);
|
|
678
|
+
if (options.all) {
|
|
679
|
+
spinnerTools?.succeed(`Using all ${ALL_TOOL_IDS.length} supported tools`);
|
|
680
|
+
} else if (options.only) {
|
|
681
|
+
const { ids, invalid } = resolveToolIds(options.only);
|
|
682
|
+
if (invalid.length > 0) {
|
|
683
|
+
spinnerTools?.fail(`Unknown tool(s): ${invalid.join(", ")}`);
|
|
684
|
+
logger.info("Run `aiignore list` to see available tools.");
|
|
685
|
+
process.exit(1);
|
|
686
|
+
}
|
|
687
|
+
spinnerTools?.succeed(`Targeting: ${ids.length} tool(s)`);
|
|
688
|
+
} else if (activeTools.length > 0) {
|
|
689
|
+
spinnerTools?.succeed(
|
|
690
|
+
`Detected ${activeTools.length} tool(s): ${activeTools.map((t) => t.name).join(", ")}`
|
|
691
|
+
);
|
|
692
|
+
} else {
|
|
693
|
+
spinnerTools?.warn("No AI tools detected");
|
|
694
|
+
log.info("Use --all to generate for all tools, or --only to pick specific ones.");
|
|
695
|
+
log.info("Run `aiignore list` to see available tools.");
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
let targetToolIds;
|
|
699
|
+
if (options.all) {
|
|
700
|
+
targetToolIds = ALL_TOOL_IDS;
|
|
701
|
+
} else if (options.only) {
|
|
702
|
+
targetToolIds = resolveToolIds(options.only).ids;
|
|
703
|
+
} else {
|
|
704
|
+
targetToolIds = activeTools.map((t) => t.id);
|
|
705
|
+
}
|
|
706
|
+
if (options.dryRun) {
|
|
707
|
+
log.heading("Dry run \u2014 files that would be created:");
|
|
708
|
+
for (const toolId of targetToolIds) {
|
|
709
|
+
const status = TOOL_STATUS[toolId];
|
|
710
|
+
if (status) {
|
|
711
|
+
console.log(` ${status.ignoreFile === "none" ? " guide" : " " + status.ignoreFile} (${status.tool})`);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
console.log();
|
|
715
|
+
log.info("Run without --dry-run to create files.");
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
const mode = options.force ? "force" : options.append ? "append" : "default";
|
|
719
|
+
log.heading("Generating ignore files...");
|
|
720
|
+
const results = runGenerators(projectDir, scanResult.patterns, targetToolIds, mode);
|
|
721
|
+
if (!options.quiet) {
|
|
722
|
+
console.log();
|
|
723
|
+
for (const result of results) {
|
|
724
|
+
if (result.skipped) {
|
|
725
|
+
logger.dim(` skip ${result.filePath} \u2014 ${result.message}`);
|
|
726
|
+
} else if (result.created) {
|
|
727
|
+
console.log(` ${chalk2.green("+")} ${chalk2.bold(result.filePath)} ${chalk2.dim(`(${result.toolName})`)}`);
|
|
728
|
+
if (result.message) {
|
|
729
|
+
logger.dim(` ${result.message}`);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
const created = results.filter((r) => r.created).length;
|
|
735
|
+
const skipped = results.filter((r) => r.skipped).length;
|
|
736
|
+
if (!options.quiet) {
|
|
737
|
+
console.log();
|
|
738
|
+
logger.success(`${created} file(s) created${skipped > 0 ? `, ${skipped} skipped` : ""}`);
|
|
739
|
+
}
|
|
740
|
+
if (targetToolIds.includes("claudeCode") && !options.quiet) {
|
|
741
|
+
console.log();
|
|
742
|
+
logger.warn("Claude Code: Read() deny blocks Bash cat too, but permissions.deny has known bugs");
|
|
743
|
+
logger.info("For stronger protection, set up PreToolUse hooks:");
|
|
744
|
+
logger.dim(" -> https://code.claude.com/docs/en/hooks");
|
|
745
|
+
}
|
|
746
|
+
if (targetToolIds.includes("copilot") && !options.quiet) {
|
|
747
|
+
console.log();
|
|
748
|
+
logger.warn("Copilot: No file-level protection for individual developers");
|
|
749
|
+
logger.info("See .github/copilot-security-guide.md for alternatives");
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function noop(_msg) {
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// src/commands/verify.ts
|
|
756
|
+
import chalk3 from "chalk";
|
|
757
|
+
import fs9 from "fs";
|
|
758
|
+
import path9 from "path";
|
|
759
|
+
var REQUIRED_PATTERNS = [".env", "*.pem", "*.key", "credentials.json"];
|
|
760
|
+
async function verifyCommand(options) {
|
|
761
|
+
const projectDir = process.cwd();
|
|
762
|
+
const detectedTools = detectTools(projectDir);
|
|
763
|
+
const results = [];
|
|
764
|
+
for (const tool of detectedTools) {
|
|
765
|
+
if (!tool.detected) continue;
|
|
766
|
+
const status = TOOL_STATUS[tool.id];
|
|
767
|
+
if (!status) continue;
|
|
768
|
+
const ignoreExists = checkIgnoreExists(projectDir, tool.id, status.ignoreFile);
|
|
769
|
+
const missingPatterns = ignoreExists ? checkMissingPatterns(projectDir, tool.id, status.ignoreFile) : [];
|
|
770
|
+
let protectionStatus;
|
|
771
|
+
if (status.reliability === "none" || !ignoreExists) {
|
|
772
|
+
protectionStatus = "none";
|
|
773
|
+
} else if (status.reliability === "high") {
|
|
774
|
+
protectionStatus = "best-effort";
|
|
775
|
+
} else {
|
|
776
|
+
protectionStatus = "unreliable";
|
|
777
|
+
}
|
|
778
|
+
results.push({
|
|
779
|
+
tool: status.tool,
|
|
780
|
+
status: protectionStatus,
|
|
781
|
+
reliability: status.reliability,
|
|
782
|
+
ignoreFile: status.ignoreFile,
|
|
783
|
+
exists: ignoreExists,
|
|
784
|
+
missingPatterns,
|
|
785
|
+
limitations: status.knownLimitations
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
if (options.json) {
|
|
789
|
+
console.log(JSON.stringify(results, null, 2));
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
if (results.length === 0) {
|
|
793
|
+
logger.warn("No AI tools detected in this project.");
|
|
794
|
+
logger.info("Run `aiignore init --all` to generate ignore files for all tools.");
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
logger.heading("AI Tool Protection Status");
|
|
798
|
+
console.log();
|
|
799
|
+
const statusLabel = (s) => {
|
|
800
|
+
switch (s) {
|
|
801
|
+
case "best-effort":
|
|
802
|
+
return chalk3.green("[ok] Best-effort");
|
|
803
|
+
case "unreliable":
|
|
804
|
+
return chalk3.yellow("[!] Unreliable");
|
|
805
|
+
case "none":
|
|
806
|
+
return chalk3.red("[x] None");
|
|
807
|
+
default:
|
|
808
|
+
return s;
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
for (const r of results) {
|
|
812
|
+
console.log(` ${chalk3.bold(r.tool.padEnd(20))} ${statusLabel(r.status)}`);
|
|
813
|
+
if (r.exists) {
|
|
814
|
+
logger.dim(` File: ${r.ignoreFile}`);
|
|
815
|
+
} else if (r.ignoreFile !== "none") {
|
|
816
|
+
logger.dim(` Missing: ${r.ignoreFile}`);
|
|
817
|
+
}
|
|
818
|
+
if (r.missingPatterns.length > 0) {
|
|
819
|
+
logger.warn(` Missing patterns: ${r.missingPatterns.join(", ")}`);
|
|
820
|
+
}
|
|
821
|
+
if (r.limitations.length > 0 && !options.ci) {
|
|
822
|
+
logger.dim(` Limitation: ${r.limitations[0]}`);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
const bestEffortCount = results.filter((r) => r.status === "best-effort").length;
|
|
826
|
+
const unreliableCount = results.filter((r) => r.status === "unreliable").length;
|
|
827
|
+
const noneCount = results.filter((r) => r.status === "none").length;
|
|
828
|
+
console.log();
|
|
829
|
+
logger.info(
|
|
830
|
+
`Coverage: ${bestEffortCount} best-effort | ${unreliableCount} unreliable | ${noneCount} none`
|
|
831
|
+
);
|
|
832
|
+
if (noneCount > 0 || unreliableCount > 0) {
|
|
833
|
+
console.log();
|
|
834
|
+
logger.info("Run `aiignore init` to improve protection.");
|
|
835
|
+
}
|
|
836
|
+
if (options.ci && noneCount > 0) {
|
|
837
|
+
process.exit(1);
|
|
838
|
+
}
|
|
839
|
+
if (options.strict && (noneCount > 0 || unreliableCount > 0)) {
|
|
840
|
+
process.exit(1);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
function checkIgnoreExists(projectDir, toolId, ignoreFile) {
|
|
844
|
+
if (ignoreFile === "none") return false;
|
|
845
|
+
const filePath = path9.join(projectDir, ignoreFile);
|
|
846
|
+
if (fs9.existsSync(filePath)) return true;
|
|
847
|
+
if (toolId === "claudeCode") {
|
|
848
|
+
const settingsPath = path9.join(projectDir, ".claude", "settings.json");
|
|
849
|
+
if (fs9.existsSync(settingsPath)) {
|
|
850
|
+
try {
|
|
851
|
+
const settings = JSON.parse(fs9.readFileSync(settingsPath, "utf-8"));
|
|
852
|
+
const deny = settings?.permissions?.deny;
|
|
853
|
+
return Array.isArray(deny) && deny.some((d) => d.startsWith("Read("));
|
|
854
|
+
} catch {
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
return false;
|
|
860
|
+
}
|
|
861
|
+
function checkMissingPatterns(projectDir, toolId, ignoreFile) {
|
|
862
|
+
if (toolId === "claudeCode") {
|
|
863
|
+
return checkClaudePatterns(projectDir);
|
|
864
|
+
}
|
|
865
|
+
const filePath = path9.join(projectDir, ignoreFile);
|
|
866
|
+
if (!fs9.existsSync(filePath)) return REQUIRED_PATTERNS;
|
|
867
|
+
const content = fs9.readFileSync(filePath, "utf-8");
|
|
868
|
+
return REQUIRED_PATTERNS.filter((p) => !content.includes(p));
|
|
869
|
+
}
|
|
870
|
+
function checkClaudePatterns(projectDir) {
|
|
871
|
+
const settingsPath = path9.join(projectDir, ".claude", "settings.json");
|
|
872
|
+
if (!fs9.existsSync(settingsPath)) return REQUIRED_PATTERNS;
|
|
873
|
+
try {
|
|
874
|
+
const settings = JSON.parse(fs9.readFileSync(settingsPath, "utf-8"));
|
|
875
|
+
const deny = settings?.permissions?.deny ?? [];
|
|
876
|
+
return REQUIRED_PATTERNS.filter((p) => !deny.some((d) => d.includes(p)));
|
|
877
|
+
} catch {
|
|
878
|
+
return REQUIRED_PATTERNS;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// src/commands/list.ts
|
|
883
|
+
import chalk4 from "chalk";
|
|
884
|
+
function listCommand() {
|
|
885
|
+
console.log();
|
|
886
|
+
console.log(chalk4.bold("Supported tools:"));
|
|
887
|
+
console.log();
|
|
888
|
+
for (const [id, status] of Object.entries(TOOL_STATUS)) {
|
|
889
|
+
const reliability = formatReliability(status.reliability);
|
|
890
|
+
const file = status.ignoreFile === "none" ? chalk4.dim("(no ignore file)") : status.ignoreFile;
|
|
891
|
+
console.log(` ${chalk4.bold(status.tool.padEnd(20))} ${file.toString().padEnd(30)} ${reliability}`);
|
|
892
|
+
}
|
|
893
|
+
console.log();
|
|
894
|
+
console.log(chalk4.bold("Aliases for --only:"));
|
|
895
|
+
console.log();
|
|
896
|
+
const grouped = {};
|
|
897
|
+
for (const [alias, toolId] of Object.entries(TOOL_ALIASES)) {
|
|
898
|
+
if (!grouped[toolId]) grouped[toolId] = [];
|
|
899
|
+
grouped[toolId].push(alias);
|
|
900
|
+
}
|
|
901
|
+
for (const [toolId, aliases] of Object.entries(grouped)) {
|
|
902
|
+
const status = TOOL_STATUS[toolId];
|
|
903
|
+
if (status) {
|
|
904
|
+
console.log(` ${aliases.join(", ").padEnd(35)} ${chalk4.dim(status.tool)}`);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
console.log();
|
|
908
|
+
}
|
|
909
|
+
function formatReliability(level) {
|
|
910
|
+
switch (level) {
|
|
911
|
+
case "high":
|
|
912
|
+
return chalk4.green(level);
|
|
913
|
+
case "medium":
|
|
914
|
+
return chalk4.yellow(level);
|
|
915
|
+
case "low":
|
|
916
|
+
return chalk4.red(level);
|
|
917
|
+
case "none":
|
|
918
|
+
return chalk4.dim(level);
|
|
919
|
+
default:
|
|
920
|
+
return level;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// src/index.ts
|
|
925
|
+
var program = new Command();
|
|
926
|
+
program.name("aiignore").description("Protect your secrets from AI coding tools").version("1.0.0");
|
|
927
|
+
program.command("init", { isDefault: true }).description("Generate ignore files for detected AI coding tools").option("--all", "Generate for all supported tools (skip detection)").option("--only <tools>", "Generate for specific tools (comma-separated)").option("--append", "Add missing patterns to existing files instead of skipping").option("--dry-run", "Preview what would be created without writing files").option("--force", "Overwrite existing ignore files").option("-q, --quiet", "Suppress non-essential output").action(initCommand);
|
|
928
|
+
program.command("verify").description("Check protection status for detected AI tools").option("--ci", "CI mode: exit code 1 if unprotected").option("--strict", "Strict mode: exit code 1 if any tool is unreliable or unprotected").option("--json", "Output results as JSON").option("-q, --quiet", "Suppress non-essential output").action(verifyCommand);
|
|
929
|
+
program.command("list").description("Show all supported AI tools and aliases").action(listCommand);
|
|
930
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aiignore-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "One command to protect your secrets from all AI coding tools",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"aiignore": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsup",
|
|
12
|
+
"dev": "tsup --watch",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"test:watch": "vitest",
|
|
15
|
+
"lint": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"ai",
|
|
19
|
+
"ignore",
|
|
20
|
+
"security",
|
|
21
|
+
"secrets",
|
|
22
|
+
"ai-security",
|
|
23
|
+
"ai-ignore",
|
|
24
|
+
"cursor",
|
|
25
|
+
"cursorignore",
|
|
26
|
+
"cursor-ignore",
|
|
27
|
+
"claude-code",
|
|
28
|
+
"claude-ignore",
|
|
29
|
+
"copilot",
|
|
30
|
+
"gemini",
|
|
31
|
+
"geminiignore",
|
|
32
|
+
"windsurf",
|
|
33
|
+
"codeium",
|
|
34
|
+
"codeiumignore",
|
|
35
|
+
"jetbrains",
|
|
36
|
+
"aiignore",
|
|
37
|
+
"dotfiles"
|
|
38
|
+
],
|
|
39
|
+
"author": "yjcho9317",
|
|
40
|
+
"license": "Apache-2.0",
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist"
|
|
46
|
+
],
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"chalk": "^5.6.2",
|
|
49
|
+
"commander": "^14.0.3",
|
|
50
|
+
"fast-glob": "^3.3.3",
|
|
51
|
+
"ora": "^9.3.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^25.5.0",
|
|
55
|
+
"tsup": "^8.5.1",
|
|
56
|
+
"typescript": "^5.9.3",
|
|
57
|
+
"vitest": "^3.2.4"
|
|
58
|
+
}
|
|
59
|
+
}
|