npm package: @potnoddle/n8n-nodes-article-gen
Description: Custom n8n nodes for LLM workflows.
Author: potnoddle
Latest version: 1.0.5

# @potnoddle/n8n-nodes-article-gen

A comprehensive suite of custom n8n nodes designed to power advanced AI agent workflows. These nodes handle complex data normalization, prompt rendering, and robust LLM output parsing, offloading logic from your agents to ensure reliable automation.

## 📦 Included Nodes

### 1. 🔍 Universal Data Lookup

Dynamically searches across inconsistent JSON data structures without complex expression logic.

* **Problem**: APIs return data in different shapes: Lists `[{id:1}]`, Grouped Dictionaries `{ "Category": [{id:1}] }`, or Key-Value Maps `{ "id_1": {name...} }`.
* **Solution**: This node automatically detects the structure and finds your item based on a lookup value.
* **Modes**:
  * **Auto-Detect**: Smartly identifies the structure (Array, Grouped Array, or Map).
  * **Manual Overrides**: Specify `Flat Array`, `Grouped Array`, or `Key-Value Map` if needed.
  * **Return Modes**: Get just the matching item, or the item plus its category key.

### 2. 📝 Nunjucks Prompt Renderer

Renders complex text prompts using the Nunjucks engine (Jinja2 compatible).

* **Why**: Standard n8n expressions don't support logic like `{% if variable %}...{% endif %}` which is essential for professional prompt engineering.
* **Features**:
  * **Full Syntax**: Supports full Jinja2/Nunjucks syntax.
  * **Data Injection**: Inject n8n JSON variables directly into templates.
  * **Use Cases**: Perfect for dynamic system prompts and multi-turn instructions.

### 3. 🤖 Smart JSON Parser

Robustly parses JSON outputs from Large Language Models (LLMs).

* **Problem**: LLMs often wrap JSON in Markdown code fences (e.g., ` ```json { ... } ``` `) or add conversational filler, breaking standard JSON parsers.
* **Solution**: Automatic cleaning strips markdown fences and extracts the valid JSON block before parsing, returning properties directly to the root.

### 4. 🧹 Content Cleaner

Sanitize raw AI text outputs for production use.

* **Function**: Strips "chain-of-thought" markers, boundary lines, or specific keywords (e.g., `START TASK OUTPUT`, `*** END ***`).
* **Result**: Clean, usable content ready for publishing or downstream nodes.

### 5. 🖼️ Image Gen Utility

Specialized pre-processing for AI Image Generation prompts.

* **Features**:
  * **Marker Extraction**: Extracts specific prompts from verbose LLM explanations using boundary markers.
  * **Boundary Logic**: Isolates content between `START IMAGE GENERATION OUTPUT HERE` and `END IMAGE GENERATION OUTPUT HERE`.
  * **Priority**: Handles "Primary Prompt" extraction if labeled.

### 6. 🔍 SEO Toolkit

Utilities for content validation and optimization.

* **Operations**:
  * **Analyze**: Detailed Keyword Density analysis across provided text.
  * **Validate**: Checks Markdown heading structure (e.g., Ensuring a single H1, proper hierarchy).

### 7. 🏛️ ArXiv

Standardized interface for academic research using the ArXiv API.

* **Features**:
  * **Direct Query**: Query the ArXiv API directly with support for specific fields (title, author, category).
  * **Sorting**: Configurable results limit and sorting options (relevance, date).
  * **Output**: Returns structured JSON for each paper found.

---

## 🚀 Installation

### Option 1: Community Node (Recommended)

1. In your n8n instance, go to **Settings** > **Community Nodes**.
2. Click **Install**.
3. Enter the package name: `@potnoddle/n8n-nodes-article-gen`.
4. Click **Install**.

### Option 2: Manual / Local Development

If you want to modify these nodes or run them locally:

1. **Clone the Repository**:

   ```bash
   git clone https://github.com/potnoddle/n8n-nodes.git
   cd n8n-nodes
   ```

2. **Install Dependencies & Build**:

   ```bash
   npm install
   npm run build
   ```

3. **Link to n8n**:

   * In this directory: `npm link`
   * Go to your n8n configuration directory (usually `~/.n8n/custom`):

     ```bash
     cd ~/.n8n/custom
     npm link @potnoddle/n8n-nodes-article-gen
     ```

   * Start n8n: `n8n start`

### Option 3: Docker

Map the volume to your n8n container:

```yaml
volumes:
  - ./path/to/n8n-nodes/dist:/home/node/.n8n/custom/node_modules/@potnoddle/n8n-nodes-article-gen
```

## 🛠️ Development

* **Build**: `npm run build` - Compiles TypeScript to JavaScript in `dist/`.
* **Watch**: `npm run dev` - Watches for changes and recompiles.

## License

MIT