opendraft 1.4.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/README.md +57 -0
- package/bin/opendraft.js +207 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# OpenDraft
|
|
2
|
+
|
|
3
|
+
AI-powered research paper draft generator.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx opendraft
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
That's it! The CLI will:
|
|
12
|
+
1. Check if Python 3.9+ is installed
|
|
13
|
+
2. Install the OpenDraft package if needed
|
|
14
|
+
3. Launch the interactive paper generator
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Interactive mode (recommended)
|
|
20
|
+
npx opendraft
|
|
21
|
+
|
|
22
|
+
# Quick generate
|
|
23
|
+
npx opendraft "Impact of AI on Modern Education"
|
|
24
|
+
|
|
25
|
+
# With options
|
|
26
|
+
npx opendraft "Your Topic" --level master --style apa
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Options
|
|
30
|
+
|
|
31
|
+
| Option | Values | Default |
|
|
32
|
+
|--------|--------|---------|
|
|
33
|
+
| `--level, -l` | research_paper, bachelor, master, phd | research_paper |
|
|
34
|
+
| `--style, -s` | apa, mla, chicago, ieee | apa |
|
|
35
|
+
| `--output, -o` | Directory path | ./opendraft_output |
|
|
36
|
+
|
|
37
|
+
## Requirements
|
|
38
|
+
|
|
39
|
+
- Node.js 16+ (for npx)
|
|
40
|
+
- Python 3.9+ (installed automatically if missing guidance provided)
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- 19 specialized AI agents working together
|
|
45
|
+
- Real citations from CrossRef, Semantic Scholar, arXiv
|
|
46
|
+
- PDF and Word output
|
|
47
|
+
- Multiple citation styles (APA, MLA, Chicago, IEEE)
|
|
48
|
+
|
|
49
|
+
## Links
|
|
50
|
+
|
|
51
|
+
- Website: https://opendraft.xyz
|
|
52
|
+
- Documentation: https://opendraft.xyz/docs
|
|
53
|
+
- GitHub: https://github.com/federicodeponte/opendraft
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
package/bin/opendraft.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OpenDraft CLI - npm wrapper for the Python paper generator
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* npx opendraft - Interactive mode
|
|
8
|
+
* npx opendraft "Your Topic" - Quick generate
|
|
9
|
+
* npx opendraft --install - Install/update Python package
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { spawn, execSync } = require('child_process');
|
|
13
|
+
const os = require('os');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
|
|
16
|
+
const PURPLE = '\x1b[95m';
|
|
17
|
+
const GREEN = '\x1b[92m';
|
|
18
|
+
const YELLOW = '\x1b[93m';
|
|
19
|
+
const RED = '\x1b[91m';
|
|
20
|
+
const CYAN = '\x1b[96m';
|
|
21
|
+
const GRAY = '\x1b[90m';
|
|
22
|
+
const BOLD = '\x1b[1m';
|
|
23
|
+
const RESET = '\x1b[0m';
|
|
24
|
+
|
|
25
|
+
function print(msg) {
|
|
26
|
+
console.log(` ${msg}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function printLogo() {
|
|
30
|
+
console.log(`
|
|
31
|
+
${PURPLE}${BOLD} ╔══════════════════════════════════════════════════════════╗
|
|
32
|
+
║ ║
|
|
33
|
+
║ ██████╗ ██████╗ ███████╗███╗ ██╗ ║
|
|
34
|
+
║ ██╔═══██╗██╔══██╗██╔════╝████╗ ██║ ║
|
|
35
|
+
║ ██║ ██║██████╔╝█████╗ ██╔██╗ ██║ ║
|
|
36
|
+
║ ██║ ██║██╔═══╝ ██╔══╝ ██║╚██╗██║ ║
|
|
37
|
+
║ ╚██████╔╝██║ ███████╗██║ ╚████║ ║
|
|
38
|
+
║ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ║
|
|
39
|
+
║ ██████╗ ██████╗ █████╗ ███████╗████████╗ ║
|
|
40
|
+
║ ██╔══██╗██╔══██╗██╔══██╗██╔════╝╚══██╔══╝ ║
|
|
41
|
+
║ ██║ ██║██████╔╝███████║█████╗ ██║ ║
|
|
42
|
+
║ ██║ ██║██╔══██╗██╔══██║██╔══╝ ██║ ║
|
|
43
|
+
║ ██████╔╝██║ ██║██║ ██║██║ ██║ ║
|
|
44
|
+
║ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ║
|
|
45
|
+
║ ║
|
|
46
|
+
╚══════════════════════════════════════════════════════════╝${RESET}
|
|
47
|
+
`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function checkPython() {
|
|
51
|
+
const pythonCommands = ['python3', 'python'];
|
|
52
|
+
|
|
53
|
+
for (const cmd of pythonCommands) {
|
|
54
|
+
try {
|
|
55
|
+
const version = execSync(`${cmd} --version 2>&1`, { encoding: 'utf8' }).trim();
|
|
56
|
+
const match = version.match(/Python (\d+)\.(\d+)/);
|
|
57
|
+
if (match) {
|
|
58
|
+
const major = parseInt(match[1]);
|
|
59
|
+
const minor = parseInt(match[2]);
|
|
60
|
+
if (major >= 3 && minor >= 9) {
|
|
61
|
+
return { cmd, version: `${major}.${minor}` };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
// Command not found, try next
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function checkOpendraftInstalled(pythonCmd) {
|
|
72
|
+
try {
|
|
73
|
+
execSync(`${pythonCmd} -c "import opendraft"`, { encoding: 'utf8', stdio: 'pipe' });
|
|
74
|
+
return true;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function installOpendraft(pythonCmd) {
|
|
81
|
+
print(`${CYAN}Installing OpenDraft...${RESET}`);
|
|
82
|
+
try {
|
|
83
|
+
execSync(`${pythonCmd} -m pip install --upgrade opendraft`, {
|
|
84
|
+
encoding: 'utf8',
|
|
85
|
+
stdio: 'inherit'
|
|
86
|
+
});
|
|
87
|
+
return true;
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function runOpendraft(pythonCmd, args) {
|
|
94
|
+
const proc = spawn(pythonCmd, ['-m', 'opendraft', ...args], {
|
|
95
|
+
stdio: 'inherit',
|
|
96
|
+
env: process.env
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
proc.on('close', (code) => {
|
|
100
|
+
process.exit(code);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function showInstallInstructions() {
|
|
105
|
+
console.log();
|
|
106
|
+
print(`${RED}Python 3.9+ is required but not found.${RESET}`);
|
|
107
|
+
console.log();
|
|
108
|
+
|
|
109
|
+
const platform = os.platform();
|
|
110
|
+
|
|
111
|
+
if (platform === 'darwin') {
|
|
112
|
+
print(`${BOLD}Install Python on macOS:${RESET}`);
|
|
113
|
+
console.log();
|
|
114
|
+
print(` ${CYAN}brew install python@3.11${RESET}`);
|
|
115
|
+
console.log();
|
|
116
|
+
print(`Or download from: ${CYAN}https://www.python.org/downloads/${RESET}`);
|
|
117
|
+
} else if (platform === 'win32') {
|
|
118
|
+
print(`${BOLD}Install Python on Windows:${RESET}`);
|
|
119
|
+
console.log();
|
|
120
|
+
print(` 1. Download from: ${CYAN}https://www.python.org/downloads/${RESET}`);
|
|
121
|
+
print(` 2. ${YELLOW}Check "Add Python to PATH" during installation${RESET}`);
|
|
122
|
+
} else {
|
|
123
|
+
print(`${BOLD}Install Python on Linux:${RESET}`);
|
|
124
|
+
console.log();
|
|
125
|
+
print(` ${CYAN}sudo apt install python3 python3-pip${RESET} # Debian/Ubuntu`);
|
|
126
|
+
print(` ${CYAN}sudo dnf install python3 python3-pip${RESET} # Fedora`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
console.log();
|
|
130
|
+
print(`Then run: ${CYAN}npx opendraft${RESET}`);
|
|
131
|
+
console.log();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function main() {
|
|
135
|
+
const args = process.argv.slice(2);
|
|
136
|
+
|
|
137
|
+
// Handle --version
|
|
138
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
139
|
+
const pkg = require('../package.json');
|
|
140
|
+
console.log(`opendraft ${pkg.version} (npm wrapper)`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Handle --help
|
|
145
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
146
|
+
printLogo();
|
|
147
|
+
print(`${BOLD}Usage:${RESET}`);
|
|
148
|
+
print(` ${CYAN}npx opendraft${RESET} Interactive mode`);
|
|
149
|
+
print(` ${CYAN}npx opendraft "Your Topic"${RESET} Quick generate`);
|
|
150
|
+
print(` ${CYAN}npx opendraft --install${RESET} Install/update`);
|
|
151
|
+
console.log();
|
|
152
|
+
print(`${BOLD}Options:${RESET}`);
|
|
153
|
+
print(` --level, -l Academic level (research_paper, bachelor, master, phd)`);
|
|
154
|
+
print(` --style, -s Citation style (apa, mla, chicago, ieee)`);
|
|
155
|
+
print(` --output, -o Output directory`);
|
|
156
|
+
console.log();
|
|
157
|
+
print(`${GRAY}More info: https://opendraft.xyz/docs${RESET}`);
|
|
158
|
+
console.log();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Check Python
|
|
163
|
+
const python = checkPython();
|
|
164
|
+
|
|
165
|
+
if (!python) {
|
|
166
|
+
printLogo();
|
|
167
|
+
showInstallInstructions();
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Handle --install
|
|
172
|
+
if (args.includes('--install')) {
|
|
173
|
+
printLogo();
|
|
174
|
+
print(`${GREEN}✓${RESET} Python ${python.version} found`);
|
|
175
|
+
if (installOpendraft(python.cmd)) {
|
|
176
|
+
print(`${GREEN}✓${RESET} OpenDraft installed successfully`);
|
|
177
|
+
console.log();
|
|
178
|
+
print(`Run: ${CYAN}npx opendraft${RESET}`);
|
|
179
|
+
} else {
|
|
180
|
+
print(`${RED}✗${RESET} Installation failed`);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
console.log();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Check if opendraft is installed
|
|
188
|
+
if (!checkOpendraftInstalled(python.cmd)) {
|
|
189
|
+
printLogo();
|
|
190
|
+
print(`${YELLOW}First time setup...${RESET}`);
|
|
191
|
+
console.log();
|
|
192
|
+
if (!installOpendraft(python.cmd)) {
|
|
193
|
+
print(`${RED}✗${RESET} Failed to install OpenDraft`);
|
|
194
|
+
process.exit(1);
|
|
195
|
+
}
|
|
196
|
+
print(`${GREEN}✓${RESET} OpenDraft installed`);
|
|
197
|
+
console.log();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Run opendraft
|
|
201
|
+
runOpendraft(python.cmd, args);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
main().catch((err) => {
|
|
205
|
+
console.error(err);
|
|
206
|
+
process.exit(1);
|
|
207
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opendraft",
|
|
3
|
+
"version": "1.4.3",
|
|
4
|
+
"description": "AI-powered research paper draft generator",
|
|
5
|
+
"bin": {
|
|
6
|
+
"opendraft": "./bin/opendraft.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "node bin/opendraft.js --version"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"research",
|
|
13
|
+
"paper",
|
|
14
|
+
"thesis",
|
|
15
|
+
"academic",
|
|
16
|
+
"ai",
|
|
17
|
+
"writing",
|
|
18
|
+
"citations",
|
|
19
|
+
"generator"
|
|
20
|
+
],
|
|
21
|
+
"author": "OpenDraft Team",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/federicodeponte/opendraft.git"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://opendraft.xyz",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=16.0.0"
|
|
30
|
+
}
|
|
31
|
+
}
|