apero-kit-cli 2.4.1 → 2.4.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/dist/index.js +150 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
+
}) : x)(function(x) {
|
|
8
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
9
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
+
});
|
|
5
11
|
var __esm = (fn, res) => function __init() {
|
|
6
12
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
13
|
};
|
|
@@ -823,6 +829,47 @@ async function copyDiscordBaseFiles(destDir, mergeMode = false) {
|
|
|
823
829
|
}
|
|
824
830
|
return copied;
|
|
825
831
|
}
|
|
832
|
+
async function updateDiscordConfig(destDir, token, guildId) {
|
|
833
|
+
const configPath = join2(destDir, "config.json5");
|
|
834
|
+
if (!fs.existsSync(configPath)) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
let content = await fs.readFile(configPath, "utf-8");
|
|
838
|
+
content = content.replace(
|
|
839
|
+
'"token": "${DISCORD_BOT_TOKEN}"',
|
|
840
|
+
`"token": "${token}"`
|
|
841
|
+
);
|
|
842
|
+
if (guildId) {
|
|
843
|
+
const guildConfig = `"${guildId}": {
|
|
844
|
+
"requireMention": true,
|
|
845
|
+
"users": [],
|
|
846
|
+
"roles": [],
|
|
847
|
+
"channels": {}
|
|
848
|
+
}`;
|
|
849
|
+
content = content.replace(
|
|
850
|
+
'"guilds": {\n // Example guild configuration',
|
|
851
|
+
`"guilds": {
|
|
852
|
+
${guildConfig},
|
|
853
|
+
// Example guild configuration`
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
await fs.writeFile(configPath, content, "utf-8");
|
|
857
|
+
}
|
|
858
|
+
async function setupOpenClawConfig(token) {
|
|
859
|
+
const { execSync: execSync3 } = await import("child_process");
|
|
860
|
+
try {
|
|
861
|
+
execSync3("which openclaw", { stdio: "ignore" });
|
|
862
|
+
} catch {
|
|
863
|
+
return { success: false, message: "OpenClaw CLI not installed. Run: npm install -g openclaw" };
|
|
864
|
+
}
|
|
865
|
+
try {
|
|
866
|
+
execSync3(`openclaw config set channels.discord.token '"${token}"' --json`, { stdio: "ignore" });
|
|
867
|
+
execSync3("openclaw config set channels.discord.enabled true --json", { stdio: "ignore" });
|
|
868
|
+
return { success: true, message: "OpenClaw configured successfully!" };
|
|
869
|
+
} catch (error) {
|
|
870
|
+
return { success: false, message: `Failed to configure OpenClaw: ${error.message}` };
|
|
871
|
+
}
|
|
872
|
+
}
|
|
826
873
|
function extractKeywords(content, commandName) {
|
|
827
874
|
const keywords = /* @__PURE__ */ new Set();
|
|
828
875
|
keywords.add(commandName);
|
|
@@ -1258,6 +1305,64 @@ async function promptUpdateConfirm(updates) {
|
|
|
1258
1305
|
console.log("");
|
|
1259
1306
|
return promptConfirm("Apply these updates?", true);
|
|
1260
1307
|
}
|
|
1308
|
+
function isOpenClawInstalled() {
|
|
1309
|
+
try {
|
|
1310
|
+
const { execSync: execSync3 } = __require("child_process");
|
|
1311
|
+
execSync3("which openclaw", { stdio: "ignore" });
|
|
1312
|
+
return true;
|
|
1313
|
+
} catch {
|
|
1314
|
+
return false;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
async function promptDiscordSetup() {
|
|
1318
|
+
console.log("");
|
|
1319
|
+
console.log(pc.cyan("\u2501\u2501\u2501 Discord Bot Setup \u2501\u2501\u2501"));
|
|
1320
|
+
const openclawInstalled = isOpenClawInstalled();
|
|
1321
|
+
if (!openclawInstalled) {
|
|
1322
|
+
console.log(pc.yellow("\u26A0 OpenClaw CLI not found. Install it first:"));
|
|
1323
|
+
console.log(pc.white(" npm install -g openclaw"));
|
|
1324
|
+
console.log("");
|
|
1325
|
+
}
|
|
1326
|
+
console.log(pc.gray("Get your bot token from: https://discord.com/developers/applications"));
|
|
1327
|
+
console.log("");
|
|
1328
|
+
const token = await p.password({
|
|
1329
|
+
message: "Discord Bot Token:",
|
|
1330
|
+
mask: "*",
|
|
1331
|
+
validate: (value) => {
|
|
1332
|
+
if (!value || !value.trim()) return "Bot token is required";
|
|
1333
|
+
if (value.length < 50) return "Invalid token format";
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
if (p.isCancel(token)) process.exit(0);
|
|
1337
|
+
const hasGuild = await p.confirm({
|
|
1338
|
+
message: "Do you have a Discord Server ID to configure?",
|
|
1339
|
+
initialValue: false
|
|
1340
|
+
});
|
|
1341
|
+
if (p.isCancel(hasGuild)) process.exit(0);
|
|
1342
|
+
let guildId;
|
|
1343
|
+
if (hasGuild) {
|
|
1344
|
+
const guild = await p.text({
|
|
1345
|
+
message: "Discord Server ID:",
|
|
1346
|
+
placeholder: "123456789012345678",
|
|
1347
|
+
validate: (value) => {
|
|
1348
|
+
if (!value || !value.trim()) return "Server ID is required";
|
|
1349
|
+
if (!/^\d{17,20}$/.test(String(value))) return "Invalid Server ID format (should be 17-20 digits)";
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1352
|
+
if (p.isCancel(guild)) process.exit(0);
|
|
1353
|
+
guildId = guild;
|
|
1354
|
+
}
|
|
1355
|
+
const autoSetup = await p.confirm({
|
|
1356
|
+
message: "Auto-setup OpenClaw config? (requires openclaw CLI)",
|
|
1357
|
+
initialValue: true
|
|
1358
|
+
});
|
|
1359
|
+
if (p.isCancel(autoSetup)) process.exit(0);
|
|
1360
|
+
return {
|
|
1361
|
+
token,
|
|
1362
|
+
guildId,
|
|
1363
|
+
autoSetup
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1261
1366
|
var init_prompts = __esm({
|
|
1262
1367
|
"src/utils/prompts.ts"() {
|
|
1263
1368
|
"use strict";
|
|
@@ -1296,10 +1401,10 @@ async function initCommand(projectName, options) {
|
|
|
1296
1401
|
return;
|
|
1297
1402
|
}
|
|
1298
1403
|
} else if (process.stdin.isTTY && !options.yes) {
|
|
1299
|
-
const { password } = await import("@clack/prompts").then((p4) => ({
|
|
1404
|
+
const { password: password2 } = await import("@clack/prompts").then((p4) => ({
|
|
1300
1405
|
password: p4.password
|
|
1301
1406
|
}));
|
|
1302
|
-
const inputPassword = await
|
|
1407
|
+
const inputPassword = await password2({
|
|
1303
1408
|
message: "Enter access code:",
|
|
1304
1409
|
mask: "*"
|
|
1305
1410
|
});
|
|
@@ -1338,6 +1443,11 @@ async function initCommand(projectName, options) {
|
|
|
1338
1443
|
} else {
|
|
1339
1444
|
cliTargets = await promptCliTargets();
|
|
1340
1445
|
}
|
|
1446
|
+
let discordConfig = null;
|
|
1447
|
+
let openclawSetupSuccess = false;
|
|
1448
|
+
if (cliTargets.includes("discord") && process.stdin.isTTY && !options.yes) {
|
|
1449
|
+
discordConfig = await promptDiscordSetup();
|
|
1450
|
+
}
|
|
1341
1451
|
let existingAction = null;
|
|
1342
1452
|
const existingTargets = [];
|
|
1343
1453
|
for (const target of cliTargets) {
|
|
@@ -1526,6 +1636,19 @@ async function initCommand(projectName, options) {
|
|
|
1526
1636
|
} else if (target === "discord") {
|
|
1527
1637
|
spinner.text = mergeMode ? `Merging config (${targetLabel})...` : `Copying config (${targetLabel})...`;
|
|
1528
1638
|
await copyDiscordBaseFiles(targetDir, mergeMode);
|
|
1639
|
+
if (discordConfig) {
|
|
1640
|
+
spinner.text = "Configuring Discord bot...";
|
|
1641
|
+
await updateDiscordConfig(targetDir, discordConfig.token, discordConfig.guildId);
|
|
1642
|
+
if (discordConfig.autoSetup) {
|
|
1643
|
+
spinner.text = "Setting up OpenClaw...";
|
|
1644
|
+
const result = await setupOpenClawConfig(discordConfig.token);
|
|
1645
|
+
openclawSetupSuccess = result.success;
|
|
1646
|
+
if (!result.success) {
|
|
1647
|
+
console.log(pc2.yellow(`
|
|
1648
|
+
Note: ${result.message}`));
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1529
1652
|
}
|
|
1530
1653
|
}
|
|
1531
1654
|
if (source.agentsMd && cliTargets.includes("claude")) {
|
|
@@ -1565,6 +1688,31 @@ async function initCommand(projectName, options) {
|
|
|
1565
1688
|
console.log(pc2.gray(" ak status - Check file status"));
|
|
1566
1689
|
console.log(pc2.gray(" ak add <item> - Add more agents/skills"));
|
|
1567
1690
|
console.log(pc2.gray(" ak update - Sync from source"));
|
|
1691
|
+
if (cliTargets.includes("discord")) {
|
|
1692
|
+
console.log("");
|
|
1693
|
+
console.log(pc2.cyan("Discord Bot Setup:"));
|
|
1694
|
+
let openclawInstalled = false;
|
|
1695
|
+
try {
|
|
1696
|
+
const { execSync: execSync3 } = await import("child_process");
|
|
1697
|
+
execSync3("which openclaw", { stdio: "ignore" });
|
|
1698
|
+
openclawInstalled = true;
|
|
1699
|
+
} catch {
|
|
1700
|
+
}
|
|
1701
|
+
if (!openclawInstalled) {
|
|
1702
|
+
console.log(pc2.yellow(" 0. npm install -g openclaw - Install OpenClaw CLI first!"));
|
|
1703
|
+
console.log(pc2.white(" 1. openclaw gateway - Start the bot"));
|
|
1704
|
+
console.log(pc2.white(" 2. Invite bot to server - Use OAuth2 URL from Discord Portal"));
|
|
1705
|
+
console.log(pc2.white(" 3. DM the bot to pair - Approve with: openclaw pairing approve discord <code>"));
|
|
1706
|
+
} else {
|
|
1707
|
+
if (openclawSetupSuccess) {
|
|
1708
|
+
console.log(pc2.green(" \u2713 OpenClaw configured"));
|
|
1709
|
+
}
|
|
1710
|
+
console.log(pc2.white(" 1. openclaw gateway - Start the bot"));
|
|
1711
|
+
console.log(pc2.white(" 2. Invite bot to server - Use OAuth2 URL from Discord Portal"));
|
|
1712
|
+
console.log(pc2.white(" 3. DM the bot to pair - Approve with: openclaw pairing approve discord <code>"));
|
|
1713
|
+
}
|
|
1714
|
+
console.log(pc2.gray(" See .discord/README.md for full guide"));
|
|
1715
|
+
}
|
|
1568
1716
|
console.log("");
|
|
1569
1717
|
} catch (error) {
|
|
1570
1718
|
spinner.fail(pc2.red("Failed to create project"));
|