채팅: pubmed_search에 치과 저널(journals)·논문 종류(paper_types) 필터 추가 — 저널 목록을 tools/dental-journals.ts로 공용화해 앱과 채팅이 같은 목록 사용

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5.5 committed 2026-10-19 21:22:17 +09:00
1 parent 30d5ba3f35
commit 328dbf14e5
5 files changed
+66 -29

No files matched your search

+2
View File
@@ -661,6 +661,8 @@ export function createBuildTools(isOrchestrationSkillEnabled: () => boolean) {
min_year: { type: 'number', description: 'Filter articles from this year onwards' },
offset: { type: 'number', description: 'Skip this many results (paging)' },
compact: { type: 'boolean', description: 'true = one line per result (PMID | journal | year | title) and max_results up to 200 — use to read a long result set in one call' },
journals: { type: 'string', description: 'Restrict to dental journals: "dental" (JOE, IEJ, JAD, JERD, Oper Dent, Dent Mater, JDR, J Dent, Clin Oral Investig, Dent Mater J, Am J Dent, J Conserv Dent) or comma-separated ids (joe,iej,jad,jerd,od,dm,jdr,jdent,coi,dmj,ajd,jcd). Use for 치과 저널/치의학 논문 requests; query must be English keywords.' },
paper_types: { type: 'string', description: 'Comma-separated: rct,ct,sr,ma,review,obs,case,guide' },
},
},
},
+1 -1
View File
@@ -109,7 +109,7 @@ const TOOL_BLOCKS: Record<string, string> = {
memory: `MEMORY TOOLS: memory_browse(file) → list categories in user.md or soul.md. memory_write(file,category,content) → add/update a fact (creates category if new). memory_read(file) → full file contents. File is "user" or "soul". Browse first to find the right category. Write immediately when you learn something — don't wait. memory_stats() → report vector-store document counts and on-disk size — use this (not memory_read) when asked how much you remember or how big the memory database is.`,
pubmed: `PUBMED TOOLS: pubmed_search(query, max_results?, sort?, min_year?) → search PubMed, returns PMIDs + titles + authors + links. pubmed_fetch(pmids) → get abstract + metadata for comma-separated PMIDs. pubmed_fulltext(pmcid, format?, save_path?) → download full text or PDF of an open-access PMC article to workspace. RULES: NEVER use web_search or browser_open for PubMed/PMC queries — they return no useful results. NEVER use browser_open on pubmed.ncbi.nlm.nih.gov URLs — call pubmed_fetch or pubmed_fulltext instead. When user gives you a PMC ID (e.g. PMC8765432) and asks for full text/전문: call pubmed_fulltext immediately. For multi-paper research tasks (여러 논문, 다수 논문, N편 검색+요약): use spawn_agent(agentId="pubmed_researcher") instead. CITATION & LINKS (ALWAYS): For every paper in your response, include: ① 저자(들), 제목, 학술지, 연도 (APA 형식 권장) ② PubMed URL (https://pubmed.ncbi.nlm.nih.gov/<PMID>/) ③ DOI 링크 (있을 경우) ④ PMC ID가 있으면 전문 링크 (https://www.ncbi.nlm.nih.gov/pmc/articles/<PMCID>/) — 검색 결과에 이미 포함되어 있으므로 반드시 그대로 전달할 것.`,
pubmed: `PUBMED TOOLS: pubmed_search(query, max_results?, sort?, min_year?, journals?, paper_types?) → search PubMed, returns PMIDs + titles + authors + links. 치과 저널/치의학 논문 요청이면 journals="dental"(또는 joe,iej,jad,jerd,od,dm,jdr,jdent,coi,dmj,ajd,jcd 중 지정)을 쓰고 query는 영어 키워드로, RCT/체계적문헌고찰 등은 paper_types(rct,ct,sr,ma,review,obs,case,guide)로 거를 것 — 직접 [ta] 태그를 쓰지 말 것. pubmed_fetch(pmids) → get abstract + metadata for comma-separated PMIDs. pubmed_fulltext(pmcid, format?, save_path?) → download full text or PDF of an open-access PMC article to workspace. RULES: NEVER use web_search or browser_open for PubMed/PMC queries — they return no useful results. NEVER use browser_open on pubmed.ncbi.nlm.nih.gov URLs — call pubmed_fetch or pubmed_fulltext instead. When user gives you a PMC ID (e.g. PMC8765432) and asks for full text/전문: call pubmed_fulltext immediately. For multi-paper research tasks (여러 논문, 다수 논문, N편 검색+요약): use spawn_agent(agentId="pubmed_researcher") instead. CITATION & LINKS (ALWAYS): For every paper in your response, include: ① 저자(들), 제목, 학술지, 연도 (APA 형식 권장) ② PubMed URL (https://pubmed.ncbi.nlm.nih.gov/<PMID>/) ③ DOI 링크 (있을 경우) ④ PMC ID가 있으면 전문 링크 (https://www.ncbi.nlm.nih.gov/pmc/articles/<PMCID>/) — 검색 결과에 이미 포함되어 있으므로 반드시 그대로 전달할 것.`,
scholar: `SCHOLAR TOOLS: openalex_search(query, max_results?, min_year?, open_access_only?, sort?) → search 200M+ papers across all fields via OpenAlex (no API key needed). semantic_search(query, max_results?, year_from?) → search Semantic Scholar (great for CS/AI, has citation influence metrics; add api_key to config for higher rate limits). Use openalex_search as the default broad search. Use semantic_search for CS/AI papers or when influential citation count matters. NEVER use web_search for academic paper searches — use openalex_search or semantic_search instead.`,
+2 -28
View File
@@ -1,34 +1,8 @@
import express from 'express';
import { toPaperSearchQuery } from '../../tools/query-translate.js';
// 치과 전용 저널 검색 — PubMed의 [ta](저널 약칭) 필드로 저널을 고정해서 검색한다.
// 저널을 늘리려면 이 목록에 한 줄만 추가하면 된다(약칭은 PubMed NLM 약칭).
export const DENTAL_JOURNALS: { id: string; short: string; name: string; ta: string; area: string }[] = [
{ id: 'joe', short: 'JOE', name: 'Journal of Endodontics', ta: 'J Endod', area: '근관치료' },
{ id: 'iej', short: 'IEJ', name: 'International Endodontic Journal', ta: 'Int Endod J', area: '근관치료' },
{ id: 'jad', short: 'JAD', name: 'Journal of Adhesive Dentistry', ta: 'J Adhes Dent', area: '접착치의학' },
{ id: 'jerd', short: 'JERD', name: 'Journal of Esthetic and Restorative Dentistry', ta: 'J Esthet Restor Dent', area: '심미·수복' },
{ id: 'od', short: 'Oper Dent', name: 'Operative Dentistry', ta: 'Oper Dent', area: '수복치의학' },
{ id: 'dm', short: 'Dent Mater', name: 'Dental Materials', ta: 'Dent Mater', area: '치과재료' },
{ id: 'jdr', short: 'JDR', name: 'Journal of Dental Research', ta: 'J Dent Res', area: '치의학 전반·기초' },
{ id: 'jdent', short: 'J Dent', name: 'Journal of Dentistry', ta: 'J Dent', area: '수복·재료·임상' },
{ id: 'coi', short: 'Clin Oral Investig', name: 'Clinical Oral Investigations', ta: 'Clin Oral Investig', area: '구강 임상·수복' },
{ id: 'dmj', short: 'Dent Mater J', name: 'Dental Materials Journal', ta: 'Dent Mater J', area: '치과재료(일본)' },
{ id: 'ajd', short: 'Am J Dent', name: 'American Journal of Dentistry', ta: 'Am J Dent', area: '수복·접착·심미' },
{ id: 'jcd', short: 'J Conserv Dent', name: 'Journal of Conservative Dentistry', ta: 'J Conserv Dent', area: '보존치의학' },
];
// 논문 종류 필터 — PubMed [pt](Publication Type). 여러 개를 고르면 OR, 저널·검색어와는 AND.
export const PAPER_TYPES: { id: string; label: string; pt: string }[] = [
{ id: 'rct', label: 'RCT', pt: 'Randomized Controlled Trial' },
{ id: 'ct', label: '임상시험', pt: 'Clinical Trial' },
{ id: 'sr', label: '체계적 문헌고찰', pt: 'Systematic Review' },
{ id: 'ma', label: '메타분석', pt: 'Meta-Analysis' },
{ id: 'review', label: '리뷰', pt: 'Review' },
{ id: 'obs', label: '관찰연구', pt: 'Observational Study' },
{ id: 'case', label: '증례보고', pt: 'Case Reports' },
{ id: 'guide', label: '가이드라인', pt: 'Practice Guideline' },
];
import { DENTAL_JOURNALS, PAPER_TYPES } from '../../tools/dental-journals.js';
export { DENTAL_JOURNALS, PAPER_TYPES };
// 저널 제한 없이 PubMed 전체를 검색하는 소스. 켜면 저널 카드와 무관하게 전체 범위(치과 외 논문도 섞임).
export const PUBMED_ALL = { id: 'pubmed', short: 'PubMed', name: 'PubMed 전체', area: '저널 제한 없음' };
+51
View File
@@ -0,0 +1,51 @@
// 치과 전용 저널 검색 — PubMed의 [ta](저널 약칭) 필드로 저널을 고정해서 검색한다.
// 저널을 늘리려면 이 목록에 한 줄만 추가하면 된다(약칭은 PubMed NLM 약칭).
export const DENTAL_JOURNALS: { id: string; short: string; name: string; ta: string; area: string }[] = [
{ id: 'joe', short: 'JOE', name: 'Journal of Endodontics', ta: 'J Endod', area: '근관치료' },
{ id: 'iej', short: 'IEJ', name: 'International Endodontic Journal', ta: 'Int Endod J', area: '근관치료' },
{ id: 'jad', short: 'JAD', name: 'Journal of Adhesive Dentistry', ta: 'J Adhes Dent', area: '접착치의학' },
{ id: 'jerd', short: 'JERD', name: 'Journal of Esthetic and Restorative Dentistry', ta: 'J Esthet Restor Dent', area: '심미·수복' },
{ id: 'od', short: 'Oper Dent', name: 'Operative Dentistry', ta: 'Oper Dent', area: '수복치의학' },
{ id: 'dm', short: 'Dent Mater', name: 'Dental Materials', ta: 'Dent Mater', area: '치과재료' },
{ id: 'jdr', short: 'JDR', name: 'Journal of Dental Research', ta: 'J Dent Res', area: '치의학 전반·기초' },
{ id: 'jdent', short: 'J Dent', name: 'Journal of Dentistry', ta: 'J Dent', area: '수복·재료·임상' },
{ id: 'coi', short: 'Clin Oral Investig', name: 'Clinical Oral Investigations', ta: 'Clin Oral Investig', area: '구강 임상·수복' },
{ id: 'dmj', short: 'Dent Mater J', name: 'Dental Materials Journal', ta: 'Dent Mater J', area: '치과재료(일본)' },
{ id: 'ajd', short: 'Am J Dent', name: 'American Journal of Dentistry', ta: 'Am J Dent', area: '수복·접착·심미' },
{ id: 'jcd', short: 'J Conserv Dent', name: 'Journal of Conservative Dentistry', ta: 'J Conserv Dent', area: '보존치의학' },
];
// 논문 종류 필터 — PubMed [pt](Publication Type). 여러 개를 고르면 OR, 저널·검색어와는 AND.
export const PAPER_TYPES: { id: string; label: string; pt: string }[] = [
{ id: 'rct', label: 'RCT', pt: 'Randomized Controlled Trial' },
{ id: 'ct', label: '임상시험', pt: 'Clinical Trial' },
{ id: 'sr', label: '체계적 문헌고찰', pt: 'Systematic Review' },
{ id: 'ma', label: '메타분석', pt: 'Meta-Analysis' },
{ id: 'review', label: '리뷰', pt: 'Review' },
{ id: 'obs', label: '관찰연구', pt: 'Observational Study' },
{ id: 'case', label: '증례보고', pt: 'Case Reports' },
{ id: 'guide', label: '가이드라인', pt: 'Practice Guideline' },
];
// 채팅 도구(pubmed_search)용: 저널·논문 종류 id를 PubMed 검색식으로 감싼다.
// journals: "dental"|"all"(치과 저널 전체) 또는 id/약칭 목록(쉼표 구분 문자열·배열). 알 수 없는 값은 unknown에 모은다.
export function applyDentalFilters(query: string, journals: unknown, paperTypes: unknown): { term: string; unknown: string[] } {
const list = (v: unknown): string[] => (Array.isArray(v) ? v : String(v ?? '').split(','))
.map(x => String(x).trim().toLowerCase()).filter(Boolean);
const unknown: string[] = [];
const js = list(journals);
const clauses: string[] = [];
if (query.trim()) clauses.push(`(${query.trim()})`);
if (js.length) {
const picked = js.includes('all') || js.includes('dental') ? DENTAL_JOURNALS : DENTAL_JOURNALS.filter(j => js.some(x => x === j.id || x === j.short.toLowerCase() || x === j.ta.toLowerCase()));
for (const x of js) if (x !== 'all' && x !== 'dental' && !DENTAL_JOURNALS.some(j => x === j.id || x === j.short.toLowerCase() || x === j.ta.toLowerCase())) unknown.push(x);
if (picked.length) clauses.push('(' + picked.map(j => `"${j.ta}"[ta]`).join(' OR ') + ')');
}
const ts = list(paperTypes);
if (ts.length) {
const picked = PAPER_TYPES.filter(t => ts.includes(t.id));
for (const x of ts) if (!PAPER_TYPES.some(t => t.id === x)) unknown.push(x);
if (picked.length) clauses.push('(' + picked.map(t => `"${t.pt}"[pt]`).join(' OR ') + ')');
}
return { term: clauses.join(' AND '), unknown };
}
+10
View File
@@ -5,6 +5,7 @@ import { promisify } from 'util';
import { ToolResult } from '../types.js';
import { getConfig } from '../config/config.js';
import { getWorkspacePath } from '../config/paths.js';
import { applyDentalFilters, DENTAL_JOURNALS, PAPER_TYPES } from './dental-journals.js';
const execFileAsync = promisify(execFile);
@@ -68,6 +69,8 @@ export const pubmedSearchTool = {
min_year: 'Optional: filter articles from this year onwards (e.g. 2020)',
offset: 'Optional: skip this many results (paging)',
compact: 'Optional: true = one line per result ("PMID | journal | year | title"), allows max_results up to 200 — use to read a long result set in one call',
journals: 'Optional: restrict to dental journals — "dental" (all 12) or comma-separated ids: ' + DENTAL_JOURNALS.map(j => j.id).join(','),
paper_types: 'Optional: comma-separated paper types: ' + PAPER_TYPES.map(t => t.id).join(','),
},
jsonSchema: {
type: 'object',
@@ -78,6 +81,8 @@ export const pubmedSearchTool = {
min_year: { type: 'number', description: 'Filter articles from this year onwards' },
offset: { type: 'number', description: 'Skip this many results (paging)' },
compact: { type: 'boolean', description: 'One line per result, max_results up to 200' },
journals: { type: 'string', description: 'Dental journal filter: "dental" or comma-separated ids' },
paper_types: { type: 'string', description: 'Paper type filter, comma-separated ids' },
},
required: ['query'],
additionalProperties: false,
@@ -95,6 +100,11 @@ export const pubmedSearchTool = {
const sort = args?.sort === 'date' ? 'pub+date' : 'relevance';
const minYear = args?.min_year ? Number(args.min_year) : null;
if (args?.journals || args?.paper_types) {
const f = applyDentalFilters(query, args.journals, args.paper_types);
if (f.unknown.length) return { success: false, error: `unknown journals/paper_types: ${f.unknown.join(', ')}` };
query = f.term;
}
if (!query) return { success: false, error: 'query is required' };
const fullQuery = minYear ? `${query} AND ${minYear}:3000[pdat]` : query;