repo-cloak-cli 1.2.4 → 1.3.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/medium.md DELETED
@@ -1,319 +0,0 @@
1
- # Repo-Cloak: A CLI Tool for Safely Using AI Coding Assistants on Proprietary Codebases
2
-
3
- The rise of AI-powered coding assistants like GitHub Copilot, Cursor, and Claude has fundamentally changed how developers write software. These tools can dramatically accelerate development, debug complex issues, and even architect entire systems. But for engineers working on proprietary or enterprise codebases, there is a persistent concern: *How do you leverage these powerful AI tools without exposing sensitive business logic, customer data, or confidential intellectual property?*
4
-
5
- This article introduces **Repo-Cloak**, a command-line tool I built to address this exact challenge. It provides a secure, selective approach to sharing code with AI assistants while maintaining complete control over what information leaves your environment.
6
-
7
- ---
8
-
9
- ## The Problem: AI Assistance vs Enterprise Security
10
-
11
- Modern AI coding assistants require context to be effective. The more code they can see, the better their suggestions. But enterprise environments present unique challenges:
12
-
13
- - **Proprietary Business Logic**: Core algorithms, pricing engines, and competitive differentiators must remain confidential
14
- - **Customer Data References**: Database schemas, API endpoints, and configuration files often contain sensitive identifiers
15
- - **Company-Specific Naming**: Project names, internal tools, and organizational structures reveal information about your infrastructure
16
- - **Compliance Requirements**: Healthcare, finance, and government sectors have strict regulations about data handling
17
-
18
- The traditional approach forces developers to choose between two suboptimal paths: either manually copy-paste sanitized code snippets (losing context and wasting time), or share entire repositories with AI tools (accepting security risks). Repo-Cloak offers a third path.
19
-
20
- ---
21
-
22
- ## The Solution: Selective Extraction with Intelligent Anonymization
23
-
24
- Repo-Cloak operates on a simple but powerful principle: **extract only what you need, anonymize what you must protect, and maintain a reversible mapping for seamless integration**.
25
-
26
- ```
27
- ┌─────────────────────────────────────────────────────────────────────┐
28
- │ ORIGINAL REPOSITORY │
29
- │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
30
- │ │ XCorpAPI/ │ │ Payments/ │ │ Analytics/ │ │
31
- │ │ auth.cs │ │ stripe.cs │ │ metrics.cs │ │
32
- │ │ users.cs │ │ billing.cs │ │ reports.cs │ │
33
- │ └──────────────┘ └──────────────┘ └──────────────┘ │
34
- └─────────────────────────────────────────────────────────────────────┘
35
-
36
- │ PULL (selective + anonymize)
37
-
38
- ┌─────────────────────────────────────────────────────────────────────┐
39
- │ CLOAKED WORKSPACE │
40
- │ ┌──────────────┐ │
41
- │ │ AcmeAPI/ │ ← Folder names anonymized │
42
- │ │ auth.cs │ ← Content: "XCorp" → "Acme" │
43
- │ │ users.cs │ ← Safe to share with AI assistants │
44
- │ └──────────────┘ │
45
- │ │
46
- │ .repo-cloak-map.json ← Encrypted mapping for restoration │
47
- └─────────────────────────────────────────────────────────────────────┘
48
-
49
- │ AI AGENT MAKES MODIFICATIONS
50
-
51
- ┌─────────────────────────────────────────────────────────────────────┐
52
- │ PUSH (restore + de-anonymize) │
53
- │ │
54
- │ Modified files pushed back to original repository │
55
- │ All anonymization reversed automatically │
56
- │ "Acme" → "XCorp" in both content and file paths │
57
- └─────────────────────────────────────────────────────────────────────┘
58
- ```
59
-
60
- ---
61
-
62
- ## How It Works: A Technical Deep Dive
63
-
64
- ### 1. Interactive File Selection
65
-
66
- Rather than extracting entire directories, Repo-Cloak provides an interactive file selector with hierarchical navigation. Developers can search, filter, and selectively choose exactly which files to extract.
67
-
68
- ```
69
- ? Select files to extract:
70
- ◉ 📁 src/Services
71
- ◉ 📄 BookService.cs
72
- ◯ 📄 PaymentService.cs ← Excluded: contains billing logic
73
- ◉ 📄 UserService.cs
74
- ◯ 📁 src/Infrastructure ← Entire folder excluded
75
- ```
76
-
77
- The selector supports pagination for large codebases, folder-level selection (selecting a folder automatically includes all children), and real-time filtering.
78
-
79
- ### 2. Intelligent Content Anonymization
80
-
81
- The anonymization engine performs case-preserving replacements across all extracted content. This means your code remains syntactically valid and readable:
82
-
83
- ```csharp
84
- // Original
85
- namespace XCorp.Services {
86
- public class XCorpBookManager : IXCorpService {
87
- private const string XCORP_API_KEY = "...";
88
- }
89
- }
90
-
91
- // Anonymized (case preservation maintained)
92
- namespace Acme.Services {
93
- public class AcmeBookManager : IAcmeService {
94
- private const string ACME_API_KEY = "...";
95
- }
96
- }
97
- ```
98
-
99
- The engine handles:
100
- - **PascalCase**: `XCorpService` becomes `AcmeService`
101
- - **camelCase**: `xcorpClient` becomes `acmeClient`
102
- - **SCREAMING_CASE**: `XCORP_KEY` becomes `ACME_KEY`
103
- - **lowercase**: `xcorp` becomes `acme`
104
-
105
- ### 3. Path Anonymization
106
-
107
- Beyond content, Repo-Cloak also anonymizes folder and file names. This prevents directory structures from revealing organizational patterns:
108
-
109
- ```
110
- Original: src/XCorpFrontEnd/XCorpComponents/XCorpButton.tsx
111
- Cloaked: src/AcmeFrontEnd/AcmeComponents/AcmeButton.tsx
112
- ```
113
-
114
- ### 4. Encrypted Mapping with User-Specific Secrets
115
-
116
- Here is where security becomes critical. The mapping file that tracks original-to-anonymized paths must itself be protected. Repo-Cloak uses AES-256-GCM encryption with a user-specific secret key:
117
-
118
- ```
119
- ┌──────────────────────────────────────────────────────────────┐
120
- │ ENCRYPTION ARCHITECTURE │
121
- ├──────────────────────────────────────────────────────────────┤
122
- │ │
123
- │ ~/.repo-cloak/secret.key │
124
- │ ├── Generated automatically on first use │
125
- │ ├── 256-bit cryptographically random key │
126
- │ ├── Stored with 0600 permissions (owner-only) │
127
- │ └── Unique per user/machine │
128
- │ │
129
- │ .repo-cloak-map.json │
130
- │ ├── Source paths: ENCRYPTED │
131
- │ ├── Original keywords: ENCRYPTED │
132
- │ ├── Replacement keywords: VISIBLE (safe values) │
133
- │ └── Cloaked file paths: VISIBLE (already anonymized) │
134
- │ │
135
- └──────────────────────────────────────────────────────────────┘
136
- ```
137
-
138
- The mapping file can be safely committed or shared because:
139
- - The encrypted fields cannot be decrypted without the user's secret key
140
- - The visible fields contain only anonymized, non-sensitive values
141
- - Even if an attacker obtains the mapping, they cannot determine original values
142
-
143
- If a user loses their secret key (machine reinstall, key deletion), the tool prompts for manual keyword entry during restoration. Since developers know their own codebase, they can provide the original terms when needed.
144
-
145
- ### 5. Incremental Extraction Support
146
-
147
- Real-world usage rarely involves a single extraction. As AI assistants request additional context, developers need to pull more files. Repo-Cloak handles this with intelligent merging:
148
-
149
- ```
150
- Pull #1: BookService.cs → Mapping tracks 1 file
151
- Pull #2: UserService.cs → Mapping tracks 2 files (merged)
152
- Pull #3: Same files again → Deduplication, no duplicates added
153
- ```
154
-
155
- Each pull is tracked in a history log:
156
- ```json
157
- {
158
- "pullHistory": [
159
- { "timestamp": "2024-01-15T10:30:00Z", "filesAdded": 5, "totalFiles": 5 },
160
- { "timestamp": "2024-01-15T14:22:00Z", "filesAdded": 3, "totalFiles": 8 }
161
- ]
162
- }
163
- ```
164
-
165
- ---
166
-
167
- ## The Workflow in Practice
168
-
169
- ### Step 1: Pull Files from Your Repository
170
-
171
- ```bash
172
- repo-cloak pull
173
- ```
174
-
175
- The interactive interface guides you through:
176
- 1. Selecting a source directory (your project)
177
- 2. Choosing specific files via the tree selector
178
- 3. Defining keyword replacements (e.g., "XCorp" to "Acme")
179
- 4. Specifying an output directory
180
-
181
- ### Step 2: Work with AI Assistants
182
-
183
- Open the cloaked workspace in your preferred AI-enabled IDE. The anonymized code is syntactically valid and maintains all structural relationships. AI assistants can:
184
- - Analyze patterns and suggest improvements
185
- - Debug issues with full context
186
- - Generate new code that follows your conventions
187
- - Refactor existing implementations
188
-
189
- ### Step 3: Push Changes Back
190
-
191
- ```bash
192
- repo-cloak push
193
- ```
194
-
195
- The tool automatically:
196
- 1. Locates the mapping file in the cloaked directory
197
- 2. Decrypts the mapping using your secret key
198
- 3. Reverses all anonymization in both content and file paths
199
- 4. Copies modified files back to the original repository
200
-
201
- ---
202
-
203
- ## Security Considerations
204
-
205
- ### What Gets Protected
206
-
207
- | Element | Protection Method |
208
- |---------|------------------|
209
- | File content keywords | Case-preserving replacement |
210
- | Folder names | Path anonymization |
211
- | File names | Path anonymization |
212
- | Original keywords in mapping | AES-256-GCM encryption |
213
- | Source directory path | AES-256-GCM encryption |
214
- | Original file paths | AES-256-GCM encryption |
215
-
216
- ### What Remains Visible
217
-
218
- | Element | Reason |
219
- |---------|--------|
220
- | Replacement keywords | Already anonymized, safe to expose |
221
- | Cloaked file paths | Already anonymized, safe to expose |
222
- | Code structure and logic | Required for AI assistance |
223
-
224
- ### Threat Model
225
-
226
- Repo-Cloak protects against:
227
- - **Accidental exposure**: AI tools cannot see original company names, project identifiers, or sensitive naming
228
- - **Mapping file leakage**: Even if the mapping file is exposed, encryption prevents recovery of original values
229
- - **Third-party logging**: Cloud-based AI services only receive anonymized content
230
-
231
- Repo-Cloak does not protect against:
232
- - **Logic inference**: Sufficiently advanced analysis might infer business purpose from code structure
233
- - **Unique patterns**: Highly distinctive algorithms may be recognizable regardless of naming
234
- - **Malicious insiders**: Users with the secret key have full access
235
-
236
- ### User Responsibility
237
-
238
- Repo-Cloak is a tool that assists with anonymization, but it does not replace sound judgment. **The responsibility for selecting appropriate files lies entirely with the user.**
239
-
240
- Before extracting any code, you should:
241
-
242
- 1. **Review your organization's policies**: Most companies have guidelines about sharing code with external tools or AI services. Ensure you understand and comply with these policies before using Repo-Cloak or any similar tool.
243
-
244
- 2. **Avoid proprietary algorithms**: Even with anonymized naming, core business logic, patented algorithms, or trade secrets should not be extracted. If an algorithm is proprietary, changing variable names does not make it safe to share.
245
-
246
- 3. **Verify file contents before extraction**: The selective file picker exists precisely so you can make informed decisions. Do not blindly select entire directories without understanding what they contain.
247
-
248
- 4. **Cross-check with your team**: When in doubt, consult with your security team, legal department, or engineering leadership. A quick conversation can prevent significant issues.
249
-
250
- 5. **Use the minimum necessary context**: Extract only what the AI assistant needs to help you. More files means more exposure, even if that exposure is anonymized.
251
-
252
- This tool provides a layer of protection, but no tool can substitute for thoughtful decision-making about what code should or should not leave your environment.
253
-
254
- ---
255
-
256
- ## Installation and Usage
257
-
258
- ```bash
259
- # Install globally via npm
260
- npm install -g repo-cloak-cli
261
-
262
- # Run the interactive interface
263
- repo-cloak
264
-
265
- # Or use specific commands
266
- repo-cloak pull --source ./my-project --dest ./cloaked-output
267
- repo-cloak push --source ./cloaked-output --dest ./my-project
268
- ```
269
-
270
- ---
271
-
272
- ## Technical Architecture
273
-
274
- ```
275
- repo-cloak/
276
- ├── bin/
277
- │ └── repo-cloak.js # CLI entry point
278
- ├── src/
279
- │ ├── commands/
280
- │ │ ├── pull.js # Extraction and anonymization
281
- │ │ └── push.js # Restoration and de-anonymization
282
- │ ├── core/
283
- │ │ ├── anonymizer.js # Case-preserving replacement engine
284
- │ │ ├── copier.js # File operations with transformation
285
- │ │ ├── crypto.js # AES-256-GCM encryption
286
- │ │ ├── mapper.js # Mapping file management
287
- │ │ └── scanner.js # File discovery and filtering
288
- │ └── ui/
289
- │ ├── fileSelector.js # Interactive tree selector
290
- │ └── prompts.js # User input handling
291
- └── tests/
292
- ├── anonymizer.test.js # 13 test cases
293
- ├── copier.test.js # 5 test cases
294
- ├── crypto.test.js # 9 test cases
295
- ├── mapper.test.js # 10 test cases
296
- └── scanner.test.js # 8 test cases
297
- ```
298
-
299
- The project includes 45 unit tests covering all core functionality, ensuring reliability for production use.
300
-
301
- ---
302
-
303
- ## Conclusion
304
-
305
- The tension between leveraging AI tools and maintaining code security is real, but it does not have to be a binary choice. Repo-Cloak provides a practical middle ground: keep your proprietary information private while still benefiting from the productivity gains of modern AI coding assistants.
306
-
307
- By implementing selective extraction, intelligent anonymization, and encrypted reversible mappings, developers can confidently use tools like Cursor, GitHub Copilot, or any AI coding assistant without exposing sensitive business logic or company-specific information.
308
-
309
- The tool is open-source and available on npm. Contributions, feedback, and feature requests are welcome.
310
-
311
- ---
312
-
313
- **Repository**: [github.com/iamshz97/repo-cloak](https://github.com/iamshz97/repo-cloak)
314
-
315
- **npm**: `npm install -g repo-cloak-cli`
316
-
317
- ---
318
-
319
- *Shazni Shiraz is a software engineer focused on developer tooling and enterprise software architecture.*