UNPKG

article-summarizer-jp

Version:

CLI tool for summarizing web articles in Japanese using Anthropic Claude API. Fetches content from URLs and generates both 3-line summaries and full translations in polite Japanese.

185 lines (132 loc) β€’ 3.82 kB
# Article Summarizer JP A CLI tool that fetches articles from URLs and summarizes them in Japanese using Anthropic Claude API. ## Features - 🌐 Fetches content from any URL - πŸ“¦ Supports multiple URLs in single command - πŸ€– Falls back to headless browser if regular fetch fails - πŸ“ Generates 3-line Japanese summary - 🈲 Provides full Japanese translation - πŸ’Ύ Saves output as Markdown files - βš™οΈ Configurable API key storage - πŸ“Š Shows detailed progress and results summary ## Prerequisites - Node.js 14 or higher - npm or yarn - Anthropic API key (get one at https://console.anthropic.com/) ## Installation ### From npm (Recommended) ```bash npm install -g article-summarizer-jp ``` ### From source ```bash # Clone the repository git clone https://github.com/sKawashima/article-summarizer-jp.git cd article-summarizer-jp # Install dependencies npm install # Build the project npm run build ``` ## Configuration Before first use, configure your Anthropic API key: ```bash article-summarizer-jp --config # or use the short alias asumjp --config ``` You'll be prompted to enter your API key, which will be securely stored. ## Usage ### Basic usage with URL argument ```bash # Single URL article-summarizer-jp https://example.com/article # Multiple URLs article-summarizer-jp https://example.com/article1 https://example.com/article2 https://example.com/article3 # or use the short alias asumjp https://example.com/article1 https://example.com/article2 ``` ### Interactive mode (prompts for URL) ```bash article-summarizer-jp # or asumjp ``` ### Development mode (if installed from source) ```bash npm run dev https://example.com/article ``` ## Output The tool creates a Markdown file with the format: - Filename: `πŸ“° [Article Title].md` - Content includes: - Original article link - Scraping date - 3-line summary in Japanese - Full Japanese translation ## Example Output ```markdown # [Article Title](https://example.com/article) scrap at [[2024-01-06]] ## 3θ‘ŒγΎγ¨γ‚ 1. First key point in Japanese 2. Second key point in Japanese 3. Third key point in Japanese ## ε…¨ζ–‡ε’Œθ¨³ [Full Japanese translation of the article] ``` ## Development ```bash # Run in development mode npm run dev # Build TypeScript npm run build # Type check npm run lint ``` ## Publishing to npm If you want to publish this package to npm: ### Prerequisites - npm account (create at https://www.npmjs.com/) - npm CLI logged in (`npm login`) ### Steps 1. **Update version** (choose one): ```bash # Patch version (1.1.0 β†’ 1.1.1) npm version patch # Minor version (1.1.0 β†’ 1.2.0) npm version minor # Major version (1.1.0 β†’ 2.0.0) npm version major ``` 2. **Build the project**: ```bash npm run build ``` 3. **Publish to npm**: ```bash # Public package npm publish # Scoped package (if package name starts with @) npm publish --access public ``` 4. **Verify publication**: ```bash npm info article-summarizer-jp ``` ### Publishing checklist - [ ] Tests pass (`npm test` if available) - [ ] Build succeeds (`npm run build`) - [ ] README is up to date - [ ] Version is updated appropriately - [ ] All changes are committed to git - [ ] Package.json metadata is correct (description, keywords, etc.) ## Troubleshooting ### "API key not configured" error Run `article-summarizer-jp --config` (or `asumjp --config`) to set up your API key. ### Content extraction fails The tool automatically falls back to a headless browser (Puppeteer) if the initial fetch fails. This handles JavaScript-rendered content and pages with anti-bot measures. ### Rate limiting If you encounter rate limiting from the Anthropic API, consider adding delays between requests or upgrading your API plan. ## License ISC