agentic examples

The Setup Doctor

The Setup Doctor: every onboarding wiki page is a bug. This runs the checks a README asks a new hire to do by hand - gem loads, bundle health, git state, catalog presence - in parallel, then one diagnosis task reads them all BY NAME and prescribes.

Developer Experience Round 4 DHH exit 0

source on github

bundle exec ruby examples/setup_doctor.rb

a real captured run

SETUP DOCTOR

  ok   ruby     agentic 0.2.0 loaded (ruby 3.3.11)
  ok   bundle   all gems installed
  ok   git      on main, 0 uncommitted change(s)
  ok   catalog  178 runnable examples (bin/smoke checks them all)

you're good. write code, not wiki pages.

source

# frozen_string_literal: true

# The Setup Doctor: every onboarding wiki page is a bug. This runs the
# checks a README asks a new hire to do by hand - gem loads, bundle
# health, git state, catalog presence - in parallel, then one
# diagnosis task reads them all BY NAME and prescribes.
#
#   bundle exec ruby examples/setup_doctor.rb
#
# Runs offline against the current repo. Exit 0 means "start coding".

require class="s">"bundler/setup"
require class="s">"agentic"

ROOT = File.expand_path(class="s">"..", __dir__)

def check(description)
  Agentic:class="y">:Task.new(
    description: description,
    agent_spec: {class="s">"name" => description, class="s">"instructions" => class="s">"examine the machine"}
  )
end

orchestrator = Agentic:class="y">:PlanOrchestrator.new(concurrency_limit: 4)

ruby = check(class="s">"agentic gem")
orchestrator.add_task(ruby, agent: ->(_t) {
  {ok: defined?(Agentic:class="y">:VERSION) ? true : false,
   detail: class="s">"agentic #{Agentic:class="y">:VERSION} loaded (ruby #{RUBY_VERSION})"}
})

bundle = check(class="s">"bundle health")
orchestrator.add_task(bundle, agent: ->(_t) {
  ok = system(class="s">"bundle check > /dev/null 2>&1", chdir: ROOT)
  {ok: ok, detail: ok ? class="s">"all gems installed" : class="s">"run bin/setup (or bundle install)"}
})

git = check(class="s">"git state")
orchestrator.add_task(git, agent: ->(_t) {
  dirty = `git -C #{ROOT} status --porcelain`.lines.size
  branch = `git -C #{ROOT} branch --show-current`.strip
  {ok: true, detail: class="s">"on #{branch}, #{dirty} uncommitted change(s)"}
})

suite = check(class="s">"example catalog")
orchestrator.add_task(suite, agent: ->(_t) {
  examples = Dir[File.join(ROOT, class="s">"examples", class="s">"*.rb")].size
  {ok: examples.positive?, detail: class="s">"#{examples} runnable examples (bin/smoke checks them all)"}
})

diagnosis = check(class="s">"diagnosis")
orchestrator.add_task(diagnosis, needs: {ruby: ruby, bundle: bundle, git: git, suite: suite}, agent: ->(t) {
  findings = {
    class="s">"ruby" => t.needs.ruby,
    class="s">"bundle" => t.needs.bundle,
    class="s">"git" => t.needs.git,
    class="s">"catalog" => t.needs.suite
  }
  {healthy: findings.values.all? { |f| f[class="y">:ok] }, findings: findings}
})

result = orchestrator.execute_plan
verdict = result.results[diagnosis.id].output

puts class="s">"SETUP DOCTOR"
puts
verdict[class="y">:findings].each do |name, finding|
  puts format(class="s">"  %s  %-8s %s", finding[class="y">:ok] ? class="s">"ok " : class="s">"FIX", name, finding[class="y">:detail])
end
puts
if verdict[class="y">:healthy]
  puts class="s">"you're good. write code, not wiki pages."
else
  puts class="s">"fix the FIX lines above, run me again."
  exit 1
end