Skip to content

fix(sdd): parse model spec at first separator and consolidate duplicated parsers#374

Open
Basparin wants to merge 3 commits intoGentleman-Programming:mainfrom
Basparin:fix/260-openrouter-free-continuation
Open

fix(sdd): parse model spec at first separator and consolidate duplicated parsers#374
Basparin wants to merge 3 commits intoGentleman-Programming:mainfrom
Basparin:fix/260-openrouter-free-continuation

Conversation

@Basparin
Copy link
Copy Markdown
Contributor

@Basparin Basparin commented Apr 24, 2026

🔗 Linked Issue

Closes #260


🔄 Continuation Notice

This PR continues and supersedes #242 by @ACDPDEV, who explicitly handed off the work in #242 (comment) (university commitments prevented him from landing the review suggestions himself).

Full credit for the original fix goes to @ACDPDEV — his commit 28c3378 is preserved verbatim with original author metadata intact. This PR applies @Alan-TheGentleman's two review suggestions from #242 on top:

  1. Shared SplitProviderModel helper — consolidates three identical copies of the first-separator logic. This matches @ACDPDEV's final ask in the handoff: "abstraer lo que se repite en una función".
  2. Regression test for OpenRouter /free format + dedicated coverage for extractModelFromAgent, which previously had no direct tests.

Once this PR lands, #242 can be closed — the full contribution (with review feedback applied) lives here.


🏷️ PR Type

  • type:bug — Bug fix (non-breaking change that fixes an issue)
  • type:feature
  • type:docs
  • type:refactor
  • type:chore
  • type:breaking-change

📝 Summary

  • Fixes OpenRouter free-model parsing where openrouter/qwen/qwen3.6-plus:free was split at : before the leading /, producing a broken ProviderID=openrouter/qwen/qwen3.6-plus, ModelID=free.
  • Consolidates three identical copies of the provider/model split logic into a single exported SplitProviderModel helper in the model package.
  • Adds regression coverage for the OpenRouter format and fills the coverage gap around extractModelFromAgent.

📂 Changes

File / Area What Changed
internal/model/split.go New: exported SplitProviderModel(spec) (provider, model, ok) helper
internal/model/split_test.go New: 11 cases including OpenRouter regression and malformed inputs
internal/cli/sync.go parseModelSpec now delegates to the shared helper
internal/components/sdd/profiles.go extractModelFromAgent now delegates to the shared helper
internal/components/sdd/read_assignments.go Inline parser replaced with a call to the shared helper
internal/components/sdd/profiles_test.go Adds TestExtractModelFromAgent — no previous coverage
internal/components/sdd/read_assignments_test.go Adds TestReadCurrentModelAssignmentsOpenRouterFreeSuffix regression test

Net: +255 / −41, 7 files. No behavior change in the happy path — existing TestReadCurrentModelAssignments* suite still passes unchanged.


🧪 Test Plan

Unit Tests

go test ./internal/model/... ./internal/cli/... ./internal/components/sdd/...

E2E Tests (Docker required)

Not run

Pre-existing test failures in the Windows sandbox around unique-names-generator / bun install are unrelated to this PR — they're tracked in a separate PR (#372).

  • Unit tests pass on affected packages
  • E2E tests pass (cd e2e && ./docker-test.sh)
  • Parsing logic verified via new unit tests across edge cases

🤖 Automated Checks

Check Status Description
Check Issue Reference Closes #260
Check Issue Has status:approved Verified: #260 carries status:approved
Check PR Has type:* Label Requesting type:bug
Unit Tests CI will validate
E2E Tests CI matrix will validate

✅ Contributor Checklist


💬 Notes for Reviewers

ACDPDEV and others added 3 commits April 24, 2026 17:33
…ee bug

Both extractModelFromAgent and ReadCurrentModelAssignments incorrectly
preferred colon over slash when splitting model strings. For OpenRouter
free models like openrouter/qwen/qwen3.6-plus:free, this produced
openrouter/qwen/qwen3.6-plus/free instead of the correct :free suffix.

Fix: find the FIRST occurrence of either / or : (whichever comes first),
matching the correct implementation already present in parseModelSpec.
… parsing

Consolidates three identical copies of the "split on first '/' or ':'" logic into a shared helper in the model package:

- internal/cli/sync.go -> parseModelSpec

- internal/components/sdd/profiles.go -> extractModelFromAgent

- internal/components/sdd/read_assignments.go -> ReadCurrentModelAssignments

No behavior change. Addresses review feedback on Gentleman-Programming#242.
Adds test coverage per review feedback on Gentleman-Programming#242:

- Dedicated TestExtractModelFromAgent (previously no coverage)

- Regression case for openrouter/qwen/qwen3.6-plus:free in read_assignments_test.go. The combined slash-then-colon format motivating issue Gentleman-Programming#260 must be split at the first separator (the leading '/'), not at ':'.
@ACDPDEV
Copy link
Copy Markdown

ACDPDEV commented Apr 24, 2026

Gracias por la mención, estoy ansioso por revisar esta PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure Opencode Models writes invalid model ID prefix (opencode/ instead of openrouter/)

2 participants