libero-mcp 0.2.2 → 0.2.3

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/COLD_START.md CHANGED
@@ -1,15 +1,15 @@
1
- # libero 冷启动(装机后、reload 前)
1
+ # libero 冷启动(host agent 专用,不是用户手册)
2
2
 
3
- > Hermes / OpenClaw 等 host agent 读。装完包后**先把下面欢迎发给用户**,再 `/reload-mcp`。
3
+ > **禁止**把本文当成用户步骤(「请你让 agent 读这个文件」= 产品失败)。
4
+ > 用户只说「帮我装 libero」或跑 `npm i -g libero-mcp@latest`。欢迎必须由 host **自动**发出。
4
5
 
5
- ## 装机顺序
6
+ ## Host 在装机时自动做
6
7
 
7
- 1. `npm i -g libero-mcp@latest`
8
- 2. 配置 `mcp_servers.libero.command: libero-mcp`(如需)
9
- 3. **先介绍**:把「欢迎原文」原样发给用户(不要列工具名、不要问 user_id)
10
- 4. **再刷新**:`/reload-mcp`(或等价)挂上工具
8
+ 1. `npm i -g libero-mcp@latest`(postinstall 会在 stderr 打印 `LIBERO_HOST_ACTION` + 欢迎原文)
9
+ 2. **立刻**把欢迎原文作为下一条对用户的回复发出(不要列工具、不要问 user_id)
10
+ 3. 再写 `mcp_servers.libero.command: libero-mcp`(如需)并 `/reload-mcp`
11
11
 
12
- ## 欢迎原文(原样发给用户)
12
+ ## 欢迎原文
13
13
 
14
14
  ```
15
15
  你好,我是 libero,帮你管时间和精力。
package/README.md CHANGED
@@ -10,43 +10,25 @@ AI 辅助的精力管理教练:观察实绩 → 发现问题 → 对齐方案
10
10
  npm i -g libero-mcp@latest
11
11
  ```
12
12
 
13
- ### 给 host agent(Hermes / OpenClaw)的装机顺序
13
+ 或对你的 agent 说一句:**帮我装 libero**。
14
14
 
15
- 1. 装包并写好 MCP 配置
16
- 2. **先介绍**:把 [`COLD_START.md`](COLD_START.md) 里的欢迎原文发给用户(不要列工具、不要问 user_id)
17
- 3. **再刷新**:`/reload-mcp`(或等价)挂上工具
15
+ 装完后你会直接看到欢迎与试用例句(计时 / 日程 / 拆任务 / 看数据 / 复盘)。
16
+ 不需要再配置、不需要起 user_id、不需要提醒 agent「去读某个文件」。
18
17
 
19
- 用户装完后应直接看到欢迎与试用例句,而不是配置问卷。
20
-
21
- ### 用户怎么试
22
-
23
- 装完后直接说:
18
+ 试试说:
24
19
 
25
20
  > 开始计时写代码
26
21
 
27
- 或:
28
-
29
- > 这周时间都花哪儿了?帮我复盘一下
30
-
31
22
  ## 能说什么
32
23
 
33
24
  | 想做的事 | 这样说 |
34
25
  |---|---|
35
26
  | 开始一段专注 | "开始计时写代码" / "开个 25 分钟番茄钟读书" |
36
27
  | 停下来 | "停一下" / "看看今天计了多久" |
37
- | 安排日程 | "明天 9 点到 11 点写报告" / "下周二下午开会" |
38
- | 看时间分布 | "这周时间都花哪儿了" / "看看今天的四象限" |
39
- | 复盘 | "复盘一下这周" / "帮我分析最近的时间使用" |
28
+ | 安排日程 | "明天 9 点到 11 点写报告" |
29
+ | 看时间分布 | "这周时间都花哪儿了" |
30
+ | 复盘 | "复盘一下这周" |
40
31
  | 拆任务 | "这个任务太大,帮我拆一下" |
41
- | 安排提醒 | "明天 8 点提醒我打卡" |
42
-
43
- ## 数据存在哪
44
-
45
- 默认在 `~/.libero/libero.db`(SQLite)。想换位置:
46
-
47
- ```bash
48
- DB_PATH=/your/path.db libero-mcp
49
- ```
50
32
 
