token27/nexus-ai-content

Generic content orchestration layer for NexusAI workflows, prompts, tracking, pricing, and domain extensions.

Maintainers

Package info

github.com/token27/nexus-ai-content

pkg:composer/token27/nexus-ai-content

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-22 05:04 UTC

This package is auto-updated.

Last update: 2026-05-22 05:18:19 UTC


README

CI PHPStan Level 8 Latest Version PHP 8.3+ License: MIT Tests

A framework-agnostic, workflow-first PHP 8.3+ content orchestration layer for the NexusAI ecosystem. Compose versioned prompts, AI drivers, resumable workflows, tracking, pricing, and domain extensions behind one fluent API.

Why nexus-ai-content?

Article generation, social posts, newsletters, scripts, product descriptions, and future content types all need the same foundation:

  • choose a content type and workflow
  • resolve versioned prompts from nexus-ai-prompts
  • execute nodes through nexus-ai-workflows
  • call providers through nexus-ai
  • track every run through nexus-ai-tracking
  • calculate cost and enforce budgets through nexus-ai-pricing
  • keep domain packages focused on their domain instead of infrastructure

nexus-ai-content is that shared layer. It is intentionally not an article generator. Article logic belongs in nexus-ai-content-articles.

Features

  • Engine + Builder + Registry pattern consistent with the NexusAI libraries.
  • Fluent content API for provider/model selection, workflow selection, variables, language, run id, tracking, pricing, and budgets.
  • Workflow registry keyed by contentType/workflowName.
  • Prompt-aware AI node with ContentAINode.
  • Tracking-ready execution with run id, prompt id, prompt version, content type, workflow, provider, model, tokens, cost, and latency.
  • Pricing-ready execution with post-request cost calculation and optional pre-request budget checks.
  • Extension bootstrap so packages like nexus-ai-content-articles can register workflows cleanly.
  • Test-friendly driver injection through withDriver().

Installation

composer require token27/nexus-ai-content

Requires: PHP 8.3+ and the core NexusAI packages listed in composer.json.

Quick Start

use Token27\NexusAI\Content\ContentEngine;
use Token27\NexusAI\Content\Node\ContentAINode;
use Token27\NexusAI\Workflows\Engine\WorkflowBuilder;

$workflow = WorkflowBuilder::named('default')
    ->addNode('draft', new ContentAINode(
        promptIdentifier: 'content/draft',
        outputKey: 'content',
        promptVersion: '1.0.0',
    ))
    ->build();

$engine = ContentEngine::create()
    ->withPromptRegistry($promptRegistry)
    ->withTracking($tracking)
    ->withPricing($pricing);

$engine->getRegistry()->register('article', $workflow);

$result = $engine
    ->for('openai', 'gpt-4o-mini')
    ->withContentType('article')
    ->withLanguage('es')
    ->withVariable('topic', 'Calidad de contenido con IA')
    ->withBudget(0.25)
    ->generate();

echo $result->text;

For tests, inject a pre-built driver:

$result = $engine
    ->for('fake', 'test-model')
    ->withContentType('article')
    ->withDriver($fakeDriver)
    ->generate();

Documentation

Guide Description
Documentation Home Full documentation map
Installation Composer, dependencies, and first setup
Quick Start First workflow with a fake driver
Fluent API Engine and builder methods
Workflows Registering and running content workflows
Prompts Using nexus-ai-prompts with ContentAINode
Tracking and Pricing Telemetry, costs, budgets, and tokenizer notes
Extending Creating domain extensions
Testing Testing content workflows and nodes
Contributing Development setup and collaboration rules
Architecture Why this package exists before article domains
Troubleshooting Common failures and fixes

Examples

The examples/ directory contains runnable production-style examples that read .env, configure real providers through NexusAI, load prompts, enable pricing, and optionally write tracking events:

Quality Gates

composer validate --strict
vendor/bin/php-cs-fixer fix --dry-run --diff
vendor/bin/phpstan analyse --level=8 src tests
vendor/bin/phpunit

License

MIT. See LICENSE.