autoscholar-cli 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AutoScholar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ <p align="center">
2
+ <br/>
3
+ <strong>
4
+ <code>&nbsp;A u t o S c h o l a r&nbsp;&nbsp;C L I&nbsp;</code>
5
+ </strong>
6
+ <br/><br/>
7
+ <em>A quant researcher + economist + data scientist living inside your terminal.</em>
8
+ <br/><br/>
9
+ <a href="https://www.npmjs.com/package/autoscholar-cli"><img src="https://img.shields.io/npm/v/autoscholar-cli?color=0EA5E9&label=npm&style=flat-square" alt="npm version"></a>
10
+ <a href="https://www.npmjs.com/package/autoscholar-cli"><img src="https://img.shields.io/npm/dm/autoscholar-cli?color=06B6D4&style=flat-square" alt="downloads"></a>
11
+ <a href="https://github.com/autoscholar/autoscholar-cli/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/autoscholar-cli?color=14B8A6&style=flat-square" alt="license"></a>
12
+ <img src="https://img.shields.io/badge/node-%3E%3D18-0EA5E9?style=flat-square" alt="node version">
13
+ <img src="https://img.shields.io/badge/python-%3E%3D3.9-0EA5E9?style=flat-square" alt="python version">
14
+ </p>
15
+
16
+ ---
17
+
18
+ **AutoScholar CLI** is an autonomous scientific research agent that generates **publication-ready academic papers** entirely from the command line. It orchestrates five AI agents to search literature, collect data, build datasets, run econometric analysis, and compile LaTeX PDFs — all without a browser or GUI.
19
+
20
+ ```
21
+ _ _ ____ _ _
22
+ / \ _ _| |_ ___ / ___| ___| |__ ___ | | __ _ _ __
23
+ / _ \| | | | __/ _ \ \___ \ / __| '_ \ / _ \| |/ _` | '__|
24
+ / ___ \ |_| | || (_) | ___) | (__| | | | (_) | | (_| | |
25
+ /_/ \_\__,_|\__\___/ |____/ \___|_| |_|\___/|_|\__,_|_|
26
+
27
+ Autonomous Scientific Research Agent v1.0.0
28
+ ```
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ npm install -g autoscholar-cli
34
+ ```
35
+
36
+ ### Python Dependencies
37
+
38
+ AutoScholar requires Python 3.9+ with the following packages:
39
+
40
+ ```bash
41
+ pip3 install pandas numpy scipy matplotlib seaborn scikit-learn statsmodels arch linearmodels
42
+ ```
43
+
44
+ ### LaTeX (optional, for PDF compilation)
45
+
46
+ Install [TeX Live](https://www.tug.org/texlive/) or [MacTeX](https://www.tug.org/mactex/) for PDF generation. Without LaTeX, papers are saved as `.tex` source files.
47
+
48
+ ## Quick Start
49
+
50
+ ```bash
51
+ # Launch interactive mode
52
+ autoscholar
53
+
54
+ # Or run directly with flags
55
+ autoscholar run --topic "Volatility spillovers between crypto and commodities 2015-2025"
56
+ ```
57
+
58
+ On first launch, AutoScholar will walk you through an interactive **setup wizard** to configure your API keys.
59
+
60
+ ## Commands
61
+
62
+ | Command | Description |
63
+ |---------|-------------|
64
+ | `autoscholar` | Interactive mode (default) |
65
+ | `autoscholar run` | Run the full research pipeline |
66
+ | `autoscholar config` | Manage API keys |
67
+ | `autoscholar outputs` | Browse generated papers |
68
+ | `autoscholar resume <id>` | Resume an incomplete project |
69
+
70
+ ### Run Options
71
+
72
+ ```bash
73
+ autoscholar run \
74
+ --topic "Factor momentum in US equities" \
75
+ --assets "AAPL,MSFT,GOOG,AMZN" \
76
+ --method "DCC-GARCH" \
77
+ --hf \ # high-frequency data
78
+ --dry # show plan only
79
+ ```
80
+
81
+ ## How It Works
82
+
83
+ AutoScholar orchestrates **five specialized AI agents** through a 7-stage pipeline:
84
+
85
+ ```
86
+ Plan -> Gauss -> Turing -> Newton -> Fisher -> Write -> Compile
87
+ | | | | | | |
88
+ | Search Fetch Clean & Run Write LaTeX
89
+ | 250M+ FMP, merge GARCH, 8 paper to
90
+ | papers EODHD, sources OLS, sections PDF
91
+ | FRED Panel
92
+ |
93
+ Euler (orchestrator)
94
+ ```
95
+
96
+ ### The Five Agents
97
+
98
+ | Agent | Role | What it does |
99
+ |-------|------|-------------|
100
+ | **Euler** | Orchestrator | Plans the study, coordinates agents, writes the paper |
101
+ | **Gauss** | Literature | Searches 250M+ papers via OpenAlex, arXiv, CrossRef. Identifies research gaps. |
102
+ | **Turing** | Data Collection | Fetches data from FMP, EODHD, FRED, World Bank, IMF |
103
+ | **Newton** | Dataset Builder | Cleans, merges, and constructs analysis-ready datasets |
104
+ | **Fisher** | Analysis Engine | Runs econometric models, generates figures & tables |
105
+
106
+ ### Governor Engine
107
+
108
+ A rule-based decision engine monitors the pipeline in real-time:
109
+
110
+ - Automatic **profile switching** (academic figures, debug recovery, LaTeX fallback)
111
+ - **Retry budgets** (5 Python, 3 data, 3 LaTeX retries)
112
+ - **Confidence scoring** that adapts to errors and successes
113
+
114
+ ## Data Sources
115
+
116
+ | Source | Coverage | Key Required |
117
+ |--------|----------|-------------|
118
+ | **OpenAlex** | 250M+ academic papers | No |
119
+ | **arXiv** | Preprints (finance, econ, stat) | No |
120
+ | **CrossRef** | 140M+ articles, DOI resolution | No |
121
+ | **FMP** | 230+ financial data endpoints | Yes |
122
+ | **EODHD** | Historical prices, intraday, options | Yes |
123
+ | **FRED** | 840,000+ macroeconomic series | Yes |
124
+ | **World Bank** | 16,000+ development indicators | No |
125
+ | **IMF** | Global Financial Stability data | No |
126
+ | **Firecrawl** | Web scraping & extraction | Yes |
127
+ | **Serper / SerpAPI** | Web & Google Scholar search | Yes |
128
+ | **Tavily** | AI-powered search | Yes |
129
+ | **Exa** | Semantic neural search | Yes |
130
+
131
+ ## API Keys
132
+
133
+ API keys are stored securely in `~/.autoscholar/.env`. Configure them interactively:
134
+
135
+ ```bash
136
+ autoscholar config
137
+ ```
138
+
139
+ | Key | Required | Purpose |
140
+ |-----|----------|---------|
141
+ | `ANTHROPIC_API_KEY` | **Yes** | Powers all AI agents |
142
+ | `FMP_API_KEY` | Recommended | Financial data (stocks, fundamentals) |
143
+ | `EODHD_API_KEY` | Recommended | Historical prices, options chains |
144
+ | `FRED_API_KEY` | Recommended | Macroeconomic data |
145
+ | `SERPER_API_KEY` | Optional | Web search |
146
+ | `SERPAPI_API_KEY` | Optional | Google Scholar |
147
+ | `FIRECRAWL_API_KEY` | Optional | Web scraping |
148
+ | `TAVILY_API_KEY` | Optional | AI search |
149
+ | `EXA_API_KEY` | Optional | Semantic search |
150
+
151
+ ## Output Structure
152
+
153
+ All outputs are stored locally:
154
+
155
+ ```
156
+ ~/.autoscholar/projects/{project-id}/
157
+ data/
158
+ fmp_prices.csv
159
+ fred_macro.csv
160
+ final_dataset.csv
161
+ code/
162
+ fisher_analysis.py
163
+ newton_build_dataset.py
164
+ output/
165
+ paper.tex
166
+ paper.pdf
167
+ references.bib
168
+ figures/
169
+ correlation_matrix.png
170
+ time_series.png
171
+ ols_diagnostics.png
172
+ ...
173
+ logs/
174
+ run_2025-01-15T10-30-00.log
175
+ meta.json
176
+ ```
177
+
178
+ ## Supported Methods
179
+
180
+ ### Econometrics
181
+ OLS, Robust SE, IV/2SLS, GMM, Panel Fixed Effects, Panel Random Effects, Hausman Test, Fama-MacBeth, GARCH, DCC-GARCH, VAR, VECM, Granger Causality, Local Projections
182
+
183
+ ### Statistics
184
+ t-tests, ANOVA, Chi-square, Mann-Whitney, Kruskal-Wallis, Bootstrap Confidence Intervals
185
+
186
+ ### Machine Learning
187
+ Random Forest, XGBoost, LightGBM, SVM/SVR, ElasticNet, PCA, k-means, SHAP
188
+
189
+ ## Requirements
190
+
191
+ - **Node.js** >= 18
192
+ - **Python** >= 3.9
193
+ - **Anthropic API key** (required)
194
+ - **LaTeX** (optional, for PDF output)
195
+
196
+ ## Philosophy
197
+
198
+ AutoScholar CLI should feel like:
199
+
200
+ > *"A quant researcher + economist + data scientist living inside your terminal"*
201
+
202
+ It is:
203
+
204
+ - **Autonomous** — end-to-end paper generation with no manual steps
205
+ - **Reproducible** — all code, data, and logs saved per project
206
+ - **Modular** — five specialized agents with clean interfaces
207
+ - **Local-first** — everything runs on your machine, no cloud dependency
208
+ - **Premium** — beautiful terminal UX inspired by Vercel and Stripe CLIs
209
+
210
+ ## License
211
+
212
+ MIT
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runEulerPipeline = runEulerPipeline;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const llm_1 = require("../utils/llm");
9
+ const banner_1 = require("../cli/banner");
10
+ const governor_1 = require("./governor");
11
+ const gauss_1 = require("./gauss");
12
+ const turing_1 = require("./turing");
13
+ const newton_1 = require("./newton");
14
+ const fisher_1 = require("./fisher");
15
+ const generator_1 = require("../latex/generator");
16
+ const project_1 = require("../utils/project");
17
+ const logger_1 = require("../utils/logger");
18
+ async function runEulerPipeline(topic, projectId, config, logger, options) {
19
+ const startTime = Date.now();
20
+ const governor = new governor_1.GovernorEngine();
21
+ const stages = {};
22
+ (0, banner_1.printStageHeader)('Euler: Research Pipeline', '\u25B6');
23
+ console.log();
24
+ (0, banner_1.printKV)('Topic', topic);
25
+ if (options.assets)
26
+ (0, banner_1.printKV)('Assets', options.assets);
27
+ if (options.method)
28
+ (0, banner_1.printKV)('Method', options.method);
29
+ console.log();
30
+ (0, banner_1.printStep)(1, 7, 'Planning research strategy...');
31
+ const plan = await planResearch(topic, options, config);
32
+ logger.info(`[EULER] Plan: ${JSON.stringify(plan)}`);
33
+ console.log();
34
+ (0, banner_1.printKV)('Title', plan.title);
35
+ (0, banner_1.printKV)('Methodology', plan.methodology);
36
+ (0, banner_1.printKV)('Type', plan.methodType);
37
+ (0, banner_1.printKV)('Steps', plan.analysisSteps.join(chalk_1.default.hex('#0EA5E9')(' \u2192 ')));
38
+ console.log();
39
+ (0, project_1.updateProject)(projectId, { method: plan.methodology });
40
+ if (options.dryRun) {
41
+ (0, banner_1.printSuccess)('Dry run complete. Plan generated without execution.');
42
+ return {
43
+ success: true, projectId, title: plan.title,
44
+ figureCount: 0, duration: Date.now() - startTime, stages,
45
+ };
46
+ }
47
+ (0, banner_1.printStep)(2, 7, 'Gauss \u2014 Literature Gap Analysis');
48
+ (0, project_1.updateProject)(projectId, { status: 'gauss', lastStage: 'gauss' });
49
+ const gaussStart = Date.now();
50
+ let gapAnalysis;
51
+ try {
52
+ gapAnalysis = await (0, gauss_1.runGauss)(topic, config, logger);
53
+ governor.evaluate({ stage: 'gauss', success: gapAnalysis.success });
54
+ stages.gauss = { success: gapAnalysis.success, duration: Date.now() - gaussStart };
55
+ if (gapAnalysis.success) {
56
+ (0, project_1.updateProject)(projectId, { gapAnalysis: { title: gapAnalysis.suggestedTitle, gaps: gapAnalysis.gaps.length, papers: gapAnalysis.totalPapersAnalyzed } });
57
+ }
58
+ }
59
+ catch (err) {
60
+ logger.error(`[EULER] Gauss failed: ${err.message}`);
61
+ governor.evaluate({ stage: 'gauss', success: false, output: err.message });
62
+ gapAnalysis = { success: false, topic, totalPapersAnalyzed: 0, sourcesUsed: [], sourcesFailed: [], gaps: [], recommendedGap: null, suggestedTitle: topic, suggestedAbstract: '', suggestedContributions: [], literatureSynthesis: '', thematicClusters: [], scientificLandscape: { dominantMethods: [], commonDatasets: [], sharedLimitations: [], futureDirections: [] }, bibtexBlock: '', papers: [] };
63
+ stages.gauss = { success: false, duration: Date.now() - gaussStart };
64
+ }
65
+ console.log();
66
+ (0, banner_1.printStep)(3, 7, 'Turing \u2014 Data Collection');
67
+ (0, project_1.updateProject)(projectId, { status: 'turing', lastStage: 'turing' });
68
+ const turingStart = Date.now();
69
+ let dataResult;
70
+ try {
71
+ dataResult = await (0, turing_1.runTuring)(topic, options.assets, plan.methodology, !!options.hf, projectId, config, logger, gapAnalysis);
72
+ governor.evaluate({ stage: 'turing', success: dataResult.success });
73
+ stages.turing = { success: dataResult.success, duration: Date.now() - turingStart };
74
+ }
75
+ catch (err) {
76
+ logger.error(`[EULER] Turing failed: ${err.message}`);
77
+ governor.evaluate({ stage: 'turing', success: false, output: err.message });
78
+ dataResult = { success: false, datasets: [], totalRows: 0, sources: [], errors: [err.message] };
79
+ stages.turing = { success: false, duration: Date.now() - turingStart };
80
+ }
81
+ console.log();
82
+ if (!dataResult.success || dataResult.datasets.length === 0) {
83
+ (0, banner_1.printSection)('Pipeline Halted');
84
+ console.log(chalk_1.default.red(' No data collected. Cannot proceed with analysis.'));
85
+ (0, project_1.updateProject)(projectId, { status: 'failed' });
86
+ return {
87
+ success: false, projectId, title: plan.title,
88
+ figureCount: 0, duration: Date.now() - startTime, stages,
89
+ };
90
+ }
91
+ (0, banner_1.printStep)(4, 7, 'Newton \u2014 Dataset Construction');
92
+ (0, project_1.updateProject)(projectId, { status: 'newton', lastStage: 'newton' });
93
+ const newtonStart = Date.now();
94
+ let datasetResult;
95
+ try {
96
+ datasetResult = await (0, newton_1.runNewton)(topic, projectId, config, logger, {
97
+ datasets: dataResult.datasets.map((d) => ({
98
+ filename: d.filename, filePath: d.filePath,
99
+ columns: d.columns, rows: d.rows,
100
+ })),
101
+ });
102
+ governor.evaluate({ stage: 'newton', success: datasetResult.success });
103
+ stages.newton = { success: datasetResult.success, duration: Date.now() - newtonStart };
104
+ }
105
+ catch (err) {
106
+ logger.error(`[EULER] Newton failed: ${err.message}`);
107
+ governor.evaluate({ stage: 'newton', success: false, output: err.message });
108
+ const fallbackDs = dataResult.datasets[0];
109
+ datasetResult = {
110
+ success: true,
111
+ finalDatasetPath: fallbackDs.filePath,
112
+ rows: fallbackDs.rows,
113
+ columns: fallbackDs.columns,
114
+ description: 'Raw dataset (Newton fallback)',
115
+ transformations: [],
116
+ dataDictionary: {},
117
+ };
118
+ stages.newton = { success: false, duration: Date.now() - newtonStart };
119
+ }
120
+ console.log();
121
+ (0, banner_1.printStep)(5, 7, 'Fisher \u2014 Empirical Analysis');
122
+ (0, project_1.updateProject)(projectId, { status: 'fisher', lastStage: 'fisher' });
123
+ const fisherStart = Date.now();
124
+ let analysisResult;
125
+ try {
126
+ analysisResult = await (0, fisher_1.runFisher)(topic, plan.methodology, projectId, config, logger, {
127
+ finalDatasetPath: datasetResult.finalDatasetPath,
128
+ columns: datasetResult.columns,
129
+ rows: datasetResult.rows,
130
+ dataDictionary: datasetResult.dataDictionary,
131
+ }, gapAnalysis);
132
+ governor.evaluate({
133
+ stage: 'fisher', success: analysisResult.success,
134
+ figuresGenerated: analysisResult.figures.length,
135
+ });
136
+ stages.fisher = { success: analysisResult.success, duration: Date.now() - fisherStart };
137
+ }
138
+ catch (err) {
139
+ logger.error(`[EULER] Fisher failed: ${err.message}`);
140
+ governor.evaluate({ stage: 'fisher', success: false, output: err.message });
141
+ analysisResult = { success: false, models: [], figures: [], tables: [], summary: '', diagnostics: [] };
142
+ stages.fisher = { success: false, duration: Date.now() - fisherStart };
143
+ }
144
+ console.log();
145
+ (0, banner_1.printStep)(6, 7, 'Euler \u2014 Writing Research Paper');
146
+ (0, project_1.updateProject)(projectId, { status: 'writing', lastStage: 'euler_write' });
147
+ const writeStart = Date.now();
148
+ let paperResult;
149
+ try {
150
+ paperResult = await (0, generator_1.generatePaper)({
151
+ topic,
152
+ title: gapAnalysis.suggestedTitle || plan.title,
153
+ abstract: gapAnalysis.suggestedAbstract || '',
154
+ contributions: gapAnalysis.suggestedContributions || [],
155
+ methodology: plan.methodology,
156
+ methodType: plan.methodType,
157
+ literatureSynthesis: gapAnalysis.literatureSynthesis || '',
158
+ bibtexBlock: gapAnalysis.bibtexBlock || '',
159
+ dataDescription: {
160
+ sources: dataResult.sources,
161
+ totalRows: dataResult.totalRows,
162
+ datasets: dataResult.datasets,
163
+ transformations: datasetResult.transformations,
164
+ },
165
+ analysisResults: analysisResult,
166
+ gapAnalysis,
167
+ }, projectId, config, logger);
168
+ governor.evaluate({ stage: 'euler_write', success: paperResult.success });
169
+ stages.euler_write = { success: paperResult.success, duration: Date.now() - writeStart };
170
+ }
171
+ catch (err) {
172
+ logger.error(`[EULER] Paper generation failed: ${err.message}`);
173
+ governor.evaluate({ stage: 'euler_write', success: false, output: err.message });
174
+ paperResult = { success: false, pdfPath: '', pageCount: 0, compilationLog: err.message };
175
+ stages.euler_write = { success: false, duration: Date.now() - writeStart };
176
+ }
177
+ console.log();
178
+ (0, banner_1.printStep)(7, 7, 'Finalizing');
179
+ const totalDuration = Date.now() - startTime;
180
+ (0, project_1.updateProject)(projectId, {
181
+ status: paperResult.success ? 'complete' : 'failed',
182
+ pdfPath: paperResult.pdfPath,
183
+ figureCount: analysisResult.figures.length,
184
+ pageCount: paperResult.pageCount,
185
+ lastStage: 'complete',
186
+ });
187
+ const govState = governor.getState();
188
+ logger.info(`[EULER] Governor final state: confidence=${govState.confidence.toFixed(2)}, profile=${govState.profile}`);
189
+ if (paperResult.success) {
190
+ const summaryLines = [
191
+ `${chalk_1.default.hex('#94A3B8')('Paper')} ${chalk_1.default.white(gapAnalysis.suggestedTitle || plan.title)}`,
192
+ paperResult.pdfPath ? `${chalk_1.default.hex('#94A3B8')('PDF')} ${chalk_1.default.white(paperResult.pdfPath)}` : '',
193
+ `${chalk_1.default.hex('#94A3B8')('Pages')} ${chalk_1.default.white(String(paperResult.pageCount))}`,
194
+ `${chalk_1.default.hex('#94A3B8')('Figures')} ${chalk_1.default.white(String(analysisResult.figures.length))}`,
195
+ `${chalk_1.default.hex('#94A3B8')('Models')} ${chalk_1.default.white(String(analysisResult.models.length))}`,
196
+ `${chalk_1.default.hex('#94A3B8')('Duration')} ${chalk_1.default.white((0, logger_1.formatDuration)(totalDuration))}`,
197
+ `${chalk_1.default.hex('#94A3B8')('Confidence')} ${chalk_1.default.white(`${(govState.confidence * 100).toFixed(0)}%`)}`,
198
+ '',
199
+ ...Object.entries(stages).map(([stage, info]) => {
200
+ const icon = info.success ? chalk_1.default.hex('#22C55E')('\u2714') : chalk_1.default.hex('#EF4444')('\u2718');
201
+ return ` ${icon} ${chalk_1.default.hex('#94A3B8')(stage.padEnd(14))} ${chalk_1.default.hex('#64748B')((0, logger_1.formatDuration)(info.duration))}`;
202
+ }),
203
+ ].filter(Boolean);
204
+ (0, banner_1.printSummaryBox)(summaryLines, true);
205
+ }
206
+ else {
207
+ const summaryLines = [
208
+ chalk_1.default.hex('#F59E0B')('Paper generation failed'),
209
+ `${chalk_1.default.hex('#94A3B8')('Duration')} ${chalk_1.default.white((0, logger_1.formatDuration)(totalDuration))}`,
210
+ '',
211
+ ...Object.entries(stages).map(([stage, info]) => {
212
+ const icon = info.success ? chalk_1.default.hex('#22C55E')('\u2714') : chalk_1.default.hex('#EF4444')('\u2718');
213
+ return ` ${icon} ${chalk_1.default.hex('#94A3B8')(stage.padEnd(14))} ${chalk_1.default.hex('#64748B')((0, logger_1.formatDuration)(info.duration))}`;
214
+ }),
215
+ ];
216
+ (0, banner_1.printSummaryBox)(summaryLines, false);
217
+ }
218
+ return {
219
+ success: paperResult.success,
220
+ projectId,
221
+ title: gapAnalysis.suggestedTitle || plan.title,
222
+ pdfPath: paperResult.pdfPath,
223
+ figureCount: analysisResult.figures.length,
224
+ pageCount: paperResult.pageCount,
225
+ duration: totalDuration,
226
+ stages,
227
+ };
228
+ }
229
+ async function planResearch(topic, options, config) {
230
+ const response = await (0, llm_1.callLLM)(config, `You are Euler, the master research orchestrator of AutoScholar.
231
+ Plan a comprehensive research study for the given topic.
232
+
233
+ Classify the methodology type:
234
+ - econometrics: OLS, IV, GMM, panel data, GARCH, VAR
235
+ - statistics: hypothesis testing, ANOVA, chi-square
236
+ - ml: random forest, XGBoost, neural networks
237
+ - ai: deep learning, NLP, computer vision
238
+
239
+ Respond as JSON:
240
+ {
241
+ "title": "Full paper title",
242
+ "methodology": "Specific method name (e.g., DCC-GARCH, Panel Fixed Effects)",
243
+ "methodType": "econometrics|statistics|ml|ai",
244
+ "dataRequirements": ["Type of data needed"],
245
+ "analysisSteps": ["Step 1", "Step 2"],
246
+ "expectedSections": ["introduction", "literature_review", "methodology", "data", "results", "discussion", "conclusion"],
247
+ "estimatedTime": "20-30 minutes"
248
+ }`, `Topic: ${topic}\nAssets: ${options.assets || 'auto'}\nPreferred method: ${options.method || 'auto'}\nHigh-frequency: ${options.hf || false}`, { maxTokens: 2048 });
249
+ const parsed = (0, llm_1.parseJsonResponse)(response);
250
+ if (parsed)
251
+ return parsed;
252
+ return {
253
+ title: topic,
254
+ methodology: options.method || 'OLS',
255
+ methodType: 'econometrics',
256
+ dataRequirements: ['Financial data', 'Macroeconomic data'],
257
+ analysisSteps: ['Data collection', 'Data preparation', 'Model estimation', 'Robustness checks'],
258
+ expectedSections: ['introduction', 'literature_review', 'methodology', 'data', 'results', 'discussion', 'conclusion'],
259
+ estimatedTime: '20-30 minutes',
260
+ };
261
+ }