Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Fixture-backed `evals/skills/create-service-object/basic`: fat `OrdersController`, passing starting tests, and a condensed `skills/create-service-object/SKILL.md`.
- Fixture-backed `evals/skills/write-yard-docs/basic`: undocumented `PriceCalculator`, passing starting tests, and a condensed `skills/write-yard-docs/SKILL.md`.

### Documentation
- Align user docs with shipped 1.3.1: OpenRouter and mock in the provider list, Azure env var `SKILL_BENCH_AZURE_OPENAI_API_KEY`, Mistral key via `skill-bench.json` (no env mapping).
Expand Down
2 changes: 1 addition & 1 deletion evals/skills/write-yard-docs/basic/criteria.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"context": "Evaluate ruby task",
"context": "Evaluate whether skill context helps add complete YARD (@param, @return, @raise) to PriceCalculator public methods without changing behavior",
"dimensions": [
{ "name": "correctness", "max_score": 30 },
{ "name": "skill_adherence", "max_score": 25 },
Expand Down
19 changes: 19 additions & 0 deletions evals/skills/write-yard-docs/basic/price_calculator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

class PriceCalculator
def self.call(cents:, quantity:)
new(cents: cents, quantity: quantity).call
end

def initialize(cents:, quantity:)
@cents = cents
@quantity = quantity
end

def call
raise ArgumentError, 'cents must be non-negative' if @cents.negative?
raise ArgumentError, 'quantity must be positive' unless @quantity.positive?

@cents * @quantity
end
end
22 changes: 22 additions & 0 deletions evals/skills/write-yard-docs/basic/price_calculator_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require 'minitest/autorun'
require_relative 'price_calculator'

class PriceCalculatorTest < Minitest::Test
def test_call_multiplies_cents_by_quantity
assert_equal 2000, PriceCalculator.call(cents: 1000, quantity: 2)
end

def test_call_rejects_negative_cents
error = assert_raises(ArgumentError) { PriceCalculator.call(cents: -1, quantity: 1) }

assert_equal 'cents must be non-negative', error.message
end

def test_call_rejects_non_positive_quantity
error = assert_raises(ArgumentError) { PriceCalculator.call(cents: 1000, quantity: 0) }

assert_equal 'quantity must be positive', error.message
end
end
24 changes: 19 additions & 5 deletions evals/skills/write-yard-docs/basic/task.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
# Eval: write-yard-docs-basic

The sandbox starts with `price_calculator.rb` and `price_calculator_test.rb`.
`PriceCalculator` already works. Public methods have no YARD.

## Task
Add YARD documentation to the provided Ruby class with public methods. For each public method write @param, @return, and @raise tags where appropriate.

Add YARD to `PriceCalculator` without changing behavior.

1. Class: one-line summary of responsibility.
2. `self.call` and `#call` each get their own docs. Do not document only one of them.
3. Every public method gets `@param`, `@return`, and `@raise` where they apply.
4. `@param` for `cents` and `quantity` on `self.call` (and on `initialize` if you treat it as public).
5. `@return` states the type (`Integer` total cents, or the Hash/result shape if you change nothing else).
6. One `@raise [ArgumentError]` tag per raising method, with the actual messages (`cents must be non-negative`, `quantity must be positive`). Do not group exceptions on one tag.
7. Leave `ruby price_calculator_test.rb` passing. Do not add `process_order.rb` or extract a new service.

## Success Criteria
- All public methods have YARD documentation.
- @param tags are accurate and complete.
- @return tags specify the return type and structure.
- @raise tags document exceptions where applicable.

- All public methods have YARD.
- `@param` tags match `cents:` and `quantity:`.
- `@return` names the return type.
- `@raise` documents `ArgumentError` on methods that raise.
- `ruby price_calculator_test.rb` exits 0.
47 changes: 47 additions & 0 deletions skills/write-yard-docs/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Write YARD Docs

Use when documenting Ruby public APIs with YARD.

## Pattern

```ruby
# frozen_string_literal: true

# Multiplies unit price in cents by quantity.
class PriceCalculator
# Multiply unit cents by quantity.
#
# @param cents [Integer] non-negative unit price in cents
# @param quantity [Integer] positive unit count
# @return [Integer] total price in cents
# @raise [ArgumentError] when cents is negative or quantity is not positive
def self.call(cents:, quantity:)
new(cents: cents, quantity: quantity).call
end

def initialize(cents:, quantity:)
@cents = cents
@quantity = quantity
end

# Multiply unit cents by quantity.
#
# @return [Integer] total price in cents
# @raise [ArgumentError] when cents is negative or quantity is not positive
def call
raise ArgumentError, 'cents must be non-negative' if @cents.negative?
raise ArgumentError, 'quantity must be positive' unless @quantity.positive?

@cents * @quantity
end
end
```

## Hard rules

1. Every public method gets YARD. Document `self.call` separately from `#call`.
2. `@param` for each argument. `@return` names the type (and Hash keys when the result is a Hash).
3. One `@raise` tag per exception class that can escape. Never group two exceptions on one tag.
4. Class gets a one-line summary.
5. YARD text is English unless the user asked otherwise.
6. Do not change runtime behavior to make the docs easier.
54 changes: 54 additions & 0 deletions test/evals/write_yard_docs_basic_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

require 'test_helper'
require 'open3'
require 'tempfile'

module SkillBench
class WriteYardDocsBasicEvalTest < Minitest::Test
EVAL_DIR = File.expand_path('../../evals/skills/write-yard-docs/basic', __dir__)
SKILL_PATH = File.expand_path('../../skills/write-yard-docs/SKILL.md', __dir__)

def test_eval_loads_and_names_the_fixture_files
evaluation = Models::Eval.load(EVAL_DIR)

assert_includes evaluation.task, 'price_calculator.rb'
assert_includes evaluation.task, 'price_calculator_test.rb'
end

def test_eval_ships_undocumented_public_methods
source = File.read(File.join(EVAL_DIR, 'price_calculator.rb'))

assert_path_exists File.join(EVAL_DIR, 'price_calculator.rb')
assert_path_exists File.join(EVAL_DIR, 'price_calculator_test.rb')
refute_includes source, '@param'
refute_includes source, '@return'
refute_includes source, '@raise'
end

def test_starting_calculator_tests_pass
stdout, stderr, status = Open3.capture3('ruby', 'price_calculator_test.rb', chdir: EVAL_DIR)

assert_predicate status, :success?, "fixture tests failed:\n#{stdout}\n#{stderr}"
assert_includes stdout, '0 failures'
end

def test_skill_example_is_valid_ruby_with_yard_tags
skill = File.read(SKILL_PATH)
example = skill[/```ruby\n(.*?)```/m, 1]

refute_nil example, 'SKILL.md must include a ruby example'
assert_includes example, '@param'
assert_includes example, '@return'
assert_includes example, '@raise'

Tempfile.create(['yard_example', '.rb']) do |file|
file.write(example)
file.flush
_stdout, stderr, status = Open3.capture3('ruby', '-c', file.path)

assert_predicate status, :success?, stderr
end
end
end
end
16 changes: 8 additions & 8 deletions test/evaluator/source_path_resolver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,38 +81,38 @@ def test_local_skills_resolve_first_with_empty_sources
def test_falls_back_to_skill_sources_when_local_not_found
Dir.mktmpdir do |tmpdir|
source_path = File.join(tmpdir, 'code-quality')
skill_dir = File.join(source_path, 'write-yard-docs')
skill_dir = File.join(source_path, 'unshipped-skill')
FileUtils.mkdir_p(skill_dir)
File.write(File.join(skill_dir, 'SKILL.md'), '# Write YARD Docs')
File.write(File.join(skill_dir, 'SKILL.md'), '# Unshipped Skill')

resolved = Execution::SourcePathResolver.call(
eval_folder_path: 'tmp/evals/skills/write-yard-docs/basic',
eval_folder_path: 'tmp/evals/skills/unshipped-skill/basic',
skill_sources: { 'core' => tmpdir }
)

assert_equal File.join(source_path, 'write-yard-docs'), resolved
assert_equal File.join(source_path, 'unshipped-skill'), resolved
end
end

def test_first_matching_source_wins
Dir.mktmpdir do |tmpdir_a|
Dir.mktmpdir do |tmpdir_b|
source_a = File.join(tmpdir_a, 'code-quality')
skill_a = File.join(source_a, 'write-yard-docs')
skill_a = File.join(source_a, 'unshipped-skill')
FileUtils.mkdir_p(skill_a)
File.write(File.join(skill_a, 'SKILL.md'), '# A')

source_b = File.join(tmpdir_b, 'patterns')
skill_b = File.join(source_b, 'write-yard-docs')
skill_b = File.join(source_b, 'unshipped-skill')
FileUtils.mkdir_p(skill_b)
File.write(File.join(skill_b, 'SKILL.md'), '# B')

resolved = Execution::SourcePathResolver.call(
eval_folder_path: 'custom/evals/skills/write-yard-docs/basic',
eval_folder_path: 'custom/evals/skills/unshipped-skill/basic',
skill_sources: { 'first' => tmpdir_a, 'second' => tmpdir_b }
)

assert_equal File.join(source_a, 'write-yard-docs'), resolved
assert_equal File.join(source_a, 'unshipped-skill'), resolved
end
end
end
Expand Down
Loading