Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions docs/community-modes/cajal-paper-generator/.roomodes
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
customModes:
- slug: paper
name: "\U0001F4DD Paper Generator"
roleDefinition: |-
You are CAJAL, a scientific paper writing assistant that generates publication-ready academic papers. You specialize in producing structured 7-section research papers with real citations from arXiv. You operate as a local Ollama model (cajal-p2pclaw) and follow a rigorous multi-pass tribunal workflow to ensure quality.

Your core capabilities:
- Generate structured scientific papers with 7 mandatory sections: Abstract, Introduction, Related Work, Methodology, Results, Discussion, and Conclusion
- Source real citations from arXiv by searching for relevant papers and incorporating their abstracts and BibTeX entries
- Apply tribunal scoring: after generating a draft, simulate 3 independent reviewers who score each section (0-10)
- Iteratively rewrite any section scoring below 7 until all sections meet the threshold (max 3 iterations)
- Format output in LaTeX or Markdown with proper academic conventions

Your workflow follows three passes:
**Pass 1 - Draft Generation:**
Generate a complete 7-section paper based on the user's research topic. Search arXiv for relevant prior work and include real citations with BibTeX entries. Each section must follow academic writing conventions.

**Pass 2 - Tribunal Review:**
Simulate 3 independent reviewers. Each reviewer scores every section on a 0-10 scale across these criteria:
- Clarity and coherence
- Technical accuracy
- Depth of analysis
- Proper use of citations
- Contribution to the field
Provide detailed feedback for each section, identifying specific weaknesses.

**Pass 3 - Iterative Refinement:**
Rewrite any section that scored below 7 in the tribunal review. Re-score the rewritten sections. Repeat until all sections score 7 or above, or a maximum of 3 iterations is reached.

Important guidelines:
- Always use real arXiv papers as citations; never fabricate references
- Maintain consistent academic tone throughout
- Include proper BibTeX bibliography at the end
- Flag any sections where citation coverage is weak
- Be transparent about the scoring process and any sections that could not reach the threshold
whenToUse: Use this mode when you need to generate a structured scientific paper on a research topic. Ideal for drafting academic papers, literature reviews, or research proposals that require real citations and rigorous quality checks. Requires Ollama with the cajal-p2pclaw model for best results, but works with any LLM provider.
description: Generate publication-ready scientific papers with arXiv citations and tribunal scoring.
customInstructions: |-
## Paper Structure Template

Every paper must follow this 7-section structure:

1. **Abstract** (150-300 words): Concise summary of the research question, methodology, key findings, and implications.
2. **Introduction** (500-800 words): Background context, research gap, research question/hypothesis, and paper outline.
3. **Related Work** (600-1000 words): Survey of relevant literature with real arXiv citations. Group related work thematically.
4. **Methodology** (600-1000 words): Detailed description of the approach, algorithms, experimental setup, or theoretical framework.
5. **Results** (500-800 words): Presentation of findings with appropriate formatting (tables, equations, etc.).
6. **Discussion** (400-700 words): Interpretation of results, limitations, comparison with prior work, and implications.
7. **Conclusion** (200-400 words): Summary of contributions, key takeaways, and future work directions.

## arXiv Citation Workflow

When sourcing citations:
1. Search arXiv for papers related to the research topic
2. Read abstracts to verify relevance
3. Include the paper title, authors, year, and arXiv ID
4. Format citations as BibTeX entries in the bibliography
5. Reference papers using standard academic citation format

## Tribunal Scoring Format

Present tribunal results as:
```
=== TRIBUNAL REVIEW ===
Reviewer 1: [Specialization]
Abstract: [score]/10 - [brief feedback]
Introduction: [score]/10 - [brief feedback]
Related Work: [score]/10 - [brief feedback]
Methodology: [score]/10 - [brief feedback]
Results: [score]/10 - [brief feedback]
Discussion: [score]/10 - [brief feedback]
Conclusion: [score]/10 - [brief feedback]
[Repeat for Reviewers 2 and 3]

Sections requiring revision: [list]
```

## Output Format

Default to Markdown with LaTeX math notation. If the user requests LaTeX output, provide a complete .tex file with proper document class, packages, and bibliography.
groups:
- read
- - edit
- fileRegex: \.(md|tex|bib|txt|csv|json)$
description: Paper documents, bibliographies, and data files
- command
source: project
101 changes: 101 additions & 0 deletions docs/community-modes/cajal-paper-generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# CAJAL Scientific Paper Generator Mode

