@intelligentelectron/pdf-analyzer 0.0.3

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,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 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
+ Copyright 2024-2025 Valentino Zegna
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.md ADDED
@@ -0,0 +1,220 @@
1
+ # PDF Analyzer MCP Server
2
+
3
+ The **PDF Analyzer MCP Server** gives AI agents the ability to read and
4
+ analyze PDF documents, enabling document Q&A through natural conversations.
5
+
6
+ Powered by Google's Gemini API. You'll need a free API key from Google AI Studio.
7
+
8
+ ## Native Install (Recommended)
9
+
10
+ **macOS / Linux:**
11
+
12
+ ```bash
13
+ curl -fsSL https://raw.githubusercontent.com/IntelligentElectron/pdf-analyzer/main/install.sh | bash
14
+ ```
15
+
16
+ **Windows (PowerShell):**
17
+
18
+ ```powershell
19
+ irm https://raw.githubusercontent.com/IntelligentElectron/pdf-analyzer/main/install.ps1 | iex
20
+ ```
21
+
22
+ Why use the native installer:
23
+ - **No dependencies** — standalone binary, no Node.js required
24
+ - **Auto-updates** — checks for updates on startup
25
+ - **Signed binaries** — macOS binaries are notarized by Apple
26
+
27
+ | Platform | Install Directory |
28
+ |----------|-------------------|
29
+ | macOS | `~/Library/Application Support/pdf-analyzer/` |
30
+ | Linux | `~/.pdf-analyzer/` |
31
+ | Windows | `%LOCALAPPDATA%\pdf-analyzer\` |
32
+
33
+ ### Update
34
+
35
+ The server checks for updates on startup. To update manually:
36
+
37
+ ```bash
38
+ pdf-analyzer --update
39
+ ```
40
+
41
+ ## Get Your Gemini API Key
42
+
43
+ 1. Go to [Google AI Studio](https://aistudio.google.com/apikey)
44
+ 2. Create a new API key (free tier available)
45
+ 3. Create a `.env` file in your project folder:
46
+
47
+ ```
48
+ GEMINI_API_KEY=your-api-key-here
49
+ ```
50
+
51
+ The server automatically loads the API key from `.env` in your current working directory.
52
+
53
+ ## Connect the MCP with your favorite AI tool
54
+
55
+ ### Claude Desktop
56
+
57
+ Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
58
+ or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "pdf-analyzer": {
64
+ "command": "pdf-analyzer"
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ <details>
71
+ <summary><strong>Claude Code</strong></summary>
72
+
73
+ ```bash
74
+ claude mcp add pdf-analyzer -- pdf-analyzer
75
+ ```
76
+
77
+ Or using the standalone binary path:
78
+
79
+ macOS:
80
+
81
+ ```bash
82
+ claude mcp add pdf-analyzer -- ~/Library/Application\ Support/pdf-analyzer/bin/pdf-analyzer
83
+ ```
84
+
85
+ Linux:
86
+
87
+ ```bash
88
+ claude mcp add pdf-analyzer -- ~/.pdf-analyzer/bin/pdf-analyzer
89
+ ```
90
+
91
+ </details>
92
+
93
+ <details>
94
+ <summary><strong>VS Code (GitHub Copilot)</strong></summary>
95
+
96
+ Add to `.vscode/mcp.json` in your project.
97
+
98
+ **macOS:**
99
+
100
+ ```json
101
+ {
102
+ "servers": {
103
+ "pdf-analyzer": {
104
+ "type": "stdio",
105
+ "command": "/Users/YOUR_USERNAME/Library/Application Support/pdf-analyzer/bin/pdf-analyzer"
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ **Linux:**
112
+
113
+ ```json
114
+ {
115
+ "servers": {
116
+ "pdf-analyzer": {
117
+ "type": "stdio",
118
+ "command": "/home/YOUR_USERNAME/.pdf-analyzer/bin/pdf-analyzer"
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ **Windows:**
125
+
126
+ ```json
127
+ {
128
+ "servers": {
129
+ "pdf-analyzer": {
130
+ "type": "stdio",
131
+ "command": "C:\\Users\\YOUR_USERNAME\\AppData\\Local\\pdf-analyzer\\bin\\pdf-analyzer.exe"
132
+ }
133
+ }
134
+ }
135
+ ```
136
+
137
+ Then enable in **Configure Tools** (click the tools icon in Copilot chat).
138
+
139
+ </details>
140
+
141
+ <details>
142
+ <summary><strong>Gemini CLI</strong></summary>
143
+
144
+ Add to `~/.gemini/settings.json` (global) or `.gemini/settings.json` (project).
145
+
146
+ **macOS:**
147
+
148
+ ```json
149
+ {
150
+ "mcpServers": {
151
+ "pdf-analyzer": {
152
+ "command": "/Users/YOUR_USERNAME/Library/Application Support/pdf-analyzer/bin/pdf-analyzer"
153
+ }
154
+ }
155
+ }
156
+ ```
157
+
158
+ **Linux:**
159
+
160
+ ```json
161
+ {
162
+ "mcpServers": {
163
+ "pdf-analyzer": {
164
+ "command": "/home/YOUR_USERNAME/.pdf-analyzer/bin/pdf-analyzer"
165
+ }
166
+ }
167
+ }
168
+ ```
169
+
170
+ **Windows:**
171
+
172
+ ```json
173
+ {
174
+ "mcpServers": {
175
+ "pdf-analyzer": {
176
+ "command": "C:\\Users\\YOUR_USERNAME\\AppData\\Local\\pdf-analyzer\\bin\\pdf-analyzer.exe"
177
+ }
178
+ }
179
+ }
180
+ ```
181
+
182
+ </details>
183
+
184
+ ## Usage
185
+
186
+ Once connected, ask your AI assistant to analyze any PDF:
187
+
188
+ - "Analyze /path/to/document.pdf and summarize the key points"
189
+ - "What tables are in this PDF? Extract the data from table 2"
190
+ - "Compare the findings in sections 3 and 5 of this report"
191
+
192
+ The server accepts:
193
+ - Local file paths: `/Users/name/docs/report.pdf`
194
+ - URLs: `https://example.com/document.pdf`
195
+
196
+ ## Supported Platforms
197
+
198
+ | Platform | Binary |
199
+ |----------|--------|
200
+ | macOS (Apple Silicon) | `pdf-analyzer-darwin-arm64` |
201
+ | macOS (Intel) | `pdf-analyzer-darwin-x64` |
202
+ | Linux (x64) | `pdf-analyzer-linux-x64` |
203
+ | Linux (ARM64) | `pdf-analyzer-linux-arm64` |
204
+ | Windows (x64) | `pdf-analyzer-windows-x64.exe` |
205
+
206
+ ## Documentation
207
+
208
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines.
209
+
210
+ ---
211
+
212
+ ## About
213
+
214
+ Created by **Valentino Zegna**
215
+
216
+ This project is hosted on GitHub under the [IntelligentElectron](https://github.com/IntelligentElectron) organization.
217
+
218
+ ## License
219
+
220
+ Apache License 2.0 - see [LICENSE](LICENSE)
@@ -0,0 +1,19 @@
1
+ /**
2
+ * CLI command handlers for --version, --help, --update, and --uninstall.
3
+ */
4
+ /**
5
+ * Print version information.
6
+ */
7
+ export declare const printVersion: () => void;
8
+ /**
9
+ * Print help message.
10
+ */
11
+ export declare const printHelp: () => void;
12
+ /**
13
+ * Handle the --update flag: check and apply updates interactively.
14
+ */
15
+ export declare const handleUpdateCommand: () => Promise<void>;
16
+ /**
17
+ * Handle the --uninstall flag: remove pdf-analyzer from the system.
18
+ */
19
+ export declare const handleUninstallCommand: () => Promise<void>;
@@ -0,0 +1,147 @@
1
+ /**
2
+ * CLI command handlers for --version, --help, --update, and --uninstall.
3
+ */
4
+ import * as fs from "node:fs";
5
+ import * as path from "node:path";
6
+ import * as os from "node:os";
7
+ import { VERSION, GITHUB_REPO, BINARY_NAME } from "../version.js";
8
+ import { checkForUpdate, performUpdate } from "./updater.js";
9
+ import { removeFromPath } from "./shell.js";
10
+ /**
11
+ * Print version information.
12
+ */
13
+ export const printVersion = () => {
14
+ console.log(`${BINARY_NAME} v${VERSION}`);
15
+ };
16
+ /**
17
+ * Print help message.
18
+ */
19
+ export const printHelp = () => {
20
+ console.log(`
21
+ ${BINARY_NAME} v${VERSION}
22
+
23
+ MCP server for analyzing PDF documents using Gemini AI.
24
+
25
+ USAGE:
26
+ ${BINARY_NAME} [OPTIONS]
27
+
28
+ OPTIONS:
29
+ --version, -v Print version and exit
30
+ --update Check for updates and apply if available
31
+ --uninstall Remove ${BINARY_NAME} from the system
32
+ --no-update Skip auto-update check on startup
33
+ --help, -h Show this help message
34
+
35
+ ENVIRONMENT VARIABLES:
36
+ GEMINI_API_KEY Required. Your Gemini API key from Google AI Studio.
37
+ PDF_MCP_NO_UPDATE=1 Disable auto-updates
38
+
39
+ INSTALLATION:
40
+ curl -fsSL https://raw.githubusercontent.com/${GITHUB_REPO}/main/install.sh | bash
41
+
42
+ MCP CONFIGURATION:
43
+ {
44
+ "mcpServers": {
45
+ "pdf-analyzer": {
46
+ "command": "${BINARY_NAME}",
47
+ "env": {
48
+ "GEMINI_API_KEY": "your-api-key-here"
49
+ }
50
+ }
51
+ }
52
+ }
53
+
54
+ MORE INFO:
55
+ https://github.com/${GITHUB_REPO}
56
+ `.trim());
57
+ };
58
+ /**
59
+ * Simple confirmation prompt for terminal.
60
+ */
61
+ const confirm = async (message) => {
62
+ return new Promise((resolve) => {
63
+ process.stdout.write(`${message} [y/N] `);
64
+ const onData = (data) => {
65
+ const answer = data.toString().trim().toLowerCase();
66
+ process.stdin.removeListener("data", onData);
67
+ process.stdin.pause();
68
+ resolve(answer === "y" || answer === "yes");
69
+ };
70
+ process.stdin.resume();
71
+ process.stdin.setEncoding("utf8");
72
+ process.stdin.once("data", onData);
73
+ });
74
+ };
75
+ /**
76
+ * Handle the --update flag: check and apply updates interactively.
77
+ */
78
+ export const handleUpdateCommand = async () => {
79
+ console.log(`Current version: ${VERSION}`);
80
+ console.log("Checking for updates...");
81
+ const check = await checkForUpdate();
82
+ if (check.error) {
83
+ console.error(`Error checking for updates: ${check.error}`);
84
+ process.exit(1);
85
+ }
86
+ if (!check.updateAvailable) {
87
+ console.log(`Already up to date (${VERSION})`);
88
+ return;
89
+ }
90
+ if (!check.downloadUrl || !check.latestVersion) {
91
+ console.error("Update available but no download URL found for your platform");
92
+ process.exit(1);
93
+ }
94
+ console.log(`Update available: ${VERSION} → ${check.latestVersion}`);
95
+ console.log("Downloading...");
96
+ const result = await performUpdate(check.downloadUrl, check.latestVersion);
97
+ if (!result.success) {
98
+ console.error(`Update failed: ${result.error}`);
99
+ process.exit(1);
100
+ }
101
+ // On Windows, we need to ensure stdout is flushed before exiting
102
+ // because replacing the running executable can cause issues
103
+ const message = `Successfully updated to ${result.newVersion}\n`;
104
+ await new Promise((resolve) => {
105
+ process.stdout.write(message, () => resolve());
106
+ });
107
+ };
108
+ /**
109
+ * Handle the --uninstall flag: remove pdf-analyzer from the system.
110
+ */
111
+ export const handleUninstallCommand = async () => {
112
+ const home = os.homedir();
113
+ const installDir = path.join(home, `.${BINARY_NAME}`);
114
+ const binaryPath = path.join(installDir, "bin", BINARY_NAME);
115
+ console.log("");
116
+ console.log(`This will remove ${BINARY_NAME} from your system:`);
117
+ console.log(` - Binary: ${binaryPath}`);
118
+ console.log(` - Directory: ${installDir}`);
119
+ console.log(" - PATH entries from shell config files");
120
+ console.log("");
121
+ const confirmed = await confirm("Are you sure you want to uninstall?");
122
+ if (!confirmed) {
123
+ console.log("Uninstall cancelled.");
124
+ return;
125
+ }
126
+ console.log("");
127
+ // Remove PATH entries from shell rc files
128
+ const modifiedFiles = removeFromPath();
129
+ if (modifiedFiles.length > 0) {
130
+ console.log("Removed PATH entries from:");
131
+ for (const file of modifiedFiles) {
132
+ console.log(` - ${file}`);
133
+ }
134
+ }
135
+ // Remove the installation directory
136
+ if (fs.existsSync(installDir)) {
137
+ fs.rmSync(installDir, { recursive: true });
138
+ console.log(`Removed: ${installDir}`);
139
+ }
140
+ console.log("");
141
+ console.log("Uninstall complete!");
142
+ console.log("");
143
+ console.log("To reinstall, run:");
144
+ console.log(` curl -fsSL https://raw.githubusercontent.com/${GITHUB_REPO}/main/install.sh | bash`);
145
+ console.log("");
146
+ };
147
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAS,EAAE;IACrC,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,KAAK,OAAO,EAAE,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF;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E,CAAC;QAC9B,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,YAAY,UAAU,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAClC,OAAO,CAAC,GAAG,CACT,kDAAkD,WAAW,yBAAyB,CACvF,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shell rc file manipulation for PATH integration.
3
+ */
4
+ /**
5
+ * Get shell configuration file paths to check for PATH entries.
6
+ */
7
+ export declare const getShellRcFiles: () => string[];
8
+ /**
9
+ * Remove pdf-analyzer PATH entries from shell rc files.
10
+ * Looks for "# PDF Analyzer" comment blocks and removes them.
11
+ */
12
+ export declare const removeFromPath: () => string[];
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Shell rc file manipulation for PATH integration.
3
+ */
4
+ import * as fs from "node:fs";
5
+ import * as path from "node:path";
6
+ import * as os from "node:os";
7
+ import { BINARY_NAME } from "../version.js";
8
+ /**
9
+ * Get shell configuration file paths to check for PATH entries.
10
+ */
11
+ export const getShellRcFiles = () => {
12
+ const home = os.homedir();
13
+ return [
14
+ path.join(home, ".zshrc"),
15
+ path.join(home, ".bashrc"),
16
+ path.join(home, ".bash_profile"),
17
+ path.join(home, ".profile"),
18
+ path.join(home, ".config", "fish", "config.fish"),
19
+ ];
20
+ };
21
+ /**
22
+ * Remove pdf-analyzer PATH entries from shell rc files.
23
+ * Looks for "# PDF Analyzer" comment blocks and removes them.
24
+ */
25
+ export const removeFromPath = () => {
26
+ const modified = [];
27
+ for (const rcFile of getShellRcFiles()) {
28
+ if (!fs.existsSync(rcFile))
29
+ continue;
30
+ const content = fs.readFileSync(rcFile, "utf-8");
31
+ const lines = content.split("\n");
32
+ const filtered = [];
33
+ let i = 0;
34
+ let changed = false;
35
+ while (i < lines.length) {
36
+ const line = lines[i];
37
+ // Skip "# PDF Analyzer" comment and the following export/fish_add_path line
38
+ if (line.trim() === "# PDF Analyzer") {
39
+ changed = true;
40
+ i++; // Skip comment
41
+ // Skip the next line if it's the PATH export
42
+ if (i < lines.length && lines[i].includes(BINARY_NAME)) {
43
+ i++;
44
+ }
45
+ // Skip trailing empty line if present
46
+ if (i < lines.length && lines[i].trim() === "") {
47
+ i++;
48
+ }
49
+ continue;
50
+ }
51
+ filtered.push(line);
52
+ i++;
53
+ }
54
+ if (changed) {
55
+ // Remove trailing newlines
56
+ while (filtered.length > 0 && filtered[filtered.length - 1] === "") {
57
+ filtered.pop();
58
+ }
59
+ fs.writeFileSync(rcFile, filtered.join("\n") + "\n");
60
+ modified.push(rcFile);
61
+ }
62
+ }
63
+ return modified;
64
+ };
65
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/cli/shell.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAa,EAAE;IAC5C,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC1B,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC;QAC1B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