mindforge-cc 11.5.1 → 11.7.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.
Files changed (214) hide show
  1. package/.agent/mindforge/skill-tdd.md +53 -0
  2. package/.agent/mindforge/skills-index.md +118 -0
  3. package/.agent/mindforge/systematic-debug.md +60 -0
  4. package/.agent/mindforge/wf-catalog.md +37 -0
  5. package/.agent/mindforge/wf-code-audit.md +31 -0
  6. package/.agent/mindforge/wf-competitive-analysis.md +31 -0
  7. package/.agent/mindforge/wf-deep-research.md +32 -0
  8. package/.agent/mindforge/wf-feature-planner.md +31 -0
  9. package/.agent/mindforge/wf-incident-response.md +31 -0
  10. package/.agent/mindforge/wf-onboard-codebase.md +31 -0
  11. package/.agent/mindforge/wf-perf-optimize.md +31 -0
  12. package/.agent/mindforge/wf-pr-review.md +31 -0
  13. package/.agent/mindforge/wf-refactor-plan.md +31 -0
  14. package/.agent/mindforge/wf-release-prep.md +31 -0
  15. package/.agent/mindforge/wf-tdd-sprint.md +31 -0
  16. package/.agent/mindforge/wf-tech-evaluation.md +31 -0
  17. package/.agent/skills/1password-skill/SKILL.md +156 -0
  18. package/.agent/skills/1password-skill/references/cli-examples.md +31 -0
  19. package/.agent/skills/1password-skill/references/get-started.md +21 -0
  20. package/.agent/skills/article-illustrator/SKILL.md +199 -0
  21. package/.agent/skills/article-illustrator/references/prompt-construction.md +426 -0
  22. package/.agent/skills/article-illustrator/references/style-presets.md +80 -0
  23. package/.agent/skills/article-illustrator/references/styles.md +224 -0
  24. package/.agent/skills/article-illustrator/references/usage.md +50 -0
  25. package/.agent/skills/article-illustrator/references/workflow.md +332 -0
  26. package/.agent/skills/arxiv/SKILL.md +275 -0
  27. package/.agent/skills/blogwatcher/SKILL.md +130 -0
  28. package/.agent/skills/code-wiki/SKILL.md +438 -0
  29. package/.agent/skills/code-wiki/templates/README.md +31 -0
  30. package/.agent/skills/code-wiki/templates/architecture.md +30 -0
  31. package/.agent/skills/code-wiki/templates/getting-started.md +47 -0
  32. package/.agent/skills/code-wiki/templates/module.md +38 -0
  33. package/.agent/skills/codebase-inspection/SKILL.md +109 -0
  34. package/.agent/skills/comic-creator/SKILL.md +240 -0
  35. package/.agent/skills/comic-creator/references/analysis-framework.md +176 -0
  36. package/.agent/skills/comic-creator/references/auto-selection.md +71 -0
  37. package/.agent/skills/comic-creator/references/base-prompt.md +98 -0
  38. package/.agent/skills/comic-creator/references/character-template.md +180 -0
  39. package/.agent/skills/comic-creator/references/ohmsha-guide.md +85 -0
  40. package/.agent/skills/comic-creator/references/partial-workflows.md +106 -0
  41. package/.agent/skills/comic-creator/references/storyboard-template.md +143 -0
  42. package/.agent/skills/comic-creator/references/workflow.md +401 -0
  43. package/.agent/skills/concept-diagrams/SKILL.md +355 -0
  44. package/.agent/skills/concept-diagrams/references/dashboard-patterns.md +43 -0
  45. package/.agent/skills/concept-diagrams/references/infrastructure-patterns.md +144 -0
  46. package/.agent/skills/concept-diagrams/references/physical-shape-cookbook.md +42 -0
  47. package/.agent/skills/creative-ideation/SKILL.md +144 -0
  48. package/.agent/skills/creative-ideation/references/full-prompt-library.md +110 -0
  49. package/.agent/skills/devops-cli/SKILL.md +149 -0
  50. package/.agent/skills/devops-cli/references/app-discovery.md +112 -0
  51. package/.agent/skills/devops-cli/references/authentication.md +59 -0
  52. package/.agent/skills/devops-cli/references/cli-reference.md +104 -0
  53. package/.agent/skills/devops-cli/references/running-apps.md +171 -0
  54. package/.agent/skills/devops-watchers/SKILL.md +103 -0
  55. package/.agent/skills/docker-management/SKILL.md +273 -0
  56. package/.agent/skills/domain-intel/SKILL.md +96 -0
  57. package/.agent/skills/duckduckgo-search/SKILL.md +230 -0
  58. package/.agent/skills/github-auth/SKILL.md +240 -0
  59. package/.agent/skills/github-code-review/SKILL.md +474 -0
  60. package/.agent/skills/github-code-review/references/review-output-template.md +74 -0
  61. package/.agent/skills/github-issues/SKILL.md +363 -0
  62. package/.agent/skills/github-issues/templates/bug-report.md +35 -0
  63. package/.agent/skills/github-issues/templates/feature-request.md +31 -0
  64. package/.agent/skills/github-pr-workflow/SKILL.md +360 -0
  65. package/.agent/skills/github-pr-workflow/references/ci-troubleshooting.md +183 -0
  66. package/.agent/skills/github-pr-workflow/references/conventional-commits.md +71 -0
  67. package/.agent/skills/github-pr-workflow/templates/pr-body-bugfix.md +35 -0
  68. package/.agent/skills/github-pr-workflow/templates/pr-body-feature.md +33 -0
  69. package/.agent/skills/github-repo-management/SKILL.md +509 -0
  70. package/.agent/skills/github-repo-management/references/github-api-cheatsheet.md +161 -0
  71. package/.agent/skills/godmode/SKILL.md +396 -0
  72. package/.agent/skills/godmode/references/jailbreak-templates.md +128 -0
  73. package/.agent/skills/godmode/references/refusal-detection.md +142 -0
  74. package/.agent/skills/hyperframes/SKILL.md +182 -0
  75. package/.agent/skills/hyperframes/references/cli.md +185 -0
  76. package/.agent/skills/hyperframes/references/composition.md +129 -0
  77. package/.agent/skills/hyperframes/references/features.md +289 -0
  78. package/.agent/skills/hyperframes/references/gsap.md +136 -0
  79. package/.agent/skills/hyperframes/references/troubleshooting.md +137 -0
  80. package/.agent/skills/hyperframes/references/website-to-video.md +145 -0
  81. package/.agent/skills/jupyter-live-kernel/SKILL.md +160 -0
  82. package/.agent/skills/kanban-orchestrator/SKILL.md +209 -0
  83. package/.agent/skills/kanban-worker/SKILL.md +188 -0
  84. package/.agent/skills/llm-wiki/SKILL.md +499 -0
  85. package/.agent/skills/meme-generation/SKILL.md +122 -0
  86. package/.agent/skills/node-inspect-debugger/SKILL.md +312 -0
  87. package/.agent/skills/obsidian/SKILL.md +60 -0
  88. package/.agent/skills/osint-investigation/SKILL.md +269 -0
  89. package/.agent/skills/osint-investigation/templates/source-template.md +59 -0
  90. package/.agent/skills/oss-forensics/SKILL.md +422 -0
  91. package/.agent/skills/oss-forensics/references/evidence-types.md +89 -0
  92. package/.agent/skills/oss-forensics/references/github-archive-guide.md +184 -0
  93. package/.agent/skills/oss-forensics/references/investigation-templates.md +131 -0
  94. package/.agent/skills/oss-forensics/references/recovery-techniques.md +164 -0
  95. package/.agent/skills/oss-forensics/templates/forensic-report.md +151 -0
  96. package/.agent/skills/oss-forensics/templates/malicious-package-report.md +43 -0
  97. package/.agent/skills/parallel-cli/SKILL.md +384 -0
  98. package/.agent/skills/pinggy-tunnel/SKILL.md +302 -0
  99. package/.agent/skills/pixel-art/SKILL.md +209 -0
  100. package/.agent/skills/pixel-art/references/palettes.md +49 -0
  101. package/.agent/skills/plan/SKILL.md +331 -0
  102. package/.agent/skills/polymarket/SKILL.md +75 -0
  103. package/.agent/skills/polymarket/references/api-endpoints.md +220 -0
  104. package/.agent/skills/python-debugpy/SKILL.md +368 -0
  105. package/.agent/skills/requesting-code-review/SKILL.md +273 -0
  106. package/.agent/skills/research-paper-writing/SKILL.md +2367 -0
  107. package/.agent/skills/research-paper-writing/references/autoreason-methodology.md +394 -0
  108. package/.agent/skills/research-paper-writing/references/checklists.md +434 -0
  109. package/.agent/skills/research-paper-writing/references/citation-workflow.md +563 -0
  110. package/.agent/skills/research-paper-writing/references/experiment-patterns.md +728 -0
  111. package/.agent/skills/research-paper-writing/references/human-evaluation.md +476 -0
  112. package/.agent/skills/research-paper-writing/references/paper-types.md +481 -0
  113. package/.agent/skills/research-paper-writing/references/reviewer-guidelines.md +433 -0
  114. package/.agent/skills/research-paper-writing/references/sources.md +191 -0
  115. package/.agent/skills/research-paper-writing/references/writing-guide.md +474 -0
  116. package/.agent/skills/research-paper-writing/templates/README.md +251 -0
  117. package/.agent/skills/rest-graphql-debug/SKILL.md +507 -0
  118. package/.agent/skills/s6-container-supervision/SKILL.md +171 -0
  119. package/.agent/skills/scrapling/SKILL.md +328 -0
  120. package/.agent/skills/sherlock/SKILL.md +186 -0
  121. package/.agent/skills/simplify-code/SKILL.md +168 -0
  122. package/.agent/skills/skill-authoring/SKILL.md +158 -0
  123. package/.agent/skills/spike/SKILL.md +190 -0
  124. package/.agent/skills/subagent-driven-development/SKILL.md +345 -0
  125. package/.agent/skills/subagent-driven-development/references/context-budget-discipline.md +53 -0
  126. package/.agent/skills/subagent-driven-development/references/gates-taxonomy.md +93 -0
  127. package/.agent/skills/systematic-debugging/SKILL.md +360 -0
  128. package/.agent/skills/test-driven-development/SKILL.md +336 -0
  129. package/.agent/skills/video-orchestrator/SKILL.md +194 -0
  130. package/.agent/skills/video-orchestrator/references/examples.md +227 -0
  131. package/.agent/skills/video-orchestrator/references/intake.md +166 -0
  132. package/.agent/skills/video-orchestrator/references/kanban-setup.md +278 -0
  133. package/.agent/skills/video-orchestrator/references/monitoring.md +180 -0
  134. package/.agent/skills/video-orchestrator/references/role-archetypes.md +298 -0
  135. package/.agent/skills/video-orchestrator/references/tool-matrix.md +317 -0
  136. package/.agent/skills/web-pentest/SKILL.md +332 -0
  137. package/.agent/skills/web-pentest/references/bypass-techniques.md +133 -0
  138. package/.agent/skills/web-pentest/references/exploitation-techniques.md +204 -0
  139. package/.agent/skills/web-pentest/references/scope-enforcement.md +110 -0
  140. package/.agent/skills/web-pentest/references/vuln-taxonomy.md +81 -0
  141. package/.agent/skills/web-pentest/templates/authorization.md +69 -0
  142. package/.agent/skills/web-pentest/templates/pentest-report.md +178 -0
  143. package/.claude/commands/mindforge/skill-tdd.md +53 -0
  144. package/.claude/commands/mindforge/skills-index.md +118 -0
  145. package/.claude/commands/mindforge/systematic-debug.md +60 -0
  146. package/.claude/commands/mindforge/wf-catalog.md +37 -0
  147. package/.claude/commands/mindforge/wf-code-audit.md +31 -0
  148. package/.claude/commands/mindforge/wf-competitive-analysis.md +31 -0
  149. package/.claude/commands/mindforge/wf-deep-research.md +32 -0
  150. package/.claude/commands/mindforge/wf-feature-planner.md +31 -0
  151. package/.claude/commands/mindforge/wf-incident-response.md +31 -0
  152. package/.claude/commands/mindforge/wf-onboard-codebase.md +31 -0
  153. package/.claude/commands/mindforge/wf-perf-optimize.md +31 -0
  154. package/.claude/commands/mindforge/wf-pr-review.md +31 -0
  155. package/.claude/commands/mindforge/wf-refactor-plan.md +31 -0
  156. package/.claude/commands/mindforge/wf-release-prep.md +31 -0
  157. package/.claude/commands/mindforge/wf-tdd-sprint.md +31 -0
  158. package/.claude/commands/mindforge/wf-tech-evaluation.md +31 -0
  159. package/.mindforge/config.json +2 -2
  160. package/.mindforge/dynamic-workflows/REGISTRY.md +65 -0
  161. package/.mindforge/dynamic-workflows/index.json +171 -0
  162. package/.mindforge/dynamic-workflows/scripts/code-audit.js +103 -0
  163. package/.mindforge/dynamic-workflows/scripts/competitive-analysis.js +85 -0
  164. package/.mindforge/dynamic-workflows/scripts/deep-research.js +151 -0
  165. package/.mindforge/dynamic-workflows/scripts/feature-planner.js +104 -0
  166. package/.mindforge/dynamic-workflows/scripts/incident-response.js +106 -0
  167. package/.mindforge/dynamic-workflows/scripts/onboard-codebase.js +102 -0
  168. package/.mindforge/dynamic-workflows/scripts/perf-optimize.js +128 -0
  169. package/.mindforge/dynamic-workflows/scripts/pr-review.js +87 -0
  170. package/.mindforge/dynamic-workflows/scripts/refactor-plan.js +121 -0
  171. package/.mindforge/dynamic-workflows/scripts/release-prep.js +102 -0
  172. package/.mindforge/dynamic-workflows/scripts/tdd-sprint.js +103 -0
  173. package/.mindforge/dynamic-workflows/scripts/tech-evaluation.js +72 -0
  174. package/.mindforge/memory/sync-manifest.json +1 -1
  175. package/.mindforge/skills/arxiv/SKILL.md +294 -0
  176. package/.mindforge/skills/blogwatcher/SKILL.md +147 -0
  177. package/.mindforge/skills/code-wiki/SKILL.md +457 -0
  178. package/.mindforge/skills/codebase-inspection/SKILL.md +126 -0
  179. package/.mindforge/skills/concept-diagrams/SKILL.md +373 -0
  180. package/.mindforge/skills/creative-ideation/SKILL.md +162 -0
  181. package/.mindforge/skills/domain-intel/SKILL.md +116 -0
  182. package/.mindforge/skills/duckduckgo-search/SKILL.md +249 -0
  183. package/.mindforge/skills/github-code-review/SKILL.md +493 -0
  184. package/.mindforge/skills/github-issues/SKILL.md +382 -0
  185. package/.mindforge/skills/github-pr-workflow/SKILL.md +379 -0
  186. package/.mindforge/skills/jupyter-live-kernel/SKILL.md +179 -0
  187. package/.mindforge/skills/kanban-orchestrator/SKILL.md +227 -0
  188. package/.mindforge/skills/kanban-worker/SKILL.md +206 -0
  189. package/.mindforge/skills/meme-generation/SKILL.md +141 -0
  190. package/.mindforge/skills/obsidian/SKILL.md +80 -0
  191. package/.mindforge/skills/osint-investigation/SKILL.md +288 -0
  192. package/.mindforge/skills/oss-forensics/SKILL.md +421 -0
  193. package/.mindforge/skills/pixel-art/SKILL.md +228 -0
  194. package/.mindforge/skills/plan/SKILL.md +350 -0
  195. package/.mindforge/skills/requesting-code-review/SKILL.md +292 -0
  196. package/.mindforge/skills/research-paper-writing/SKILL.md +2384 -0
  197. package/.mindforge/skills/scrapling/SKILL.md +345 -0
  198. package/.mindforge/skills/sherlock/SKILL.md +203 -0
  199. package/.mindforge/skills/simplify-code/SKILL.md +187 -0
  200. package/.mindforge/skills/spike/SKILL.md +209 -0
  201. package/.mindforge/skills/subagent-driven-development/SKILL.md +364 -0
  202. package/.mindforge/skills/systematic-debugging/SKILL.md +379 -0
  203. package/.mindforge/skills/test-driven-development/SKILL.md +355 -0
  204. package/.mindforge/skills/web-pentest/SKILL.md +327 -0
  205. package/CHANGELOG.md +71 -0
  206. package/MINDFORGE.md +2 -2
  207. package/README.md +72 -3
  208. package/RELEASENOTES.md +109 -0
  209. package/bin/installer-core.js +6 -2
  210. package/bin/mindforge-cli.js +7 -0
  211. package/bin/workflows/workflow-runner.js +110 -0
  212. package/docs/commands-reference.md +25 -0
  213. package/docs/getting-started.md +42 -5
  214. package/package.json +2 -1
