fm-bench 0.7.0 → 0.7.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fm-bench",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Dynamic benchmark CLI for Apple's fm command on macOS 27+.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  "release:patch": "npm version patch && git push --follow-tags",
22
22
  "release:minor": "npm version minor && git push --follow-tags",
23
23
  "release:major": "npm version major && git push --follow-tags",
24
- "publish:dry-run": "npm publish --dry-run --access public",
24
+ "publish:dry-run": "node scripts/publish-dry-run.mjs",
25
25
  "check:pack": "node scripts/check-package.mjs"
26
26
  },
27
27
  "keywords": [
package/src/bench.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import crypto from 'node:crypto';
2
2
  import { detectFmCapabilities } from './capabilities.js';
3
- import { checkModelAvailability, collectEnvironment, countTokens, getQuotaUsage, respond } from './fm.js';
3
+ import { checkModelAvailability, collectEnvironment, countTokens, fmBinaryFromOptions, getQuotaUsage, respond } from './fm.js';
4
4
  import { metricAvailability } from './metrics.js';
5
5
  import { loadPrompts } from './prompts.js';
6
6
  import { finalizeReportPayload } from './schema.js';
7
7
  import { summarizeByModel } from './stats.js';
8
8
 
9
9
  export async function inspectModels(options = {}) {
10
- const fmBin = options.fmBin || process.env.FM_BIN || 'fm';
10
+ const fmBin = fmBinaryFromOptions(options);
11
11
  const capabilities = options.capabilities ?? await detectFmCapabilities(fmBin, options);
12
12
  const discovered = {
13
13
  fmBin,
@@ -52,7 +52,7 @@ export async function inspectModels(options = {}) {
52
52
 
53
53
  export async function runBenchmark(options = {}) {
54
54
  const startedAt = new Date().toISOString();
55
- const fmBin = options.fmBin || process.env.FM_BIN || 'fm';
55
+ const fmBin = fmBinaryFromOptions(options);
56
56
 
57
57
  notify(options, { type: 'phase', phase: 'capabilities', message: 'probing fm capabilities' });
58
58
  const capabilities = options.capabilities ?? await detectFmCapabilities(fmBin, options);
@@ -9,7 +9,7 @@
9
9
 
10
10
  import crypto from 'node:crypto';
11
11
  import { stripAnsi } from './ansi.js';
12
- import { parseModelsFromHelp } from './fm-help.js';
12
+ import { parseAvailabilityList, parseModelsFromHelp } from './fm-help.js';
13
13
  import { runProcess } from './process.js';
14
14
 
15
15
  const SECTION_HEADER = /^\s*[A-Z][A-Z0-9 /-]+\s*$/;
@@ -179,16 +179,8 @@ async function discoverModelsFromAvailability(fmBin, options = {}) {
179
179
  env: options.env ?? process.env
180
180
  });
181
181
  if (result.error) return [];
182
- const text = stripAnsi(`${result.stdout}${result.stderr}`);
183
- const models = new Map();
184
- for (const line of text.split(/\r?\n/)) {
185
- const match = line.match(/^\s*([A-Za-z0-9._-]+)(?:\s+model)?\s+(?:is\s+)?(available|unavailable|not available)\b/i);
186
- if (!match) continue;
187
- const name = match[1].toLowerCase();
188
- if (['the', 'no', 'model', 'system'].includes(name) && name !== 'system') continue;
189
- models.set(name, { name, description: '' });
190
- }
191
- return [...models.values()];
182
+ return parseAvailabilityList(`${result.stdout}${result.stderr}`)
183
+ .map((model) => ({ name: model.name, description: '' }));
192
184
  }
193
185
 
194
186
  function escapeRegExp(value) {
package/src/fm.js CHANGED
@@ -25,22 +25,6 @@ export async function getFmHelp(fmBin, timeoutMs = 10_000) {
25
25
  };
26
26
  }
27
27
 
28
- /**
29
- * Discover models, preferring an already-detected capability probe so a run
30
- * does not spawn `fm --help` more than once.
31
- * @param {Record<string, any>} options
32
- */
33
- export async function discoverModels(options = {}) {
34
- const fmBin = fmBinaryFromOptions(options);
35
- const capabilities = options.capabilities ?? await detectFmCapabilities(fmBin, options);
36
- return {
37
- fmBin,
38
- models: capabilities.models,
39
- help: capabilities.help,
40
- capabilities
41
- };
42
- }
43
-
44
28
  /**
45
29
  * Check one model against the detected `fm` build.
46
30
  *
package/src/metrics.js CHANGED
@@ -192,15 +192,6 @@ export function metricAvailability(capabilities = {}, options = {}) {
192
192
  return metrics;
193
193
  }
194
194
 
195
- export function metricDefinition(key) {
196
- const definition = DEFINITIONS.find((item) => item.key === key);
197
- return definition ? { ...definition, requires: [...definition.requires] } : null;
198
- }
199
-
200
- export function metricDefinitions() {
201
- return DEFINITIONS.map((definition) => ({ ...definition, requires: [...definition.requires] }));
202
- }
203
-
204
195
  /** Short human line for CLI output, e.g. "token counting: yes, quota: no". */
205
196
  export function formatCapabilitySummary(capabilities = {}) {
206
197
  const features = capabilities.features ?? {};