modelfunction-cli 0.1.0 → 0.1.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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  ## 安装
6
6
 
7
7
  ```bash
8
- npx -y modelfunction-cli@0.1.0 --version
8
+ npx -y modelfunction-cli@0.1.1 --version
9
9
  # 或
10
10
  npm i -D modelfunction-cli
11
11
  npx mf --version
@@ -31,6 +31,28 @@ SILICONFLOW_API_KEY=... mf eval --models dsv4-flash
31
31
  OPENAI_API_KEY=... mf eval --models openai
32
32
  ```
33
33
 
34
+ ### 自建 / 内网网关
35
+
36
+ 企业内网基本都是 OpenAI 兼容协议,写一个 models-file 即可,Key 只走环境变量、不落盘:
37
+
38
+ ```json
39
+ {
40
+ "internal-ds": {
41
+ "type": "openai",
42
+ "baseUrl": "https://llm.example.internal/v1",
43
+ "model": "deepseek-v4-flash",
44
+ "apiKeyEnv": "INTERNAL_LLM_KEY"
45
+ }
46
+ }
47
+ ```
48
+
49
+ ```bash
50
+ INTERNAL_LLM_KEY=... mf eval --suite mf.suite.json \
51
+ --models-file my-models.json --models internal-ds
52
+ ```
53
+
54
+ `pricing` 可省(省了就不输出成本);要算成本请按自家价目填写,默认 registry 里的价格只是参考值。
55
+
34
56
  ## 命令
35
57
 
36
58
  | 命令 | 作用 |
@@ -54,7 +76,7 @@ OPENAI_API_KEY=... mf eval --models openai
54
76
  "mcpServers": {
55
77
  "modelfunction": {
56
78
  "command": "npx",
57
- "args": ["-y", "modelfunction-cli@0.1.0", "mcp"]
79
+ "args": ["-y", "modelfunction-cli@0.1.1", "mcp"]
58
80
  }
59
81
  }
60
82
  }
@@ -72,4 +94,26 @@ OPENAI_API_KEY=... mf eval --models openai
72
94
 
73
95
  由你或你的编码 Agent 撰写,规则模板见包内 `skills/mf-cases/SKILL.md`。未复核用例(`reviewed:false`)不计入正式分数。
74
96
 
97
+ 工具一多就别手工誊抄,直接让编码 Agent 驱动 `mf`:
98
+
99
+ ```bash
100
+ # 1. 把 mf 挂成 MCP server
101
+ claude mcp add modelfunction -- npx -y modelfunction-cli@0.1.1 mcp
102
+ ```
103
+
104
+ ```text
105
+ # 2. 让 Agent 扫仓库并写出套件草稿
106
+ 用 modelfunction 的 scan_tools 扫 .,probe=true,writeSuite=mf.suite.json
107
+
108
+ # 3. 让 Agent 补用例
109
+ 按 skills/mf-cases/SKILL.md 的规则,为每个工具补 3 条正例和 1 条负例,用 add_cases
110
+ 写入 mf.suite.json,然后跑 coverage 看还缺哪些参数和负例
111
+ ```
112
+
113
+ ```bash
114
+ # 4. 人工复核:把认可的用例 reviewed 改为 true,再跑正式评分
115
+ mf coverage --suite mf.suite.json
116
+ mf eval --suite mf.suite.json --models internal-ds
117
+ ```
118
+
75
119
  License: MIT
@@ -2,7 +2,7 @@
2
2
  "name": "recruiting-agent",
3
3
  "description": "招聘 Agent 的 function-calling 评测集:简历评分、面试题、薪资区间、JD 改写。",
