You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add dedicated text processing and content generation tools for copywriting, editing, SEO analysis, social media content, translation, and structured data extraction.
Motivation
The existing tools handle file extraction, web search, and image generation — but there is no dedicated capability for text processing and content generation. Marketing workflows specifically need: tone adjustment, summarization, rewriting, SEO analysis (keyword density, meta descriptions, SERP analysis), social media content generation (post scheduling, platform-specific formatting), translation, and text-to-structured-data (entity extraction, sentiment analysis). Currently the agent must rely on the LLM chain-of-thought without structured tooling, which is inconsistent and loses context.
Proposed Solution
Create a suite of text processing tools:
Copywriting/Editing: Tone adjustment, summarization, rewriting, grammar correction, length adjustment (shorten/expand)
SEO Analysis: Keyword density analysis, meta description generation, SERP analysis, content optimization suggestions
Social Media Content: Platform-specific formatting (Twitter/X, LinkedIn, Instagram, TikTok), post scheduling, hashtag generation
Translation: Multi-language translation with language detection
This project uses OpenSpec for feature development. If this request is approved, I will:
Run /opsx:propose to generate a full proposal with specs and tasks
Iterate on the design before any code is written
Follow the task-driven implementation workflow
Additional Context
This should integrate with the document creation gap (#778) — e.g., generating marketing copy and then embedding it in a DOCX report. The existing webExtract tool could feed content into the text processing tools for analysis.
Dependencies
Copywriting/Editing: Built-in LLM calls via the existing agent framework. No additional npm dependencies — the tool acts as a structured wrapper around LLM text generation with specific prompts.
SEO Analysis: Built-in LLM calls for analysis. For keyword density: count occurrences via string matching (no NLP library needed). For SERP analysis: use the existing web search tool (no new dependency).
Social Media Content: Built-in LLM calls. Hashtag generation: use a curated list of popular hashtags per platform, or generate via LLM.
Translation: google-translate-api (v3.x) — lightweight wrapper around Google Translate. Requires API key via env var GOOGLE_TRANSLATE_API_KEY. Alternative: LibreTranslate (self-hosted, no API key required but requires server setup).
Structured Data Extraction: Built-in LLM calls for entity extraction, sentiment analysis, topic classification. For key phrase extraction: keytext (v1.x) or simple TF-IDF via natural (v2.x).
Text Comparison: diff (built-in Node.js). Similarity scoring: string-similarity (v4.x) or lcs (v2.x) for Levenshtein distance. Plagiarism detection: defer to a follow-up PR (requires external API or complex indexing).
Testing Strategy
Unit tests: Mock LLM responses for copywriting, editing, and structured data extraction. Verify Zod schema validation for all inputs. Test keyword density calculation, string similarity, and diff against known inputs.
Translation: Use a mock translation API response. Verify language detection and translation output format.
SEO analysis: Test keyword density calculation against known text. Verify meta description generation format.
Edge cases: Empty input, very long text (>10k characters), unsupported languages, special characters, Unicode text, mixed-language input.
Security Considerations
PII handling: Text processing may involve sensitive content. Strip PII before logging (per AGENTS.md 1.2). Do not store processed text in logs or error messages.
Translation API key: Stored in process.env.GOOGLE_TRANSLATE_API_KEY only — never in config files or logs.
Input size limits: Limit input text to 10,000 characters per request to prevent excessive LLM token usage. Chunk larger inputs and process sequentially.
Output sanitization: Strip HTML tags and scripts from output. Limit output size (default: 50,000 characters).
Rate limiting: Implement client-side rate limiting for translation API calls (default: 10 requests/second) to avoid triggering provider blocks.
Language support: Only support languages available via the translation API. Document supported languages in the tool description.
Implementation Notes
Split into three tools:
text (copywriting, editing, summarization, rewriting)
seo (keyword density, meta descriptions, SERP analysis, content optimization)
social (platform-specific formatting, hashtag generation, post scheduling)
translate (multi-language translation, language detection)
LLM integration: Each text processing tool acts as a structured wrapper around the existing LLM chain. Define specific system prompts for each action type. Return structured JSON output (not free-text) so the agent can parse results reliably.
Caching: Cache translation results by (input, sourceLanguage, targetLanguage) key. TTL: 24 hours. Store in memory or SQLite.
Fallback: If translation API is unavailable, fall back to LLM-based translation (less accurate but no API key required). Document this as a known limitation.
Summary
Add dedicated text processing and content generation tools for copywriting, editing, SEO analysis, social media content, translation, and structured data extraction.
Motivation
The existing tools handle file extraction, web search, and image generation — but there is no dedicated capability for text processing and content generation. Marketing workflows specifically need: tone adjustment, summarization, rewriting, SEO analysis (keyword density, meta descriptions, SERP analysis), social media content generation (post scheduling, platform-specific formatting), translation, and text-to-structured-data (entity extraction, sentiment analysis). Currently the agent must rely on the LLM chain-of-thought without structured tooling, which is inconsistent and loses context.
Proposed Solution
Create a suite of text processing tools:
Each tool should follow the existing tool pattern in src/tools/ — a zod schema, an impl function, and registration in index.js.
Alternatives Considered
OpenSpec Note
This project uses OpenSpec for feature development. If this request is approved, I will:
Additional Context
This should integrate with the document creation gap (#778) — e.g., generating marketing copy and then embedding it in a DOCX report. The existing webExtract tool could feed content into the text processing tools for analysis.
Dependencies
Testing Strategy
Security Considerations
Implementation Notes
Split into three tools:
Start with text, seo, and translate as the MVP. Defer social, extract, and text comparison to follow-up PRs.
Zod schema for text tool: { action: "summarize" | "rewrite" | "tone" | "grammar" | "shorten" | "expand", input: string, options?: { tone?: string, targetLength?: number, language?: string } }.
Zod schema for seo tool: { action: "keyword-density" | "meta-description" | "serp-analysis" | "optimize", input: string, keywords?: string[], options?: { targetKeywords?: number, includeSuggestions?: boolean } }.
Zod schema for translate tool: { action: "translate" | "detect", input: string, targetLanguage?: string, sourceLanguage?: string }.
LLM integration: Each text processing tool acts as a structured wrapper around the existing LLM chain. Define specific system prompts for each action type. Return structured JSON output (not free-text) so the agent can parse results reliably.
Caching: Cache translation results by (input, sourceLanguage, targetLanguage) key. TTL: 24 hours. Store in memory or SQLite.
Fallback: If translation API is unavailable, fall back to LLM-based translation (less accurate but no API key required). Document this as a known limitation.
Post scheduling: Defer to a follow-up PR. Requires integration with a calendar tool (feat: add calendar management (read, create, schedule) #781) or external scheduling API.