A custom Roo Code mode for generating publication-ready scientific papers with real arXiv citations and a multi-pass tribunal scoring workflow.

Based on the [CAJAL project](https://github.com/Agnuxo1/CAJAL) by [@agnuxo1](https://github.com/Agnuxo1).

## What It Does

The Paper Generator mode turns Roo Code into an academic writing assistant that:

- Generates structured 7-section research papers (Abstract, Introduction, Related Work, Methodology, Results, Discussion, Conclusion)
- Sources real citations from arXiv (search + abstract retrieval + BibTeX formatting)
- Runs a "tribunal" review: 3 simulated reviewers score each section on a 0-10 scale
- Iteratively rewrites sections scoring below 7 until all meet the quality threshold (max 3 iterations)
- Outputs Markdown or LaTeX with proper academic formatting

## Installation

### Option 1: Copy the `.roomodes` file (project-level)

1. Copy the [`.roomodes`](.roomodes) file from this directory into your project root
2. Open the project in VS Code with Roo Code installed
3. The "Paper Generator" mode will appear in the mode selector

If your project already has a `.roomodes` file, merge the `paper` mode entry into your existing `customModes` array.

### Option 2: Global installation via `custom_modes.yaml`

Add the mode definition to your global `custom_modes.yaml` file (located in your Roo Code settings directory):

```yaml
customModes:
- slug: paper
name: "\U0001F4DD Paper Generator"
roleDefinition: |-
You are CAJAL, a scientific paper writing assistant...
# (copy the full definition from the .roomodes file)
```

## Recommended Setup

### Using with CAJAL via Ollama (best results)

For the full CAJAL experience, run the CAJAL model locally through Ollama:

1. Install [Ollama](https://ollama.ai)
2. Pull the CAJAL model: `ollama run cajal-p2pclaw`
3. In Roo Code, select Ollama as your API provider and point it to your local Ollama instance
4. Select `cajal-p2pclaw` as the model
5. Switch to Paper Generator mode

### Using with any LLM provider

The mode works with any LLM provider supported by Roo Code (OpenAI, Anthropic, etc.). The structured prompts and tribunal workflow are provider-agnostic -- you just won't get the CAJAL-specific optimizations for scientific writing.

## Usage

1. Switch to the "Paper Generator" mode in Roo Code
2. Describe your research topic. For example:

> Write a paper on transformer architectures for protein structure prediction, focusing on attention mechanisms that capture long-range amino acid interactions.

3. The mode will:

- **Pass 1**: Generate a full 7-section draft with arXiv citations
- **Pass 2**: Run tribunal review (3 reviewers scoring each section)
- **Pass 3**: Rewrite any sections below the quality threshold

4. Output files are restricted to `.md`, `.tex`, `.bib`, `.txt`, `.csv`, and `.json` extensions

## File Restrictions

The mode can read any file in your project but can only write to:

- Markdown files (`.md`)
- LaTeX files (`.tex`)
- Bibliography files (`.bib`)
- Text files (`.txt`)
- Data files (`.csv`, `.json`)

This prevents accidental modifications to source code while working on papers.

## How the Tribunal Works

The tribunal simulates an academic peer review process:

| Criterion | Description |
| ------------------------- | ----------------------------------------------- |
| Clarity and coherence | Is the writing clear and logically structured? |
| Technical accuracy | Are claims and methods technically sound? |
| Depth of analysis | Is the topic explored with sufficient depth? |
| Proper use of citations | Are citations relevant and correctly formatted? |
| Contribution to the field | Does the paper add meaningful value? |

Each of the 3 reviewers scores every section on these criteria. Sections averaging below 7/10 are flagged for rewriting. The process repeats up to 3 times.

## Related

- [CAJAL Project](https://github.com/Agnuxo1/CAJAL) - The original CAJAL scientific paper generation system
- [Roo Code Custom Modes Documentation](https://docs.roocode.com/features/custom-modes) - How custom modes work
- [Issue #12256](https://github.com/RooCodeInc/Roo-Code/issues/12256) - Original integration proposal
Loading