@juicesharp/rpiv-config 1.17.1 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.18.0] - 2026-06-04
2
+
3
+ ### Added
4
+ - `modelKey` and `parseModelKey` are now exported from `@juicesharp/rpiv-config` (consolidated out of `rpiv-advisor`) so all consumers share one model-key codec.
5
+
6
+ ### Changed
7
+ - `parseModelKey` now accepts both `provider/modelId` (canonical slash form) and `provider:modelId` (legacy colon form), preferring slash when both separators are present.
8
+ - `modelKey()` now emits only the canonical slash form (`provider/modelId`); it previously emitted `provider:modelId`. Paired with the tolerant read, persisted colon-form keys auto-migrate to slash on the next save by any consumer that re-serialises through the codec.
9
+
1
10
  ## [1.17.1] - 2026-06-01
2
11
 
3
12
  ## [1.17.0] - 2026-06-01
package/config.ts CHANGED
@@ -142,6 +142,43 @@ export function validateGuidanceFields(fields: unknown): GuidanceFields {
142
142
  return result;
143
143
  }
144
144
 
145
+ // ---------------------------------------------------------------------------
146
+ // Model key codec — provider:id string ↔ { provider, modelId } object.
147
+ // ---------------------------------------------------------------------------
148
+
149
+ /**
150
+ * Parse a model key string into its components.
151
+ *
152
+ * Accepts EITHER separator on read:
153
+ * - "provider/modelId" — canonical form (emitted by modelKey and persisted
154
+ * by post-slash-canonical-migration consumers).
155
+ * - "provider:modelId" — legacy form (persisted by released rpiv-advisor
156
+ * 1.16+ before the migration). Auto-rewritten on the next save by any
157
+ * consumer that re-serialises via modelKey.
158
+ *
159
+ * Slash is preferred when present — a key like "provider:foo/bar" splits on
160
+ * `/`, so the modelId is "bar" rather than re-introducing the legacy
161
+ * interpretation. No current model id contains a `/` so this asymmetry has
162
+ * no real-world ambiguity.
163
+ */
164
+ export function parseModelKey(key: string): { provider: string; modelId: string } | undefined {
165
+ const slashIdx = key.indexOf("/");
166
+ if (slashIdx >= 1) return { provider: key.slice(0, slashIdx), modelId: key.slice(slashIdx + 1) };
167
+ const colonIdx = key.indexOf(":");
168
+ if (colonIdx >= 1) return { provider: key.slice(0, colonIdx), modelId: key.slice(colonIdx + 1) };
169
+ return undefined;
170
+ }
171
+
172
+ /**
173
+ * Compose the canonical "provider/modelId" string from provider and modelId
174
+ * components. Slash-only emission; paired with parseModelKey's tolerant read,
175
+ * legacy colon-form persisted values auto-migrate the next time any consumer
176
+ * re-serialises through this codec.
177
+ */
178
+ export function modelKey(m: { provider: string; id: string }): string {
179
+ return `${m.provider}/${m.id}`;
180
+ }
181
+
145
182
  // ---------------------------------------------------------------------------
146
183
  // Env-var fallback
147
184
  // ---------------------------------------------------------------------------
package/index.ts CHANGED
@@ -3,6 +3,8 @@ export {
3
3
  type GuidanceFields,
4
4
  GuidanceFieldsSchema,
5
5
  loadJsonConfig,
6
+ modelKey,
7
+ parseModelKey,
6
8
  readEnvVar,
7
9
  saveJsonConfig,
8
10
  validateConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-config",
3
- "version": "1.17.1",
3
+ "version": "1.18.0",
4
4
  "description": "Shared config I/O utilities for rpiv-mono sibling packages",
5
5
  "keywords": [
6
6
  "rpiv",