AGI‑assisted content creation in Codmir — plan, draft, review, and publish high‑quality content with sub‑agents and live streaming.

Content Creation Tool

Codmir’s Content Creation Tool turns an idea into a publishable artifact (blog post, docs page, release notes, social thread) using an AI‑first workflow. It orchestrates small, reliable sub‑steps — analysis → brief → outline → draft → review → SEO → publish — while preserving context and artifacts in a durable memory.

  • Human-in-the-loop by default, fully automated when desired.
  • Streams progress to a terminal‑style UI so you can watch agents work.
  • Produces reproducible outputs and a clear record of work.

Why this exists

Content pipelines break down across tools (docs, SEO, images, PRs) and lose context. Codmir keeps the story, references, drafts, diffs, and approvals together inside a ticket — a Context Capsule — that both people and agents can use.

Architecture

  • Orchestrator (Next.js)
    • Loads a declarative workflow (YAML/JSON) and runs steps + dependencies.
    • Uses lightweight LLM calls for analysis and planning.
    • Streams events/logs via SSE to the UI.
  • Sub‑agents (MCP tools + Docker workers)
    • MCP tools: analysis, outline, editorial review, SEO checks.
    • Docker workers: heavy tasks (formatting, link checks, repo PR, image generation).
  • Context & Memory (Prisma)
    • Stores artifacts, diffs, and decisions so future runs start smarter.

Agents and roles

  • Analyst → distills the goal and audience, drafts a creative brief.
  • Writer → turns the brief + outline into an initial draft.
  • Editor → fixes clarity, structure, and correctness.
  • SEO → titles, descriptions, keywords, internal links.
  • Publisher → commits the MDX/Markdown to the repo and opens a PR.

Workflow (YAML)

The tool uses declarative workflows stored in src/workflows/*.yml.

Example: content-creation.yml (installed with this repo)

workflow: "content-creation"
description: "Generate and publish a content piece with AGI sub-agents"
steps:
  - id: analyze
    title: "Analyze topic and goals"
    agent: "analyst"
    model: "openai:gemini-3-flash-preview"
    inputs:
      topic: "{your-topic}"
      audience: "{target-audience}"
      goal: "{goal}"

  - id: brief
    title: "Create creative brief"
    agent: "writer"
    dependsOn: ["analyze"]
    inputs: {}

  - id: outline
    title: "Propose outline"
    agent: "writer"
    dependsOn: ["brief"]
    inputs: {}

  - id: draft
    title: "Write first draft"
    agent: "writer"
    dependsOn: ["outline"]
    inputs:
      tone: "practical, confident, concise"
      length: "1200-1600 words"

  - id: review
    title: "Editorial review"
    agent: "editor"
    dependsOn: ["draft"]
    inputs: {}

  - id: seo
    title: "SEO polish"
    agent: "seo"
    dependsOn: ["review"]
    inputs:
      includeToc: true
      generateSummary: true

  - id: publish
    title: "Commit and open PR"
    agent: "git"
    dependsOn: ["seo"]
    inputs:
      repoUrl: "https://github.com/your/repo"
      branch: "content/auto-{date}"
      path: "apps/web/content/blog/{slug}.mdx"
      title: "{auto-title}"
      message: "docs: add {auto-title}"

Running the workflow

  • API: POST /api/workflow/content-creation/run
    • Body example:
      { "topic": "AGI orchestration for content teams", "audience": "engineering managers", "goal": "education" }
    • Returns { jobId }.
  • Streaming: GET /api/agi/{jobId}/stream (Server‑Sent Events)
    • Your terminal UI appends incoming lines and auto‑scrolls.

Note: If you run locally with Docker workers, set RUN_MODE=local and build the runner image. On serverless, switch to a remote runner.

Inputs and outputs

  • Inputs: topic, audience, goal, tone, length, repo/branch/path, slug.
  • Artifacts: brief, outline, draft, edited draft, SEO metadata, PR URL.
  • Memory: saved in the ticket’s capsule (decisions, links, references).

UI

  • Use the Task Runner chat (src/components/assistant/task-runner-chat.tsx) for prompts + terminal streaming.
  • Show progress badges per step and the latest artifact (e.g., PR URL, MDX link).

Permissions & secrets

  • OPENAI_API_KEY — LLM calls (analysis, brief, outline, edits).
  • GH_TOKEN — pushing branches and opening PRs.
  • CODEX_API_URL / NEXT_PUBLIC_CODEX_API_URL — if using the Codex runner container.

Keep secrets server‑side only. Never expose them to the client. Ensure worker logs never print secret values.

Roadmap

  • Images: generate banners/diagrams and embed into the MDX.
  • Multichannel: auto‑derive social thread + newsletter from the article.
  • Review flows: gated approval and suggestion mode.
  • Style memory: learn tone and formatting rules per workspace.
  • Search indexing: add metadata for your docs/blog engine.

If you want to add your own agents, publish a plugin under /agents/<your-plugin> and register tools via the OpenAI Agents runtime. The orchestrator will discover them and expose in workflows.