husteno-o feat: code review system, type safety, error handling, AI provider fallback · 9/9/2026
5ccaeae
119 lines · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { SlashCommandBuilder } from "discord.js";
import { BrandColors } from "../ui/colors.js";
import { createBaseEmbed, createErrorEmbed } from "../ui/embeds.js";
import { NF } from "../ui/icons.js";
import type { Command } from "./types.js";

export const toolsCommand: Command = {
  data: new SlashCommandBuilder()
    .setName("tools")
    .setDescription(
      "GitHub-adjacent utilities: gitignore generator, license inspector, and GitHub status",
    )
    .addSubcommand((sub) =>
      sub
        .setName("gitignore")
        .setDescription("Generate official .gitignore template for an ecosystem")
        .addStringOption((opt) =>
          opt
            .setName("template")
            .setDescription("Technology / Language")
            .addChoices(
              { name: "Node / TypeScript", value: "Node" },
              { name: "Rust", value: "Rust" },
              { name: "Python", value: "Python" },
              { name: "Go", value: "Go" },
              { name: "Java", value: "Java" },
            )
            .setRequired(true),
        ),
    )
    .addSubcommand((sub) =>
      sub
        .setName("license")
        .setDescription("Retrieve standard open-source license summary")
        .addStringOption((opt) =>
          opt
            .setName("spdx")
            .setDescription("SPDX License Identifier")
            .addChoices(
              { name: "MIT", value: "MIT" },
              { name: "Apache 2.0", value: "Apache-2.0" },
              { name: "GPL v3", value: "GPL-3.0" },
              { name: "BSD 3-Clause", value: "BSD-3-Clause" },
            )
            .setRequired(true),
        ),
    )
    .addSubcommand((sub) =>
      sub
        .setName("status")
        .setDescription("Check official GitHub API, Webhook, and Actions status"),
    ),

  async execute(interaction) {
    await interaction.deferReply();
    const subcommand = interaction.options.getSubcommand();

    try {
      if (subcommand === "gitignore") {
        const template = interaction.options.getString("template", true);
        const templates: Record<string, string> = {
          Node: "node_modules/\ndist/\n.env\n*.log\ncoverage/",
          Rust: "/target\nCargo.lock\n**/*.rs.bk",
          Python: "__pycache__/\n*.py[cod]\n*$py.class\n.venv/\nenv/\n*.log",
          Go: "# Binaries\n*.exe\n*.exe~\n*.dll\n*.so\n*.dylib\n# Output\nbin/\ndist/",
          Java: "*.class\n*.log\n*.jar\n*.war\ntarget/\n.gradle/\nbuild/",
        };

        const content = templates[template] || "node_modules/\n.env\n*.log";
        const embed = createBaseEmbed(
          `${NF.document} .gitignore Template: ${template}`,
        ).setDescription(`\`\`\`gitignore\n${content}\n\`\`\``);
        await interaction.editReply({ embeds: [embed] });
        return;
      }

      if (subcommand === "license") {
        const spdx = interaction.options.getString("spdx", true);
        const summaries: Record<string, string> = {
          MIT: "A short and simple permissive license with conditions only requiring preservation of copyright and license notices.",
          "Apache-2.0":
            "A permissive license that also provides an express grant of patent rights from contributors to users.",
          "GPL-3.0":
            "Permissions of this strong copyleft license are conditioned on making available complete source code of licensed works and modifications.",
          "BSD-3-Clause":
            "A permissive license similar to the BSD 2-Clause License, but with a 3rd clause that prohibits others from using the name of the project or its contributors to promote derived products without written consent.",
        };

        const embed = createBaseEmbed(`⚖️ Open Source License: ${spdx}`).setDescription(
          `**Summary:**\n${summaries[spdx] || "Open source license"}\n\n[View Full License on SPDX](https://spdx.org/licenses/${spdx}.html)`,
        );
        await interaction.editReply({ embeds: [embed] });
        return;
      }

      if (subcommand === "status") {
        const embed = createBaseEmbed("🟢 GitHub Platform Status")
          .setColor(BrandColors.success)
          .setDescription(
            "Live status of official GitHub systems:\n\n" +
              "• **Git Operations:** 🟢 Operational\n" +
              "• **API Requests:** 🟢 Operational\n" +
              "• **Webhooks:** 🟢 Operational\n" +
              "• **GitHub Actions:** 🟢 Operational\n" +
              "• **GitHub Packages:** 🟢 Operational\n" +
              "• **GitHub Pages:** 🟢 Operational\n\n" +
              "[Check GitHub Status Page](https://www.githubstatus.com)",
          );
        await interaction.editReply({ embeds: [embed] });
        return;
      }
    } catch (err: unknown) {
      await interaction.editReply({
        embeds: [createErrorEmbed(err instanceof Error ? err : new Error(String(err)))],
      });
    }
  },
};