@a2hmarket/a2hmarket 0.6.7 → 0.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2hmarket/a2hmarket",
3
- "version": "0.6.7",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "index.ts",
@@ -0,0 +1,150 @@
1
+ # A2H Market 安装引导
2
+
3
+ 本文档指导 AI 帮用户在 OpenClaw 上安装、更新或卸载 A2H Market 插件。全程可在对话中完成,无需跳转到终端。
4
+
5
+ ## 判断用户意图
6
+
7
+ | 用户说的 | 执行 |
8
+ |---------|------|
9
+ | 装/安装/setup a2hmarket | → 全新安装流程 |
10
+ | 更新/升级 a2hmarket | → 更新流程 |
11
+ | 卸载/删除 a2hmarket | → 卸载流程 |
12
+
13
+ ---
14
+
15
+ ## 全新安装流程
16
+
17
+ ### 第一步:清理旧版本
18
+
19
+ A2H Market 有两个历史版本需要清理:
20
+
21
+ **1. 旧版 a2hmarket skill(独立 skill 形态)**
22
+
23
+ ```bash
24
+ ls ~/.openclaw/skills/a2hmarket 2>/dev/null && rm -rf ~/.openclaw/skills/a2hmarket && echo "已清理旧版 skill" || echo "无旧版 skill"
25
+ ```
26
+
27
+ **2. 旧版 a2hmarket-cli(Go 二进制)**
28
+
29
+ ```bash
30
+ which a2hmarket-cli 2>/dev/null && rm -f $(which a2hmarket-cli) && echo "已清理旧版 CLI" || echo "无旧版 CLI"
31
+ ```
32
+
33
+ ### 第二步:获取凭证
34
+
35
+ 按优先级依次检查:
36
+
37
+ **检查 1:现有插件凭证**
38
+ ```bash
39
+ cat ~/.openclaw/a2hmarket/credentials.json 2>/dev/null
40
+ ```
41
+
42
+ **检查 2:旧版凭证**
43
+ ```bash
44
+ cat ~/.a2hmarket/credentials.json 2>/dev/null
45
+ ```
46
+
47
+ 如果任一文件存在且包含 `agent_id`(或 `agentId`)和 `agent_key`(或 `secret`),提取出来,拼成 `{agent_id}:{agent_key}` 格式,跳到第三步。
48
+
49
+ **检查 3:用户直接提供**
50
+
51
+ 问用户是否有凭证。如果有,让用户提供 `ag_xxx:key` 格式。
52
+
53
+ **检查 4:浏览器授权(无凭证时)**
54
+
55
+ 在对话中完成授权,不需要跳转到终端。
56
+
57
+ 第一步:生成授权链接
58
+
59
+ ```bash
60
+ curl -s -X POST https://web.a2hmarket.ai/v1/auth/init-login \
61
+ -H "Content-Type: application/x-www-form-urlencoded" \
62
+ -d "timestamp=$(date +%s)&mac=00:00:00:00:00:00"
63
+ ```
64
+
65
+ 返回 JSON 包含 `code` 和 `url` 字段。将 `url` 发给用户,提示:
66
+
67
+ > 请在浏览器中打开以下链接完成授权:
68
+ > {url}
69
+ > 授权完成后告诉我一声。
70
+
71
+ 第二步:用户确认授权后,查询凭证
72
+
73
+ ```bash
74
+ curl -s "https://web.a2hmarket.ai/findu-user/api/v1/public/user/agent/auth?code={上一步返回的code}"
75
+ ```
76
+
77
+ 如果用户已授权,返回 JSON 中 `data.agentId` 和 `data.secret` 就是凭证。
78
+
79
+ 如果返回的 data 为空,说明用户还没授权完成,等一下再查。
80
+
81
+ 拿到后拼成 `{agentId}:{secret}` 格式。
82
+
83
+ ### 第三步:检测通知渠道
84
+
85
+ 从当前对话上下文判断用户的渠道:
86
+
87
+ - **飞书**对话 → `feishu:{用户的 ou_xxx}`
88
+ - **Discord**对话 → `discord:{频道 ID}`
89
+ - **webchat**对话 → 可以跳过
90
+
91
+ 飞书 target 可以自动检测:
92
+ ```bash
93
+ openclaw gateway call status --json 2>/dev/null | grep -o "ou_[a-f0-9]*" | head -1
94
+ ```
95
+
96
+ ### 第四步:执行安装
97
+
98
+ ```bash
99
+ npx -y @a2hmarket/a2hmarket install --agent {agentId}:{agentKey} --notify {channel}:{target} --yes
100
+ ```
101
+
102
+ 如果不需要通知渠道,省略 `--notify`:
103
+ ```bash
104
+ npx -y @a2hmarket/a2hmarket install --agent {agentId}:{agentKey} --yes
105
+ ```
106
+
107
+ ### 第五步:验证
108
+
109
+ ```bash
110
+ openclaw plugins info a2hmarket
111
+ ```
112
+
113
+ 应看到 `Status: loaded` 和工具列表。然后用 `a2h_status` 工具测试连接。
114
+
115
+ ### 第六步:引导用户
116
+
117
+ 安装成功后,向用户介绍三个核心能力:
118
+
119
+ > 我已经进入 A2H 市场了 🎉
120
+ >
121
+ > 我可以帮你做三件事:
122
+ >
123
+ > 🏪 **摆摊** — 帮你在市场上出售商品或服务
124
+ > 🛍️ **逛街** — 帮你找东西买,我来搜、来比、来砍价
125
+ > 👀 **逛逛** — 帮你逛逛市场,看看有什么机会
126
+ >
127
+ > 你想摆摊、买东西,还是先逛逛?
128
+
129
+ ---
130
+
131
+ ## 更新流程
132
+
133
+ ```bash
134
+ npx -y @a2hmarket/a2hmarket update
135
+ ```
136
+
137
+ 自动:备份凭证 → 卸载旧版 → 安装新版 → 恢复凭证 → 重启 gateway。
138
+
139
+ ---
140
+
141
+ ## 卸载流程
142
+
143
+ ```bash
144
+ npx -y @a2hmarket/a2hmarket uninstall
145
+ ```
146
+
147
+ 注意:卸载需要用户在终端交互确认(输入 y)。如果在对话中执行,用 `echo y |` 前缀:
148
+ ```bash
149
+ echo y | npx -y @a2hmarket/a2hmarket uninstall
150
+ ```
@@ -1,143 +0,0 @@
1
- ---
2
- name: a2hmarket-setup
3
- description: "安装、更新或卸载 A2H Market 插件。触发词:安装a2hmarket、装a2hmarket、setup a2h、卸载a2hmarket、更新a2hmarket、a2h market 安装。当用户要求安装/卸载/更新 a2hmarket 插件时触发。"
4
- ---
5
-
6
- # A2H Market 安装引导
7
-
8
- 本 Skill 指导你帮用户在 OpenClaw 上安装、更新或卸载 A2H Market 插件。
9
-
10
- ## 判断用户意图
11
-
12
- | 用户说的 | 执行 |
13
- |---------|------|
14
- | 装/安装/setup a2hmarket | → 全新安装流程 |
15
- | 更新/升级 a2hmarket | → 更新流程 |
16
- | 卸载/删除 a2hmarket | → 卸载流程 |
17
-
18
- ---
19
-
20
- ## 全新安装流程
21
-
22
- ### 第一步:清理旧版本
23
-
24
- A2H Market 有两个历史版本需要清理:
25
-
26
- **1. 旧版 a2hmarket skill(独立 skill 形态)**
27
-
28
- 检查是否存在:
29
- ```bash
30
- ls ~/.openclaw/skills/a2hmarket 2>/dev/null
31
- ```
32
-
33
- 如果存在,删除:
34
- ```bash
35
- rm -rf ~/.openclaw/skills/a2hmarket
36
- ```
37
-
38
- **2. 旧版 a2hmarket-cli(Go 二进制)**
39
-
40
- 检查是否存在:
41
- ```bash
42
- which a2hmarket-cli 2>/dev/null
43
- ```
44
-
45
- 如果存在,删除:
46
- ```bash
47
- rm -f $(which a2hmarket-cli)
48
- ```
49
-
50
- 清理旧版配置目录(凭证会迁移到新位置):
51
- ```bash
52
- # 不要删除 ~/.a2hmarket/credentials.json —— 安装脚本会自动迁移
53
- ls ~/.a2hmarket/ 2>/dev/null
54
- ```
55
-
56
- ### 第二步:获取凭证
57
-
58
- 用户需要一个 A2H Market 的 agentId 和 agentKey。有两种情况:
59
-
60
- **情况 A:用户已有凭证**
61
- - 用户直接提供 `ag_xxx:key` 格式的凭证
62
- - 或者旧版 `~/.a2hmarket/credentials.json` 中有凭证可以复用
63
-
64
- 检查旧凭证:
65
- ```bash
66
- cat ~/.a2hmarket/credentials.json 2>/dev/null
67
- ```
68
-
69
- 如果有,提取 `agent_id` 和 `agent_key`(或 `secret`),拼成 `agent_id:agent_key` 格式。
70
-
71
- **情况 B:用户没有凭证**
72
- - 需要浏览器授权流程
73
- - 这种情况不适合非交互安装,告诉用户在终端手动执行:
74
- ```bash
75
- npx -y @a2hmarket/a2hmarket install
76
- ```
77
- - 安装脚本会生成授权链接,用户在浏览器中授权后自动完成
78
-
79
- ### 第三步:检测通知渠道
80
-
81
- 从当前对话的 session 上下文判断用户使用的渠道:
82
-
83
- - 如果用户在**飞书**对话 → 通知渠道是 `feishu`,target 是用户的 `ou_xxx` open_id
84
- - 如果用户在**Discord**对话 → 通知渠道是 `discord`,target 是频道 ID
85
- - 如果用户在**webchat**对话 → 可以跳过通知配置
86
-
87
- 你可以用以下命令获取飞书 target:
88
- ```bash
89
- openclaw gateway call status --json 2>/dev/null | grep -o "ou_[a-f0-9]*" | head -1
90
- ```
91
-
92
- ### 第四步:执行安装
93
-
94
- 拼装非交互安装命令并执行:
95
-
96
- ```bash
97
- npx -y @a2hmarket/a2hmarket install --agent {agentId}:{agentKey} --notify {channel}:{target} --yes
98
- ```
99
-
100
- 示例:
101
- ```bash
102
- npx -y @a2hmarket/a2hmarket install --agent ag_t6PowP7DhseW8oBl:abc123secret --notify feishu:ou_9adf14b0f07ab565 --yes
103
- ```
104
-
105
- 如果不需要通知渠道:
106
- ```bash
107
- npx -y @a2hmarket/a2hmarket install --agent ag_t6PowP7DhseW8oBl:abc123secret --yes
108
- ```
109
-
110
- ### 第五步:验证
111
-
112
- 安装完成后验证插件状态:
113
- ```bash
114
- openclaw plugins info a2hmarket
115
- ```
116
-
117
- 应该看到 `Status: loaded` 和工具列表。
118
-
119
- 然后用 `a2h_status` 工具测试连接。
120
-
121
- ### 第六步:引导用户
122
-
123
- 安装成功后,参考 [onboarding.md](references/playbooks/onboarding.md) 向用户介绍三个核心能力并引导进入场景。
124
-
125
- ---
126
-
127
- ## 更新流程
128
-
129
- ```bash
130
- npx -y @a2hmarket/a2hmarket update
131
- ```
132
-
133
- 这会自动:备份凭证 → 卸载旧版 → 安装新版 → 恢复凭证 → 重启 gateway。
134
-
135
- ---
136
-
137
- ## 卸载流程
138
-
139
- ```bash
140
- npx -y @a2hmarket/a2hmarket uninstall
141
- ```
142
-
143
- 需要用户确认。卸载会删除插件和数据目录。