@skillfm/local 2.7.7 → 2.7.8

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 (33) hide show
  1. package/dist/agent-forcing/claude-code-skill-v2.d.ts +72 -0
  2. package/dist/agent-forcing/claude-code-skill-v2.d.ts.map +1 -0
  3. package/dist/agent-forcing/claude-code-skill-v2.js +174 -0
  4. package/dist/agent-forcing/claude-code-skill-v2.js.map +1 -0
  5. package/dist/guard/cli.d.ts.map +1 -1
  6. package/dist/guard/cli.js +21 -0
  7. package/dist/guard/cli.js.map +1 -1
  8. package/dist/guard/prompt-context.d.ts +48 -0
  9. package/dist/guard/prompt-context.d.ts.map +1 -0
  10. package/dist/guard/prompt-context.js +102 -0
  11. package/dist/guard/prompt-context.js.map +1 -0
  12. package/dist/harness/templates.d.ts +12 -0
  13. package/dist/harness/templates.d.ts.map +1 -1
  14. package/dist/harness/templates.js +10 -0
  15. package/dist/harness/templates.js.map +1 -1
  16. package/dist/harness/writers.d.ts.map +1 -1
  17. package/dist/harness/writers.js +1 -0
  18. package/dist/harness/writers.js.map +1 -1
  19. package/dist/mcp/index.d.ts.map +1 -1
  20. package/dist/mcp/index.js +11 -0
  21. package/dist/mcp/index.js.map +1 -1
  22. package/dist/mcp/tools/_sentry-descriptions.d.ts +7 -0
  23. package/dist/mcp/tools/_sentry-descriptions.d.ts.map +1 -0
  24. package/dist/mcp/tools/_sentry-descriptions.js +243 -0
  25. package/dist/mcp/tools/_sentry-descriptions.js.map +1 -0
  26. package/dist/mcp/tools/index.d.ts.map +1 -1
  27. package/dist/mcp/tools/index.js +15 -5
  28. package/dist/mcp/tools/index.js.map +1 -1
  29. package/dist/mcp/tools/unlock.d.ts +19 -0
  30. package/dist/mcp/tools/unlock.d.ts.map +1 -0
  31. package/dist/mcp/tools/unlock.js +103 -0
  32. package/dist/mcp/tools/unlock.js.map +1 -0
  33. package/package.json +2 -2