51
33
  ## 升级
52
34
 
@@ -54,11 +36,8 @@ DB_PATH=/your/path.db libero-mcp
54
36
  npm update -g libero-mcp
55
37
  ```
56
38
 
57
- DB schema 升级在启动时自动跑,不用手工干预。
58
-
59
- ## 给开发者
39
+ ## 给开发者 / host 实现者
60
40
 
61
- - 冷启动文案:[COLD_START.md](COLD_START.md)(与 MCP `instructions` 同源)
41
+ - Host 装机自动行为见 [COLD_START.md](COLD_START.md)(**不是**用户步骤)
62
42
  - 协作宪法:[AGENTS.md](AGENTS.md)
63
- - 部署细节:[docs/operations/deploy-to-hermes.md](docs/operations/deploy-to-hermes.md)
64
- - Skills:`skills/`(libero-coach / libero-record / libero-onboarding / libero-decompose)
43
+ - 排查:[docs/operations/deploy-to-hermes.md](docs/operations/deploy-to-hermes.md)
@@ -1,13 +1,9 @@
1
1
  /**
2
2
  * Cold-start copy for host agents (Hermes / OpenClaw) and MCP server instructions.
3
3
  *
4
- * Timing (user perspective):
5
- * 1. After npm install / config written
6
- * 2. FIRST show COLD_START_WELCOME to the user (before tools are live)
7
- * 3. THEN /reload-mcp (or equivalent) to attach tools
8
- *
9
- * MCP cannot push a chat message by itself — hosts must speak this text in the
10
- * install turn. Server `instructions` reinforce the same rules after connect.
4
+ * User perspective: one line `npm i -g` or "帮我装 libero" → welcome appears.
5
+ * Host perspective: postinstall prints LIBERO_HOST_ACTION; host relays welcome,
6
+ * then /reload-mcp. Never ask the human to coach the agent.
11
7
  */
12
8
  /** Short welcome users should see (natural language only). */
13
9
  export const COLD_START_WELCOME = `你好,我是 libero,帮你管时间和精力。
@@ -28,23 +24,20 @@ export function buildServerInstructions() {
28
24
  return [
29
25
  "# libero — 时间与精力管理助手",
30
26
  "",
31
- "## 装机顺序(硬规矩)",
32
- "1. npm i -g libero-mcp@latest 配置好 mcp_servers 后:",
33
- "2. **先介绍**:把下面「冷启动欢迎」原样发给用户(不要列工具名 / 不要问配置)",
34
- "3. **再 reload**:用户看完介绍后,再执行 /reload-mcp(或等价刷新)挂上工具",
35
- "4. 禁止在介绍或首次对话里索取 user_id / DB_PATH / YAML",
27
+ "## 装机(对 host agent,不是对用户)",
28
+ "用户只说「帮我装 libero」或跑 npm i -g。**禁止**让用户再提醒你读 md / 执行命令。",
29
+ "npm postinstall 会打印 LIBERO_HOST_ACTION + 欢迎原文:你的**下一条对用户回复**必须是该欢迎,然后再 /reload-mcp。",
30
+ "禁止问 user_id;禁止列工具表。",
36
31
  "",
37
32
  "## 冷启动欢迎(原样发给用户)",
38
33
  COLD_START_WELCOME,
39
34
  "",
40
35
  "## user_id(硬纪律)",
41
- "- 调用任何需要 user_id 的工具时:从当前会话上下文静默取(平台用户 ID / 会话稳定 ID)",
42
- "- 取不到时用稳定占位 local:default",
43
- "- **禁止问用户起 user_id**;禁止输出 wechat_你的ID / test_1 这类工程师问卷",
44
- "- 可选问称呼(display_name),一句即可,可跳过",
36
+ "- 从当前会话上下文静默取;取不到用 local:default",
37
+ "- **禁止问用户起 user_id**;禁止 wechat_你的ID / test_1 问卷",
45
38
  "",
46
39
  "## 对用户说话",
47
40
  "- 只说自然语言能做什么;不要提 MCP / 工具表 / schema / 数据库",
48
- "- 用户选了试用例句 → 直接执行对应能力,不要重复整段介绍",
41
+ "- 用户选了试用例句 → 直接执行,不要重复整段介绍",
49
42
  ].join("\n");
50
43
  }
