Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,40 @@ ACTIVE_CLIENT=saas-consultoria-imagem
LLM_DEFAULT=claude
LLM_FALLBACK=codex
LLM_CHEAP=deepseek

# LLM providers
OPENAI_API_KEY=
DEEPSEEK_API_KEY=
ANTHROPIC_API_KEY=
# Local fallback — leave OLLAMA_HOST blank to skip
OLLAMA_HOST=http://localhost:11434
OLLAMA_MODEL=llama3.2

# Image / video providers
HIGGSFIELD_MCP_ACTIVE=true
TOPVIEW_API_KEY=
WAVESPEED_API_KEY=

# Publish + ads
ADAPTLYPOST_API_KEY=
META_ADS_MCP_ACTIVE=true

# Analytics (production fetchers; DRY_RUN keeps deterministic synthetic data)
META_ACCESS_TOKEN=
META_PAGE_ID=
TIKTOK_ACCESS_TOKEN=
YOUTUBE_API_KEY=
YOUTUBE_CHANNEL_ID=

# Calendar
NOTION_TOKEN=
NOTION_CALENDAR_DB_ID=

# Optional observability webhook (Slack/Discord/generic POST)
ALERT_WEBHOOK_URL=

# Compliance: when false, enables an extra LLM secondary pass on the report
COMPLIANCE_LLM_SECONDARY=false

# Always start in DRY_RUN. Flip to false only after a human review of one piece.
DRY_RUN=true
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ jobs:
cache: "npm"
- run: npm ci
- run: npm run typecheck
- run: npx playwright install --with-deps chromium
# Specs run on the Node test runner, not a browser context, so chromium is
# not required. Avoids the --with-deps apt step that breaks on Ubuntu noble.
- run: npm run test:e2e
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release
on:
push:
tags:
- "v1.*"
- "v2.*"

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
cache: "npm"
- run: npm ci
- run: npm run typecheck
- run: npm run test:e2e
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
94 changes: 94 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Changelog

All notable changes to this project are documented here. Format based on
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versioning follows
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- `lib/providers/matrix.ts` parses `.specs/architecture/PROVIDERS.md` as the single
source of routing truth (ADR-001). Embedded defaults are used when the file is
missing or malformed, with a stderr warning.
- `lib/providers/policy.ts` — shared retry/backoff/timeout helper (`withRetry`),
per-provider pricing table and `estimateCost`/`estimateTokens` helpers.
- `lib/router.ts` exposes `runWithFallback` — wraps any provider call with the
primary/fallback chain documented in `PROVIDERS.md` and writes one structured
line per attempt to `data/llm-usage.jsonl` (`ok`, `fallback_used`, `attempt`,
`latency_ms`).
- `lib/data/runs.ts` and `lib/data/manifest.ts` write the artefacts the AGENTS
Definition of Done requires: `data/runs.jsonl` per piece run and
`outputs/<client>/<date>/<piece-id>/manifest.json` per piece.
- `lib/pieces/{id,frontmatter,store}.ts` — piece engine. ISO-8601 week-numbered
IDs (`PIECE-YYYYWww-NNN`), zero-dependency YAML frontmatter parser, state
machine (`draft → scheduled → published → measured`, side state `review`).
- `lib/cli/generate.ts` — real generation loop that reads `pieces/`, routes
every task through the matrix + fallback chain, runs inline compliance,
writes outputs/script/captions/compliance.json/manifest.json, transitions
status, and appends to `data/runs.jsonl`.
- `lib/cli/promote.ts` — real promotion loop that classifies `data/analytics.jsonl`
(top/bottom 20% by save rate, ≥100 impressions), writes `ads-draft.json`
for winners, appends `data/learnings.md` for losers.
- `lib/calendar/notion.ts` — Notion calendar reader (`pullCalendar`, `syncToLocal`,
`pushStatus`). DRY_RUN-safe.
- `lib/publish/adaptlypost.ts` — real AdaptlyPost wiring with retry/backoff;
DRY_RUN still writes `adaptlypost-draft.json` locally.
- `lib/publish/meta-ads.ts` — Meta Ads draft builder + `data/promotions.jsonl`
writer. Real Meta API call is a stub (calls into the meta-ads MCP layer when
available).
- `lib/analytics/{meta,tiktok,youtube}.ts` — DRY_RUN keeps deterministic synthetic
data; non-DRY paths call Graph / TikTok Business / YouTube Data APIs.
- `lib/compliance/{generic,loader}.ts` — executable cross-vertical audit, writes
`data/compliance/<piece>.json`, escalates blocks to `data/compliance-blocked/`,
exposes `detectStreaks` for the alerts module.
- `lib/skills/{humanizer,brand-voice}.ts` — executable critic skills (regex pass
+ LLM secondary stub, voice-axis distance scoring).
- `lib/qa/tech-specs.ts` — ffprobe/identify wrapper with filename fallback;
per-platform validation against `CHANNELS.md` specs.
- `lib/observability/{cost,ab-report,failures}.ts` — cost summary + HTML report,
A/B per (task, provider) ROI table, failure-rate detector + webhook poster.
- `lib/schedule/cron.ts` — cron / launchd install / uninstall / status helpers
with marker block isolation.
- CLI gains: `new-piece`, `status`, `logs`, `cost`, `ab-report`, `alerts`,
`sync`, `schedule`. Each delegates to a TypeScript module via the bundled
`tsx` runtime.
- E2E coverage (Playwright) across all of the above: matrix parsing,
fallback chain, policy retry/timeout/cost, pieces engine, init/scan/generate
loop, promote loop, compliance, qa-tech-specs, observability, CLI surface.

### Changed

- `lib/router.ts` no longer hardcodes routing tables; everything resolves via
`lib/providers/matrix.ts`.
- `lib/providers/{llm,image,video}.ts` now contain real adapter classes that
call concrete APIs. Mock variants live under `lib/providers/__mocks__/` and
the factory switches based on `DRY_RUN`.
- `bin/marketing-engine.mjs` `generate` / `promote` are no longer placeholders.

### Notes

- All new external behavior is gated by `DRY_RUN=true` (the default) — CI never
reaches real API endpoints.
- The mock providers preserve the original deterministic output, so previously
authored e2e specs continue to pass.

## [0.1.0] - 2026-05-08

### Added

- CLI scaffold (`bin/marketing-engine.mjs`): `init`, `scan`, `check` commands.
- Provider type interfaces (`lib/providers/{types,llm,image,video}.ts`) and
mock implementations.
- Publish + analytics scaffolds (`lib/publish/adaptlypost.ts`,
`lib/analytics/{meta,tiktok,youtube}.ts`).
- Specs tree under `.specs/`: architecture (DESIGN, PROVIDERS, ROUTING-MATRIX,
ADR-001), product (BRAND, CHANNELS, COMPLIANCE, PERSONAS, PILLARS), piece +
campaign templates, client `_template/` overrides.
- 11 SKILL.md documents under `.skills/` (provider-neutral skills).
- E2E suite (Playwright): CLI, compliance, caption-format, tech-specs,
provider-router, AdaptlyPost-publish.
- CI workflow + DoD workflow.
- Remotion video explainer (PT-BR + EN) under `video/`.
- Bilingual README + SETUP + CONTRIBUTING + AGENTS.md (charter) + Apache-2.0
LICENSE.
Loading
Loading