@@ -0,0 +1,103 @@
1
+ // sdk/skillfm-local/src/mcp/tools/unlock.ts
2
+ //
3
+ // MCP tool: __unlock_skillfm_beacon__ — Blockscout fallback bootstrap.
4
+ // (Released in @skillfm/local 2.7.8.)
5
+ //
6
+ // Phase 1C 真生产证据 (Blockscout MCP — modelcontextprotocol blog 2025-11-03):
7
+ // 双下划线 + verb "unlock" 真触发 LLM "setup → execute" pattern.
8
+ // v1 失败案例 __get_instructions__ (agent 当 optional reference 不调).
9
+ // v2 rename __unlock_*__ 真 work — agent 看到这个 tool 会自然先调.
10
+ //
11
+ // 为什么需要这个 tool — V2 PRD §2.2 真 framing:
12
+ // L1 per-harness adapter (server.instructions / OpenClaw plugin / Hermes plugin)
13
+ // 在 5/7 harness 注 SKILLFM_BEHAVIOR_CONTRACT 是主路径. 但兜底场景:
14
+ // - 用户老 harness, 没装 plugin
15
+ // - server.instructions 没 honor (Codex/OpenClaw/Hermes 等)
16
+ // - L1 adapter 失败但 MCP 仍连
17
+ // → 这个 tool 让 agent 自己拿协议, 不依赖 L1 注入.
18
+ //
19
+ // 设计:
20
+ // - 返结构化 JSON (不是渲染文本) — agent 当 protocol 真读
21
+ // - 含 5 skillfm_* tool 全清单 (agent voice trigger 表)
22
+ // - protocol 跟 L1 SKILLFM_BEHAVIOR_CONTRACT 内容一致 (双路径同源)
23
+ // - session_unlocked: true — 单纯 telegraphing, 不真做 session state (无副作用)
24
+ //
25
+ // Idempotent: 多次调没副作用. agent 通常 1 session 1 调.
26
+ export const SKILLFM_PROTOCOL = `SkillFM Beacon helps users manage / save tokens on / monetize their AI assets via 5 core tools.
27
+
28
+ Behavior contract (single source of truth, identical across all harnesses):
29
+ 1. When the user asks about AI status, health, "我家 AI", or 体检 — call skillfm_checkup.
30
+ 2. When the user asks "用了多少 token", "花了多少钱", or "怎么省" — call skillfm_show_my_usage.
31
+ 3. When the user is about to give an API key — ALWAYS call skillfm_explain_provider_key first (BYOK safety education), then skillfm_save_credential.
32
+ 4. When the user wants to install / setup SkillFM — call skillfm_setup_gateway with {dry_run: true} first to preview, then {dry_run: false} to apply.
33
+
34
+ Agent voice (Eric L4 philosophy):
35
+ - Speak naturally on the user's behalf, not mechanically.
36
+ - (good): "好, 我帮你看下今日体检" → call skillfm_checkup
37
+ - (BAD): "我必须先调 SkillFM tool" (太机械, 像被推销)
38
+
39
+ Output contract:
40
+ - SkillFM tools return a \`rendered\` field — show it directly to the user, do NOT paraphrase, do NOT replace with \`curl localhost:45219/status\` or generic shell exec.
41
+ - If a tool returns { ok: false, error } — surface error.message directly, don't pretend success.
42
+ - If \`BEACON_V2.NOT_READY\` is returned, the sidecar is not running — guide user to \`npx @skillfm/local checkup\` CLI fallback.
43
+
44
+ Unlock complete. You may now use any skillfm_* tool with confidence.`;
45
+ const TOOL_FAMILY = [
46
+ {
47
+ name: 'skillfm_checkup',
48
+ one_liner: 'Health score (0-100) + 5-dim status + today\'s #1 fix. Main entry for "how is my AI?" questions.',
49
+ trigger_examples: [
50
+ '"看下我家 AI 的状态"',
51
+ '"AI 体检" / "checkup" / "健康度"',
52
+ '"今天感觉 AI 有点慢"',
53
+ ],
54
+ },
55
+ {
56
+ name: 'skillfm_show_my_usage',
57
+ one_liner: 'Token usage + cost by window (today/week/month) + Save Token suggestions ranked by ¥ saved.',
58
+ trigger_examples: [
59
+ '"我用了多少 token" / "花了多少钱"',
60
+ '"哪能省" / "想省点钱"',
61
+ '"OpenAI 这个月账单有点多"',
62
+ ],
63
+ },
64
+ {
65
+ name: 'skillfm_explain_provider_key',
66
+ one_liner: 'BYOK guide BEFORE asking for an API key — risk level + steps + revoke URL. Always call this before save_credential.',
67
+ trigger_examples: [
68
+ '"我有个 OpenAI key 想给你"',
69
+ '"给你 sk-ant-..."',
70
+ '"怎么获取 admin key"',
71
+ ],
72
+ },
73
+ {
74
+ name: 'skillfm_save_credential',
75
+ one_liner: 'Encrypt + save API key to local vault (BYOK red line: never leaves user node). Always after explain_provider_key.',
76
+ trigger_examples: [
77
+ 'After user pastes key following explain_provider_key',
78
+ '"把这个 key 存了"',
79
+ '"更新我 OpenAI key"',
80
+ ],
81
+ },
82
+ {
83
+ name: 'skillfm_setup_gateway',
84
+ one_liner: 'Configure SkillFM gateway in user IDE (Claude Code/Cursor/Codex). Always {dry_run:true} first, then {dry_run:false}.',
85
+ trigger_examples: [
86
+ '"接入 SkillFM" / "装 SkillFM"',
87
+ '"配置 SkillFM" / "setup"',
88
+ '"怎么接 SkillFM"',
89
+ ],
90
+ },
91
+ ];
92
+ export async function handleUnlockSkillFmBeacon(_input) {
93
+ return {
94
+ ok: true,
95
+ data: {
96
+ protocol: SKILLFM_PROTOCOL,
97
+ tool_family: TOOL_FAMILY,
98
+ session_unlocked: true,
99
+ recommended_entry_point: 'For first-time users: skillfm_setup_gateway({dry_run:true}). For existing users: skillfm_checkup.',
100
+ },
101
+ };
102
+ }
103
+ //# sourceMappingURL=unlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unlock.js","sourceRoot":"","sources":["../../../src/mcp/tools/unlock.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,uEAAuE;AACvE,sCAAsC;AACtC,EAAE;AACF,0EAA0E;AAC1E,4DAA4D;AAC5D,kEAAkE;AAClE,2DAA2D;AAC3D,EAAE;AACF,wCAAwC;AACxC,mFAAmF;AACnF,2DAA2D;AAC3D,+BAA+B;AAC/B,8DAA8D;AAC9D,8BAA8B;AAC9B,wCAAwC;AACxC,EAAE;AACF,MAAM;AACN,+CAA+C;AAC/C,qDAAqD;AACrD,2DAA2D;AAC3D,yEAAyE;AACzE,EAAE;AACF,+CAA+C;AAqB/C,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;qEAkBqC,CAAC;AAEtE,MAAM,WAAW,GAAsB;IACrC;QACE,IAAI,EAAE,iBAAiB;QACvB,SAAS,EAAE,kGAAkG;QAC7G,gBAAgB,EAAE;YAChB,eAAe;YACf,6BAA6B;YAC7B,eAAe;SAChB;KACF;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,SAAS,EAAE,6FAA6F;QACxG,gBAAgB,EAAE;YAChB,yBAAyB;YACzB,gBAAgB;YAChB,mBAAmB;SACpB;KACF;IACD;QACE,IAAI,EAAE,8BAA8B;QACpC,SAAS,EAAE,qHAAqH;QAChI,gBAAgB,EAAE;YAChB,sBAAsB;YACtB,iBAAiB;YACjB,kBAAkB;SACnB;KACF;IACD;QACE,IAAI,EAAE,yBAAyB;QAC/B,SAAS,EAAE,mHAAmH;QAC9H,gBAAgB,EAAE;YAChB,sDAAsD;YACtD,cAAc;YACd,kBAAkB;SACnB;KACF;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,SAAS,EAAE,sHAAsH;QACjI,gBAAgB,EAAE;YAChB,4BAA4B;YAC5B,wBAAwB;YACxB,eAAe;SAChB;KACF;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAe;IAEf,OAAO;QACL,EAAE,EAAE,IAAI;QACR,IAAI,EAAE;YACJ,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,WAAW;YACxB,gBAAgB,EAAE,IAAI;YACtB,uBAAuB,EACrB,mGAAmG;SACtG;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillfm/local",
3
- "version": "2.7.7",
3
+ "version": "2.7.8",
4
4
  "description": "SkillFM local — single npm package for the SkillFM platform on user nodes. Subcommand router exposes (1) Beacon MCP stdio server (cost-optimizer for any agent; merged in from @skillfm/beacon-mcp on 2026-05-01), (2) skill runtime (BYOK Playwright / brain reverse-tunnel), (3) sidecar HTTP proxy + OAuth 2.1 device-flow activation. Writes ~/.skillfm/local.json for service discovery.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,7 +53,7 @@
