|
| 1 | +--- |
| 2 | +name: find-bib |
| 3 | +description: Find or construct a BibTeX reference for an OptimizationProblems.jl meta file. Given a DOI, problem name, or free-form reference text, searches for the DOI online, fetches BibTeX from doi2bib.org, and formats the result as a Julia raw string ready to paste into src/Meta/<name>.jl. |
| 4 | +argument-hint: <problem-name | DOI | "free-form reference text"> |
| 5 | +allowed-tools: [Read, Glob, Grep, WebSearch, WebFetch] |
| 6 | +--- |
| 7 | + |
| 8 | +# find-bib |
| 9 | + |
| 10 | +Find or construct a BibTeX reference and format it as a Julia raw string for `src/Meta/<name>.jl`. |
| 11 | + |
| 12 | +## Arguments |
| 13 | + |
| 14 | +The user invoked this skill with: $ARGUMENTS |
| 15 | + |
| 16 | +This can be: |
| 17 | +- A **problem name** from `src/Meta/` (e.g. `zangwil3`, `hs1`) — skill will read the file and extract context |
| 18 | +- A **DOI** (e.g. `10.1145/355934.355936` or `https://doi.org/10.1145/355934.355356`) |
| 19 | +- **Free-form reference text** (title, authors, journal, year — quoted or unquoted) |
| 20 | +- **Empty** — if no argument is given, ask the user to specify a problem name or reference |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## Instructions |
| 25 | + |
| 26 | +Follow these steps in order. |
| 27 | + |
| 28 | +### Step 1 — Gather source material |
| 29 | + |
| 30 | +If `$ARGUMENTS` looks like a problem name (no spaces, no slashes, exists as `src/Meta/<name>.jl`): |
| 31 | +- Read `src/Meta/$ARGUMENTS.jl` |
| 32 | +- Extract `:url`, `:notes`, `:origin_notes`, and the existing `:reference` field (may be empty) |
| 33 | +- Use this text as the source for Steps 2–4 |
| 34 | + |
| 35 | +Otherwise, treat `$ARGUMENTS` directly as a DOI or free-form reference text. |
| 36 | + |
| 37 | +### Step 2 — Extract or find a DOI |
| 38 | + |
| 39 | +1. Regex-scan all gathered text for a DOI pattern: `10\.\d{4,}/\S+` |
| 40 | + - DOIs appear in `:url`, `:notes`, `:origin_notes`, or in the argument itself |
| 41 | +2. If no DOI is found, run a **WebSearch** to locate one: |
| 42 | + - Try: `"<title or key terms>" "<first author>" DOI` |
| 43 | + - Try: `site:doi.org "<title or key terms>"` |
| 44 | + - Try CrossRef: `site:search.crossref.org "<title or key terms>"` |
| 45 | +3. Extract the DOI string from any search result that contains one. |
| 46 | + |
| 47 | +### Step 3 — Fetch BibTeX |
| 48 | + |
| 49 | +If a DOI was found (say `10.1145/355934.355936`), try these endpoints in order: |
| 50 | + |
| 51 | +1. **CrossRef** (primary): `https://api.crossref.org/works/10.1145/355934.355936/transform/application/x-bibtex` |
| 52 | +2. **doi2bib.org** (fallback): `https://www.doi2bib.org/bib/10.1145/355934.355936` |
| 53 | + |
| 54 | +The response is plain-text BibTeX — clean up whitespace if needed, then apply these normalizations: |
| 55 | + |
| 56 | +- **Citation key**: CrossRef often returns auto-generated keys like `More_1981` or `more1981testingunconstrained`. Always rename the key to the `Author1Author2YYYY` format described in Step 4 (e.g. `MoreGarbowHillstrom1981`). |
| 57 | +- **`pages` field**: normalize to BibTeX double-hyphen. Replace Unicode en-dash `–` or a single hyphen `-` between page numbers with `--` (e.g. `175--184`). |
| 58 | + |
| 59 | +If both endpoints fail or return an error, fall through to Step 4. |
| 60 | + |
| 61 | +### Step 4 — Construct BibTeX manually (fallback) |
| 62 | + |
| 63 | +If no DOI was found or doi2bib.org failed, construct the best possible BibTeX from all available information. |
| 64 | + |
| 65 | +Choose the entry type: |
| 66 | + |
| 67 | +| Type | Use when | |
| 68 | +|---|---| |
| 69 | +| `@article` | journal or conference paper | |
| 70 | +| `@book` | book or edited volume | |
| 71 | +| `@techreport` | institutional or technical report | |
| 72 | +| `@misc` | dataset, software, website, or unclear | |
| 73 | + |
| 74 | +**Citation key format:** `Author1Author2YYYY` using last names only (e.g. `MoreGarbowHillstrom1981`, `HockSchittkowski1981`). For a single author: `AuthorYYYY`. For institutional authors use a compact CamelCase form (e.g. `NISTStRD`). |
| 75 | + |
| 76 | +**`pages` field:** always use double-hyphen: `175--184`. Convert Unicode en-dash `–`, em-dash `—`, or single hyphen `-` between page numbers to `--`. |
| 77 | + |
| 78 | +**LaTeX encoding for special characters:** `Mor{\'e}`, `{\'E}`, etc. |
| 79 | + |
| 80 | +**Flag uncertain fields** with a trailing `% UNVERIFIED` comment on that line. |
| 81 | + |
| 82 | +### Step 5 — Present the result |
| 83 | + |
| 84 | +Show three things: |
| 85 | + |
| 86 | +**1. Status line** — one sentence: whether the DOI was found, and from where. |
| 87 | + |
| 88 | +**2. The BibTeX entry** in a code block: |
| 89 | +```bibtex |
| 90 | +@article{AuthorYear, |
| 91 | + author = {Last, First and Last2, First2}, |
| 92 | + title = {Title of the Article}, |
| 93 | + journal = {Journal Name}, |
| 94 | + year = {YYYY}, |
| 95 | + volume = {V}, |
| 96 | + number = {N}, |
| 97 | + pages = {P1--P2}, |
| 98 | + doi = {10.xxxx/xxxxx} |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +**3. The Julia snippet** ready to paste into `src/Meta/<name>.jl`: |
| 103 | +```julia |
| 104 | +:reference => raw""" |
| 105 | +@article{AuthorYear, |
| 106 | + author = {Last, First and Last2, First2}, |
| 107 | + title = {Title of the Article}, |
| 108 | + journal = {Journal Name}, |
| 109 | + year = {YYYY}, |
| 110 | + volume = {V}, |
| 111 | + number = {N}, |
| 112 | + pages = {P1--P2}, |
| 113 | + doi = {10.xxxx/xxxxx} |
| 114 | +} |
| 115 | +""", |
| 116 | +``` |
| 117 | + |
| 118 | +### Step 6 — Suggest next steps |
| 119 | + |
| 120 | +- List any fields marked `% UNVERIFIED` that the user should check manually. |
| 121 | +- If a DOI was found and the file's `:url` field does not already contain it, suggest adding `https://doi.org/<DOI>` to `:url`. The `:url` field supports multiple URLs as a **comma-separated string**. If a URL is already present, append the new one: `"https://existing.url, https://doi.org/<DOI>"`. |
| 122 | +- If the problem name was given, name the exact file to edit: `src/Meta/<name>.jl`. |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## BibTeX type templates (reference) |
| 127 | + |
| 128 | +```bibtex |
| 129 | +@article{AuthorYear, |
| 130 | + author = {Last, First}, |
| 131 | + title = {Title}, |
| 132 | + journal = {Journal}, |
| 133 | + year = {YYYY}, |
| 134 | + volume = {V}, |
| 135 | + number = {N}, |
| 136 | + pages = {P1--P2}, |
| 137 | + doi = {10.xxxx/xxxxx} |
| 138 | +} |
| 139 | +
|
| 140 | +@book{AuthorYear, |
| 141 | + author = {Last, First}, |
| 142 | + title = {Book Title}, |
| 143 | + publisher = {Publisher}, |
| 144 | + address = {City}, |
| 145 | + year = {YYYY} |
| 146 | +} |
| 147 | +
|
| 148 | +@techreport{AuthorYear, |
| 149 | + author = {Last, First}, |
| 150 | + title = {Report Title}, |
| 151 | + institution = {Institution}, |
| 152 | + number = {Report Number}, |
| 153 | + year = {YYYY} |
| 154 | +} |
| 155 | +
|
| 156 | +@misc{AuthorYear, |
| 157 | + author = {Last, First}, |
| 158 | + title = {Title}, |
| 159 | + year = {YYYY}, |
| 160 | + howpublished = {\url{https://...}} |
| 161 | +} |
| 162 | +``` |
0 commit comments