@@ -0,0 +1,563 @@
1
+ # Citation Management & Hallucination Prevention
2
+
3
+ This reference provides a complete workflow for managing citations programmatically, preventing AI-generated citation hallucinations, and maintaining clean bibliographies.
4
+
5
+ ---
6
+
7
+ ## Contents
8
+
9
+ - [Why Citation Verification Matters](#why-citation-verification-matters)
10
+ - [Citation APIs Overview](#citation-apis-overview)
11
+ - [Verified Citation Workflow](#verified-citation-workflow)
12
+ - [Python Implementation](#python-implementation)
13
+ - [BibTeX Management](#bibtex-management)
14
+ - [Common Citation Formats](#common-citation-formats)
15
+ - [Troubleshooting](#troubleshooting)
16
+
17
+ ---
18
+
19
+ ## Why Citation Verification Matters
20
+
21
+ ### The Hallucination Problem
22
+
23
+ Research has documented significant issues with AI-generated citations:
24
+ - **~40% error rate** in AI-generated citations (Enago Academy research)
25
+ - NeurIPS 2025 found **100+ hallucinated citations** slipped through review
26
+ - Common errors include:
27
+ - Fabricated paper titles with real author names
28
+ - Wrong publication venues or years
29
+ - Non-existent papers with plausible metadata
30
+ - Incorrect DOIs or arXiv IDs
31
+
32
+ ### Consequences
33
+
34
+ - Desk rejection at some venues
35
+ - Loss of credibility with reviewers
36
+ - Potential retraction if published
37
+ - Wasted time chasing non-existent sources
38
+
39
+ ### Solution
40
+
41
+ **Never generate citations from memory—always verify programmatically.**
42
+
43
+ ---
44
+
45
+ ## Citation APIs Overview
46
+
47
+ ### Primary APIs
48
+
49
+ | API | Coverage | Rate Limits | Best For |
50
+ |-----|----------|-------------|----------|
51
+ | **Semantic Scholar** | 214M papers | 1 RPS (free key) | ML/AI papers, citation graphs |
52
+ | **CrossRef** | 140M+ DOIs | Polite pool with mailto | DOI lookup, BibTeX retrieval |
53
+ | **arXiv** | Preprints | 3-second delays | ML preprints, PDF access |
54
+ | **OpenAlex** | 240M+ works | 100K/day, 10 RPS | Open alternative to MAG |
55
+
56
+ ### API Selection Guide
57
+
58
+ ```
59
+ Need ML paper search? → Semantic Scholar
60
+ Have DOI, need BibTeX? → CrossRef content negotiation
61
+ Looking for preprint? → arXiv API
62
+ Need open data, bulk access? → OpenAlex
63
+ ```
64
+
65
+ ### No Official Google Scholar API
66
+
67
+ Google Scholar has no official API. Scraping violates ToS. Use SerpApi ($75-275/month) only if Semantic Scholar coverage is insufficient.
68
+
69
+ ---
70
+
71
+ ## Verified Citation Workflow
72
+
73
+ ### 5-Step Process
74
+
75
+ ```
76
+ 1. SEARCH → Query Semantic Scholar with specific keywords
77
+
78
+ 2. VERIFY → Confirm paper exists in 2+ sources
79
+
80
+ 3. RETRIEVE → Get BibTeX via DOI content negotiation
81
+
82
+ 4. VALIDATE → Confirm the claim appears in source
83
+
84
+ 5. ADD → Add verified entry to .bib file
85
+ ```
86
+
87
+ ### Step 1: Search
88
+
89
+ Use Semantic Scholar for ML/AI papers:
90
+
91
+ ```python
92
+ from semanticscholar import SemanticScholar
93
+
94
+ sch = SemanticScholar()
95
+ results = sch.search_paper("transformer attention mechanism", limit=10)
96
+
97
+ for paper in results:
98
+ print(f"Title: {paper.title}")
99
+ print(f"Year: {paper.year}")
100
+ print(f"DOI: {paper.externalIds.get('DOI', 'N/A')}")
101
+ print(f"arXiv: {paper.externalIds.get('ArXiv', 'N/A')}")
102
+ print(f"Citation count: {paper.citationCount}")
103
+ print("---")
104
+ ```
105
+
106
+ ### Step 2: Verify Existence
107
+
108
+ Confirm paper exists in at least two sources:
109
+
110
+ ```python
111
+ import requests
112
+
113
+ def verify_paper(doi=None, arxiv_id=None, title=None):
114
+ """Verify paper exists in multiple sources."""
115
+ sources_found = []
116
+
117
+ # Check Semantic Scholar
118
+ sch = SemanticScholar()
119
+ if doi:
120
+ paper = sch.get_paper(f"DOI:{doi}")
121
+ if paper:
122
+ sources_found.append("Semantic Scholar")
123
+
124
+ # Check CrossRef (via DOI)
125
+ if doi:
126
+ resp = requests.get(f"https://api.crossref.org/works/{doi}")
127
+ if resp.status_code == 200:
128
+ sources_found.append("CrossRef")
129
+
130
+ # Check arXiv
131
+ if arxiv_id:
132
+ resp = requests.get(
133
+ f"http://export.arxiv.org/api/query?id_list={arxiv_id}"
134
+ )
135
+ if "<entry>" in resp.text:
136
+ sources_found.append("arXiv")
137
+
138
+ return len(sources_found) >= 2, sources_found
139
+ ```
140
+
141
+ ### Step 3: Retrieve BibTeX
142
+
143
+ Use DOI content negotiation for guaranteed accuracy:
144
+
145
+ ```python
146
+ import requests
147
+
148
+ def doi_to_bibtex(doi: str) -> str:
149
+ """Get verified BibTeX from DOI via CrossRef content negotiation."""
150
+ response = requests.get(
151
+ f"https://doi.org/{doi}",
152
+ headers={"Accept": "application/x-bibtex"},
153
+ allow_redirects=True
154
+ )
155
+ response.raise_for_status()
156
+ return response.text
157
+
158
+ # Example: "Attention Is All You Need"
159
+ bibtex = doi_to_bibtex("10.48550/arXiv.1706.03762")
160
+ print(bibtex)
161
+ ```
162
+
163
+ ### Step 4: Validate Claims
164
+
165
+ Before citing a paper for a specific claim, verify the claim exists:
166
+
167
+ ```python
168
+ def get_paper_abstract(doi):
169
+ """Get abstract to verify claims."""
170
+ sch = SemanticScholar()
171
+ paper = sch.get_paper(f"DOI:{doi}")
172
+ return paper.abstract if paper else None
173
+
174
+ # Verify claim appears in abstract
175
+ abstract = get_paper_abstract("10.48550/arXiv.1706.03762")
176
+ claim = "attention mechanism"
177
+ if claim.lower() in abstract.lower():
178
+ print("Claim appears in paper")
179
+ ```
180
+
181
+ ### Step 5: Add to Bibliography
182
+
183
+ Add verified entry to your .bib file with consistent key format:
184
+
185
+ ```python
186
+ def generate_citation_key(bibtex: str) -> str:
187
+ """Generate consistent citation key: author_year_firstword."""
188
+ import re
189
+
190
+ # Extract author
191
+ author_match = re.search(r'author\s*=\s*\{([^}]+)\}', bibtex, re.I)
192
+ if author_match:
193
+ first_author = author_match.group(1).split(',')[0].split()[-1]
194
+ else:
195
+ first_author = "unknown"
196
+
197
+ # Extract year
198
+ year_match = re.search(r'year\s*=\s*\{?(\d{4})\}?', bibtex, re.I)
199
+ year = year_match.group(1) if year_match else "0000"
200
+
201
+ # Extract title first word
202
+ title_match = re.search(r'title\s*=\s*\{([^}]+)\}', bibtex, re.I)
203
+ if title_match:
204
+ first_word = title_match.group(1).split()[0].lower()
205
+ first_word = re.sub(r'[^a-z]', '', first_word)
206
+ else:
207
+ first_word = "paper"
208
+
209
+ return f"{first_author.lower()}_{year}_{first_word}"
210
+ ```
211
+
212
+ ---
213
+
214
+ ## Python Implementation
215
+
216
+ ### Complete Citation Manager Class
217
+
218
+ {% raw %}
219
+ ```python
220
+ """
221
+ Citation Manager - Verified citation workflow for ML papers.
222
+ """
223
+
224
+ import requests
225
+ import time
226
+ from typing import Optional, List, Dict, Tuple
227
+ from dataclasses import dataclass
228
+
229
+ try:
230
+ from semanticscholar import SemanticScholar
231
+ except ImportError:
232
+ print("Install: pip install semanticscholar")
233
+ SemanticScholar = None
234
+
235
+ @dataclass
236
+ class Paper:
237
+ title: str
238
+ authors: List[str]
239
+ year: int
240
+ doi: Optional[str]
241
+ arxiv_id: Optional[str]
242
+ venue: Optional[str]
243
+ citation_count: int
244
+ abstract: Optional[str]
245
+
246
+ class CitationManager:
247
+ """Manage citations with verification."""
248
+
249
+ def __init__(self, api_key: Optional[str] = None):
250
+ self.sch = SemanticScholar(api_key=api_key) if SemanticScholar else None
251
+ self.verified_papers: Dict[str, Paper] = {}
252
+
253
+ def search(self, query: str, limit: int = 10) -> List[Paper]:
254
+ """Search for papers using Semantic Scholar."""
255
+ if not self.sch:
256
+ raise RuntimeError("Semantic Scholar not available")
257
+
258
+ results = self.sch.search_paper(query, limit=limit)
259
+ papers = []
260
+
261
+ for r in results:
262
+ paper = Paper(
263
+ title=r.title,
264
+ authors=[a.name for a in (r.authors or [])],
265
+ year=r.year or 0,
266
+ doi=r.externalIds.get('DOI') if r.externalIds else None,
267
+ arxiv_id=r.externalIds.get('ArXiv') if r.externalIds else None,
268
+ venue=r.venue,
269
+ citation_count=r.citationCount or 0,
270
+ abstract=r.abstract
271
+ )
272
+ papers.append(paper)
273
+
274
+ return papers
275
+
276
+ def verify(self, paper: Paper) -> Tuple[bool, List[str]]:
277
+ """Verify paper exists in multiple sources."""
278
+ sources = []
279
+
280
+ # Already found in Semantic Scholar via search
281
+ sources.append("Semantic Scholar")
282
+
283
+ # Check CrossRef if DOI available
284
+ if paper.doi:
285
+ try:
286
+ resp = requests.get(
287
+ f"https://api.crossref.org/works/{paper.doi}",
288
+ timeout=10
289
+ )
290
+ if resp.status_code == 200:
291
+ sources.append("CrossRef")
292
+ except Exception:
293
+ pass
294
+
295
+ # Check arXiv if ID available
296
+ if paper.arxiv_id:
297
+ try:
298
+ resp = requests.get(
299
+ f"http://export.arxiv.org/api/query?id_list={paper.arxiv_id}",
300
+ timeout=10
301
+ )
302
+ if "<entry>" in resp.text and "<title>" in resp.text:
303
+ sources.append("arXiv")
304
+ except Exception:
305
+ pass
306
+
307
+ return len(sources) >= 2, sources
308
+
309
+ def get_bibtex(self, paper: Paper) -> Optional[str]:
310
+ """Get BibTeX for verified paper."""
311
+ if paper.doi:
312
+ try:
313
+ resp = requests.get(
314
+ f"https://doi.org/{paper.doi}",
315
+ headers={"Accept": "application/x-bibtex"},
316
+ timeout=10,
317
+ allow_redirects=True
318
+ )
319
+ if resp.status_code == 200:
320
+ return resp.text
321
+ except Exception:
322
+ pass
323
+
324
+ # Fallback: generate from paper data
325
+ return self._generate_bibtex(paper)
326
+
327
+ def _generate_bibtex(self, paper: Paper) -> str:
328
+ """Generate BibTeX from paper metadata."""
329
+ # Generate citation key
330
+ first_author = paper.authors[0].split()[-1] if paper.authors else "unknown"
331
+ first_word = paper.title.split()[0].lower().replace(',', '').replace(':', '')
332
+ key = f"{first_author.lower()}_{paper.year}_{first_word}"
333
+
334
+ # Format authors
335
+ authors = " and ".join(paper.authors) if paper.authors else "Unknown"
336
+
337
+ bibtex = f"""@article{{{key},
338
+ title = {{{paper.title}}},
339
+ author = {{{authors}}},
340
+ year = {{{paper.year}}},
341
+ {'doi = {' + paper.doi + '},' if paper.doi else ''}
342
+ {'eprint = {' + paper.arxiv_id + '},' if paper.arxiv_id else ''}
343
+ {'journal = {' + paper.venue + '},' if paper.venue else ''}
344
+ }}"""
345
+ return bibtex
346
+
347
+ def cite(self, query: str) -> Optional[str]:
348
+ """Full workflow: search, verify, return BibTeX."""
349
+ # Search
350
+ papers = self.search(query, limit=5)
351
+ if not papers:
352
+ return None
353
+
354
+ # Take top result
355
+ paper = papers[0]
356
+
357
+ # Verify
358
+ verified, sources = self.verify(paper)
359
+ if not verified:
360
+ print(f"Warning: Could only verify in {sources}")
361
+
362
+ # Get BibTeX
363
+ bibtex = self.get_bibtex(paper)
364
+
365
+ # Cache
366
+ if bibtex:
367
+ self.verified_papers[paper.title] = paper
368
+
369
+ return bibtex
370
+
371
+ # Usage example
372
+ if __name__ == "__main__":
373
+ cm = CitationManager()
374
+
375
+ # Search and cite
376
+ bibtex = cm.cite("attention is all you need transformer")
377
+ if bibtex:
378
+ print(bibtex)
379
+ ```
380
+ {% endraw %}
381
+
382
+ ### Quick Functions
383
+
384
+ ```python
385
+ def quick_cite(query: str) -> str:
386
+ """One-liner citation."""
387
+ cm = CitationManager()
388
+ return cm.cite(query)
389
+
390
+ def batch_cite(queries: List[str], output_file: str = "references.bib"):
391
+ """Cite multiple papers and save to file."""
392
+ cm = CitationManager()
393
+ bibtex_entries = []
394
+
395
+ for query in queries:
396
+ print(f"Processing: {query}")
397
+ bibtex = cm.cite(query)
398
+ if bibtex:
399
+ bibtex_entries.append(bibtex)
400
+ time.sleep(1) # Rate limiting
401
+
402
+ with open(output_file, 'w') as f:
403
+ f.write("\n\n".join(bibtex_entries))
404
+
405
+ print(f"Saved {len(bibtex_entries)} citations to {output_file}")
406
+ ```
407
+
408
+ ---
409
+
410
+ ## BibTeX Management
411
+
412
+ ### BibTeX vs BibLaTeX
413
+
414
+ | Feature | BibTeX | BibLaTeX |
415
+ |---------|--------|----------|
416
+ | Unicode support | Limited | Full |
417
+ | Entry types | Standard | Extended (@online, @dataset) |
418
+ | Customization | Limited | Highly flexible |
419
+ | Backend | bibtex | Biber (recommended) |
420
+
421
+ **Recommendation**: Use natbib with BibTeX for conference submissions — all major venue templates (NeurIPS, ICML, ICLR, ACL, AAAI, COLM) ship with natbib and `.bst` files. BibLaTeX with Biber is an option for journals or personal projects where you control the template.
422
+
423
+ ### LaTeX Setup
424
+
425
+ ```latex
426
+ % In preamble
427
+ \usepackage[
428
+ backend=biber,
429
+ style=numeric,
430
+ sorting=none
431
+ ]{biblatex}
432
+ \addbibresource{references.bib}
433
+
434
+ % In document
435
+ \cite{vaswani_2017_attention}
436
+
437
+ % At end
438
+ \printbibliography
439
+ ```
440
+
441
+ ### Citation Commands
442
+
443
+ ```latex
444
+ \cite{key} % Numeric: [1]
445
+ \citep{key} % Parenthetical: (Author, 2020)
446
+ \citet{key} % Textual: Author (2020)
447
+ \citeauthor{key} % Just author name
448
+ \citeyear{key} % Just year
449
+ ```
450
+
451
+ ### Consistent Citation Keys
452
+
453
+ Use format: `author_year_firstword`
454
+
455
+ ```
456
+ vaswani_2017_attention
457
+ devlin_2019_bert
458
+ brown_2020_language
459
+ ```
460
+
461
+ ---
462
+
463
+ ## Common Citation Formats
464
+
465
+ ### Conference Paper
466
+
467
+ ```bibtex
468
+ @inproceedings{vaswani_2017_attention,
469
+ title = {Attention Is All You Need},
470
+ author = {Vaswani, Ashish and Shazeer, Noam and Parmar, Niki and
471
+ Uszkoreit, Jakob and Jones, Llion and Gomez, Aidan N and
472
+ Kaiser, Lukasz and Polosukhin, Illia},
473
+ booktitle = {Advances in Neural Information Processing Systems},
474
+ volume = {30},
475
+ year = {2017},
476
+ publisher = {Curran Associates, Inc.}
477
+ }
478
+ ```
479
+
480
+ ### Journal Article
481
+
482
+ ```bibtex
483
+ @article{hochreiter_1997_long,
484
+ title = {Long Short-Term Memory},
485
+ author = {Hochreiter, Sepp and Schmidhuber, J{\"u}rgen},
486
+ journal = {Neural Computation},
487
+ volume = {9},
488
+ number = {8},
489
+ pages = {1735--1780},
490
+ year = {1997},
491
+ publisher = {MIT Press}
492
+ }
493
+ ```
494
+
495
+ ### arXiv Preprint
496
+
497
+ ```bibtex
498
+ @misc{brown_2020_language,
499
+ title = {Language Models are Few-Shot Learners},
500
+ author = {Brown, Tom and Mann, Benjamin and Ryder, Nick and others},
501
+ year = {2020},
502
+ eprint = {2005.14165},
503
+ archiveprefix = {arXiv},
504
+ primaryclass = {cs.CL}
505
+ }
506
+ ```
507
+
508
+ ---
509
+
510
+ ## Troubleshooting
511
+
512
+ ### Common Issues
513
+
514
+ **Issue: Semantic Scholar returns no results**
515
+ - Try more specific keywords
516
+ - Check spelling of author names
517
+ - Use quotation marks for exact phrases
518
+
519
+ **Issue: DOI doesn't resolve to BibTeX**
520
+ - DOI may be registered but not linked to CrossRef
521
+ - Try arXiv ID instead if available
522
+ - Generate BibTeX from metadata manually
523
+
524
+ **Issue: Rate limiting errors**
525
+ - Add delays between requests (1-3 seconds)
526
+ - Use API key if available
527
+ - Cache results to avoid repeat queries
528
+
529
+ **Issue: Encoding problems in BibTeX**
530
+ - Use proper LaTeX escaping: `{\"u}` for ü
531
+ - Ensure file is UTF-8 encoded
532
+ - Use BibLaTeX with Biber for better Unicode
533
+
534
+ ### Verification Checklist
535
+
536
+ Before adding a citation:
537
+
538
+ - [ ] Paper found in at least 2 sources
539
+ - [ ] DOI or arXiv ID verified
540
+ - [ ] BibTeX retrieved (not generated from memory)
541
+ - [ ] Entry type correct (@inproceedings vs @article)
542
+ - [ ] Author names complete and correctly formatted
543
+ - [ ] Year and venue verified
544
+ - [ ] Citation key follows consistent format
545
+
546
+ ---
547
+
548
+ ## Additional Resources
549
+
550
+ **APIs:**
551
+ - Semantic Scholar: https://api.semanticscholar.org/api-docs/
552
+ - CrossRef: https://www.crossref.org/documentation/retrieve-metadata/rest-api/
553
+ - arXiv: https://info.arxiv.org/help/api/basics.html
554
+ - OpenAlex: https://docs.openalex.org/
555
+
556
+ **Python Libraries:**
557
+ - `semanticscholar`: https://pypi.org/project/semanticscholar/
558
+ - `arxiv`: https://pypi.org/project/arxiv/
559
+ - `habanero` (CrossRef): https://github.com/sckott/habanero
560
+
561
+ **Verification Tools:**
562
+ - Citely: https://citely.ai/citation-checker
563
+ - ReciteWorks: https://reciteworks.com/