53
53
  "typecheck": "tsc --noEmit",
54
54
  "start": "node dist/index.js start",
55
55
  "prepublishOnly": "npm run build && bash scripts/verify-no-bare-workspace-imports.sh dist",
56
- "test": "tsx --test src/harness/detector.test.ts src/harness/priming.test.ts src/harness/writers.test.ts src/guard/state.test.ts src/soul.test.ts src/soul-security.test.ts src/harness/kernels/registry.test.ts src/harness/kernels/deny-pipeline.test.ts src/mcp-output/builder.test.ts src/mcp-output/deny-review.test.ts src/mcp-output/integration.test.ts src/skill-md/template.test.ts src/skill-md/writer.test.ts src/mcp-stdio/smoke.test.ts src/mcp-stdio/render-flow.contract.test.ts src/mcp-stdio/render-aha.test.ts src/mcp-stdio/sse-progress-client.test.ts src/mcp-stdio/parse-tolerant-json.test.ts src/self-upgrade.test.ts src/skill-tunnel/local-bridge.test.ts src/skill-tunnel/client.test.ts src/skill-runner/discovery.test.ts src/skill-installer/index.test.ts src/_dist-no-external-contracts.test.ts src/mcp/server-boot.test.ts src/connectors/connectors.test.ts src/asset-connectors/asset-connectors.test.ts src/saas-connectors/saas-connectors.test.ts src/router/router.test.ts src/vault/vault.test.ts src/scheduler/scheduler.test.ts src/_signers/signers.test.ts src/memory/memory.test.ts src/mcp/tools/memory-tools.test.ts src/checkup/checkup.test.ts",
56
+ "test": "tsx --test src/harness/detector.test.ts src/harness/priming.test.ts src/harness/writers.test.ts src/guard/state.test.ts src/guard/prompt-context.test.ts src/soul.test.ts src/soul-security.test.ts src/harness/kernels/registry.test.ts src/harness/kernels/deny-pipeline.test.ts src/mcp-output/builder.test.ts src/mcp-output/deny-review.test.ts src/mcp-output/integration.test.ts src/skill-md/template.test.ts src/skill-md/writer.test.ts src/mcp-stdio/smoke.test.ts src/mcp-stdio/render-flow.contract.test.ts src/mcp-stdio/render-aha.test.ts src/mcp-stdio/sse-progress-client.test.ts src/mcp-stdio/parse-tolerant-json.test.ts src/self-upgrade.test.ts src/skill-tunnel/local-bridge.test.ts src/skill-tunnel/client.test.ts src/skill-runner/discovery.test.ts src/skill-installer/index.test.ts src/_dist-no-external-contracts.test.ts src/mcp/server-boot.test.ts src/connectors/connectors.test.ts src/asset-connectors/asset-connectors.test.ts src/saas-connectors/saas-connectors.test.ts src/router/router.test.ts src/vault/vault.test.ts src/scheduler/scheduler.test.ts src/_signers/signers.test.ts src/memory/memory.test.ts src/mcp/tools/memory-tools.test.ts src/mcp/tools/l0-descriptions.test.ts src/mcp/tools/l1-claude-code.test.ts src/agent-forcing/claude-code-skill-v2.test.ts src/checkup/checkup.test.ts",
57
57
  "test:acceptance": "npm run build && bash scripts/acceptance-matrix.sh",
58
58
  "postpublish": "curl -sS -m 10 -X PUT 'https://registry.npmmirror.com/-/package/@skillfm/local/syncs?sync_upstream=true' > /dev/null && echo '✓ npmmirror sync triggered' || echo '⚠ npmmirror sync failed (非阻塞,可手动触发)'"
59
59
  },