Class: Protege::DevSetup

Inherits:
Object
  • Object
show all
Defined in:
app/services/protege/dev_setup.rb

Overview

One-command development bootstrap — the service behind bin/rails protege:setup:dev. Provisions everything a fresh host app needs to start chatting locally, except the provider API key:

  • the system toolkits (via SystemToolkits.sync!, run first so Default Tools exists to auto-attach),
  • the protege.local email domain (DKIM keypair minted on create),
  • the ExecutiveAgent class itself when the host doesn't have one — generated through the same protege:agent generator the installer uses, never guessed at or resolved from configuration,
  • Phoenix, an ExecutiveAgent record at phoenix@protege.local with starter instructions,
  • a proactive, open-gated All Tools grant, so every registered tool is exercisable in development.

Idempotent throughout — records are found-or-created, so re-running never duplicates or clobbers. Environment gating (this seeds play data) is the rake task's concern, not this service's.

Constant Summary collapse

DOMAIN =

The development email domain. Registering it is what routes inbound mail; sharing a domain with the default console_address (+console@protege.local+) is safe — console-local delivery is decided by address match, not domain registration.

'protege.local'
AGENT_NAME =

The development agent's identity.

'Phoenix'
AGENT_EMAIL =
"phoenix@#{DOMAIN}".freeze
INSTRUCTIONS =

The starter system prompt — enough personality to be pleasant and enough direction to exercise tools, while staying generic (Phoenix knows nothing about any particular host app).

<<~TEXT.strip
  You are Phoenix, a general-purpose agent running in a development environment. You communicate by
  email: read what you receive, use your tools whenever they help you act or answer accurately, and
  reply with send_email. Keep replies short, concrete, and friendly. When asked to demonstrate a
  capability, actually exercise the tool and report what happened.
TEXT

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run!Protege::Agent

Provision the full development setup.

Returns:



41
42
43
# File 'app/services/protege/dev_setup.rb', line 41

def run!
  new.run!
end

Instance Method Details

#run!Protege::Agent

Provision the full development setup.

Returns:



49
50
51
52
53
54
55
56
57
# File 'app/services/protege/dev_setup.rb', line 49

def run!
  SystemToolkits.sync!
  ensure_domain

  agent = ensure_phoenix
  ensure_all_tools_grant(agent:)

  agent
end