diff --git a/.env.sample b/.env.sample deleted file mode 100644 index feb34c3..0000000 --- a/.env.sample +++ /dev/null @@ -1,4 +0,0 @@ -ANTHROPIC_API_KEY -TAVILY_API_KEY -NOTE_STORAGE_STATE_JSON -PERPLEXITY_API_KEY diff --git a/.github/workflows/note.yaml b/.github/workflows/note.yaml index ddddc82..966ed02 100644 --- a/.github/workflows/note.yaml +++ b/.github/workflows/note.yaml @@ -66,15 +66,16 @@ jobs: with: node-version: '20' - - name: Install Claude Code SDK + - name: Install AI SDK run: | npm init -y - npm i @anthropic-ai/claude-code + npm i ai @ai-sdk/anthropic - - name: Research with Claude Code SDK + - name: Research with AI SDK run: | cat > research.mjs <<'EOF' - import { query } from '@anthropic-ai/claude-code'; + import { generateText } from 'ai'; + import { anthropic } from '@ai-sdk/anthropic'; import fs from 'fs'; const theme = process.env.THEME || ''; const target = process.env.TARGET || ''; @@ -85,23 +86,17 @@ jobs: 'あなたは最新情報の収集と要約に特化した超一流のリサーチャーです。', '事実ベース・一次情報優先・本文内にMarkdownリンクで出典を埋め込むこと。', '十分な分量(目安: 2,000語以上)。各節で出典を本文に埋め込む。', - 'WebSearch と WebFetch を必ず使用し、一次情報(公的機関・規格・論文・公式)を優先する。', + 'WebSearch と WebFetch を利用して、一次情報(公的機関・規格・論文・公式)を優先する。', ].join('\n'); const userPrompt = `以下のテーマとターゲットに対する最終版のリサーチレポートを作成してください。\n【重要】途中経過や確認質問は一切せず、最終レポートのみを返してください。不明点がある場合は「前提と仮定」セクションで簡潔に仮定を明記してから続行してください。事実ベースで一次情報を最優先し、本文にMarkdownリンクで出典を埋め込んでください。\n---\nテーマ: ${theme}\nターゲット: ${target}\n現在日付: ${today}`; - const messages = []; - for await (const msg of query({ + const { text } = await generateText({ + model: anthropic('claude-sonnet-4-5-20250929'), + system: sys, prompt: userPrompt, - options: { - customSystemPrompt: sys, - allowedTools: ['WebSearch','WebFetch'], - permissionMode: 'acceptEdits', - }, - })) { messages.push(msg); } - const assistantTexts = messages.filter(m=>m.type==='assistant').map(m=>{ - const c=m.message?.content; if(Array.isArray(c)){return c.filter(b=>b?.type==='text').map(b=>b.text).join('\n');} return ''; - }).filter(Boolean).join('\n\n'); - fs.writeFileSync(`${artifactsDir}/research.md`, assistantTexts || ''); - try { fs.writeFileSync(`${artifactsDir}/research_trace.json`, JSON.stringify(messages, null, 2)); } catch {} + temperature: 0.7, + maxTokens: 30000, + }); + fs.writeFileSync(`${artifactsDir}/research.md`, text || ''); EOF node research.mjs @@ -591,8 +586,10 @@ jobs: page.setDefaultTimeout(180000); await page.goto(START_URL, { waitUntil: 'domcontentloaded' }); - await page.waitForSelector('textarea[placeholder*="タイトル"]'); - await page.fill('textarea[placeholder*="タイトル"]', TITLE); + const html = await page.content(); + console.log(html); + await page.waitForSelector('textarea[placeholder*="記事タイトル"]'); + await page.fill('textarea[placeholder*="記事タイトル"]', TITLE); const bodyBox = page.locator('div[contenteditable="true"][role="textbox"]').first(); await bodyBox.waitFor({ state: 'visible' }); diff --git a/.gitignore b/.gitignore index df9ce98..1ab6cf5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ note-state.json # Node.js node_modules/ + +# 環境変数 +.env