Skip to main content

Implementation Plan: Creating a Work

Feature ID: creating-a-work Spec: ./spec.md Status: Done (Retrospective) Last updated: 2026-05-01


1. Architecture

2. Tech Choices

ConcernChoiceRationale
Repo provisioningGitFacadeService.createRepository × 3Principle II
AtomicityDB transaction + best-effort rollback if any repo failsAvoid orphan rows
Generation dispatchTrigger.dev work-generation taskPrinciple IV
Slug uniquenessPer-user case-insensitive lookupMatches GitHub repo naming
Form schemaPlugin form-schema-provider capabilityPipelines own their own UI

3. Data Model

  • works entity (existing) with all the fields the three flows need: name, slug, description, owner, gitProvider, deployProvider, pipeline, aiProvider, searchProvider, screenshotProvider, contentExtractor, initialPrompt, expansionFactor, generateStatus, etc.
  • No new tables. Each new field added over time ships as an additive migration.

4. API Surface

MethodEndpointDescription
POST/api/worksCreate (AI / Manual)
POST/api/works/import/previewImport dry-run
POST/api/works/importImport confirmation

5. Plugin / Web / CLI

  • Plugins: form-schema-provider lets pipelines contribute fields.
  • Web: separate steps under apps/web/src/app/[locale]/works/new/ for each method.
  • CLI: ever-works work create command wraps the API.

6. Background Jobs

  • work-generation Trigger.dev task — dispatched on AI / Awesome Import.
  • work-import-awesome-normalise — fan-out to normalise items after Awesome import.

7. Security & Permissions

  • Authenticated user only.
  • Repo creation uses the user's git provider plugin credentials.
  • Admin-enforced pipeline lock checked server-side too (defence in depth).

8. Observability

  • Activity log: work_created with method.
  • Sentry breadcrumbs for each step (validate / repos / dispatch).

9. Risks & Mitigations

RiskMitigation
Repo create fails after DB row insertedBest-effort rollback; surfaced as a clear error
User selects unavailable pluginServer-side validation in addition to UI grey-out
Pipeline form fields drift from pluginPlugin owns the schema; form re-fetches when pipeline changes

10. Constitution Reconciliation

See spec.md §9.

11. References

  • Spec: ./spec.md
  • Implementation:
    • apps/api/src/works/works.controller.ts
    • apps/web/src/app/[locale]/works/new/
    • packages/agent/src/services/work-generation.service.ts