Skip to content

Commit 82656a8

Browse files
Add user-configurable citation styles to RWA. Users pick a default style during setup (stored in .rwa-user-config.yaml), override per-project (in project-config.yaml), and each project gets a self-contained copy of its .csl file. Ship ~10 common styles in a csl/ directory; allow downloading additional styles from the Zotero Styles Repository on demand.
1 parent 79b29b1 commit 82656a8

29 files changed

Lines changed: 15926 additions & 15 deletions

.github/agents/academic-writer.agent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ Before creating a new cite-bearing document, check the target project's `project
8484
For reports, manuscripts, and protocols that include citations:
8585
- Populate YAML frontmatter with the known author metadata
8686
- Include `bibliography` and `csl` fields unless the user explicitly wants a citation-free output
87+
- **Resolve the CSL citation style using this priority chain:**
88+
1. Project's `project-config.yaml``research_assistant.output_defaults.csl`
89+
2. User's `.rwa-user-config.yaml``default_citation_style` (+ `.csl` extension)
90+
3. Fallback: `apa.csl`
91+
- Verify the resolved `.csl` file exists in the project directory. If it does not, use `bib_copy_csl_to_project` to copy it from the shared `csl/` library.
8792
- Add an editable RWA disclosure in the Methods section when AI-assisted workflow details are relevant
8893
- Add an acknowledgments / AI-disclosure section with ICMJE-compliant language
8994
- When Research Workflow Assistant (RWA) is cited in Methods or Acknowledgments, use [@vanzyl2026rwa] and add the matching BibTeX entry from `templates/rwa-citation.bib` to `references.bib`

.github/agents/project-manager.agent.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description: >
66
meeting notes, and timeline management.
77
tools:
88
- project-tracker
9+
- bibliography-manager
910
---
1011

1112
# Project Manager Agent
@@ -163,10 +164,11 @@ At natural project checkpoints, proactively ask:
163164
1. Ask the researcher about their project (title, timeline, type, and who should be listed as authors on project outputs)
164165
2. If `.rwa-user-config.yaml` contains `default_author`, offer to use it as the starting author profile for the project and let the researcher edit or override any field
165166
3. Collect any additional project authors and store them in `project-config.yaml` under `research_assistant.authors`
166-
4. Initialize tracking via `project-tracker`, preserving structured author metadata when the tool supports it
167-
5. Suggest a phase structure based on the project type
168-
6. Help define initial milestones and tasks
169-
7. Offer to generate the first brief ("starting point" baseline)
167+
4. **Citation style**: Read `default_citation_style` from `.rwa-user-config.yaml`. Ask: "Your default citation style is {style}. Should I use it for this project, or would you prefer a different style?" If the user picks a different style, check if it exists in `csl/` — if not, use `bib_download_csl_style` to fetch it. Then use `bib_copy_csl_to_project` to copy the chosen `.csl` file into the new project directory. Set `output_defaults.csl` in the project's `project-config.yaml` to match.
168+
5. Initialize tracking via `project-tracker`, preserving structured author metadata when the tool supports it
169+
6. Suggest a phase structure based on the project type
170+
7. Help define initial milestones and tasks
171+
8. Offer to generate the first brief ("starting point" baseline)
170172

171173
### Ongoing Management
172174

.github/agents/research-planner.agent.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description: >
66
tools:
77
- prisma-tracker
88
- project-tracker
9+
- bibliography-manager
910
---
1011

1112
# Research Planner Agent
@@ -42,6 +43,7 @@ Guide the researcher through creating a study protocol, adapting to the study ty
4243
- Risk of bias assessment (which tool for which study types)
4344
- Synthesis plan (narrative, meta-analysis, or both)
4445
- Use the `templates/systematic-review/protocol.qmd` template
46+
- When creating any `.qmd` document from a template, resolve the citation style using the standard chain: project `output_defaults.csl` → user `default_citation_style``apa.csl` fallback. Ensure the resolved `.csl` file exists in the project directory.
4547

4648
**Observational Study Protocol:**
4749
- Study design (cohort, case-control, cross-sectional)

.github/agents/setup.agent.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ tools:
1414
- zotero-local
1515
- project-tracker
1616
- prisma-tracker
17+
- bibliography-manager
1718
---
1819

1920
# RWA Setup Agent
@@ -265,7 +266,43 @@ default_author:
265266

266267
If `default_author` already exists, show which fields are already set and ask before overwriting them.
267268

