Commit Graph

2 Commits

Author SHA1 Message Date
8ccfe0f7cf Rename Opencode::Rails::VERSION -> Opencode::RAILS_VERSION
Critical fix: defining Opencode::Rails as a module shadowed ::Rails
under Ruby's constant lookup whenever host code referenced top-level
Rails.something from inside the Opencode:: namespace.

Caught when host code in lib/opencode/containers/container.rb failed
to boot:

  /workspaces/app/lib/opencode/containers/container.rb:433:
    undefined method 'root' for module Opencode::Rails (NoMethodError)
      "notes.md" => Rails.root.join(...)

Ruby resolved 'Rails' to 'Opencode::Rails' first (the gem's version
namespace) before falling back to ::Rails. The fix removes the
intermediate module entirely:

  module Opencode
    RAILS_VERSION = "0.0.1.alpha1"
  end

Added a regression test (test_no_opencode_rails_module) so the
shadowing never sneaks back in. opencode-ruby uses Opencode::VERSION
for its own gem version; we can't double-up on that constant, so this
gem uses RAILS_VERSION as a sibling on the same Opencode module.
2026-05-20 05:22:23 -07:00
0611a2aa82 Add smoke tests for opencode-rails
14 tests across 4 files covering the gem's public surface:

  test/opencode/loading_test.rb (5 tests)
    - All 12 gem-provided constants resolve after require
    - Transitively-loaded opencode-ruby constants are present
    - Opencode::Session source_location points at this gem
    - Opencode::Client source_location points at opencode-ruby
    - Opencode::Rails::VERSION matches semver

  test/opencode/error_reporter_test.rb (3 tests)
    - report is no-op without adapter (returns nil)
    - report forwards error + opts to adapter
    - report works with no kwargs

  test/opencode/exchange_test.rb (3 tests)
    - Initializes with empty / nil / Array(coerced) messages
    - tool_artifacts(exclude:) doesn't raise on empty input

  test/opencode/artifact_test.rb (3 tests)
    - Filename/content/content_type/metadata readers
    - metadata defaults to {} when omitted
    - Trust metadata round-trips

Behavioral tests for Session/Turn/MessageArtifacts (AR + ActiveStorage
fixtures) stay in the host application (ajent-rails) where the
integration environment exists. Same pattern as opencode-ruby:
  - gem smoke tests prove load-time correctness
  - host tests prove integration correctness
2026-05-20 05:15:49 -07:00