secretless-ai 0.3.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 ADDED
@@ -0,0 +1,201 @@
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 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 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 those 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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,186 @@
1
+ # Secretless AI
2
+
3
+ [![npm version](https://img.shields.io/npm/v/secretless-ai.svg)](https://www.npmjs.com/package/secretless-ai)
4
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
+
6
+ One command to keep secrets out of AI. Works with Claude Code, Cursor, Copilot, Windsurf, Cline, and Aider.
7
+
8
+ ```bash
9
+ npx secretless-ai init
10
+ ```
11
+
12
+ ## The Problem
13
+
14
+ AI coding tools read your files to provide context. That includes `.env` files, API keys in config, SSH keys, and cloud credentials. Once a secret enters an AI context window, it's sent to a remote API — and you can't take it back.
15
+
16
+ ## How It Works
17
+
18
+ Secretless auto-detects which AI tools you use and installs the right protections for each one:
19
+
20
+ | Tool | Protection Method |
21
+ |------|------------------|
22
+ | **Claude Code** | PreToolUse hook (blocks file reads before they happen) + deny rules + CLAUDE.md instructions |
23
+ | **Cursor** | `.cursorrules` instructions |
24
+ | **GitHub Copilot** | `.github/copilot-instructions.md` instructions |
25
+ | **Windsurf** | `.windsurfrules` instructions |
26
+ | **Cline** | `.clinerules` instructions |
27
+ | **Aider** | `.aiderignore` file patterns |
28
+
29
+ Claude Code gets the strongest protection because it supports [hooks](https://docs.anthropic.com/en/docs/claude-code/hooks) — a shell script runs *before* every file read and blocks access to secret files at the tool level. Other tools get instruction-based protection.
30
+
31
+ ## Quick Start
32
+
33
+ ```bash
34
+ # In any project directory
35
+ npx secretless-ai init
36
+ ```
37
+
38
+ Output:
39
+
40
+ ```
41
+ Secretless v0.2.0
42
+ Keeping secrets out of AI
43
+
44
+ Detected:
45
+ + Claude Code
46
+ + Cursor
47
+
48
+ Configured:
49
+ * Claude Code
50
+ * Cursor
51
+
52
+ Created:
53
+ + .claude/hooks/secretless-guard.sh
54
+ + CLAUDE.md
55
+
56
+ Modified:
57
+ ~ .claude/settings.json
58
+ ~ .cursorrules
59
+
60
+ Done. Secrets are now blocked from AI context.
61
+ ```
62
+
63
+ ## Moving Keys from AI Context to Env Vars
64
+
65
+ The safest setup: keys live in environment variables, AI tools reference them by name.
66
+
67
+ **Step 1: Move keys to your shell profile**
68
+
69
+ ```bash
70
+ # Add to ~/.zshenv (or ~/.bashrc)
71
+ export ANTHROPIC_API_KEY="sk-ant-..."
72
+ export OPENAI_API_KEY="sk-proj-..."
73
+ ```
74
+
75
+ **Step 2: Remove keys from AI config files**
76
+
77
+ Delete any hardcoded keys from `CLAUDE.md`, `.cursorrules`, `.env`, etc.
78
+
79
+ **Step 3: Run secretless init**
80
+
81
+ ```bash
82
+ npx secretless-ai init
83
+ ```
84
+
85
+ Secretless detects which env vars are set and adds a reference table to your AI tool's instruction file. The AI knows *which* keys are available and *how* to authenticate — without seeing the actual values.
86
+
87
+ **Step 4: Verify**
88
+
89
+ ```bash
90
+ npx secretless-ai verify
91
+ ```
92
+
93
+ ```
94
+ Env vars available (usable by tools):
95
+ + ANTHROPIC_API_KEY
96
+ + OPENAI_API_KEY
97
+
98
+ AI context files: clean (no credentials found)
99
+
100
+ PASS: Secrets are accessible via env vars but hidden from AI context.
101
+ ```
102
+
103
+ **Before:** Claude sees `ANTHROPIC_API_KEY=sk-ant-api03-abc123...` in CLAUDE.md — the key is in the context window, extractable via prompt injection.
104
+
105
+ **After:** Claude sees a table saying `$ANTHROPIC_API_KEY` exists and the auth header is `x-api-key: $ANTHROPIC_API_KEY`. It uses `$ANTHROPIC_API_KEY` in shell commands. The shell resolves it. Claude never sees the actual value.
106
+
107
+ ## Commands
108
+
109
+ ### `npx secretless-ai init`
110
+
111
+ Detects AI tools in your project and installs protections. If API keys are set as env vars, includes a reference table with service names and auth header formats so the AI can use them without seeing values. Safe to run multiple times.
112
+
113
+ ### `npx secretless-ai scan`
114
+
115
+ Scans config files for hardcoded credentials — both project-level and global (`~/.claude/CLAUDE.md`). Detects 12 credential patterns including Anthropic, OpenAI, AWS, GitHub, Slack, Google, Stripe, SendGrid, Supabase, and Azure keys.
116
+
117
+ ```
118
+ Found 2 credential(s):
119
+
120
+ [CRIT] Anthropic API Key
121
+ ~/.claude/CLAUDE.md:286
122
+ ANTHROPIC_API_KEY=[Anthropic API Key REDACTED]
123
+
124
+ [CRIT] OpenAI Project Key
125
+ ~/.claude/CLAUDE.md:284
126
+ OPENAI_API_KEY=[OpenAI Project Key REDACTED]
127
+ ```
128
+
129
+ ### `npx secretless-ai verify`
130
+
131
+ Confirms keys are usable but hidden from AI. Checks that env vars are set AND that the actual key values don't appear in any AI context file.
132
+
133
+ ```
134
+ PASS: Secrets are accessible via env vars but hidden from AI context.
135
+ ```
136
+
137
+ ### `npx secretless-ai status`
138
+
139
+ Shows current protection status.
140
+
141
+ ```
142
+ Protected: Yes
143
+ Tools: Claude Code, Cursor
144
+ Hook: Installed
145
+ Deny rules: 14
146
+ Secrets: 0 found in config files
147
+ ```
148
+
149
+ ## What Gets Blocked
150
+
151
+ ### File patterns (20+)
152
+
153
+ `.env`, `.env.*`, `*.key`, `*.pem`, `*.p12`, `*.pfx`, `*.crt`, `.aws/credentials`, `.ssh/*`, `.docker/config.json`, `.git-credentials`, `.npmrc`, `.pypirc`, `*.tfstate`, `*.tfvars`, `secrets/`, `credentials/`
154
+
155
+ ### Credential patterns (12)
156
+
157
+ Anthropic API keys, OpenAI keys (project + legacy), AWS access keys, GitHub PATs (classic + fine-grained), Slack tokens, Google API keys, Stripe live keys, SendGrid keys, Supabase service keys, Azure keys
158
+
159
+ ### Bash commands
160
+
161
+ Commands that dump secret files (`cat .env`, `head *.key`) and commands that echo secret environment variables (`echo $API_KEY`, `echo $SECRET`)
162
+
163
+ ## Claude Code Hook
164
+
165
+ For Claude Code, Secretless installs a PreToolUse hook that intercepts every `Read`, `Grep`, `Glob`, `Bash`, `Write`, and `Edit` tool call. The hook runs *before* the tool executes, so secrets never enter the AI context window.
166
+
167
+ ```bash
168
+ # .claude/hooks/secretless-guard.sh
169
+ # Runs before every tool call, checks file paths against block list
170
+ # Returns deny decision if a secret file is targeted
171
+ ```
172
+
173
+ Additionally, Secretless adds `permissions.deny` rules to `.claude/settings.json` as a second layer of defense, and adds instructions to `CLAUDE.md` so Claude understands why certain files are blocked.
174
+
175
+ ## Requirements
176
+
177
+ - Node.js 18+
178
+ - A project directory with at least one AI tool configured (or Secretless defaults to Claude Code)
179
+
180
+ ## Zero Dependencies
181
+
182
+ Secretless has zero runtime dependencies. The npm package is 18 KB.
183
+
184
+ ## License
185
+
186
+ Apache-2.0
package/dist/cli.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Secretless CLI
4
+ *
5
+ * Usage:
6
+ * npx secretless-ai init — Set up protections for detected AI tools
7
+ * npx secretless-ai scan — Scan for hardcoded secrets
8
+ * npx secretless-ai status — Show current protection status
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;GAOG"}
package/dist/cli.js ADDED
@@ -0,0 +1,222 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Secretless CLI
5
+ *
6
+ * Usage:
7
+ * npx secretless-ai init — Set up protections for detected AI tools
8
+ * npx secretless-ai scan — Scan for hardcoded secrets
9
+ * npx secretless-ai status — Show current protection status
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ const path = __importStar(require("path"));
46
+ const init_1 = require("./init");
47
+ const scan_1 = require("./scan");
48
+ const status_1 = require("./status");
49
+ const verify_1 = require("./verify");
50
+ const detect_1 = require("./detect");
51
+ const VERSION = '0.3.0';
52
+ function main() {
53
+ const args = process.argv.slice(2);
54
+ const command = args[0];
55
+ const dirArg = args[1];
56
+ const projectDir = dirArg ? path.resolve(dirArg) : process.cwd();
57
+ switch (command) {
58
+ case 'init':
59
+ runInit(projectDir);
60
+ break;
61
+ case 'scan':
62
+ runScan(projectDir);
63
+ break;
64
+ case 'status':
65
+ runStatus(projectDir);
66
+ break;
67
+ case 'verify':
68
+ runVerify(projectDir);
69
+ break;
70
+ case '--version':
71
+ case '-v':
72
+ console.log(`secretless v${VERSION}`);
73
+ break;
74
+ case '--help':
75
+ case '-h':
76
+ case undefined:
77
+ printHelp();
78
+ break;
79
+ default:
80
+ console.error(`Unknown command: ${command}`);
81
+ printHelp();
82
+ process.exit(1);
83
+ }
84
+ }
85
+ function runInit(projectDir) {
86
+ console.log('\n Secretless v' + VERSION);
87
+ console.log(' Keeping secrets out of AI\n');
88
+ const result = (0, init_1.init)(projectDir);
89
+ // Report detected tools
90
+ if (result.toolsDetected.length > 0) {
91
+ console.log(' Detected:');
92
+ for (const tool of result.toolsDetected) {
93
+ console.log(` + ${(0, detect_1.toolDisplayName)(tool)}`);
94
+ }
95
+ }
96
+ else {
97
+ console.log(' No AI tools detected, defaulting to Claude Code');
98
+ }
99
+ console.log();
100
+ // Report configured tools
101
+ console.log(' Configured:');
102
+ for (const tool of result.toolsConfigured) {
103
+ console.log(` * ${(0, detect_1.toolDisplayName)(tool)}`);
104
+ }
105
+ console.log();
106
+ // Report files
107
+ if (result.filesCreated.length > 0) {
108
+ console.log(' Created:');
109
+ for (const f of result.filesCreated) {
110
+ console.log(` + ${f}`);
111
+ }
112
+ console.log();
113
+ }
114
+ if (result.filesModified.length > 0) {
115
+ console.log(' Modified:');
116
+ for (const f of result.filesModified) {
117
+ console.log(` ~ ${f}`);
118
+ }
119
+ console.log();
120
+ }
121
+ // Report secrets found
122
+ if (result.secretsFound > 0) {
123
+ console.log(` Warning: found ${result.secretsFound} hardcoded credential(s)`);
124
+ console.log(' Run `npx secretless-ai scan` to see details\n');
125
+ }
126
+ console.log(' Done. Secrets are now blocked from AI context.\n');
127
+ }
128
+ function runScan(projectDir) {
129
+ console.log('\n Secretless Scanner\n');
130
+ const findings = (0, scan_1.scan)(projectDir);
131
+ if (findings.length === 0) {
132
+ console.log(' No hardcoded credentials found.\n');
133
+ return;
134
+ }
135
+ console.log(` Found ${findings.length} credential(s):\n`);
136
+ for (const finding of findings) {
137
+ const severity = finding.severity === 'critical' ? 'CRIT' : 'HIGH';
138
+ console.log(` [${severity}] ${finding.patternName}`);
139
+ console.log(` ${finding.file}:${finding.line}`);
140
+ console.log(` ${finding.preview}`);
141
+ console.log();
142
+ }
143
+ console.log(` Run \`npx secretless-ai init\` to add protections.\n`);
144
+ process.exit(findings.length > 0 ? 1 : 0);
145
+ }
146
+ function runStatus(projectDir) {
147
+ console.log('\n Secretless Status\n');
148
+ const s = (0, status_1.status)(projectDir);
149
+ console.log(` Protected: ${s.isProtected ? 'Yes' : 'No'}`);
150
+ console.log(` Tools: ${s.configuredTools.map(detect_1.toolDisplayName).join(', ') || 'None'}`);
151
+ console.log(` Hook: ${s.hookInstalled ? 'Installed' : 'Not installed'}`);
152
+ console.log(` Deny rules: ${s.denyRuleCount}`);
153
+ console.log(` Secrets: ${s.secretsFound} found in config files`);
154
+ console.log();
155
+ }
156
+ function runVerify(projectDir) {
157
+ console.log('\n Secretless Verify\n');
158
+ const result = (0, verify_1.verify)(projectDir);
159
+ // Show env var availability
160
+ const setVars = Object.entries(result.envVars).filter(([, v]) => v);
161
+ const unsetVars = Object.entries(result.envVars).filter(([, v]) => !v);
162
+ if (setVars.length > 0) {
163
+ console.log(' Env vars available (usable by tools):');
164
+ for (const [name] of setVars) {
165
+ console.log(` + ${name}`);
166
+ }
167
+ }
168
+ if (unsetVars.length > 0) {
169
+ console.log(' Env vars not set:');
170
+ for (const [name] of unsetVars) {
171
+ console.log(` - ${name}`);
172
+ }
173
+ }
174
+ console.log();
175
+ // Show context exposure
176
+ if (result.exposedInContext.length > 0) {
177
+ console.log(' EXPOSED in AI context (secrets the AI can see):');
178
+ for (const exp of result.exposedInContext) {
179
+ console.log(` ! ${exp.patternName} in ${exp.file}:${exp.line}`);
180
+ }
181
+ console.log();
182
+ }
183
+ else {
184
+ console.log(' AI context files: clean (no credentials found)\n');
185
+ }
186
+ // Verdict
187
+ if (result.passed) {
188
+ console.log(' PASS: Secrets are accessible via env vars but hidden from AI context.\n');
189
+ }
190
+ else if (result.exposedInContext.length > 0) {
191
+ console.log(' FAIL: Credentials found in AI context files.');
192
+ console.log(' Run `npx secretless-ai init` to remediate.\n');
193
+ process.exit(1);
194
+ }
195
+ else {
196
+ console.log(' WARN: No API keys found in env vars.');
197
+ console.log(' Set keys in ~/.zshenv or ~/.bashrc, then restart your terminal.\n');
198
+ process.exit(1);
199
+ }
200
+ }
201
+ function printHelp() {
202
+ console.log(`
203
+ Secretless v${VERSION}
204
+ Keep secrets out of AI context.
205
+
206
+ Usage:
207
+ npx secretless-ai init Set up protections for your AI tools
208
+ npx secretless-ai scan Scan for hardcoded secrets
209
+ npx secretless-ai status Show protection status
210
+ npx secretless-ai verify Verify keys are usable but hidden from AI
211
+
212
+ Options:
213
+ -v, --version Show version
214
+ -h, --help Show this help
215
+
216
+ Supports: Claude Code, Cursor, GitHub Copilot, Windsurf, Cline, Aider
217
+
218
+ https://opena2a.org/secretless-ai
219
+ `);
220
+ }
221
+ main();
222
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAEA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,iCAA8B;AAC9B,iCAA8B;AAC9B,qCAAkC;AAClC,qCAAkC;AAClC,qCAA2C;AAE3C,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,SAAS,IAAI;IACX,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IAEjE,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM;YACT,OAAO,CAAC,UAAU,CAAC,CAAC;YACpB,MAAM;QACR,KAAK,MAAM;YACT,OAAO,CAAC,UAAU,CAAC,CAA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auto-detect which AI tools are present in a project.
3
+ */
4
+ export type AITool = 'claude-code' | 'cursor' | 'copilot' | 'windsurf' | 'cline' | 'aider';
5
+ interface DetectionResult {
6
+ tool: AITool;
7
+ configDir: string;
8
+ settingsFile: string;
9
+ hooksSupported: boolean;
10
+ }
11
+ /**
12
+ * Detect AI tools present in the project directory.
13
+ * Returns all detected tools sorted by priority (hooks-capable first).
14
+ */
15
+ export declare function detectAITools(projectDir: string): DetectionResult[];
16
+ /** Get display name for a tool */
17
+ export declare function toolDisplayName(tool: AITool): string;
18
+ export {};
19
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,MAAM,MAAM,GAAG,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3F,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;CACzB;AAqDD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,EAAE,CA2BnE;AAED,kCAAkC;AAClC,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUpD"}