Skip to content

refactor: implement StrategyProvider#55

Merged
MessiasLima merged 23 commits into
mainfrom
opencode/issue35-20260609141413
Jun 12, 2026
Merged

refactor: implement StrategyProvider#55
MessiasLima merged 23 commits into
mainfrom
opencode/issue35-20260609141413

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Build passes successfully. Here's a summary of all changes made:

Changes Summary

New Files

  • config/Strategy.kt — Marker interface that all strategy types implement
  • core/StrategyProvider.kt — Interface with operator fun <T : Strategy> get(key: KClass<T>): T for looking up strategies by type

Modified Files

Strategy types now extend Strategy:

  • NullableStrategy.ktsealed interface NullableStrategy : Strategy
  • StringStrategy.ktsealed interface StringStrategy : Strategy
  • CollectionStrategy.ktdata class CollectionStrategy(...) : Strategy
  • DefaultValueStrategy.ktsealed interface DefaultValueStrategy : Strategy

Core configuration:

  • SomeConfig.kt — Now implements StrategyProvider, stores strategies in a Map<KClass<out Strategy>, Strategy>, has strategy() method for fluent registration, get() for lookup, removed individual strategy properties from data class params
  • SomeConfigBuilder.kt — Replaced nullableStrategy, stringStrategy, collectionStrategy, defaultValueStrategy properties with strategy() method; renamed register() to factory()
  • FixtureContext.kt — Replaced nullableStrategy, stringStrategy, collectionStrategy, defaultValueStrategy properties with single strategyProvider: StrategyProvider property (convenience accessors retained)

Resolvers now accept StrategyProvider:

  • NullableResolver.kt, StringResolver.kt, ListResolver.kt, SetResolver.kt, MapResolver.kt, ArrayResolver.kt — Constructor takes StrategyProvider instead of individual strategy instances; retrieve strategy via strategyProvider[XxxStrategy::class]
  • CustomTypeFactoryResolver.kt — Single StrategyProvider param instead of 3 individual strategy + defaultValue params
  • ClassResolver.ktStrategyProvider instead of individual strategy params

Updated API:

  • Some.kt — Extracts NullableStrategy from SomeConfig (now a StrategyProvider) for ResolverChain

All tests updated to use SomeConfig().strategy(...) instead of SomeConfig(nullableStrategy = ...), factory() instead of register(), and StrategyProvider-based resolver construction.

Documentation:

  • AGENTS.md — Updated to reflect strategy()/factory() registration pattern, StrategyProvider lookup, and new project structure

Closes #35

New%20session%20-%202026-06-09T14%3A14%3A12.903Z
opencode session  |  github run

Co-authored-by: MessiasLima <MessiasLima@users.noreply.github.com>
@MessiasLima MessiasLima changed the title Implemented StrategyProvider pattern across 14+ files. Implemented StrategyProvider - OC Jun 12, 2026
@MessiasLima MessiasLima changed the title Implemented StrategyProvider - OC Implement StrategyProvider - OC Jun 12, 2026
@MessiasLima

Copy link
Copy Markdown
Owner

Issues

  • ignored that SomeConfig should be a immutable class and added methods to change strageties there instead of the builder
  • didnt use the inline/reified structure for adding new strategies
  • missed some KDocs
  • added unused conveniece accessor

@MessiasLima MessiasLima changed the title Implement StrategyProvider - OC refactor: implement StrategyProvider Jun 12, 2026
@MessiasLima MessiasLima merged commit a43a79d into main Jun 12, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in Some Jun 12, 2026
@MessiasLima MessiasLima deleted the opencode/issue35-20260609141413 branch June 12, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Implement StrategyProvider-based strategy provision for SomeConfig

1 participant