auto-model-router 0.1.4 → 0.2.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.
Files changed (45) hide show
  1. package/.omp-plugin/marketplace.json +2 -2
  2. package/README.md +43 -55
  3. package/bun.lock +606 -0
  4. package/package.json +2 -1
  5. package/research/analyze-ledger.ts +173 -0
  6. package/research/apply-cost-tuning.ts +73 -0
  7. package/research/cost-analysis.ts +150 -0
  8. package/research/feed-check.ts +64 -0
  9. package/research/model-recommendations.ts +86 -0
  10. package/research/project-yield.ts +96 -0
  11. package/research/run-eval.ts +133 -0
  12. package/research/status.ts +55 -0
  13. package/research/tier-fill.ts +109 -0
  14. package/research/tier-map.ts +123 -0
  15. package/src/catalog/benchmark-feeds.ts +397 -0
  16. package/src/catalog/openrouter-catalog.ts +30 -0
  17. package/src/config/defaults.ts +30 -0
  18. package/src/config/load.ts +2 -0
  19. package/src/config/schema.ts +34 -0
  20. package/src/config/types.ts +106 -0
  21. package/src/cost/ledger.ts +23 -2
  22. package/src/cost/types.ts +24 -0
  23. package/src/eval/calibrate.ts +131 -0
  24. package/src/eval/grade.ts +115 -0
  25. package/src/eval/judge.ts +71 -0
  26. package/src/eval/run.ts +126 -0
  27. package/src/eval/tasks.ts +272 -0
  28. package/src/router/candidates.ts +13 -6
  29. package/src/router/explore.ts +59 -0
  30. package/src/router/select.ts +54 -4
  31. package/src/router/tier-plan.ts +57 -1
  32. package/src/router/types.ts +13 -0
  33. package/src/server/turn.ts +9 -2
  34. package/src/util/sqlite.ts +68 -1
  35. package/test/benchmark-feeds.test.ts +222 -0
  36. package/test/eval.test.ts +184 -0
  37. package/test/exploration.test.ts +251 -0
  38. package/test/failover.test.ts +4 -0
  39. package/test/hold-exploration.test.ts +124 -0
  40. package/test/tier-plan.test.ts +55 -1
  41. package/test/tokens.test.ts +7 -0
  42. package/test/trust-attribution.test.ts +96 -2
  43. package/test/turn.test.ts +45 -0
  44. package/tools/smoke.ts +2 -0
  45. package/tools/sync-marketplace-version.ts +60 -0
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Syncs the Git-marketplace catalog version with package.json.
4
+ *
5
+ * The marketplace (`.omp-plugin/marketplace.json`) serves the repo tip, and omp
6
+ * uses the catalog `version` for upgrade comparisons. If it lags the published
7
+ * package version, marketplace users are never offered new releases.
8
+ *
9
+ * This runs automatically as the npm `version` lifecycle script (`npm version`
10
+ * → this → commit), so every release keeps the catalog in step. It rewrites
11
+ * `metadata.version` and every `plugins[].version` to package.json's version and
12
+ * stages the file so it lands in the same version commit.
13
+ *
14
+ * Idempotent: a no-op when already in sync (nothing to stage). Also runnable by
15
+ * hand: `bun tools/sync-marketplace-version.ts`.
16
+ */
17
+
18
+ import { spawnSync } from "node:child_process";
19
+ import { readFileSync, writeFileSync } from "node:fs";
20
+ import { join, resolve } from "node:path";
21
+
22
+ const ROOT = resolve(import.meta.dir, "..");
23
+ const PKG_PATH = join(ROOT, "package.json");
24
+ const CATALOG_PATH = join(ROOT, ".omp-plugin", "marketplace.json");
25
+
26
+ function main(): void {
27
+ const pkg = JSON.parse(readFileSync(PKG_PATH, "utf8")) as { version?: unknown };
28
+ const version = pkg.version;
29
+ if (typeof version !== "string" || version === "") {
30
+ throw new Error(`package.json has no usable version: ${JSON.stringify(version)}`);
31
+ }
32
+
33
+ const before = readFileSync(CATALOG_PATH, "utf8");
34
+ // Replace only the value of every `"version": "..."` field, preserving all
35
+ // other formatting (single-line arrays, spacing, key order) so the tool is a
36
+ // true no-op once in sync. marketplace.json carries exactly two: the
37
+ // top-level metadata.version and the single plugin's version.
38
+ if (!/"version"\s*:\s*"/.test(before)) {
39
+ throw new Error(`no "version" field found in ${CATALOG_PATH}`);
40
+ }
41
+ const after = before.replace(
42
+ /("version"\s*:\s*")[^"]*(")/g,
43
+ (_m, head: string, tail: string) => `${head}${version}${tail}`,
44
+ );
45
+ if (after === before) {
46
+ console.log(`marketplace.json already at ${version}`);
47
+ return;
48
+ }
49
+
50
+ writeFileSync(CATALOG_PATH, after, "utf8");
51
+ console.log(`marketplace.json → ${version}`);
52
+
53
+ // Stage it so `npm version`'s commit includes the sync.
54
+ const add = spawnSync("git", ["add", CATALOG_PATH], { cwd: ROOT, stdio: "inherit" });
55
+ if (add.status !== 0) {
56
+ throw new Error(`git add failed for ${CATALOG_PATH} (exit ${add.status ?? "signal"})`);
57
+ }
58
+ }
59
+
60
+ main();