easyclaw-link 1.1.0 → 1.2.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 +31 -42
- package/dist/index.js +3146 -45
- package/package.json +13 -9
- package/dist/commands/bid.d.ts +0 -2
- package/dist/commands/bid.js +0 -108
- package/dist/commands/credits.d.ts +0 -2
- package/dist/commands/credits.js +0 -34
- package/dist/commands/list.d.ts +0 -2
- package/dist/commands/list.js +0 -51
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.js +0 -82
- package/dist/commands/publish.d.ts +0 -6
- package/dist/commands/publish.js +0 -119
- package/dist/commands/tasks.d.ts +0 -2
- package/dist/commands/tasks.js +0 -58
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/commands/whoami.js +0 -28
- package/dist/config.d.ts +0 -9
- package/dist/config.js +0 -77
- package/dist/index.d.ts +0 -3
- package/src/commands/bid.ts +0 -93
- package/src/commands/credits.ts +0 -63
- package/src/commands/list.ts +0 -70
- package/src/commands/login.ts +0 -53
- package/src/commands/publish.ts +0 -107
- package/src/commands/tasks.ts +0 -84
- package/src/commands/whoami.ts +0 -45
- package/src/config.ts +0 -45
- package/src/index.ts +0 -55
- package/tsconfig.json +0 -18
package/package.json
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easyclaw-link",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "EasyClaw Link CLI - Publish and manage skills on easyclaw.link",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"easyclaw-link": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "
|
|
10
|
+
"build": "esbuild src/index.ts --bundle --platform=node --target=node18 --outfile=dist/index.js --banner:js='#!/usr/bin/env node'",
|
|
11
11
|
"dev": "tsc --watch",
|
|
12
12
|
"prepublishOnly": "npm run build"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
|
-
"easyclaw",
|
|
16
15
|
"easyclaw-link",
|
|
17
16
|
"cli",
|
|
18
|
-
"skills"
|
|
17
|
+
"skills",
|
|
18
|
+
"ai-agent"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/"
|
|
19
25
|
],
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"homepage": "https://easyclaw.link",
|
|
22
26
|
"dependencies": {
|
|
23
|
-
"commander": "^
|
|
24
|
-
"fflate": "^0.8.2"
|
|
27
|
+
"commander": "^11.1.0"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
|
-
"@types/node": "^20.
|
|
30
|
+
"@types/node": "^20.0.0",
|
|
31
|
+
"esbuild": "^0.20.0",
|
|
28
32
|
"typescript": "^5.3.0"
|
|
29
33
|
}
|
|
30
34
|
}
|
package/dist/commands/bid.d.ts
DELETED
package/dist/commands/bid.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.bidAction = bidAction;
|
|
37
|
-
const readline = __importStar(require("readline"));
|
|
38
|
-
const config_1 = require("../config");
|
|
39
|
-
function prompt(question) {
|
|
40
|
-
const rl = readline.createInterface({
|
|
41
|
-
input: process.stdin,
|
|
42
|
-
output: process.stdout,
|
|
43
|
-
});
|
|
44
|
-
return new Promise((resolve) => {
|
|
45
|
-
rl.question(question, (answer) => {
|
|
46
|
-
rl.close();
|
|
47
|
-
resolve(answer.trim());
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
async function bidAction(taskId) {
|
|
52
|
-
const apiKey = (0, config_1.requireApiKey)();
|
|
53
|
-
const id = parseInt(taskId, 10);
|
|
54
|
-
if (isNaN(id) || id <= 0) {
|
|
55
|
-
console.error("❌ 无效的任务 ID,请传入数字 ID(例如:npx easyclaw-link bid 42)");
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
// Fetch bounty info first
|
|
59
|
-
const infoRes = await fetch(`${config_1.BASE_URL}/api/bounties/${id}`, {
|
|
60
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
61
|
-
});
|
|
62
|
-
if (!infoRes.ok) {
|
|
63
|
-
if (infoRes.status === 404) {
|
|
64
|
-
console.error(`❌ 任务 #${id} 不存在`);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
console.error(`❌ 获取任务信息失败 (${infoRes.status})`);
|
|
68
|
-
}
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
const { bounty } = (await infoRes.json());
|
|
72
|
-
if (bounty.status !== "open") {
|
|
73
|
-
console.error(`❌ 任务 #${id} 已关闭(当前状态:${bounty.status})`);
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
console.log(`📋 任务详情`);
|
|
77
|
-
console.log(`ID: ${bounty.id}`);
|
|
78
|
-
console.log(`标题: ${bounty.title}`);
|
|
79
|
-
console.log(`奖励: ${bounty.reward} 🦞`);
|
|
80
|
-
if (bounty.expires_at) {
|
|
81
|
-
console.log(`截止: ${new Date(bounty.expires_at).toLocaleString("zh-CN")}`);
|
|
82
|
-
}
|
|
83
|
-
console.log(`\n${bounty.description}\n`);
|
|
84
|
-
const content = await prompt("📝 请输入你的申请内容(描述你的方案/能力): ");
|
|
85
|
-
if (!content) {
|
|
86
|
-
console.error("❌ 申请内容不能为空");
|
|
87
|
-
process.exit(1);
|
|
88
|
-
}
|
|
89
|
-
console.log("\n⏳ 正在提交申请...");
|
|
90
|
-
const res = await fetch(`${config_1.BASE_URL}/api/bounties/${id}/submit`, {
|
|
91
|
-
method: "POST",
|
|
92
|
-
headers: {
|
|
93
|
-
Authorization: `Bearer ${apiKey}`,
|
|
94
|
-
"Content-Type": "application/json",
|
|
95
|
-
},
|
|
96
|
-
body: JSON.stringify({ content }),
|
|
97
|
-
});
|
|
98
|
-
if (!res.ok) {
|
|
99
|
-
const body = await res.json().catch(() => ({}));
|
|
100
|
-
const msg = typeof body.error === "string" ? body.error : `HTTP ${res.status}`;
|
|
101
|
-
console.error(`❌ 提交失败: ${msg}`);
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
|
-
const { submission } = (await res.json());
|
|
105
|
-
console.log(`✅ 申请提交成功!提交 ID: ${submission.id}`);
|
|
106
|
-
console.log(`🔗 查看任务: ${config_1.BASE_URL}/bounties/${id}`);
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=bid.js.map
|
package/dist/commands/credits.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.creditsAction = creditsAction;
|
|
4
|
-
const config_1 = require("../config");
|
|
5
|
-
async function creditsAction() {
|
|
6
|
-
const apiKey = (0, config_1.requireApiKey)();
|
|
7
|
-
const res = await fetch(`${config_1.BASE_URL}/api/credits`, {
|
|
8
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
9
|
-
});
|
|
10
|
-
if (!res.ok) {
|
|
11
|
-
const body = await res.text();
|
|
12
|
-
console.error(`❌ 请求失败 (${res.status}): ${body}`);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
const data = (await res.json());
|
|
16
|
-
console.log(`💰 龙虾币余额: ${data.credits} 🦞`);
|
|
17
|
-
console.log(`⭐ 声望: ${data.reputation} ${data.level.badge} ${data.level.name}\n`);
|
|
18
|
-
const recentTxs = data.transactions.slice(0, 10);
|
|
19
|
-
if (recentTxs.length === 0) {
|
|
20
|
-
console.log("📭 暂无收支记录");
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
console.log("最近收支记录:");
|
|
24
|
-
console.log("-".repeat(64));
|
|
25
|
-
for (const tx of recentTxs) {
|
|
26
|
-
const sign = tx.amount >= 0 ? "+" : "";
|
|
27
|
-
const amountStr = `${sign}${tx.amount}`.padStart(6);
|
|
28
|
-
const date = new Date(tx.created_at).toLocaleDateString("zh-CN");
|
|
29
|
-
const note = tx.note || tx.ref_type || tx.type;
|
|
30
|
-
console.log(`${date} ${amountStr} 🦞 ${note}`);
|
|
31
|
-
}
|
|
32
|
-
console.log(`\n共 ${data.transactions.length} 条记录,显示最近 ${recentTxs.length} 条`);
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=credits.js.map
|
package/dist/commands/list.d.ts
DELETED
package/dist/commands/list.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listAction = listAction;
|
|
4
|
-
const config_1 = require("../config");
|
|
5
|
-
async function listAction() {
|
|
6
|
-
const apiKey = (0, config_1.requireApiKey)();
|
|
7
|
-
console.log("⏳ 获取技能列表...\n");
|
|
8
|
-
const res = await fetch(`${config_1.BASE_URL}/api/assets?author=me`, {
|
|
9
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
10
|
-
});
|
|
11
|
-
if (!res.ok) {
|
|
12
|
-
const body = await res.text();
|
|
13
|
-
console.error(`❌ 获取失败 (${res.status}): ${body}`);
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
const { assets } = (await res.json());
|
|
17
|
-
if (!assets || assets.length === 0) {
|
|
18
|
-
console.log("📭 暂无技能,使用 npx easyclaw-link publish 发布你的第一个技能");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
// Print table header
|
|
22
|
-
const idWidth = 8;
|
|
23
|
-
const titleWidth = 36;
|
|
24
|
-
const statusWidth = 12;
|
|
25
|
-
const callsWidth = 8;
|
|
26
|
-
const header = [
|
|
27
|
-
"ID".padEnd(idWidth),
|
|
28
|
-
"Title".padEnd(titleWidth),
|
|
29
|
-
"Status".padEnd(statusWidth),
|
|
30
|
-
"Calls".padEnd(callsWidth),
|
|
31
|
-
].join(" | ");
|
|
32
|
-
const separator = [
|
|
33
|
-
"-".repeat(idWidth),
|
|
34
|
-
"-".repeat(titleWidth),
|
|
35
|
-
"-".repeat(statusWidth),
|
|
36
|
-
"-".repeat(callsWidth),
|
|
37
|
-
].join("-+-");
|
|
38
|
-
console.log(header);
|
|
39
|
-
console.log(separator);
|
|
40
|
-
for (const asset of assets) {
|
|
41
|
-
const row = [
|
|
42
|
-
String(asset.id ?? "").padEnd(idWidth),
|
|
43
|
-
(asset.title || "").slice(0, titleWidth).padEnd(titleWidth),
|
|
44
|
-
(asset.status || "").padEnd(statusWidth),
|
|
45
|
-
String(asset.calls ?? 0).padEnd(callsWidth),
|
|
46
|
-
].join(" | ");
|
|
47
|
-
console.log(row);
|
|
48
|
-
}
|
|
49
|
-
console.log(`\n共 ${assets.length} 个技能`);
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=list.js.map
|
package/dist/commands/login.d.ts
DELETED
package/dist/commands/login.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.loginAction = loginAction;
|
|
37
|
-
const readline = __importStar(require("readline"));
|
|
38
|
-
const config_1 = require("../config");
|
|
39
|
-
function prompt(question) {
|
|
40
|
-
const rl = readline.createInterface({
|
|
41
|
-
input: process.stdin,
|
|
42
|
-
output: process.stdout,
|
|
43
|
-
});
|
|
44
|
-
return new Promise((resolve) => {
|
|
45
|
-
rl.question(question, (answer) => {
|
|
46
|
-
rl.close();
|
|
47
|
-
resolve(answer.trim());
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
async function verifyApiKey(apiKey) {
|
|
52
|
-
try {
|
|
53
|
-
const res = await fetch(`${config_1.BASE_URL}/api/assets?author=me`, {
|
|
54
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
55
|
-
});
|
|
56
|
-
return res.ok;
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
async function loginAction() {
|
|
63
|
-
console.log("🔑 登录 EasyClaw 平台\n");
|
|
64
|
-
const apiKey = await prompt("请输入 API Key (eck_xxx): ");
|
|
65
|
-
if (!apiKey) {
|
|
66
|
-
console.error("❌ API Key 不能为空");
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
if (!apiKey.startsWith("eck_")) {
|
|
70
|
-
console.error("❌ API Key 格式不正确,应以 eck_ 开头");
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
console.log("⏳ 验证 API Key...");
|
|
74
|
-
const valid = await verifyApiKey(apiKey);
|
|
75
|
-
if (!valid) {
|
|
76
|
-
console.error("❌ API Key 无效,请检查后重试");
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
(0, config_1.writeConfig)({ apiKey });
|
|
80
|
-
console.log("✅ 登录成功!API Key 已保存到 ~/.easyclaw/config.json");
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=login.js.map
|
package/dist/commands/publish.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.publishAction = publishAction;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const config_1 = require("../config");
|
|
40
|
-
async function publishAction(dir, options) {
|
|
41
|
-
const apiKey = (0, config_1.requireApiKey)();
|
|
42
|
-
const targetDir = path.resolve(dir || ".");
|
|
43
|
-
// Read SKILL.md (required)
|
|
44
|
-
const skillMdPath = path.join(targetDir, "SKILL.md");
|
|
45
|
-
if (!fs.existsSync(skillMdPath)) {
|
|
46
|
-
console.error(`❌ 未找到 ${skillMdPath}`);
|
|
47
|
-
console.error(" publish 需要目录中包含 SKILL.md 文件");
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
const content = fs.readFileSync(skillMdPath, "utf-8");
|
|
51
|
-
// Read package.json (optional)
|
|
52
|
-
let pkgName;
|
|
53
|
-
let pkgVersion;
|
|
54
|
-
let pkgDescription;
|
|
55
|
-
const pkgJsonPath = path.join(targetDir, "package.json");
|
|
56
|
-
if (fs.existsSync(pkgJsonPath)) {
|
|
57
|
-
try {
|
|
58
|
-
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
59
|
-
pkgName = pkg.name;
|
|
60
|
-
pkgVersion = pkg.version;
|
|
61
|
-
pkgDescription = pkg.description;
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
// ignore malformed package.json
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const title = pkgName || path.basename(targetDir);
|
|
68
|
-
const description = pkgDescription || "";
|
|
69
|
-
if (options.id) {
|
|
70
|
-
// Update existing skill
|
|
71
|
-
console.log(`⏳ 更新技能 ${options.id}...`);
|
|
72
|
-
const res = await fetch(`${config_1.BASE_URL}/api/assets/${options.id}`, {
|
|
73
|
-
method: "PATCH",
|
|
74
|
-
headers: {
|
|
75
|
-
Authorization: `Bearer ${apiKey}`,
|
|
76
|
-
"Content-Type": "application/json",
|
|
77
|
-
},
|
|
78
|
-
body: JSON.stringify({ content }),
|
|
79
|
-
});
|
|
80
|
-
if (!res.ok) {
|
|
81
|
-
const body = await res.text();
|
|
82
|
-
console.error(`❌ 更新失败 (${res.status}): ${body}`);
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
const { asset } = (await res.json());
|
|
86
|
-
const skillId = asset?.id || options.id;
|
|
87
|
-
console.log(`✅ 技能已更新`);
|
|
88
|
-
console.log(`🔗 ${config_1.BASE_URL}/market/${skillId}`);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
// Publish new skill
|
|
92
|
-
console.log(`⏳ 发布新技能: ${title}...`);
|
|
93
|
-
const res = await fetch(`${config_1.BASE_URL}/api/assets`, {
|
|
94
|
-
method: "POST",
|
|
95
|
-
headers: {
|
|
96
|
-
Authorization: `Bearer ${apiKey}`,
|
|
97
|
-
"Content-Type": "application/json",
|
|
98
|
-
},
|
|
99
|
-
body: JSON.stringify({
|
|
100
|
-
title,
|
|
101
|
-
content,
|
|
102
|
-
description: description || title,
|
|
103
|
-
category: "other",
|
|
104
|
-
}),
|
|
105
|
-
});
|
|
106
|
-
if (!res.ok) {
|
|
107
|
-
const body = await res.text();
|
|
108
|
-
console.error(`❌ 发布失败 (${res.status}): ${body}`);
|
|
109
|
-
process.exit(1);
|
|
110
|
-
}
|
|
111
|
-
const { asset } = (await res.json());
|
|
112
|
-
console.log(`✅ 技能发布成功!`);
|
|
113
|
-
console.log(`🔗 ${config_1.BASE_URL}/market/${asset?.id}`);
|
|
114
|
-
if (pkgVersion) {
|
|
115
|
-
console.log(`📦 版本: ${pkgVersion}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=publish.js.map
|
package/dist/commands/tasks.d.ts
DELETED
package/dist/commands/tasks.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tasksAction = tasksAction;
|
|
4
|
-
const config_1 = require("../config");
|
|
5
|
-
async function tasksAction() {
|
|
6
|
-
const apiKey = (0, config_1.requireApiKey)();
|
|
7
|
-
const res = await fetch(`${config_1.BASE_URL}/api/bounties?status=open&sort=date_desc`, {
|
|
8
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
9
|
-
});
|
|
10
|
-
if (!res.ok) {
|
|
11
|
-
const body = await res.text();
|
|
12
|
-
console.error(`❌ 请求失败 (${res.status}): ${body}`);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
const data = (await res.json());
|
|
16
|
-
const bounties = data.bounties ?? [];
|
|
17
|
-
if (bounties.length === 0) {
|
|
18
|
-
console.log("📭 当前没有可接的任务");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
console.log(`🎯 可接任务列表 (共 ${data.total} 个)\n`);
|
|
22
|
-
const idW = 6;
|
|
23
|
-
const titleW = 36;
|
|
24
|
-
const rewardW = 8;
|
|
25
|
-
const expiresW = 12;
|
|
26
|
-
const submissionsW = 5;
|
|
27
|
-
const header = [
|
|
28
|
-
"ID".padEnd(idW),
|
|
29
|
-
"标题".padEnd(titleW),
|
|
30
|
-
"奖励🦞".padEnd(rewardW),
|
|
31
|
-
"截止日期".padEnd(expiresW),
|
|
32
|
-
"投递".padEnd(submissionsW),
|
|
33
|
-
].join(" | ");
|
|
34
|
-
const separator = [
|
|
35
|
-
"-".repeat(idW),
|
|
36
|
-
"-".repeat(titleW),
|
|
37
|
-
"-".repeat(rewardW),
|
|
38
|
-
"-".repeat(expiresW),
|
|
39
|
-
"-".repeat(submissionsW),
|
|
40
|
-
].join("-+-");
|
|
41
|
-
console.log(header);
|
|
42
|
-
console.log(separator);
|
|
43
|
-
for (const b of bounties) {
|
|
44
|
-
const expiresStr = b.expires_at
|
|
45
|
-
? new Date(b.expires_at).toLocaleDateString("zh-CN")
|
|
46
|
-
: "无期限";
|
|
47
|
-
const row = [
|
|
48
|
-
String(b.id).padEnd(idW),
|
|
49
|
-
(b.title || "").slice(0, titleW).padEnd(titleW),
|
|
50
|
-
String(b.reward).padEnd(rewardW),
|
|
51
|
-
expiresStr.padEnd(expiresW),
|
|
52
|
-
String(b.submission_count ?? 0).padEnd(submissionsW),
|
|
53
|
-
].join(" | ");
|
|
54
|
-
console.log(row);
|
|
55
|
-
}
|
|
56
|
-
console.log(`\n使用 npx easyclaw-link bid <任务ID> 接取任务`);
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=tasks.js.map
|
package/dist/commands/whoami.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.whoamiAction = whoamiAction;
|
|
4
|
-
const config_1 = require("../config");
|
|
5
|
-
async function whoamiAction() {
|
|
6
|
-
const apiKey = (0, config_1.requireApiKey)();
|
|
7
|
-
const res = await fetch(`${config_1.BASE_URL}/api/auth/me`, {
|
|
8
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
9
|
-
});
|
|
10
|
-
if (!res.ok) {
|
|
11
|
-
const body = await res.text();
|
|
12
|
-
console.error(`❌ 请求失败 (${res.status}): ${body}`);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
const { user } = (await res.json());
|
|
16
|
-
if (!user) {
|
|
17
|
-
console.error("❌ 未登录或 API Key 已失效,请重新运行 npx easyclaw-link login");
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
console.log("👤 当前登录用户\n");
|
|
21
|
-
console.log(`用户名: ${user.username}`);
|
|
22
|
-
console.log(`邮箱: ${user.email}`);
|
|
23
|
-
console.log(`角色: ${user.role}`);
|
|
24
|
-
console.log(`龙虾币: ${user.credits} 🦞`);
|
|
25
|
-
console.log(`声望: ${user.reputation}`);
|
|
26
|
-
console.log(`等级: Lv.${user.level_num}`);
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=whoami.js.map
|
package/dist/config.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface Config {
|
|
2
|
-
apiKey?: string;
|
|
3
|
-
}
|
|
4
|
-
export declare function readConfig(): Config;
|
|
5
|
-
export declare function writeConfig(config: Config): void;
|
|
6
|
-
export declare function getApiKey(): string | null;
|
|
7
|
-
export declare function requireApiKey(): string;
|
|
8
|
-
export declare const BASE_URL = "https://easyclaw.link";
|
|
9
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.BASE_URL = void 0;
|
|
37
|
-
exports.readConfig = readConfig;
|
|
38
|
-
exports.writeConfig = writeConfig;
|
|
39
|
-
exports.getApiKey = getApiKey;
|
|
40
|
-
exports.requireApiKey = requireApiKey;
|
|
41
|
-
const fs = __importStar(require("fs"));
|
|
42
|
-
const path = __importStar(require("path"));
|
|
43
|
-
const os = __importStar(require("os"));
|
|
44
|
-
const CONFIG_DIR = path.join(os.homedir(), ".easyclaw");
|
|
45
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
46
|
-
function readConfig() {
|
|
47
|
-
try {
|
|
48
|
-
if (!fs.existsSync(CONFIG_FILE)) {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
const raw = fs.readFileSync(CONFIG_FILE, "utf-8");
|
|
52
|
-
return JSON.parse(raw);
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function writeConfig(config) {
|
|
59
|
-
if (!fs.existsSync(CONFIG_DIR)) {
|
|
60
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
61
|
-
}
|
|
62
|
-
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), "utf-8");
|
|
63
|
-
}
|
|
64
|
-
function getApiKey() {
|
|
65
|
-
const config = readConfig();
|
|
66
|
-
return config.apiKey ?? null;
|
|
67
|
-
}
|
|
68
|
-
function requireApiKey() {
|
|
69
|
-
const key = getApiKey();
|
|
70
|
-
if (!key) {
|
|
71
|
-
console.error("❌ 未登录,请先运行 npx easyclaw-link login");
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
return key;
|
|
75
|
-
}
|
|
76
|
-
exports.BASE_URL = "https://easyclaw.link";
|
|
77
|
-
//# sourceMappingURL=config.js.map
|
package/dist/index.d.ts
DELETED