memi-agent 1.0.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/README.md +90 -0
- package/memi-agent.js +1364 -0
- package/memi-client/README.md +43 -0
- package/memi-client/dist/assets/index-CmQIBT8Z.js +210 -0
- package/memi-client/dist/assets/index-Djh6rbJ-.css +1 -0
- package/memi-client/dist/index.html +13 -0
- package/memi-config/workspace/IDENTITY.md +5 -0
- package/memi-config/workspace/MEMORY.md +3 -0
- package/memi-config/workspace/SOUL.md +4 -0
- package/memi-config/workspace/TOOLS.md +3 -0
- package/memi-config/workspace/USER.md +3 -0
- package/memi-dashboard.html +359 -0
- package/memi-server/README.md +56 -0
- package/memi-server/gateway.js +532 -0
- package/memi-server/index.js +152 -0
- package/memi-server/package-lock.json +1658 -0
- package/memi-server/package.json +16 -0
- package/memi-server/routes/api.js +744 -0
- package/memi-server/utils/agent.js +1068 -0
- package/memi-server/utils/aiProxy.js +871 -0
- package/memi-server/utils/importSkill.js +74 -0
- package/package.json +27 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// ─── 从 GitHub URL 导入技能 ─────────────────────────
|
|
2
|
+
const axios = require("axios");
|
|
3
|
+
|
|
4
|
+
async function importSkillFromUrl(url) {
|
|
5
|
+
if (!url || typeof url !== "string") throw new Error("请提供 URL");
|
|
6
|
+
const trimmed = url.trim();
|
|
7
|
+
if (!trimmed.startsWith("http")) throw new Error("无效的 URL");
|
|
8
|
+
|
|
9
|
+
// 转换为 raw URL
|
|
10
|
+
let rawUrl = trimmed;
|
|
11
|
+
const blobMatch = trimmed.match(/github\.com\/([^/]+)\/([^/]+)\/blob\/(.+)/);
|
|
12
|
+
if (blobMatch) {
|
|
13
|
+
rawUrl = `https://raw.githubusercontent.com/${blobMatch[1]}/${blobMatch[2]}/${blobMatch[3]}`;
|
|
14
|
+
}
|
|
15
|
+
const gistMatch = trimmed.match(/gist\.github\.com\/([^/]+)\/([a-f0-9]+)/);
|
|
16
|
+
if (gistMatch) {
|
|
17
|
+
rawUrl = `https://gist.githubusercontent.com/${gistMatch[1]}/${gistMatch[2]}/raw`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const response = await axios.get(rawUrl, {
|
|
21
|
+
headers: { "User-Agent": "MemiAgent/1.0" },
|
|
22
|
+
timeout: 20000,
|
|
23
|
+
responseType: "text",
|
|
24
|
+
});
|
|
25
|
+
const content = String(response.data || "");
|
|
26
|
+
|
|
27
|
+
// 尝试 JSON 解析
|
|
28
|
+
try {
|
|
29
|
+
const json = JSON.parse(content);
|
|
30
|
+
if (json.name && json.promptTemplate) {
|
|
31
|
+
return {
|
|
32
|
+
name: json.name,
|
|
33
|
+
nameEn: json.nameEn || json.name,
|
|
34
|
+
type: json.type || "llm",
|
|
35
|
+
description: json.description || "",
|
|
36
|
+
descriptionEn: json.descriptionEn || json.description || "",
|
|
37
|
+
promptTemplate: json.promptTemplate || "",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
} catch {}
|
|
41
|
+
|
|
42
|
+
// 尝试 Markdown 解析
|
|
43
|
+
const lines = content.split("\n");
|
|
44
|
+
const meta = {};
|
|
45
|
+
const bodyLines = [];
|
|
46
|
+
let inBody = false;
|
|
47
|
+
let nameFromTitle = "";
|
|
48
|
+
|
|
49
|
+
for (const line of lines) {
|
|
50
|
+
const t = line.trim();
|
|
51
|
+
if (t.startsWith("# ") && !inBody) { nameFromTitle = t.slice(2).trim(); continue; }
|
|
52
|
+
if (t.startsWith("## ") && !inBody) { meta.description = t.slice(3).trim(); continue; }
|
|
53
|
+
const kv = t.match(/^(\w+):\s*(.+)/);
|
|
54
|
+
if (kv && !inBody) { meta[kv[1]] = kv[2].trim(); continue; }
|
|
55
|
+
if (t === "---") { inBody = !inBody; continue; }
|
|
56
|
+
if (inBody || (!kv && t)) bodyLines.push(line);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const body = bodyLines.join("\n").trim();
|
|
60
|
+
if (meta.promptTemplate || body) {
|
|
61
|
+
return {
|
|
62
|
+
name: meta.name || nameFromTitle || "Imported Skill",
|
|
63
|
+
nameEn: meta.nameEn || meta.name || nameFromTitle || "Imported Skill",
|
|
64
|
+
type: meta.type || "llm",
|
|
65
|
+
description: meta.description || "",
|
|
66
|
+
descriptionEn: meta.descriptionEn || meta.description || "",
|
|
67
|
+
promptTemplate: meta.promptTemplate || body,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
throw new Error("无法解析技能定义。请确保文件包含 JSON 或 Markdown 格式");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = { importSkillFromUrl };
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "memi-agent",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "本地 AI 助手 — 终端 + 网页双模式,63 个工具,80+ 提供商,4 个消息渠道",
|
|
5
|
+
"bin": { "memi": "memi-agent.js" },
|
|
6
|
+
"files": [
|
|
7
|
+
"memi-agent.js",
|
|
8
|
+
"README.md",
|
|
9
|
+
"memi-dashboard.html",
|
|
10
|
+
"memi-server/index.js",
|
|
11
|
+
"memi-server/gateway.js",
|
|
12
|
+
"memi-server/package.json",
|
|
13
|
+
"memi-server/package-lock.json",
|
|
14
|
+
"memi-server/routes/api.js",
|
|
15
|
+
"memi-server/utils/agent.js",
|
|
16
|
+
"memi-server/utils/aiProxy.js",
|
|
17
|
+
"memi-server/utils/importSkill.js",
|
|
18
|
+
"memi-client/dist/",
|
|
19
|
+
"memi-config/workspace/"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"postinstall": "cd memi-server && npm install --omit=dev"
|
|
23
|
+
},
|
|
24
|
+
"keywords": ["ai", "agent", "cli", "llm", "deepseek", "openai"],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"engines": { "node": ">=18" }
|
|
27
|
+
}
|