4
4
  "tools": [
5
- { "ref": "../../demo/function.json" },
5
+ { "ref": "./tools/resume_score.json" },
6
6
  {
7
7
  "name": "interview_question",
8
8
  "description": "根据岗位和候选人背景生成针对性的模拟面试题。",
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "resume_score",
3
+ "description": "简历与 JD 匹配评分",
4
+ "version": "0.1.0",
5
+ "input": {
6
+ "type": "object",
7
+ "required": ["resume", "jd"],
8
+ "properties": {
9
+ "resume": {
10
+ "type": "string",
11
+ "minLength": 20,
12
+ "description": "候选人简历文本"
13
+ },
14
+ "jd": {
15
+ "type": "string",
16
+ "minLength": 20,
17
+ "description": "职位描述文本"
18
+ }
19
+ }
20
+ },
21
+ "output": {
22
+ "type": "object",
23
+ "properties": {
24
+ "score": { "type": "number", "minimum": 0, "maximum": 100 },
25
+ "reasons": { "type": "array", "items": { "type": "string" } },
26
+ "matched": { "type": "array", "items": { "type": "string" } },
27
+ "missing": { "type": "array", "items": { "type": "string" } },
28
+ "years": { "type": "number" }
29
+ }
30
+ },
31
+ "sideEffects": "none",
32
+ "model": "mock-keyword-v1",
33
+ "price": { "amount": 0.02, "currency": "CNY", "unit": "call" },
34
+ "mcp": true,
35
+ "auth": { "type": "api_key" },
36
+ "rateLimit": { "requests": 60, "window": "1m" }
37
+ }
package/lib/mcp-server.js CHANGED
@@ -6,7 +6,8 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
6
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
7
  import { z } from "zod";
8
8
  import { loadSuite } from "./suite.js";
9
- import { scanProject, addTools, redactReport } from "./scan.js";
9
+ import { scanProject, addTools, buildSuiteDraft, redactReport } from "./scan.js";
10
+ import { writeFileAtomic } from "./fsutil.js";
10
11
  import { probeStdioServer } from "./mcp-probe.js";
11
12
  import { addCases, computeCoverage } from "./cases.js";
12
13
 
@@ -31,14 +32,15 @@ export async function startMcpServer() {
31
32
  {
32
33
  title: "Scan tools",
33
34
  description:
34
- "扫描仓库里的 function.json / OpenAPI / MCP 配置 / SKILL.md / 代码内定义。probe=true 时连接 stdio MCP server 拉取 tools/list。只读,不执行工具。",
35
+ "扫描仓库里的 function.json / OpenAPI / MCP 配置 / SKILL.md / 代码内定义。probe=true 时连接 stdio MCP server 拉取 tools/list。不执行工具。默认只读;传 writeSuite 时在该路径写出套件草稿(cases 为空,需补用例并复核)。",
35
36
  inputSchema: {
36
37
  root: z.string().optional().describe("仓库目录,默认进程当前目录"),
37
38
  probe: z.boolean().optional().describe("是否连接 MCP server 拉取工具清单"),
38
- timeoutMs: z.number().optional().describe("单个 MCP server 超时(毫秒,默认 5000)")
39
+ timeoutMs: z.number().optional().describe("单个 MCP server 超时(毫秒,默认 5000)"),
40
+ writeSuite: z.string().optional().describe("套件草稿输出路径,如 mf.suite.json")
39
41
  }
40
42
  },
41
- async ({ root, probe, timeoutMs }) => {
43
+ async ({ root, probe, timeoutMs, writeSuite }) => {
42
44
  const report = await scanProject(root ?? process.cwd());
43
45
  if (probe) {
44
46
  for (const mcpServer of [...report.mcpServers]) {
@@ -60,7 +62,11 @@ export async function startMcpServer() {
60
62
  report.probes.push({ server: mcpServer.name, ok: true, toolCount: added.length, tools: added });
61
63
  }
62
64
  }
63
- return json(redactReport(report));
65
+ const payload = redactReport(report);
66
+ if (!writeSuite) return json(payload);
67
+ const target = resolve(writeSuite);
68
+ await writeFileAtomic(target, JSON.stringify(buildSuiteDraft(report), null, 2));
69
+ return json({ ...payload, suiteDraftPath: target });
64
70
  }
65
71
  );
66
72
 
package/mf.js CHANGED
@@ -46,9 +46,9 @@ Usage:
46
46
  mf mcp # start stdio MCP server for coding agents
47
47
 
48
48
  Eval options:
49
- --suite <path> eval suite (default: cli/fixtures/suite.json)
49
+ --suite <path> eval suite (default: built-in demo suite)
50
50
  --models <ids> comma-separated ids from models.json (default: models with API keys set)
51
- --models-file <path> model registry (default: cli/fixtures/models.json)
51
+ --models-file <path> model registry (default: built-in registry)
52
52
  --case <ids> run only these case ids (comma-separated, repeatable)
53
53
  --show-cases print per-case results
54
54
  --json print JSON instead of the table
@@ -563,7 +563,9 @@ function splitList(value) {
563
563
  const isMain = process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url);
564
564
 
565
565
  if (isMain) {
566
- const argv = process.argv.slice(2);
566
+ let argv = process.argv.slice(2);
567
+ // `npx modelfunction-cli mf scan` passes the bin name through; accept it.
568
+ if (argv[0] === "mf") argv = argv.slice(1);
567
569
  if (argv[0] === "--version" || argv[0] === "-v") {
568
570
  const pkg = JSON.parse(await readFile(new URL("./package.json", import.meta.url), "utf8"));
569
571
  process.stdout.write(`mf ${pkg.version}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modelfunction-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "mf — function-calling accuracy scorecard for AI agents",
@@ -13,7 +13,7 @@
13
13
  "agent"
14
14
  ],
15
15
  "bin": {
16
- "mf": "./mf.js"
16
+ "mf": "mf.js"
17
17
  },
18
18
  "files": [
19
19
  "mf.js",
@@ -9,6 +9,7 @@ description: 为 ModelFunction 评测套件撰写 function-calling 用例。当
9
9
 
10
10
  # 输入
11
11
 
12
+ 0. 还没有套件时:先调 `scan_tools`(`probe=true` 可连 MCP server)并传 `writeSuite: "mf.suite.json"`,得到工具清单草稿,再补用例。
12
13
  1. 工具定义:`mf.scan.json` 或 `mf.suite.json`(只看名字、description、parameters)
13
14
  2. 覆盖率现状:`mf coverage --suite <file> --json`
14
15
  3. 可选:用户提供的真实日志、投诉记录、产品文档