|
| 1 | +--- |
| 2 | +title: "refactor: Update dspy-ruby skill to DSPy.rb v0.34.3 API" |
| 3 | +type: refactor |
| 4 | +date: 2026-02-09 |
| 5 | +--- |
| 6 | + |
| 7 | +# Update dspy-ruby Skill to DSPy.rb v0.34.3 API |
| 8 | + |
| 9 | +## Problem |
| 10 | + |
| 11 | +The `dspy-ruby` skill uses outdated API patterns (`.forward()`, `result[:field]`, inline `T.enum([...])`, `DSPy::Tool`) and is missing 10+ features (events, lifecycle callbacks, GEPA, evaluation framework, BAML/TOON, storage, etc.). |
| 12 | + |
| 13 | +## Solution |
| 14 | + |
| 15 | +Use the engineering skill as base (already has correct API), enhance with official docs content, rewrite all reference files and templates. |
| 16 | + |
| 17 | +### Source Priority (when conflicts arise) |
| 18 | + |
| 19 | +1. **Official docs** (`../dspy.rb/docs/src/`) — source of truth for API correctness |
| 20 | +2. **Engineering skill** (`../engineering/.../dspy-rb/SKILL.md`) — source of truth for structure/style |
| 21 | +3. **NavigationContext brainstorm** — for Typed Context pattern only |
| 22 | + |
| 23 | +## Files to Update |
| 24 | + |
| 25 | +### Core (SKILL.md) |
| 26 | + |
| 27 | +1. **`skills/dspy-ruby/SKILL.md`** — Copy from engineering base, then: |
| 28 | + - Fix frontmatter: `name: dspy-rb` → `name: dspy-ruby`, keep long description format |
| 29 | + - Add sections before "Guidelines for Claude": Events System, Lifecycle Callbacks, Fiber-Local LM Context, Evaluation Framework, GEPA Optimization, Typed Context Pattern, Schema Formats (BAML/TOON) |
| 30 | + - Update Resources section with 5 references + 3 assets using markdown links |
| 31 | + - Fix any backtick references to markdown link format |
| 32 | + |
| 33 | +### References (rewrite from themed doc batches) |
| 34 | + |
| 35 | +2. **`references/core-concepts.md`** — Rewrite |
| 36 | + - Source: `core-concepts/signatures.md`, `modules.md`, `predictors.md`, `advanced/complex-types.md` |
| 37 | + - Cover: signatures (Date/Time types, T::Enum, defaults, field descriptions, BAML/TOON, recursive types), modules (.call() API, lifecycle callbacks, instruction update contract), predictors (all 4 types, concurrent predictions), type system (discriminators, union types) |
| 38 | + |
| 39 | +3. **`references/toolsets.md`** — NEW |
| 40 | + - Source: `core-concepts/toolsets.md`, `toolsets-guide.md` |
| 41 | + - Cover: Tools::Base, Tools::Toolset DSL, type safety with Sorbet sigs, schema generation, built-in toolsets, testing |
| 42 | + |
| 43 | +4. **`references/providers.md`** — Rewrite |
| 44 | + - Source: `llms.txt.erb`, engineering SKILL.md, `core-concepts/module-runtime-context.md` |
| 45 | + - Cover: per-provider adapters, RubyLLM unified adapter, Rails initializer, fiber-local LM context (`DSPy.with_lm`), feature-flagged model selection, compatibility matrix |
| 46 | + |
| 47 | +5. **`references/optimization.md`** — Rewrite |
| 48 | + - Source: `optimization/miprov2.md`, `gepa.md`, `evaluation.md`, `production/storage.md` |
| 49 | + - Cover: MIPROv2 (dspy-miprov2 gem, AutoMode presets), GEPA (dspy-gepa gem, feedback maps), Evaluation (DSPy::Evals, built-in metrics, DSPy::Example), Storage (ProgramStorage) |
| 50 | + |
| 51 | +6. **`references/observability.md`** — NEW |
| 52 | + - Source: `production/observability.md`, `core-concepts/events.md`, `advanced/observability-interception.md` |
| 53 | + - Cover: event system (module-scoped + global), dspy-o11y gems, Langfuse (env vars), score reporting (DSPy.score()), observation types, DSPy::Context.with_span |
| 54 | + |
| 55 | +### Assets (rewrite to current API) |
| 56 | + |
| 57 | +7. **`assets/signature-template.rb`** — T::Enum classes, `description:` kwarg, Date/Time types, defaults, union types, `.call()` / `result.field` usage examples |
| 58 | + |
| 59 | +8. **`assets/module-template.rb`** — `.call()` API, `result.field`, Tools::Base, lifecycle callbacks, `DSPy.with_lm`, `configure_predictor` |
| 60 | + |
| 61 | +9. **`assets/config-template.rb`** — RubyLLM adapter, `structured_outputs: true`, `after_initialize` Rails pattern, dspy-o11y env vars, feature-flagged model selection |
| 62 | + |
| 63 | +### Metadata |
| 64 | + |
| 65 | +10. **`.claude-plugin/plugin.json`** — Version `2.31.0` → `2.31.1` |
| 66 | + |
| 67 | +11. **`CHANGELOG.md`** — Add `[2.31.1] - 2026-02-09` entry under `### Changed` |
| 68 | + |
| 69 | +## Verification |
| 70 | + |
| 71 | +```bash |
| 72 | +# No old API patterns |
| 73 | +grep -n '\.forward(\|result\[:\|T\.enum(\[\|DSPy::Tool[^s]' plugins/compound-engineering/skills/dspy-ruby/SKILL.md |
| 74 | + |
| 75 | +# No backtick references |
| 76 | +grep -E '`(references|assets|scripts)/' plugins/compound-engineering/skills/dspy-ruby/SKILL.md |
| 77 | + |
| 78 | +# Frontmatter correct |
| 79 | +head -4 plugins/compound-engineering/skills/dspy-ruby/SKILL.md |
| 80 | + |
| 81 | +# JSON valid |
| 82 | +cat plugins/compound-engineering/.claude-plugin/plugin.json | jq . |
| 83 | + |
| 84 | +# All files exist |
| 85 | +ls plugins/compound-engineering/skills/dspy-ruby/{references,assets}/ |
| 86 | +``` |
| 87 | + |
| 88 | +## Success Criteria |
| 89 | + |
| 90 | +- [x] All API patterns updated (`.call()`, `result.field`, `T::Enum`, `Tools::Base`) |
| 91 | +- [x] New features covered: events, callbacks, fiber-local LM, GEPA, evals, BAML/TOON, storage, score API, RubyLLM, typed context |
| 92 | +- [x] 5 reference files present (core-concepts, toolsets, providers, optimization, observability) |
| 93 | +- [x] 3 asset templates updated to current API |
| 94 | +- [x] YAML frontmatter: `name: dspy-ruby`, description has "what" and "when" |
| 95 | +- [x] All reference links use `[file.md](./references/file.md)` format |
| 96 | +- [x] Writing style: imperative form, no "you should" |
| 97 | +- [x] Version bumped to `2.31.1`, CHANGELOG updated |
| 98 | +- [x] Verification commands all pass |
| 99 | + |
| 100 | +## Source Materials |
| 101 | + |
| 102 | +- Engineering skill: `/Users/vicente/Workspaces/vicente.services/engineering/plugins/engineering-skills/skills/dspy-rb/SKILL.md` |
| 103 | +- Official docs: `/Users/vicente/Workspaces/vicente.services/dspy.rb/docs/src/` |
| 104 | +- NavigationContext brainstorm: `/Users/vicente/Workspaces/vicente.services/observo/observo-server/docs/brainstorms/2026-02-09-typed-navigation-context-brainstorm.md` |
0 commit comments