diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0aa5267 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: Push gem + +on: + push: + tags: + - "v*" + +jobs: + push: + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + environment: release + steps: + - uses: actions/checkout@v5 + with: + persist-credentials: false + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby + bundler-cache: true + - uses: rubygems/release-gem@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 907b884..c45d798 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: matrix: ruby: ["3.2", "3.3", "3.4"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 @@ -29,11 +29,9 @@ jobs: run: gem build opencode-rails.gemspec - name: Verify gem loads after install - # opencode-rails depends on opencode-ruby; until both gems - # are on rubygems.org, the install step here will only resolve - # if opencode-ruby has been pre-installed or is reachable. - # When the gems do publish, the runtime_dependency on - # opencode-ruby will Just Work via rubygems. run: | - gem install --local opencode-rails-*.gem --conservative + client_dir="$(bundle show opencode-ruby)" + (cd "$client_dir" && gem build opencode-ruby.gemspec) + gem install "$client_dir"/opencode-ruby-*.gem --no-document + gem install opencode-rails-*.gem --no-document ruby -ropencode-rails -e 'puts Opencode::RAILS_VERSION' diff --git a/CHANGELOG.md b/CHANGELOG.md index f28861d..30271fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.0.1.alpha6 - 2026-07-18 + +### Bumped + +- Runtime dependency `opencode-ruby` pinned to `= 0.0.1.alpha6`. Rails turns + now establish and validate the OpenCode SSE subscription before submitting + `prompt_async`, and automatic SSE reconnects reopen only the subscription + without replaying the user prompt. + ## 0.0.1.alpha5 - 2026-07-15 ### Bumped diff --git a/Gemfile b/Gemfile index b4e2a20..055b104 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,7 @@ source "https://rubygems.org" +gem "opencode-ruby", + git: "https://github.com/ajaynomics/opencode-ruby.git", + ref: "b16292723e6385064064fdd61698c9618f6cb156" + gemspec diff --git a/README.md b/README.md index 2251910..6fd5821 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,14 @@ bundle install Runtime deps: `activerecord`, `activestorage`, `activesupport` (>= 7.1). Depends on `opencode-ruby` for the underlying HTTP/SSE primitives. +During the alpha series both gems are pinned in lockstep. Version 0.0.1.alpha6 +uses a subscribe-ready-before-prompt transport contract and reconnects an +accepted turn without posting its prompt again. + +Releases use RubyGems trusted publishing. Register `release.yml` as the gem's +trusted publisher (using the `release` environment); after that, a `v*` tag +publishes without a long-lived RubyGems API key. + ## Quickstart ```ruby diff --git a/lib/opencode/rails_version.rb b/lib/opencode/rails_version.rb index 8dc072d..5b1cdb6 100644 --- a/lib/opencode/rails_version.rb +++ b/lib/opencode/rails_version.rb @@ -11,5 +11,5 @@ # We can't reuse the same constant from a second gem, so we use a # distinct, non-namespaced constant. module Opencode - RAILS_VERSION = "0.0.1.alpha5" + RAILS_VERSION = "0.0.1.alpha6" end diff --git a/opencode-rails.gemspec b/opencode-rails.gemspec index c0ad951..19fd938 100644 --- a/opencode-rails.gemspec +++ b/opencode-rails.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| # this gem builds on. During alpha both gems evolve in lockstep — we pin # exactly (= not ~>) so that consumers always pick the version this gem # was tested against. - spec.add_runtime_dependency "opencode-ruby", "= 0.0.1.alpha5" + spec.add_runtime_dependency "opencode-ruby", "= 0.0.1.alpha6" # Rails sub-libraries used at runtime. Depending on these individually # (instead of the `rails` umbrella) avoids forcing host apps to load diff --git a/test/opencode/loading_test.rb b/test/opencode/loading_test.rb index b048b6c..a6c2869 100644 --- a/test/opencode/loading_test.rb +++ b/test/opencode/loading_test.rb @@ -36,23 +36,25 @@ class Opencode::LoadingTest < Minitest::Test end end - # We check via path match on both directory ("/opencode-rails/") and - # installed-gem name ("/opencode-rails-VERSION/") so the assertion is - # robust to either a sibling-repo dev setup or a bundle-resolved gem - # install. - GEM_PATH_PATTERN = ->(name) { %r{/#{Regexp.escape(name)}[-/]} } + # Match the gem's own lib path, not merely any parent directory. GitHub's + # checkout layout nests Bundler under /opencode-rails/opencode-rails, so a + # broad directory-name assertion falsely classifies a bundled + # opencode-ruby source path as belonging to this gem. + GEM_SOURCE_PATTERN = lambda do |name, file| + %r{/#{Regexp.escape(name)}(?:-[^/]+)?/lib/opencode/#{Regexp.escape(file)}\.rb\z} + end def test_session_constant_points_at_this_gem location = Opencode::Session.instance_method(:initialize).source_location.first - assert_match GEM_PATH_PATTERN.call("opencode-rails"), location, + assert_match GEM_SOURCE_PATTERN.call("opencode-rails", "session"), location, "Expected Opencode::Session to be loaded from opencode-rails, got: #{location}" end def test_client_constant_points_at_opencode_ruby location = Opencode::Client.instance_method(:initialize).source_location.first - assert_match GEM_PATH_PATTERN.call("opencode-ruby"), location, + assert_match GEM_SOURCE_PATTERN.call("opencode-ruby", "client"), location, "Expected Opencode::Client to come from opencode-ruby, got: #{location}" - refute_match GEM_PATH_PATTERN.call("opencode-rails"), location, + refute_match GEM_SOURCE_PATTERN.call("opencode-rails", "client"), location, "Opencode::Client must NOT come from opencode-rails (it's an opencode-ruby class)" end