feat: add discord-guilds skill with table merge on install
This commit is contained in:
29
skills/discord-guilds/SKILL.md
Normal file
29
skills/discord-guilds/SKILL.md
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
name: discord-guilds
|
||||
description: When calling tools that require Discord guild ID/server ID, refer to this skill for available guild IDs and their descriptions.
|
||||
---
|
||||
|
||||
# Discord Guilds
|
||||
|
||||
Use this skill when a tool or command requires a Discord `guildId` (also called server ID).
|
||||
|
||||
## Available Guilds
|
||||
|
||||
| guild-id | description |
|
||||
|----------|-------------|
|
||||
| 1480860737902743686 | Main test guild for HarborForge/Dirigent development |
|
||||
|
||||
## Usage
|
||||
|
||||
When calling tools like `dirigent_discord_control` that require a `guildId` parameter, look up the appropriate guild ID from the table above based on the context.
|
||||
|
||||
To add a new guild to this list, use the `add-guild` script:
|
||||
|
||||
```bash
|
||||
{skill}/scripts/add-guild <guild-id> <description>
|
||||
```
|
||||
|
||||
Example:
|
||||
```bash
|
||||
~/.openclaw/skills/discord-guilds/scripts/add-guild "123456789012345678" "Production server"
|
||||
```
|
||||
56
skills/discord-guilds/scripts/add-guild
Executable file
56
skills/discord-guilds/scripts/add-guild
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Add a guild entry to the discord-guilds SKILL.md table
|
||||
* Usage: add-guild <guild-id> <description>
|
||||
*/
|
||||
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const SKILL_PATH = path.resolve(__dirname, "../SKILL.md");
|
||||
|
||||
function main() {
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length < 2) {
|
||||
console.error("Usage: add-guild <guild-id> <description>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const guildId = args[0];
|
||||
const description = args.slice(1).join(" ");
|
||||
|
||||
// Validate guild ID is numeric
|
||||
if (!/^\d+$/.test(guildId)) {
|
||||
console.error("Error: guild-id must be numeric (Discord snowflake)");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Read existing SKILL.md
|
||||
let content = fs.readFileSync(SKILL_PATH, "utf8");
|
||||
|
||||
// Find the table and insert new row
|
||||
const newRow = `| ${guildId} | ${description} |`;
|
||||
|
||||
// Look for the table pattern and insert after the header
|
||||
const tablePattern = /(\| guild-id \| description \|\n\|[-\s|]+\|)/;
|
||||
|
||||
if (!tablePattern.test(content)) {
|
||||
console.error("Error: Could not find guild table in SKILL.md");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Insert new row after the table header
|
||||
content = content.replace(tablePattern, `$1\n${newRow}`);
|
||||
|
||||
// Write back
|
||||
fs.writeFileSync(SKILL_PATH, content, "utf8");
|
||||
|
||||
console.log(`✓ Added guild: ${guildId} - ${description}`);
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user