@heripo/research-radar 6.2.0 → 6.3.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 +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +247 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -352,7 +352,7 @@ Three targets are read from data.go.kr open APIs instead of scraped: 나라일
|
|
|
352
352
|
|
|
353
353
|
Newly published journal issues are not crawled. The application supplies them through `journalIssueSource` — heripo-web reads them from its KCI paper catalog — and the `KCI_학술지_신간` target serves them from that source, so its URL is never requested. Each issue (권호) becomes one article: its `uniqId` is the issue's `externalId` and its URL the issue's `url`. `usedArticles` carry only the application's article id and URL, so the application records which issues a saved newsletter introduced through the `uniqId` it stored in `saveCrawledArticles`, or through the issue URL. The article body, which scoring sees, lists every paper with its authors, keywords and an abstract truncated to 300 characters, after the keywords several papers share. Without a source the target answers with an empty list. This replaces the former crawl of the 국립문화유산연구원 헤리티지:역사와 과학 and 보존과학연구 boards.
|
|
354
354
|
|
|
355
|
-
The generation model
|
|
355
|
+
The generation model does not write these issues into the body. `ContentGenerateProvider` renders a `📖 새로 나온 논문` section itself, placed after `🎓 학술대회·학술행사` and before `📋 발굴조사보고서 (신규 제출)`. When that section is missing it goes before the next fixed category present (`⛏️ 발굴현장 공개`, `💼 채용·공고`, `📑 사업·입찰 공고`, then `📌 마무리`). Each issue links to its KCI table of contents and shows, as a table with their authors, the papers its readers would want to read, most interesting first; the rest are collapsed into a count and their topics. The criterion is the readers' interest, not academic discipline — a 역사학 paper can be left out and a non-archaeology one shown — and the readers are 한국고고학회 회원 in KRAS mode. The importance model only chooses and orders paper indices and names the topics of the papers it leaves out — titles, links and authors come from the injected data. If the selection fails or times out, every paper is listed; if the run cannot load the issues, the articles go to the model as ordinary candidates. The issue articles stay among the model's candidates, marked with the content type `자동 섹션: 📖 새로 나온 논문`: the prompt keeps them out of the body sections but weighs them like any other news for the title and briefing, so a new issue can lead the newsletter on the same terms. They count toward the publication criteria and come back in `usedArticles` like the rest. As a deterministic guard, any line the model still writes about an injected issue or one of its papers outside the briefing is removed before saving (`newsletter.journals.body.removed` is logged), along with table headers and headings left empty.
|
|
356
356
|
|
|
357
357
|
Crawling fetches pass through that check (`src/crawling/robots.ts`) before reaching the network: a disallowed request is refused rather than sent, and a missing or unreachable robots.txt allows it. `robotsExemptOrigins` in `src/config/index.ts` lists origins exempted from the check, each with its reason.
|
|
358
358
|
|
package/dist/index.d.ts
CHANGED
|
@@ -690,6 +690,8 @@ type JournalIssueRendering = {
|
|
|
690
690
|
select?: JournalPaperSelector;
|
|
691
691
|
/** Reports that the issues could not be loaded, so the model got them. */
|
|
692
692
|
onUnavailable?: (reason: string) => void;
|
|
693
|
+
/** Reports body lines about the issues removed despite the prompt. */
|
|
694
|
+
onBodyMentionsRemoved?: (removed: number) => void;
|
|
693
695
|
};
|
|
694
696
|
/**
|
|
695
697
|
* Content generation provider implementation
|
|
@@ -750,6 +752,12 @@ declare class ContentGenerateProvider implements ContentGenerateProvider$1 {
|
|
|
750
752
|
}): Promise<{
|
|
751
753
|
id: string | number;
|
|
752
754
|
}>;
|
|
755
|
+
/**
|
|
756
|
+
* Drops what the model wrote about the held issues outside the briefing.
|
|
757
|
+
* The prompt already keeps them out of the body; this makes it certain, so
|
|
758
|
+
* an issue never appears both as a model-written row and in the table.
|
|
759
|
+
*/
|
|
760
|
+
private removeJournalIssueMentions;
|
|
753
761
|
private renderJournalIssues;
|
|
754
762
|
private renderDeadlineReminders;
|
|
755
763
|
}
|
package/dist/index.js
CHANGED
|
@@ -4309,6 +4309,24 @@ const extractDeadlinesPrompt = {
|
|
|
4309
4309
|
user: ({ targetArticle }) => `원문 제목: ${targetArticle.title}\n\n원문 본문:\n${targetArticle.detailContent}`,
|
|
4310
4310
|
};
|
|
4311
4311
|
|
|
4312
|
+
// Kept free of imports: the prompt reads these, and the section reads the
|
|
4313
|
+
// prompt's category order.
|
|
4314
|
+
/**
|
|
4315
|
+
* Heading of the journal issue section. It names papers rather than journals
|
|
4316
|
+
* so papers from other sources can join it later, and it stays distinct from
|
|
4317
|
+
* any heading the model writes.
|
|
4318
|
+
*/
|
|
4319
|
+
const JOURNAL_ISSUE_SECTION_HEADING = '📖 새로 나온 논문';
|
|
4320
|
+
/**
|
|
4321
|
+
* `contentType` of a journal issue article the section renders itself.
|
|
4322
|
+
*
|
|
4323
|
+
* The article still goes to the generation model, like any other candidate, so
|
|
4324
|
+
* a new issue can lead the title and briefing on the same terms as other news.
|
|
4325
|
+
* The marker tells the prompt not to write it into a body section; the table
|
|
4326
|
+
* is rendered from the injected data instead.
|
|
4327
|
+
*/
|
|
4328
|
+
const JOURNAL_ISSUE_CONTENT_TYPE = `자동 섹션: ${JOURNAL_ISSUE_SECTION_HEADING}`;
|
|
4329
|
+
|
|
4312
4330
|
/**
|
|
4313
4331
|
* Category order. Categories listed here are emitted first, in this order;
|
|
4314
4332
|
* anything else follows, ordered by how consequential it is.
|
|
@@ -4468,6 +4486,10 @@ ${LEADING_CATEGORIES.map((c, i) => ` ${i + 1}) ${c}`).join('\n')}
|
|
|
4468
4486
|
각 분류는 Heading 2(\`##\`)를 쓴다. 분류 안에서는 중요한 것부터 배치한다.
|
|
4469
4487
|
같은 내용이 여러 출처에서 왔다면 가장 자세한 것을 기준으로 한 번만 쓴다.
|
|
4470
4488
|
|
|
4489
|
+
\`구분\`이 \`${JOURNAL_ISSUE_CONTENT_TYPE}\`인 소식은 어느 분류에도 넣지 않는다. 그 표는
|
|
4490
|
+
\`## ${JOURNAL_ISSUE_SECTION_HEADING}\` 섹션으로 자동으로 들어간다. 대신 제목과 브리핑을 고를 때는
|
|
4491
|
+
다른 소식과 똑같이 중요도로 견주고, 더 중요하면 제목이나 브리핑에 올린다.
|
|
4492
|
+
|
|
4471
4493
|
3. **마무리**: 생성하는 본문의 마지막 섹션은 \`## 📌 마무리\`로 쓴다.
|
|
4472
4494
|
|
|
4473
4495
|
오늘 다룬 주요 소식을 한 문단으로 정리한다. 행사명 뒤에 날짜를 괄호로 덧붙인다.
|
|
@@ -4554,12 +4576,15 @@ ${titleRules(context)}
|
|
|
4554
4576
|
const published = article.publishedDate
|
|
4555
4577
|
? `\n**게시일:** ${article.publishedDate}`
|
|
4556
4578
|
: '';
|
|
4579
|
+
const kind = article.contentType === JOURNAL_ISSUE_CONTENT_TYPE
|
|
4580
|
+
? `**구분:** ${JOURNAL_ISSUE_CONTENT_TYPE} — 이 소식은 \`## ${JOURNAL_ISSUE_SECTION_HEADING}\` 섹션에 표로 자동으로 실린다. 본문 분류 섹션에 쓰지 않는다. 제목과 브리핑에서는 다른 소식과 같은 기준으로 다룰 수 있다.`
|
|
4581
|
+
: `**구분:** ${article.contentType}`;
|
|
4557
4582
|
return `## 소식 ${index + 1}
|
|
4558
4583
|
**제목:** ${article.title}
|
|
4559
4584
|
**URL:** ${article.url}
|
|
4560
4585
|
**중요도:** ${article.importanceScore}/10
|
|
4561
4586
|
**태그:** ${tags}
|
|
4562
|
-
|
|
4587
|
+
${kind}${published}${image}
|
|
4563
4588
|
**본문:**
|
|
4564
4589
|
${article.detailContent}`;
|
|
4565
4590
|
})
|
|
@@ -4748,6 +4773,13 @@ class AnalysisProvider {
|
|
|
4748
4773
|
targetUrl: 'https://www.seamuse.go.kr/resources/academicreport/list/1#tab4',
|
|
4749
4774
|
minScore: 6,
|
|
4750
4775
|
},
|
|
4776
|
+
// Injected journal issues: the prompt asks for the same floor that
|
|
4777
|
+
// `update()` enforces, so the model is not asked for scores it cannot
|
|
4778
|
+
// keep.
|
|
4779
|
+
{
|
|
4780
|
+
targetUrl: JOURNAL_ISSUE_LIST_URL,
|
|
4781
|
+
minScore: JOURNAL_ISSUE_MINIMUM_SCORE,
|
|
4782
|
+
},
|
|
4751
4783
|
// Excavation report news: minimum score 2
|
|
4752
4784
|
{
|
|
4753
4785
|
targetUrl: 'https://www.e-minwon.go.kr/ge/ee/getListEcexmPrmsnAply.do',
|
|
@@ -4785,10 +4817,35 @@ class AnalysisProvider {
|
|
|
4785
4817
|
async update(article) {
|
|
4786
4818
|
await this.articleRepository.updateAnalysis({
|
|
4787
4819
|
...article,
|
|
4788
|
-
importanceScore: capScoreByHeritageDomain(
|
|
4820
|
+
importanceScore: capScoreByHeritageDomain({
|
|
4821
|
+
...article,
|
|
4822
|
+
importanceScore: raiseJournalIssueScore(article),
|
|
4823
|
+
}),
|
|
4789
4824
|
});
|
|
4790
4825
|
}
|
|
4791
4826
|
}
|
|
4827
|
+
/**
|
|
4828
|
+
* Lowest score an injected journal issue article is saved with.
|
|
4829
|
+
*
|
|
4830
|
+
* The application only injects issues of journals it chose for the
|
|
4831
|
+
* newsletter, and their papers are filtered for the readers when rendered, so
|
|
4832
|
+
* a low score must not drop a whole issue before then: the application leaves
|
|
4833
|
+
* articles scored 1 out of the candidates.
|
|
4834
|
+
*/
|
|
4835
|
+
const JOURNAL_ISSUE_MINIMUM_SCORE = 6;
|
|
4836
|
+
/**
|
|
4837
|
+
* Enforces the journal issue floor on the saved score.
|
|
4838
|
+
*
|
|
4839
|
+
* Core only states `minimumImportanceScoreRules` in the prompt; it keeps the
|
|
4840
|
+
* model's score as returned and falls back to 1 when scoring fails. The floor
|
|
4841
|
+
* is applied here so neither can drop an issue. The per-domain ceiling still
|
|
4842
|
+
* applies afterwards.
|
|
4843
|
+
*/
|
|
4844
|
+
function raiseJournalIssueScore(article) {
|
|
4845
|
+
return article.targetUrl === JOURNAL_ISSUE_LIST_URL
|
|
4846
|
+
? Math.max(article.importanceScore, JOURNAL_ISSUE_MINIMUM_SCORE)
|
|
4847
|
+
: article.importanceScore;
|
|
4848
|
+
}
|
|
4792
4849
|
/**
|
|
4793
4850
|
* Applies the per-domain score ceiling from `maximumImportanceScoreByDomain`.
|
|
4794
4851
|
*
|
|
@@ -5339,7 +5396,7 @@ ${options.heripolabNewsMarkdown}
|
|
|
5339
5396
|
})
|
|
5340
5397
|
: ''}
|
|
5341
5398
|
|
|
5342
|
-
{{NEWSLETTER_CONTENT}}
|
|
5399
|
+
<div data-research-radar-body="">{{NEWSLETTER_CONTENT}}</div>
|
|
5343
5400
|
|
|
5344
5401
|
${options?.journalIssuesMarkdown
|
|
5345
5402
|
? `<div data-research-radar-journal-issues="">${safeMarkdown2Html(options.journalIssuesMarkdown, {
|
|
@@ -5531,8 +5588,6 @@ function collectNewsletterDeadlines(content, articles, verified) {
|
|
|
5531
5588
|
return result;
|
|
5532
5589
|
}
|
|
5533
5590
|
|
|
5534
|
-
/** Heading of the journal issue section. Distinct from any 학술지 heading the model writes. */
|
|
5535
|
-
const JOURNAL_ISSUE_SECTION_HEADING = '📖 새로 나온 학술지';
|
|
5536
5591
|
/** Authors listed per paper before the rest are counted. */
|
|
5537
5592
|
const AUTHOR_LIMIT = 3;
|
|
5538
5593
|
/** Topic labels named in the summary of papers left out of the table. */
|
|
@@ -5612,12 +5667,17 @@ function renderJournalIssueSection(entries) {
|
|
|
5612
5667
|
/**
|
|
5613
5668
|
* Headings the section is placed before, in order of preference.
|
|
5614
5669
|
*
|
|
5615
|
-
*
|
|
5616
|
-
*
|
|
5617
|
-
*
|
|
5670
|
+
* New journal issues are academic news, so they follow 학술대회·학술행사 and
|
|
5671
|
+
* come before 발굴조사보고서. The headings come from the prompt's category
|
|
5672
|
+
* order, so a section missing that day moves the journals before the next one
|
|
5673
|
+
* present: 발굴현장 공개, 채용·공고, then 사업·입찰 and 마무리. The categories
|
|
5674
|
+
* the model names itself cannot be matched, so on a day with none of the fixed
|
|
5675
|
+
* ones the journals land after them. Without any anchor they go at the end of
|
|
5676
|
+
* the body.
|
|
5618
5677
|
*/
|
|
5619
5678
|
const JOURNAL_ISSUE_SECTION_ANCHORS = [
|
|
5620
|
-
'
|
|
5679
|
+
...LEADING_CATEGORIES.slice(LEADING_CATEGORIES.indexOf('📋 발굴조사보고서 (신규 제출)')),
|
|
5680
|
+
TRAILING_CATEGORY,
|
|
5621
5681
|
'📌 마무리',
|
|
5622
5682
|
];
|
|
5623
5683
|
/** Inserts the section Markdown before the first anchor heading found. */
|
|
@@ -5634,18 +5694,152 @@ function insertJournalIssueMarkdown(content, section) {
|
|
|
5634
5694
|
/**
|
|
5635
5695
|
* Inserts the rendered section before the first anchor `<h2>` found, or before
|
|
5636
5696
|
* `fallback` (the closing block) when neither heading is present.
|
|
5697
|
+
*
|
|
5698
|
+
* The body separates its sections with an `<hr>` before each heading. That
|
|
5699
|
+
* rule stays above the journal section, so the same rule is repeated between
|
|
5700
|
+
* the section and the heading it was placed before.
|
|
5637
5701
|
*/
|
|
5638
5702
|
function insertJournalIssueHtml(document, section, fallback) {
|
|
5639
5703
|
const headings = [...document.querySelectorAll('h2')];
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5704
|
+
const target = JOURNAL_ISSUE_SECTION_ANCHORS.map((anchor) => headings.find((element) => element.textContent?.replace(/\s+/g, ' ').trim() === anchor)).find((heading) => heading !== undefined) ?? fallback;
|
|
5705
|
+
const rule = target.previousElementSibling;
|
|
5706
|
+
target.before(section);
|
|
5707
|
+
if (rule?.tagName === 'HR')
|
|
5708
|
+
target.before(rule.cloneNode(true));
|
|
5709
|
+
}
|
|
5710
|
+
/** Compares links the way the model may have written them. */
|
|
5711
|
+
function normalizeLink(url) {
|
|
5712
|
+
try {
|
|
5713
|
+
return new URL(url.replaceAll('&', '&').trim()).href.replace(/\/$/, '');
|
|
5714
|
+
}
|
|
5715
|
+
catch {
|
|
5716
|
+
return url.trim();
|
|
5717
|
+
}
|
|
5718
|
+
}
|
|
5719
|
+
/** Every link the journal section owns: each issue's table of contents and its papers. */
|
|
5720
|
+
function journalIssueLinks(issues) {
|
|
5721
|
+
return new Set(issues.flatMap((issue) => [issue.url, ...issue.papers.map((paper) => paper.url)].map(normalizeLink)));
|
|
5722
|
+
}
|
|
5723
|
+
const TABLE_SEPARATOR = /^\s*\|?\s*:?-{3,}/;
|
|
5724
|
+
/**
|
|
5725
|
+
* The briefing heading the prompt asks for in both modes (`📮 {date} 브리핑`).
|
|
5726
|
+
* Matching its text, not its position, keeps the guard off the briefing when
|
|
5727
|
+
* an H1 title precedes it or the template puts notices before the body.
|
|
5728
|
+
*/
|
|
5729
|
+
function isBriefingHeading(text) {
|
|
5730
|
+
return /브리핑\s*$/.test(text.replace(/\s+/g, ' ').trim());
|
|
5731
|
+
}
|
|
5732
|
+
/**
|
|
5733
|
+
* Removes body lines the model wrote about the injected issues.
|
|
5734
|
+
*
|
|
5735
|
+
* The prompt keeps those issues out of the body sections, since the rendered
|
|
5736
|
+
* table stands for them; this is the deterministic guard behind it. The
|
|
5737
|
+
* briefing, and anything before the first section, may name them like any
|
|
5738
|
+
* other news and is left alone. Elsewhere every line linking an issue or one
|
|
5739
|
+
* of its papers is dropped, then table headers left without rows and headings
|
|
5740
|
+
* left without content.
|
|
5741
|
+
*/
|
|
5742
|
+
function removeJournalIssueMentionsMarkdown(content, links) {
|
|
5743
|
+
if (links.size === 0)
|
|
5744
|
+
return { content, removed: 0 };
|
|
5745
|
+
const mentions = (line) => [...line.matchAll(/\]\(([^)\s]+)\)|(https?:\/\/[^\s)<>|]+)/g)].some((match) => links.has(normalizeLink(match[1] ?? match[2])));
|
|
5746
|
+
let removed = 0;
|
|
5747
|
+
const kept = content.split(/(?=^## )/m).map((section) => {
|
|
5748
|
+
const [heading] = section.split('\n', 1);
|
|
5749
|
+
if (!heading.startsWith('## ') || isBriefingHeading(heading.slice(3)))
|
|
5750
|
+
return section;
|
|
5751
|
+
const lines = section.split('\n');
|
|
5752
|
+
const filtered = lines.filter((line, lineIndex) => lineIndex === 0 || !mentions(line));
|
|
5753
|
+
if (filtered.length === lines.length)
|
|
5754
|
+
return section;
|
|
5755
|
+
removed += lines.length - filtered.length;
|
|
5756
|
+
// Drop a table header and separator whose rows were all removed.
|
|
5757
|
+
const cleaned = filtered.filter((line, lineIndex) => {
|
|
5758
|
+
const next = filtered[lineIndex + 1] ?? '';
|
|
5759
|
+
const previous = filtered[lineIndex - 1] ?? '';
|
|
5760
|
+
const after = filtered[lineIndex + 2] ?? '';
|
|
5761
|
+
if (TABLE_SEPARATOR.test(next) && line.trim().startsWith('|'))
|
|
5762
|
+
return after.trim().startsWith('|');
|
|
5763
|
+
if (TABLE_SEPARATOR.test(line) && previous.trim().startsWith('|'))
|
|
5764
|
+
return next.trim().startsWith('|');
|
|
5765
|
+
return true;
|
|
5766
|
+
});
|
|
5767
|
+
return cleaned.slice(1).some((line) => line.trim())
|
|
5768
|
+
? cleaned.join('\n')
|
|
5769
|
+
: '';
|
|
5770
|
+
});
|
|
5771
|
+
return { content: kept.join(''), removed };
|
|
5772
|
+
}
|
|
5773
|
+
/**
|
|
5774
|
+
* HTML counterpart of {@link removeJournalIssueMentionsMarkdown}, applied to the
|
|
5775
|
+
* body core rendered before the journal section is inserted.
|
|
5776
|
+
*
|
|
5777
|
+
* Only the model's body (`data-research-radar-body`) is searched, so notices
|
|
5778
|
+
* the template adds before or after it are never touched. Within it the
|
|
5779
|
+
* guarded sections start at the heading after the briefing, or at the first
|
|
5780
|
+
* heading when there is no briefing heading.
|
|
5781
|
+
*/
|
|
5782
|
+
function removeJournalIssueMentionsHtml(document, links) {
|
|
5783
|
+
const body = document.querySelector('[data-research-radar-body]');
|
|
5784
|
+
if (links.size === 0 || !body)
|
|
5785
|
+
return 0;
|
|
5786
|
+
const headings = [...body.querySelectorAll('h2')];
|
|
5787
|
+
const briefing = headings.findIndex((heading) => isBriefingHeading(heading.textContent ?? ''));
|
|
5788
|
+
const guarded = headings.slice(briefing + 1);
|
|
5789
|
+
const start = guarded[0];
|
|
5790
|
+
if (!start)
|
|
5791
|
+
return 0;
|
|
5792
|
+
const touched = new Set();
|
|
5793
|
+
for (const anchor of body.querySelectorAll('a[href]')) {
|
|
5794
|
+
if (!links.has(normalizeLink(anchor.getAttribute('href') ?? '')))
|
|
5795
|
+
continue;
|
|
5796
|
+
if (!(start.compareDocumentPosition(anchor) & FOLLOWING))
|
|
5797
|
+
continue;
|
|
5798
|
+
const block = removableBlock(anchor, body);
|
|
5799
|
+
if (block)
|
|
5800
|
+
touched.add(block);
|
|
5801
|
+
}
|
|
5802
|
+
const containers = new Set();
|
|
5803
|
+
for (const block of touched) {
|
|
5804
|
+
// Only tables and lists of the body, never the template's layout table.
|
|
5805
|
+
const container = block.closest('table, ul, ol');
|
|
5806
|
+
if (container && body.contains(container))
|
|
5807
|
+
containers.add(container);
|
|
5808
|
+
block.remove();
|
|
5809
|
+
}
|
|
5810
|
+
for (const container of containers)
|
|
5811
|
+
if (!container.querySelector(container.tagName === 'TABLE' ? 'tbody tr' : 'li'))
|
|
5812
|
+
container.remove();
|
|
5813
|
+
// A heading whose section is now empty goes, with the rule before it.
|
|
5814
|
+
if (touched.size > 0)
|
|
5815
|
+
for (const heading of guarded) {
|
|
5816
|
+
const next = heading.nextElementSibling;
|
|
5817
|
+
if (next && next.tagName !== 'H2' && next.tagName !== 'HR')
|
|
5818
|
+
continue;
|
|
5819
|
+
const rule = heading.previousElementSibling;
|
|
5820
|
+
if (rule?.tagName === 'HR')
|
|
5821
|
+
rule.remove();
|
|
5822
|
+
heading.remove();
|
|
5645
5823
|
}
|
|
5824
|
+
return touched.size;
|
|
5825
|
+
}
|
|
5826
|
+
/**
|
|
5827
|
+
* The block to drop for a link: its table row or list item, whole even when its
|
|
5828
|
+
* text sits in a paragraph, otherwise its paragraph. The search stops at the
|
|
5829
|
+
* body, which itself sits inside the template's layout table.
|
|
5830
|
+
*/
|
|
5831
|
+
function removableBlock(anchor, body) {
|
|
5832
|
+
let paragraph = null;
|
|
5833
|
+
for (let element = anchor; element && element !== body; element = element.parentElement) {
|
|
5834
|
+
if (element.tagName === 'TR' || element.tagName === 'LI')
|
|
5835
|
+
return element;
|
|
5836
|
+
if (element.tagName === 'P')
|
|
5837
|
+
paragraph ??= element;
|
|
5646
5838
|
}
|
|
5647
|
-
|
|
5839
|
+
return paragraph;
|
|
5648
5840
|
}
|
|
5841
|
+
/** `Node.DOCUMENT_POSITION_FOLLOWING`, without needing a window. */
|
|
5842
|
+
const FOLLOWING = 4;
|
|
5649
5843
|
|
|
5650
5844
|
/**
|
|
5651
5845
|
* Content generation provider implementation
|
|
@@ -5747,8 +5941,13 @@ class ContentGenerateProvider {
|
|
|
5747
5941
|
const issue = issuesByUrl.get(article.url);
|
|
5748
5942
|
return issue ? [{ article, issue }] : [];
|
|
5749
5943
|
});
|
|
5944
|
+
// Held issues stay candidates, so they count toward publication and can
|
|
5945
|
+
// lead the title and briefing like any other news. The marker keeps them
|
|
5946
|
+
// out of the body sections, where the rendered table stands for them.
|
|
5750
5947
|
const held = new Set(this.heldJournalIssues.map(({ article }) => article));
|
|
5751
|
-
return candidates.
|
|
5948
|
+
return candidates.map((article) => held.has(article)
|
|
5949
|
+
? { ...article, contentType: JOURNAL_ISSUE_CONTENT_TYPE }
|
|
5950
|
+
: article);
|
|
5752
5951
|
}
|
|
5753
5952
|
/**
|
|
5754
5953
|
* Save generated newsletter to the repository
|
|
@@ -5756,7 +5955,8 @@ class ContentGenerateProvider {
|
|
|
5756
5955
|
* @returns Saved newsletter ID
|
|
5757
5956
|
*/
|
|
5758
5957
|
async saveNewsletter(input) {
|
|
5759
|
-
const {
|
|
5958
|
+
const { usedArticles } = input;
|
|
5959
|
+
const newsletter = this.removeJournalIssueMentions(input.newsletter);
|
|
5760
5960
|
// Reject conflicting model output before any persistence, rather than
|
|
5761
5961
|
// silently publishing a second schedule block or misplaced sharing link.
|
|
5762
5962
|
if (/^\s*(?:\*\*임박한 주요 일정 및 마감:|##\s+⏰\s*다가오는 (?:일정\s*·\s*마감|마감))/m.test(newsletter.content))
|
|
@@ -5789,17 +5989,10 @@ class ContentGenerateProvider {
|
|
|
5789
5989
|
insertJournalIssueHtml(document, document.importNode(journalSection, true), closing);
|
|
5790
5990
|
}
|
|
5791
5991
|
closing.outerHTML = closingDocument.querySelector('[data-research-radar-closing]').outerHTML;
|
|
5792
|
-
//
|
|
5793
|
-
//
|
|
5794
|
-
const usedIds = new Set(usedArticles.map((article) => article.id));
|
|
5992
|
+
// Held journal articles are candidates the model saw, so core already
|
|
5993
|
+
// hands them back with the rest.
|
|
5795
5994
|
return this.newsletterRepository.saveNewsletter({
|
|
5796
|
-
|
|
5797
|
-
usedArticles: [
|
|
5798
|
-
...usedArticles,
|
|
5799
|
-
...this.heldJournalIssues
|
|
5800
|
-
.map(({ article }) => article)
|
|
5801
|
-
.filter((article) => !usedIds.has(article.id)),
|
|
5802
|
-
],
|
|
5995
|
+
usedArticles,
|
|
5803
5996
|
newsletter: {
|
|
5804
5997
|
...newsletter,
|
|
5805
5998
|
content: `${insertJournalIssueMarkdown(newsletter.content, journalMarkdown)}${markdown ? `\n\n<!-- research-radar-deadline-reminders -->\n${markdown}` : ''}${share ? `\n\n<!-- research-radar-share-notice -->\n${share}` : ''}`,
|
|
@@ -5807,6 +6000,27 @@ class ContentGenerateProvider {
|
|
|
5807
6000
|
},
|
|
5808
6001
|
});
|
|
5809
6002
|
}
|
|
6003
|
+
/**
|
|
6004
|
+
* Drops what the model wrote about the held issues outside the briefing.
|
|
6005
|
+
* The prompt already keeps them out of the body; this makes it certain, so
|
|
6006
|
+
* an issue never appears both as a model-written row and in the table.
|
|
6007
|
+
*/
|
|
6008
|
+
removeJournalIssueMentions(newsletter) {
|
|
6009
|
+
const links = journalIssueLinks(this.heldJournalIssues.map(({ issue }) => issue));
|
|
6010
|
+
if (links.size === 0)
|
|
6011
|
+
return newsletter;
|
|
6012
|
+
const markdown = removeJournalIssueMentionsMarkdown(newsletter.content, links);
|
|
6013
|
+
const dom = new JSDOM(newsletter.htmlBody);
|
|
6014
|
+
const removed = removeJournalIssueMentionsHtml(dom.window.document, links);
|
|
6015
|
+
if (markdown.removed === 0 && removed === 0)
|
|
6016
|
+
return newsletter;
|
|
6017
|
+
this.journalIssues?.onBodyMentionsRemoved?.(Math.max(markdown.removed, removed));
|
|
6018
|
+
return {
|
|
6019
|
+
...newsletter,
|
|
6020
|
+
content: markdown.content,
|
|
6021
|
+
htmlBody: dom.serialize(),
|
|
6022
|
+
};
|
|
6023
|
+
}
|
|
5810
6024
|
async renderJournalIssues() {
|
|
5811
6025
|
if (this.heldJournalIssues.length === 0)
|
|
5812
6026
|
return '';
|
|
@@ -6357,6 +6571,12 @@ function createNewsletterGenerator(dependencies) {
|
|
|
6357
6571
|
data: { reason },
|
|
6358
6572
|
});
|
|
6359
6573
|
},
|
|
6574
|
+
onBodyMentionsRemoved: (removed) => {
|
|
6575
|
+
dependencies.logger?.info({
|
|
6576
|
+
event: 'newsletter.journals.body.removed',
|
|
6577
|
+
data: { removed },
|
|
6578
|
+
});
|
|
6579
|
+
},
|
|
6360
6580
|
});
|
|
6361
6581
|
return new GenerateNewsletter({
|
|
6362
6582
|
contentOptions: resolvedContentOptions,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@heripo/research-radar",
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "6.
|
|
5
|
+
"version": "6.3.0",
|
|
6
6
|
"description": "AI-driven intelligence for Korean cultural heritage. This package serves as both a ready-to-use newsletter service and a practical implementation example for the LLM-Newsletter-Kit.",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|