268-
**Transition**: "Your default author profile is saved. Would you like to create your first project?"
269+
**Transition**: "Your default author profile is saved. Let's choose your preferred citation style."
270+
271+
## Stage 7.5 — Default Citation Style
272+
273+
Ask the user to choose their preferred citation / referencing style. This becomes the default for all new projects (overridable per project).
274+
275+
1. **List bundled styles**: Use the `bib_list_csl_styles` tool from the bibliography-manager MCP server to show the available styles. Present them in a clear table:
276+
277+
| ID | Style | Type |
278+
|----|-------|------|
279+
| `apa` | APA 7th edition | Author-date |
280+
| `vancouver` | Vancouver / NLM (numbered) | Numbered |
281+
| `vancouver-superscript` | Vancouver (superscript) | Superscript numbered |
282+
| `american-medical-association` | AMA 11th edition | Superscript numbered |
283+
| `bmj` | BMJ | Numbered |
284+
| `nature` | Nature | Numbered |
285+
| `national-library-of-medicine` | NLM / Citing Medicine 2nd ed. | Numbered |
286+
| `ieee` | IEEE | Numbered (bracketed) |
287+
| `harvard-cite-them-right` | Harvard (Cite Them Right 12th ed.) | Author-date |
288+
| `chicago-author-date-17th-edition` | Chicago 17th (author-date) | Author-date |
289+
| `chicago-fullnote-bibliography` | Chicago 18th (notes & bibliography) | Footnotes |
290+
291+
2. **Ask**: "Which citation style do you prefer? Enter the style ID from the list above, or type a custom style ID from the [Zotero Style Repository](https://www.zotero.org/styles) (over 10 000 styles available). Press Enter to accept the default (APA)."
292+
293+
3. **If the user enters a bundled style ID**: Confirm the selection.
294+
4. **If the user enters a custom style ID** not in the bundled list: Use the `bib_download_csl_style` tool to download it from the Zotero Style Repository. If the download fails (style not found), inform the user and ask them to try again or browse https://www.zotero.org/styles.
295+
5. **Default**: If the user presses Enter or says "default", use `apa`.
296+
297+
Save the selection to `.rwa-user-config.yaml` under `default_citation_style`:
298+
299+
```yaml
300+
default_citation_style: vancouver-superscript
301+
```
302+
303+
If `default_citation_style` already exists, show the current value and ask if the user wants to change it.
304+
305+
**Transition**: "Your default citation style is saved. Would you like to create your first project?"
269306

270307
## Stage 8 — First Project Setup (Optional)
271308

@@ -316,7 +353,12 @@ Use the `project-tracker` server to:
316353

317354
4. Create `ai-contributions-log.md` in the project directory with the standard template header.
318355

319-
5. Create `project-config.yaml` in the project directory with:
356+
5. **Copy the citation style file** into the project directory. Ask the user:
357+
- "Should I use your default citation style ({default_citation_style from .rwa-user-config.yaml}) for this project, or would you like a different style?"
358+
- Use `bib_copy_csl_to_project` to copy the chosen `.csl` file from the shared `csl/` library into the project directory.
359+
- If the user picks a style not yet in the library, use `bib_download_csl_style` first, then copy it.
360+
361+
6. Create `project-config.yaml` in the project directory with:
320362
```yaml
321363
research_assistant:
322364
tracking_location: self
@@ -338,10 +380,11 @@ Use the `project-tracker` server to:
338380
url: {organization URL if provided}
339381
output_defaults:
340382
bibliography: references.bib
341-
csl: apa.csl
383+
csl: {chosen style}.csl
342384
include_rwa_methods_disclosure: true
343385
include_rwa_acknowledgments: true
344386
```
387+
Note: `output_defaults.csl` must match the CSL filename that was copied into the project directory in step 5.
345388

346389
**Transition**: "Your project is set up! Here is a summary of everything we configured."
347390

@@ -376,6 +419,9 @@ Print a clear summary:
376419
- Affiliation: {organization or "not configured"}
377420
- ORCID: {configured/skipped}
378421
422+
### Default Citation Style
423+
- Style: {style title} ({style ID}) / not configured (defaults to APA)
424+
379425
### First Project
380426
- {Project title} (created at {path}) / No project created yet
381427

.github/agents/systematic-reviewer.agent.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Ask the user which framework fits their question. If they are unsure, recommend
5858
Before searching, prompt the user to develop or register a protocol:
5959

6060
1. Suggest drafting a protocol using the `templates/systematic-review/protocol.qmd` template
61-
2. Mention PROSPERO registration (for systematic reviews) or OSF preregistration (for scoping reviews)
61+
2. When creating the protocol `.qmd` file, resolve the citation style using the standard chain: project `output_defaults.csl` → user `default_citation_style``apa.csl` fallback. Ensure the resolved `.csl` file exists in the project directory (copy it from `csl/` if needed using `bib_copy_csl_to_project`).
62+
3. Mention PROSPERO registration (for systematic reviews) or OSF preregistration (for scoping reviews)
6263
3. Document the planned methods: databases to search, inclusion/exclusion criteria, screening process, data extraction plan, synthesis method
6364

