mirror of
https://github.com/storytold/autocraft.git
synced 2026-11-30 18:14:06 +01:00
/autocraft help lists the commands, pings, Find issue and the reaction
This commit is contained in:
1 parent
8a2cc0e510
commit
2fccaf8976
2 files changed
+19
-1
No files matched your search
+1
-1
@@ -772,7 +772,7 @@ Optional and off by default. It counts explicit mentions of tracked items in Dis
|
||||
- **Channels.** The bot reports its servers and its text, announcement and forum channels into `discord_channels`; `watched` is the operators' choice (Discord page, or `autocraft discord watch|unwatch <channel id>`). Nothing in an unwatched channel is read. Threads and forum posts count under their parent channel: watching the parent watches them.
|
||||
- **Bot permissions.** The invite needs the `bot` and `applications.commands` scopes and the permissions View Channels, Send Messages, Add Reactions and Read Message History. With the Discord page switch "React to recorded messages" on (the default), the bot adds a ✅ to a message when it first records it against items; a refused reaction (missing permission, deleted message) is logged once per channel and skipped.
|
||||
- **REST.** `src/discord/rest.ts` is the one client for posting, editing and deleting messages, interaction callbacks and registering commands. It runs requests of a rate-limit bucket one at a time, waits out `X-RateLimit-Remaining: 0` windows, retries a 429 after the `retry_after` Discord names (up to four tries) and honours the global limit. Requests of different buckets run side by side. Interaction callbacks are sent at once, never queued behind other requests.
|
||||
- **Commands.** `src/discord/interactions.ts` keeps a table of command handlers keyed by command name (and subcommand) and button handlers keyed by `custom_id` prefix; other features add theirs with `command()` and `component()`. Every interaction is deferred first and edited when the handler is done. At READY and at each GUILD_CREATE the guild's commands are replaced with the registered set (a bulk overwrite, so it is idempotent). Registered now: `/autocraft search query:<text> [repo]` (repo choices by autocomplete), the message command "Find issue", and `/autocraft link code:<code>`, `/autocraft unlink`, `/autocraft stats [repo]` (repo choices by autocomplete: public tracked repos) and `/autocraft status item:<repo#n>` (public status layer; "No item found" for an unknown or hidden item); all replies are ephemeral. A handler that fails after the deferral edits the response with a short error.
|
||||
- **Commands.** `src/discord/interactions.ts` keeps a table of command handlers keyed by command name (and subcommand) and button handlers keyed by `custom_id` prefix; other features add theirs with `command()` and `component()`. Every interaction is deferred first and edited when the handler is done. At READY and at each GUILD_CREATE the guild's commands are replaced with the registered set (a bulk overwrite, so it is idempotent). Registered now: `/autocraft search query:<text> [repo]` (repo choices by autocomplete), the message command "Find issue", and `/autocraft link code:<code>`, `/autocraft unlink`, `/autocraft stats [repo]` (repo choices by autocomplete: public tracked repos) and `/autocraft status item:<repo#n>` (public status layer; "No item found" for an unknown or hidden item); all replies are ephemeral. A handler that fails after the deferral edits the response with a short error. `/autocraft help` answers privately with the commands, pings, the "Find issue" message command and what the ✅ reaction means.
|
||||
- **Ping replies.** A new message from a person (not a bot or webhook) that mentions the bot, directly or through its managed role, in a watched channel gets one public reply: the issues closest to the question, with `allowed_mentions` set to none. The question is the quoted message when the ping is a reply, otherwise the ping's text without mentions. Edits get no reply. A message counts as a ping only when its text contains `<@botId>`, `<@!botId>` or the bot's role mention; the author-of-the-quoted-message entry Discord adds to `mentions` does not count, and a reply to one of the bot's own messages is ignored. When the ping, or the quoted message, is deleted, the reply is deleted in Discord and then its row (the pings handler owns this, so `discord_replies` is untouched until it runs); `autocraft discord forget --message` does the same through the bot token. `discord_replies` holds a keyed hash of the ping, one of the quoted message and one of the channel, and the reply's guild, channel and message ID sealed like the mention rows; no text.
|
||||
- **Search.** A public tracked repo named in the question as a whole word (case-insensitive) restricts the search to that repo and is left out of the embedded text; when none or several are named, all public repos are searched. `/autocraft search` has two required fields, `repo` first (autocomplete: "All repos", then the public repos) and `query`; a chosen repo wins over the detection, and "All repos" or a name that is not a public repo leaves the detection to decide. Ping replies use the detection too; the channel's default repo does not restrict the search. The question is embedded in memory with the local model (loaded on first use) and compared with the stored vectors of issues of public tracked repos: open ones and ones closed as completed in the last 180 days, shown with "(closed)". The closest twenty go to a Haiku call (prompt `discord.search`, step `discord-search`, queue class 0, no tools, cost in `agent_runs`) that picks up to ten with a one-line reason; picks outside the candidate list are dropped. The picks are shown open issues first, then by activity (comments plus reactions, highest first), then by the latest update; the model's order does not matter, and a missing reaction count counts as 0. A command reply lists every pick that fits in one message; a public ping reply lists the best three. The call's prompt and reply texts are deleted when it ends, and every `discord-search` text at startup, whatever its state. The spend of the day (UTC) in `agent_runs` for that step is compared with the `discord_search_daily_usd` setting (default 1); at or above it, or when the call fails or times out waiting for an account, the reply lists the ten closest with a cosine of at least 0.55 (three for a ping), in the same order and with no reasons. Limits: 5 questions a minute per person and 20 per channel, counted in memory by keyed hash; a pinged question over a limit gets no reply, a command gets a short refusal.
|
||||
- **Reply buttons.** One link button per result, and "File a new issue", a button that opens the new-issue form (below) for the channel's default repo (set per channel on the Discord page, public tracked repos only; a thread uses its parent's), else of the top result's repo or the only public tracked repo, with the title filled from the first 80 characters of the question. Nothing is posted to GitHub.
|
||||
|
||||
@@ -29,6 +29,20 @@ export function formatStatus(s: PublicStatus): string {
|
||||
return `${s.ref} ${plain(s.title).slice(0, 100)}\n${s.step}${place}`;
|
||||
}
|
||||
|
||||
/** Lists what the slash-command picker does not show: pings, the message command and the reaction. */
|
||||
export const HELP = [
|
||||
"**AutoCraft**",
|
||||
"`/autocraft search`: find existing issues. Pick a repo (or All repos) and describe the problem.",
|
||||
"`/autocraft new-issue`: help writing a new issue, after a look for an existing one.",
|
||||
"`/autocraft status item:photocraft#123`: where an issue or pull request is.",
|
||||
"`/autocraft stats`: counts for the public repos.",
|
||||
"`/autocraft link` and `unlink`: connect this Discord account to your AutoCraft login (the code is under Link Discord in the dashboard menu).",
|
||||
"`/autocraft alerts on|off`: direct messages about decisions you can settle, once linked.",
|
||||
"Mention @AutoCraft with a question in a watched channel, or reply to a message and mention it, to get matching issues.",
|
||||
"Right-click a message, then Apps › Find issue, to search with that message's text.",
|
||||
"A ✅ on a message means AutoCraft counted it for the issues it names.",
|
||||
].join("\n");
|
||||
|
||||
export function installAccountCommands(ix: Interactions, deps: { db: DatabaseSync; keys: DiscordKeys; now?: () => number }): void {
|
||||
const { db, keys } = deps;
|
||||
const tries = new Map<string, number[]>();
|
||||
@@ -54,6 +68,7 @@ export function installAccountCommands(ix: Interactions, deps: { db: DatabaseSyn
|
||||
{ type: 1, name: "alerts", description: "Direct messages about new decisions you can settle", options: [{ type: 3, name: "state", description: "on or off", required: true, choices: [{ name: "on", value: "on" }, { name: "off", value: "off" }] }] },
|
||||
{ type: 1, name: "stats", description: "Counts for the public repos", options: [{ type: 3, name: "repo", description: "One repo; all public repos when left out", autocomplete: true }] },
|
||||
{ type: 1, name: "status", description: "Where an issue or pull request is in AutoCraft", options: [{ type: 3, name: "item", description: "For example photocraft#123", required: true, max_length: 100 }] },
|
||||
{ type: 1, name: "help", description: "What the AutoCraft bot can do" },
|
||||
],
|
||||
};
|
||||
ix.command("autocraft link", def, async (call) => {
|
||||
@@ -79,6 +94,9 @@ export function installAccountCommands(ix: Interactions, deps: { db: DatabaseSyn
|
||||
const typed = (call.focused()?.value ?? "").toLowerCase();
|
||||
return publicRepoNames(db).filter((r) => r.toLowerCase().includes(typed)).map((r) => ({ name: r, value: r }));
|
||||
});
|
||||
ix.command("autocraft help", null, async (call) => {
|
||||
await call.edit({ content: HELP });
|
||||
});
|
||||
ix.command("autocraft status", null, async (call) => {
|
||||
if (!mayRead(call)) return void (await call.edit({ content: TOO_MANY }));
|
||||
const m = REF.exec(call.option("item") ?? "");
|
||||
|
||||
Reference in new issue
Block a user