@@ -47,7 +47,7 @@ export function buildServer(db) {
47
47
  const scheduler = createSchedulerTools(timeblockRepo, reminderRepo, categoryRepo);
48
48
  const task = createTaskTools(db);
49
49
  // instructions 必须放在第 2 参 ServerOptions(不是 serverInfo)—— SDK 只从 options 读
50
- const server = new McpServer({ name: "libero-mcp", version: "0.2.2" }, { instructions: buildServerInstructions() });
50
+ const server = new McpServer({ name: "libero-mcp", version: "0.2.3" }, { instructions: buildServerInstructions() });
51
51
  // ============================================================
52
52
  // categories (2 tools)
53
53
  // ============================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libero-mcp",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "AI 时间管理教练 MCP 工具集——时间块记录、统计、矩阵诊断、计时、分类、profile",
5
5
  "license": "MIT",
6
6
  "author": "amosyuan",
@@ -32,6 +32,7 @@
32
32
  "format:check": "prettier --check .",
33
33
  "db:init": "tsx data/db.ts",
34
34
  "build": "tsc -p tsconfig.build.json && cp -r data/migrations dist/data/ && cp data/schema.sql dist/data/",
35
+ "postinstall": "node scripts/postinstall-cold-start.js",
35
36
  "prepublishOnly": "npm test && npm run build",
36
37
  "knowledge:validate": "tsx knowledge/validate.ts",
37
38
  "case:panel": "tsx eval/case-panel/server.ts"
@@ -40,7 +41,8 @@
40
41
  "dist",
41
42
  "data/migrations",
42
43
  "data/schema.sql",
43
- "COLD_START.md"
44
+ "COLD_START.md",
45
+ "scripts/postinstall-cold-start.js"
44
46
  ],
45
47
  "dependencies": {
46
48
  "@modelcontextprotocol/sdk": "^1.29.0",
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * postinstall — print cold-start for the *installing host agent* (Hermes/OpenClaw).
4
+ * End users never need to remember this; the host must relay the welcome as its
5
+ * next chat message, then reload MCP. Do not ask the human to coach the agent.
6
+ */
7
+ import { readFileSync, existsSync } from "node:fs";
8
+ import { dirname, join } from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+
11
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
12
+ const welcomePath = join(root, "COLD_START.md");
13
+
14
+ const FALLBACK_WELCOME = `你好,我是 libero,帮你管时间和精力。
15
+
16
+ 常用这几件事,直接说就行:
17
+ • 计时:「开始计时写代码」/「开个 25 分钟番茄钟」
18
+ • 日程:「明天 9 点到 11 点写报告」
19
+ • 拆任务:「这个太大了,帮我拆一下」
20
+ • 看数据:「这周时间都花哪儿了」
21
+ • 复盘:「帮我复盘一下这周」
22
+
23
+ 想先试哪一句?`;
24
+
25
+ function extractWelcome(md) {
26
+ const m = md.match(/```\n([\s\S]*?)\n```/);
27
+ return m ? m[1].trim() : FALLBACK_WELCOME;
28
+ }
29
+
30
+ const welcome = existsSync(welcomePath)
31
+ ? extractWelcome(readFileSync(welcomePath, "utf-8"))
32
+ : FALLBACK_WELCOME;
33
+
34
+ // Markers are for the installing agent reading npm output — never for the human checklist.
35
+ process.stderr.write(`
36
+ ========== LIBERO_HOST_ACTION (installing agent only) ==========
37
+ Your NEXT message to the human MUST be the welcome block below (verbatim).
38
+ Do NOT ask for user_id. Do NOT list MCP tools / schemas.
39
+ THEN configure mcp_servers.libero (command: libero-mcp) if needed and /reload-mcp.
40
+ The human must NOT be told to "read a md" or "remind the agent".
41
+ ---------- welcome (send to human) ----------
42
+ ${welcome}
43
+ ---------- end welcome ----------
44
+ ===============================================================
45
+ `);