6465
### Phase 3: Search Strategy Development

.github/copilot-instructions.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,22 @@ Agents should:
224224
- Recommend [Quarto CLI](https://quarto.org/docs/get-started/) installation when rendering is needed
225225
- See `docs/posit-quarto-guide.md` for the full Posit/Quarto ecosystem guide
226226

227+
### Citation Style Defaults
228+
229+
Citation formatting uses **CSL (Citation Style Language)** files processed by Pandoc citeproc. The repository ships a shared style library in `csl/` with common styles pre-bundled. Additional styles can be downloaded on demand from the [Zotero Style Repository](https://www.zotero.org/styles) (10,000+ styles) via the `bib_download_csl_style` tool.
230+
231+
**Resolution chain** (agents must follow this priority order):
232+
1. **Project config**`output_defaults.csl` in `project-config.yaml`
233+
2. **User config**`default_citation_style` in `.rwa-user-config.yaml`
234+
3. **Fallback**`apa` (APA 7th edition)
235+
236+
**Rules for all agents:**
237+
- Each project directory gets its own copy of the `.csl` file (for portability). Use `bib_copy_csl_to_project` to copy from the shared library.
238+
- When instantiating a Quarto template, resolve the CSL style via the chain above and substitute the `csl:` field in the YAML front matter.
239+
- Never hardcode a path back to the repo-root `csl/` directory in project documents — always use a local copy.
240+
- If the resolved style is not in the shared library, download it first with `bib_download_csl_style`.
241+
- See `csl/README.md` for the full list of bundled styles and instructions for adding more.
242+
227243
### Diagram and Table Defaults
228244

229245
**Diagrams:** The default diagram tool is **Mermaid**, which is natively supported by Quarto via ` ```{mermaid} ` code blocks (no extensions or installs required). Use Mermaid for:

csl/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Citation Style Library
2+
3+
This directory contains [Citation Style Language (CSL)](https://citationstyles.org/) files used by Quarto/Pandoc to format in-text citations and bibliographies.
4+
5+
## Bundled Styles
6+
7+
| File | Style | Type | Common In |
8+
|------|-------|------|-----------|
9+
| `apa.csl` | APA Style 7th edition | Author-date | Psychology, education, social sciences |
10+
| `vancouver.csl` | Vancouver (NLM, citation-sequence) | Numbered | Medicine, biomedical sciences |
11+
| `vancouver-superscript.csl` | Vancouver (superscript numbers) | Superscript numbered | Medicine, clinical journals |
12+
| `american-medical-association.csl` | AMA Manual of Style 11th edition | Superscript numbered | US medical journals |
13+
| `bmj.csl` | BMJ | Numbered | BMJ family journals |
14+
| `nature.csl` | Nature | Numbered | Nature family journals |
15+
| `national-library-of-medicine.csl` | NLM/Citing Medicine 2nd edition | Numbered | Library science, government reports |
16+
| `ieee.csl` | IEEE Reference Guide | Numbered (bracketed) | Engineering, computer science |
17+
| `harvard-cite-them-right.csl` | Cite Them Right 12th ed. (Harvard) | Author-date | UK universities, general |
18+
| `chicago-author-date-17th-edition.csl` | Chicago 17th edition (author-date) | Author-date | History, humanities, social sciences |
19+
| `chicago-fullnote-bibliography.csl` | Chicago 18th edition (notes & bibliography) | Footnotes | History, arts, humanities |
20+
21+
## Using a Style
22+
23+
In your Quarto (`.qmd`) document YAML front matter:
24+
25+
```yaml
26+
bibliography: references.bib
27+
csl: vancouver-superscript.csl
28+
```
29+
30+
The CSL file should be in the same directory as your `.qmd` file (RWA copies the appropriate file into each project directory during project creation).
31+
32+
## Adding More Styles
33+
34+
Over 10,000 styles are available from the [Zotero Style Repository](https://www.zotero.org/styles). To add a new style:
35+
36+
1. **Via RWA**: Ask any agent to download a citation style — it will use the `download_csl_style` tool to fetch and save it automatically.
37+
2. **Manually**: Download the `.csl` file from [zotero.org/styles](https://www.zotero.org/styles) and place it in this directory.
38+
39+
## Configuration
40+
41+
- **User default**: Set `default_citation_style` in `.rwa-user-config.yaml` (configured during `@setup`).
42+
- **Per-project override**: Set `output_defaults.csl` in your project's `project-config.yaml`.
43+
- **Resolution chain**: Project config → User config → `apa` (fallback).
44+
45+
## License
46+
47+
All CSL styles in this directory are sourced from the [Citation Style Language](https://github.com/citation-style-language/styles) project and are licensed under the [Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)](https://creativecommons.org/licenses/by-sa/3.0/) license.

0 commit comments

Comments
 (0)