apero-kit-cli 2.4.1 → 2.4.2
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 +113 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -823,6 +823,47 @@ async function copyDiscordBaseFiles(destDir, mergeMode = false) {
|
|
|
823
823
|
}
|
|
824
824
|
return copied;
|
|
825
825
|
}
|
|
826
|
+
async function updateDiscordConfig(destDir, token, guildId) {
|
|
827
|
+
const configPath = join2(destDir, "config.json5");
|
|
828
|
+
if (!fs.existsSync(configPath)) {
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
let content = await fs.readFile(configPath, "utf-8");
|
|
832
|
+
content = content.replace(
|
|
833
|
+
'"token": "${DISCORD_BOT_TOKEN}"',
|
|
834
|
+
`"token": "${token}"`
|
|
835
|
+
);
|
|
836
|
+
if (guildId) {
|
|
837
|
+
const guildConfig = `"${guildId}": {
|
|
838
|
+
"requireMention": true,
|
|
839
|
+
"users": [],
|
|
840
|
+
"roles": [],
|
|
841
|
+
"channels": {}
|
|
842
|
+
}`;
|
|
843
|
+
content = content.replace(
|
|
844
|
+
'"guilds": {\n // Example guild configuration',
|
|
845
|
+
`"guilds": {
|
|
846
|
+
${guildConfig},
|
|
847
|
+
// Example guild configuration`
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
await fs.writeFile(configPath, content, "utf-8");
|
|
851
|
+
}
|
|
852
|
+
async function setupOpenClawConfig(token) {
|
|
853
|
+
const { execSync: execSync3 } = await import("child_process");
|
|
854
|
+
try {
|
|
855
|
+
execSync3("which openclaw", { stdio: "ignore" });
|
|
856
|
+
} catch {
|
|
857
|
+
return { success: false, message: "OpenClaw CLI not installed. Run: npm install -g openclaw" };
|
|
858
|
+
}
|
|
859
|
+
try {
|
|
860
|
+
execSync3(`openclaw config set channels.discord.token '"${token}"' --json`, { stdio: "ignore" });
|
|
861
|
+
execSync3("openclaw config set channels.discord.enabled true --json", { stdio: "ignore" });
|
|
862
|
+
return { success: true, message: "OpenClaw configured successfully!" };
|
|
863
|
+
} catch (error) {
|
|
864
|
+
return { success: false, message: `Failed to configure OpenClaw: ${error.message}` };
|
|
865
|
+
}
|
|
866
|
+
}
|
|
826
867
|
function extractKeywords(content, commandName) {
|
|
827
868
|
const keywords = /* @__PURE__ */ new Set();
|
|
828
869
|
keywords.add(commandName);
|
|
@@ -1258,6 +1299,49 @@ async function promptUpdateConfirm(updates) {
|
|
|
1258
1299
|
console.log("");
|
|
1259
1300
|
return promptConfirm("Apply these updates?", true);
|
|
1260
1301
|
}
|
|
1302
|
+
async function promptDiscordSetup() {
|
|
1303
|
+
console.log("");
|
|
1304
|
+
console.log(pc.cyan("\u2501\u2501\u2501 Discord Bot Setup \u2501\u2501\u2501"));
|
|
1305
|
+
console.log(pc.gray("Get your bot token from: https://discord.com/developers/applications"));
|
|
1306
|
+
console.log("");
|
|
1307
|
+
const token = await p.password({
|
|
1308
|
+
message: "Discord Bot Token:",
|
|
1309
|
+
mask: "*",
|
|
1310
|
+
validate: (value) => {
|
|
1311
|
+
if (!value || !value.trim()) return "Bot token is required";
|
|
1312
|
+
if (value.length < 50) return "Invalid token format";
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
if (p.isCancel(token)) process.exit(0);
|
|
1316
|
+
const hasGuild = await p.confirm({
|
|
1317
|
+
message: "Do you have a Discord Server ID to configure?",
|
|
1318
|
+
initialValue: false
|
|
1319
|
+
});
|
|
1320
|
+
if (p.isCancel(hasGuild)) process.exit(0);
|
|
1321
|
+
let guildId;
|
|
1322
|
+
if (hasGuild) {
|
|
1323
|
+
const guild = await p.text({
|
|
1324
|
+
message: "Discord Server ID:",
|
|
1325
|
+
placeholder: "123456789012345678",
|
|
1326
|
+
validate: (value) => {
|
|
1327
|
+
if (!value || !value.trim()) return "Server ID is required";
|
|
1328
|
+
if (!/^\d{17,20}$/.test(String(value))) return "Invalid Server ID format (should be 17-20 digits)";
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
if (p.isCancel(guild)) process.exit(0);
|
|
1332
|
+
guildId = guild;
|
|
1333
|
+
}
|
|
1334
|
+
const autoSetup = await p.confirm({
|
|
1335
|
+
message: "Auto-setup OpenClaw config? (requires openclaw CLI)",
|
|
1336
|
+
initialValue: true
|
|
1337
|
+
});
|
|
1338
|
+
if (p.isCancel(autoSetup)) process.exit(0);
|
|
1339
|
+
return {
|
|
1340
|
+
token,
|
|
1341
|
+
guildId,
|
|
1342
|
+
autoSetup
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1261
1345
|
var init_prompts = __esm({
|
|
1262
1346
|
"src/utils/prompts.ts"() {
|
|
1263
1347
|
"use strict";
|
|
@@ -1296,10 +1380,10 @@ async function initCommand(projectName, options) {
|
|
|
1296
1380
|
return;
|
|
1297
1381
|
}
|
|
1298
1382
|
} else if (process.stdin.isTTY && !options.yes) {
|
|
1299
|
-
const { password } = await import("@clack/prompts").then((p4) => ({
|
|
1383
|
+
const { password: password2 } = await import("@clack/prompts").then((p4) => ({
|
|
1300
1384
|
password: p4.password
|
|
1301
1385
|
}));
|
|
1302
|
-
const inputPassword = await
|
|
1386
|
+
const inputPassword = await password2({
|
|
1303
1387
|
message: "Enter access code:",
|
|
1304
1388
|
mask: "*"
|
|
1305
1389
|
});
|
|
@@ -1338,6 +1422,10 @@ async function initCommand(projectName, options) {
|
|
|
1338
1422
|
} else {
|
|
1339
1423
|
cliTargets = await promptCliTargets();
|
|
1340
1424
|
}
|
|
1425
|
+
let discordConfig = null;
|
|
1426
|
+
if (cliTargets.includes("discord") && process.stdin.isTTY && !options.yes) {
|
|
1427
|
+
discordConfig = await promptDiscordSetup();
|
|
1428
|
+
}
|
|
1341
1429
|
let existingAction = null;
|
|
1342
1430
|
const existingTargets = [];
|
|
1343
1431
|
for (const target of cliTargets) {
|
|
@@ -1526,6 +1614,18 @@ async function initCommand(projectName, options) {
|
|
|
1526
1614
|
} else if (target === "discord") {
|
|
1527
1615
|
spinner.text = mergeMode ? `Merging config (${targetLabel})...` : `Copying config (${targetLabel})...`;
|
|
1528
1616
|
await copyDiscordBaseFiles(targetDir, mergeMode);
|
|
1617
|
+
if (discordConfig) {
|
|
1618
|
+
spinner.text = "Configuring Discord bot...";
|
|
1619
|
+
await updateDiscordConfig(targetDir, discordConfig.token, discordConfig.guildId);
|
|
1620
|
+
if (discordConfig.autoSetup) {
|
|
1621
|
+
spinner.text = "Setting up OpenClaw...";
|
|
1622
|
+
const result = await setupOpenClawConfig(discordConfig.token);
|
|
1623
|
+
if (!result.success) {
|
|
1624
|
+
console.log(pc2.yellow(`
|
|
1625
|
+
Note: ${result.message}`));
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1529
1629
|
}
|
|
1530
1630
|
}
|
|
1531
1631
|
if (source.agentsMd && cliTargets.includes("claude")) {
|
|
@@ -1565,6 +1665,17 @@ async function initCommand(projectName, options) {
|
|
|
1565
1665
|
console.log(pc2.gray(" ak status - Check file status"));
|
|
1566
1666
|
console.log(pc2.gray(" ak add <item> - Add more agents/skills"));
|
|
1567
1667
|
console.log(pc2.gray(" ak update - Sync from source"));
|
|
1668
|
+
if (cliTargets.includes("discord")) {
|
|
1669
|
+
console.log("");
|
|
1670
|
+
console.log(pc2.cyan("Discord Bot Setup:"));
|
|
1671
|
+
if (discordConfig?.autoSetup) {
|
|
1672
|
+
console.log(pc2.green(" \u2713 OpenClaw configured"));
|
|
1673
|
+
}
|
|
1674
|
+
console.log(pc2.white(" 1. openclaw gateway - Start the bot"));
|
|
1675
|
+
console.log(pc2.white(" 2. Invite bot to server - Use OAuth2 URL from Discord Portal"));
|
|
1676
|
+
console.log(pc2.white(" 3. DM the bot to pair - Approve with: openclaw pairing approve discord <code>"));
|
|
1677
|
+
console.log(pc2.gray(" See .discord/README.md for full guide"));
|
|
1678
|
+
}
|
|
1568
1679
|
console.log("");
|
|
1569
1680
|
} catch (error) {
|
|
1570
1681
|
spinner.fail(pc2.red("Failed to create project"));
|