erdos-problems 0.1.13 → 0.2.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/README.md +77 -4
- package/docs/RESEARCH_LOOP.md +14 -2
- package/package.json +1 -1
- package/packs/number-theory/README.md +13 -0
- package/packs/number-theory/problems/1/CONTEXT.md +8 -0
- package/packs/number-theory/problems/1/context.yaml +25 -0
- package/packs/number-theory/problems/2/CONTEXT.md +8 -0
- package/packs/number-theory/problems/2/context.yaml +25 -0
- package/packs/sunflower/README.md +17 -4
- package/packs/sunflower/problems/20/CHECKPOINT_TEMPLATE.md +29 -0
- package/packs/sunflower/problems/20/FRONTIER_NOTE.md +13 -0
- package/packs/sunflower/problems/20/OPS_DETAILS.yaml +44 -0
- package/packs/sunflower/problems/20/REPORT_TEMPLATE.md +23 -0
- package/packs/sunflower/problems/20/ROUTE_HISTORY.md +18 -0
- package/packs/sunflower/problems/536/OPS_DETAILS.yaml +39 -0
- package/packs/sunflower/problems/856/OPS_DETAILS.yaml +39 -0
- package/packs/sunflower/problems/857/CHECKPOINT_TEMPLATE.md +32 -0
- package/packs/sunflower/problems/857/FRONTIER_NOTE.md +18 -0
- package/packs/sunflower/problems/857/OPS_DETAILS.yaml +65 -0
- package/packs/sunflower/problems/857/REPORT_TEMPLATE.md +26 -0
- package/packs/sunflower/problems/857/ROUTE_HISTORY.md +25 -0
- package/src/cli/index.js +14 -2
- package/src/commands/archive.js +46 -0
- package/src/commands/maintainer.js +20 -2
- package/src/commands/problem.js +3 -0
- package/src/commands/pull.js +127 -4
- package/src/commands/sunflower.js +290 -12
- package/src/commands/upstream.js +129 -0
- package/src/commands/workspace.js +4 -0
- package/src/runtime/archive.js +87 -0
- package/src/runtime/checkpoints.js +27 -0
- package/src/runtime/maintainer-seed.js +70 -0
- package/src/runtime/paths.js +16 -0
- package/src/runtime/state.js +32 -3
- package/src/runtime/sunflower.js +329 -2
- package/src/runtime/workspace.js +4 -0
- package/src/upstream/literature.js +83 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function normalizeText(value) {
|
|
2
|
+
return String(value ?? '').replace(/\s+/g, ' ').trim();
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function uniqueStrings(values) {
|
|
6
|
+
return [...new Set(values.map((value) => normalizeText(value)).filter(Boolean))];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function buildLiteratureQueries(problemId, title) {
|
|
10
|
+
const cleanTitle = normalizeText(title);
|
|
11
|
+
return uniqueStrings([
|
|
12
|
+
`Erdos Problem ${problemId}`,
|
|
13
|
+
cleanTitle,
|
|
14
|
+
cleanTitle ? `${cleanTitle} Erdos` : null,
|
|
15
|
+
cleanTitle ? `${cleanTitle} combinatorics` : null,
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function fetchCrossrefLiterature(problemId, title) {
|
|
20
|
+
const query = buildLiteratureQueries(problemId, title)[0] ?? `Erdos Problem ${problemId}`;
|
|
21
|
+
const url = `https://api.crossref.org/works?query.title=${encodeURIComponent(query)}&rows=5&sort=relevance`;
|
|
22
|
+
const response = await fetch(url, {
|
|
23
|
+
headers: {
|
|
24
|
+
'User-Agent': 'erdos-problems-cli',
|
|
25
|
+
Accept: 'application/json',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
throw new Error(`Crossref lookup failed for problem ${problemId}: ${response.status}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const payload = await response.json();
|
|
34
|
+
const items = Array.isArray(payload?.message?.items) ? payload.message.items : [];
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
provider: 'crossref',
|
|
38
|
+
fetchedAt: new Date().toISOString(),
|
|
39
|
+
problemId: String(problemId),
|
|
40
|
+
query,
|
|
41
|
+
results: items.slice(0, 5).map((item) => ({
|
|
42
|
+
title: normalizeText(Array.isArray(item?.title) ? item.title[0] : item?.title),
|
|
43
|
+
url: normalizeText(item?.URL),
|
|
44
|
+
doi: normalizeText(item?.DOI),
|
|
45
|
+
publisher: normalizeText(item?.publisher),
|
|
46
|
+
published:
|
|
47
|
+
item?.issued?.['date-parts']?.[0]?.filter((value) => value !== null && value !== undefined).join('-')
|
|
48
|
+
?? null,
|
|
49
|
+
})),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function fetchOpenAlexLiterature(problemId, title) {
|
|
54
|
+
const query = buildLiteratureQueries(problemId, title)[0] ?? `Erdos Problem ${problemId}`;
|
|
55
|
+
const url = `https://api.openalex.org/works?search=${encodeURIComponent(query)}&per-page=5&sort=relevance_score:desc`;
|
|
56
|
+
const response = await fetch(url, {
|
|
57
|
+
headers: {
|
|
58
|
+
'User-Agent': 'erdos-problems-cli',
|
|
59
|
+
Accept: 'application/json',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
throw new Error(`OpenAlex lookup failed for problem ${problemId}: ${response.status}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const payload = await response.json();
|
|
68
|
+
const results = Array.isArray(payload?.results) ? payload.results : [];
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
provider: 'openalex',
|
|
72
|
+
fetchedAt: new Date().toISOString(),
|
|
73
|
+
problemId: String(problemId),
|
|
74
|
+
query,
|
|
75
|
+
results: results.slice(0, 5).map((item) => ({
|
|
76
|
+
title: normalizeText(item?.title),
|
|
77
|
+
url: normalizeText(item?.primary_location?.landing_page_url ?? item?.id),
|
|
78
|
+
doi: normalizeText(item?.doi),
|
|
79
|
+
citedByCount: Number(item?.cited_by_count ?? 0),
|
|
80
|
+
publicationYear: item?.publication_year ?? null,
|
|
81
|
+
})),
|
|
82
|
+
};
|
|
83
|
+
}
|