Vibescript Showcase

Trial offer

Generate trial offers with account-type enums, Duration terms, and template-based onboarding copy.

Showcase
Source showcase/policies/trial_offer.vibe
# title: Trial offer
# category: Vibescript Showcase
# difficulty: Showcase
# summary: Generate trial offers with account-type enums, Duration terms, and template-based onboarding copy.
# description: This example keeps product-policy logic compact while still making the trial shape, timing, and output structure explicit.
# tags: policies, durations, enums, templates
# vibe: 0.2

enum AccountKind
  Personal
  Team
  Enterprise
end

def trial_length(kind: AccountKind) -> duration
  if kind == AccountKind::Personal
    14.days
  elsif kind == AccountKind::Team
    21.days
  else
    30.days
  end
end

def trial_offer(account_id: string, kind: AccountKind, created_at: time) -> hash
  length = trial_length(kind)

  {
    account_id: account_id,
    account_kind: kind.name,
    trial_length: length.iso8601,
    expires_at: length.after(created_at).format("2006-01-02T15:04:05Z"),
    welcome: "{{account}} starts a {{kind}} trial".template({ account: account_id, kind: kind.name })
  }
end

def run
  created_at = Time.at(1700800000)

  {
    personal: trial_offer("acct_personal_22", AccountKind::Personal, created_at),
    enterprise: trial_offer("acct_enterprise_09", AccountKind::Enterprise, created_at)
  }
end
Output
Press run to execute run from this example.
showcase idiomatic-vibescript policies durations enums templates browser-runner