mc-pdf-studio 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/README.md +154 -0
- package/index.js +46 -0
- package/package.json +48 -0
- package/public/index.html +1700 -0
- package/src/server.js +250 -0
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# ✦ MC PDF Studio
|
|
2
|
+
|
|
3
|
+
> A polished PDF viewer CLI with dark/light themes, minimap navigation, and a multi-provider AI Sidekick (Claude, Ollama, OpenAI, xAI).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Screenshots
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g mc-pdf-studio
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
mc-pdf-studio open [file] [options]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or without global install:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
node index.js open [file] [options]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Options
|
|
38
|
+
|
|
39
|
+
| Flag | Description | Default |
|
|
40
|
+
|------|-------------|---------|
|
|
41
|
+
| `[file]` | Path to a PDF file to open immediately | — |
|
|
42
|
+
| `-p, --port <port>` | Port to listen on | `3000` |
|
|
43
|
+
| `--enable-ai` | Enable AI Sidekick | disabled |
|
|
44
|
+
| `--ai-provider <provider>` | AI provider: `anthropic`, `ollama`, `openai`, `xai` | `anthropic` |
|
|
45
|
+
| `--ai-model <model>` | Model name for the chosen provider | provider default |
|
|
46
|
+
| `--ai-base-url <url>` | Base URL for Ollama or OpenAI-compatible providers | provider default |
|
|
47
|
+
| `--no-minimap` | Hide the page minimap panel | shown |
|
|
48
|
+
| `--theme <dark\|light>` | Initial color theme | `dark` |
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Examples
|
|
53
|
+
|
|
54
|
+
**Open the viewer (no file):**
|
|
55
|
+
```bash
|
|
56
|
+
mc-pdf-studio open
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Open a specific PDF:**
|
|
60
|
+
```bash
|
|
61
|
+
mc-pdf-studio open ./report.pdf
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**AI Sidekick with Claude (Anthropic):**
|
|
65
|
+
```bash
|
|
66
|
+
ANTHROPIC_API_KEY=sk-ant-... mc-pdf-studio open ./report.pdf --enable-ai
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**AI Sidekick with Ollama (local, no API key needed):**
|
|
70
|
+
```bash
|
|
71
|
+
mc-pdf-studio open ./report.pdf --enable-ai --ai-provider ollama --ai-model llama3.2:latest
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**AI Sidekick with OpenAI:**
|
|
75
|
+
```bash
|
|
76
|
+
OPENAI_API_KEY=sk-... mc-pdf-studio open ./report.pdf --enable-ai --ai-provider openai --ai-model gpt-4o
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**AI Sidekick with xAI (Grok):**
|
|
80
|
+
```bash
|
|
81
|
+
XAI_API_KEY=... mc-pdf-studio open ./report.pdf --enable-ai --ai-provider xai --ai-model grok-beta
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Light theme, custom port, no minimap:**
|
|
85
|
+
```bash
|
|
86
|
+
mc-pdf-studio open ./doc.pdf --theme light --port 8080 --no-minimap
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## AI Provider Environment Variables
|
|
92
|
+
|
|
93
|
+
| Provider | Env Var | Notes |
|
|
94
|
+
|----------|---------|-------|
|
|
95
|
+
| `anthropic` | `ANTHROPIC_API_KEY` | Default provider |
|
|
96
|
+
| `ollama` | — | Local, no key needed |
|
|
97
|
+
| `openai` | `OPENAI_API_KEY` | |
|
|
98
|
+
| `xai` | `XAI_API_KEY` | |
|
|
99
|
+
|
|
100
|
+
You can also change the provider at runtime without restarting — open **Settings ⚙️** in the UI to switch providers, fetch available Ollama models, and set the active model.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Features
|
|
105
|
+
|
|
106
|
+
### 📄 PDF Viewer
|
|
107
|
+
- Renders all pages using PDF.js in the browser
|
|
108
|
+
- Smooth scroll through all pages
|
|
109
|
+
- Drag & drop PDF files to open them
|
|
110
|
+
- Upload button for file browsing
|
|
111
|
+
|
|
112
|
+
### 🗺️ Minimap Panel
|
|
113
|
+
- Thumbnail preview of every page in a left sidebar
|
|
114
|
+
- Click any thumbnail to jump to that page
|
|
115
|
+
- Highlights the currently visible page
|
|
116
|
+
- Toggle with the minimap button in the header
|
|
117
|
+
|
|
118
|
+
### 🔍 Navigation & Zoom
|
|
119
|
+
- Page number input (click to type a page number)
|
|
120
|
+
- Previous/Next arrow buttons
|
|
121
|
+
- Keyboard arrows: `←/→` or `↑/↓` to move pages
|
|
122
|
+
- Zoom in/out buttons and fit-to-width mode
|
|
123
|
+
- Keyboard: `+` / `-` / `0` for zoom
|
|
124
|
+
|
|
125
|
+
### 🌙 Dark / Light Theme
|
|
126
|
+
- Toggle with the sun/moon button in the header
|
|
127
|
+
|
|
128
|
+
### ✦ AI Sidekick
|
|
129
|
+
- Slide-in panel on the right side
|
|
130
|
+
- Chat about your PDF: ask questions, get summaries, extract data
|
|
131
|
+
- Quick-prompt chips: Summarize, Key points, Overview, Numbers & dates, Conclusions
|
|
132
|
+
- Full markdown rendering in responses
|
|
133
|
+
- Maintains conversation history within a session
|
|
134
|
+
- **Settings UI** (⚙️ button) to switch providers and models live — no restart required
|
|
135
|
+
- Supports: Claude by Anthropic, Ollama (local), OpenAI, xAI (Grok)
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## API Routes
|
|
140
|
+
|
|
141
|
+
| Route | Description |
|
|
142
|
+
|-------|-------------|
|
|
143
|
+
| `GET /api/config` | Returns server config (AI provider, theme, etc.) |
|
|
144
|
+
| `GET /api/initial-pdf` | Streams the startup PDF if one was provided |
|
|
145
|
+
| `POST /api/upload` | Accepts a PDF upload, returns a temp path |
|
|
146
|
+
| `GET /api/pdf?path=...` | Streams an uploaded PDF by temp path |
|
|
147
|
+
| `GET /api/pdf-info?path=...` | Returns page count and metadata |
|
|
148
|
+
| `POST /api/ai/chat` | Chat endpoint (requires `--enable-ai`) |
|
|
149
|
+
| `POST /api/ai/settings` | Update AI provider/model at runtime |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
- MIT (c) Mohan Chinnappan
|
package/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
program
|
|
8
|
+
.name('mc-pdf-studio')
|
|
9
|
+
.description('✦ MC PDF Studio — beautiful PDF viewer with multi-provider AI Sidekick')
|
|
10
|
+
.version('1.0.0');
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.command('open [file]')
|
|
14
|
+
.description('Open a PDF file in the viewer')
|
|
15
|
+
.option('-p, --port <port>', 'Port to run the server on', '3000')
|
|
16
|
+
.option('--enable-ai', 'Enable AI Sidekick')
|
|
17
|
+
.option('--ai-provider <provider>', 'AI provider: anthropic, ollama, openai, xai', 'anthropic')
|
|
18
|
+
.option('--ai-model <model>', 'Model name for the chosen provider')
|
|
19
|
+
.option('--ai-base-url <url>', 'Base URL for Ollama or OpenAI-compatible providers')
|
|
20
|
+
.option('--no-minimap', 'Disable the minimap panel')
|
|
21
|
+
.option('--theme <theme>', 'Default theme: dark or light', 'dark')
|
|
22
|
+
.action((file, options) => {
|
|
23
|
+
if (file && !fs.existsSync(file)) {
|
|
24
|
+
console.error(`\n ✗ File not found: ${file}\n`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const server = require('./src/server');
|
|
29
|
+
server.start({
|
|
30
|
+
port: parseInt(options.port),
|
|
31
|
+
enableAi: options.enableAi,
|
|
32
|
+
aiProvider: options.aiProvider || 'anthropic',
|
|
33
|
+
aiModel: options.aiModel || null,
|
|
34
|
+
aiBaseUrl: options.aiBaseUrl || null,
|
|
35
|
+
minimap: options.minimap !== false,
|
|
36
|
+
theme: options.theme,
|
|
37
|
+
initialFile: file ? path.resolve(file) : null,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
program.parse(process.argv);
|
|
42
|
+
|
|
43
|
+
// If no command given, show help
|
|
44
|
+
if (!process.argv.slice(2).length) {
|
|
45
|
+
program.outputHelp();
|
|
46
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mc-pdf-studio",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MC PDF Studio — a beautiful PDF viewer CLI with dark/light themes, minimap navigation, and a multi-provider AI Sidekick (Claude, Ollama, OpenAI, xAI)",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node index.js open",
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"pdf",
|
|
12
|
+
"viewer",
|
|
13
|
+
"cli",
|
|
14
|
+
"pdf-viewer",
|
|
15
|
+
"ai",
|
|
16
|
+
"ollama",
|
|
17
|
+
"claude",
|
|
18
|
+
"openai",
|
|
19
|
+
"dark-theme",
|
|
20
|
+
"minimap"
|
|
21
|
+
],
|
|
22
|
+
"author": "Mohan Chinnappan",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"files": [
|
|
25
|
+
"index.js",
|
|
26
|
+
"src/",
|
|
27
|
+
"public/",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"commander": "^14.0.3",
|
|
32
|
+
"cors": "^2.8.6",
|
|
33
|
+
"express": "^5.2.1",
|
|
34
|
+
"multer": "^2.1.1",
|
|
35
|
+
"pdf-parse": "^1.1.4"
|
|
36
|
+
},
|
|
37
|
+
"bin": {
|
|
38
|
+
"mc-pdf-studio": "./index.js",
|
|
39
|
+
"mc-pdf": "./index.js"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/mchinnappan/mc-pdf-studio"
|
|
47
|
+
}
|
|
48
|
+
}
|