Skip to content

Commit bda2af0

Browse files
feat!: switch comment commands to @home-assistant <command> (#10)
1 parent 72c0138 commit bda2af0

25 files changed

Lines changed: 130 additions & 121 deletions

‎src/env.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export const envSchema = z.object({
1212
BOT_SLUG: z.string().default("home-assistant"),
1313

1414
// Comment-command prefix — the bot reacts to comments starting with
15-
// `/${COMMAND_SLUG} <command>`.
16-
COMMAND_SLUG: z.string().default("ha-bot"),
15+
// `@${COMMAND_SLUG} <command>`.
16+
COMMAND_SLUG: z.string().default("home-assistant"),
1717

1818
// Discord bot token. The gateway only starts when this is set —
1919
// absence means "no Discord", not a misconfiguration.

‎src/github/engine/command-render.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface CommandHelpEntry {
1717
description: string;
1818
permission: CommandPermission;
1919
/**
20-
* Sample invocation without the `/<slug> ` prefix (e.g. `rename "A better
20+
* Sample invocation without the `@<slug> ` prefix (e.g. `rename "A better
2121
* title"`), shown in rendered command help for arg-taking commands.
2222
*/
2323
example?: string;
@@ -47,7 +47,7 @@ export interface CommandHelpView {
4747
description: string;
4848
/** "" or " *(author)*" / " *(code owners)*". */
4949
permissionNote: string;
50-
/** "" or " — e.g. `/<slug> <example>`" for arg-taking commands. */
50+
/** "" or " — e.g. `@<slug> <example>`" for arg-taking commands. */
5151
exampleSuffix: string;
5252
}
5353

@@ -65,7 +65,7 @@ export function commandViews(
6565
name: c.name,
6666
description: c.description,
6767
permissionNote: PERMISSION_NOTES[c.permission],
68-
exampleSuffix: c.example ? ` — e.g. \`/${slug} ${c.example}\`` : "",
68+
exampleSuffix: c.example ? ` — e.g. \`@${slug} ${c.example}\`` : "",
6969
}));
7070
}
7171

‎src/github/engine/dispatch.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ async function react(context: CommandContext, content: "+1" | "-1"): Promise<voi
488488
* The command counterpart of dispatch(): validate each invocation in the
489489
* comment against its command's declared constraints, run the handlers in
490490
* order, and apply the collected outputs. A comment can carry several
491-
* commands (one per `/<slug>` line) mixed with prose. The invoking comment
491+
* commands (one per `@<slug>` line) mixed with prose. The invoking comment
492492
* gets a 👍 when every invocation ran and a 👎 when any was rejected or
493493
* failed. Returns the applied outputs, undefined when nothing ran.
494494
*/

‎src/github/engine/event.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ export enum EventType {
1414
PULL_REQUEST_UNLABELED = "pull_request.unlabeled",
1515

1616
/**
17-
* Synthetic PR event to reevaluate a rule (cron sweep, `/<slug> update`).
17+
* Synthetic PR event to reevaluate a rule (cron sweep, `@<slug> update`).
1818
*/
1919
ON_DEMAND = "on_demand",
2020

2121
/**
22-
* Synthetic issue counterpart of ON_DEMAND (`/<slug> update` on an issue).
22+
* Synthetic issue counterpart of ON_DEMAND (`@<slug> update` on an issue).
2323
*/
2424
ISSUES_ON_DEMAND = "issues.on_demand",
2525
}

‎src/github/engine/model/command-context.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function escapeRegExp(s: string): string {
1818
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1919
}
2020

21-
/** Whether any line of the comment addresses the bot (`/<slug> …`). */
21+
/** Whether any line of the comment addresses the bot (`@<slug> …`). */
2222
export function isBotCommand(commentBody: string, slug: string): boolean {
23-
return new RegExp(`^/${escapeRegExp(slug)}\\b`, "im").test(commentBody);
23+
return new RegExp(`^@${escapeRegExp(slug)}\\b`, "im").test(commentBody);
2424
}
2525

2626
export interface CommandInvocation {
@@ -45,13 +45,13 @@ function parseArgs(rest: string | undefined): Pick<CommandInvocation, "args" | "
4545
}
4646

4747
/**
48-
* Every command in the comment, one per line that starts with `/<slug>`.
48+
* Every command in the comment, one per line that starts with `@<slug>`.
4949
* Surrounding prose lines are ignored, so commands can be mixed with text
5050
* and several commands can be stacked in one comment.
5151
*/
5252
export function parseCommands(commentBody: string, slug: string): CommandInvocation[] {
5353
const re = new RegExp(
54-
`^/${escapeRegExp(slug)}\\s+([\\w-]+)(?:[^\\S\\n]+(\\S[^\\n]*?))?[^\\S\\n]*$`,
54+
`^@${escapeRegExp(slug)}\\s+([\\w-]+)(?:[^\\S\\n]+(\\S[^\\n]*?))?[^\\S\\n]*$`,
5555
"gim",
5656
);
5757
return [...commentBody.matchAll(re)].map((match) => ({

‎src/github/engine/status/render.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type StatusTarget = "pull_request" | "issue";
6262
export interface StatusExtras {
6363
/** Target author login, mentioned in the issue greeting. */
6464
author?: string;
65-
/** Comment-command prefix; defaults to `ha-bot`. */
65+
/** Comment-command prefix; defaults to `home-assistant`. */
6666
commandSlug?: string;
6767
/** The repo's registered commands, listed in the collapsed help. */
6868
commands?: readonly CommandHelpEntry[];
@@ -117,7 +117,7 @@ export function renderStatus(
117117
target: StatusTarget = "pull_request",
118118
extras: StatusExtras = {},
119119
): string {
120-
const slug = extras.commandSlug ?? "ha-bot";
120+
const slug = extras.commandSlug ?? "home-assistant";
121121
const blocks = extras.blocks ?? {};
122122
const display = sections.map(displaySection);
123123
const passing = display.filter((s) => s.status === "pass");

‎src/github/engine/status/templates/dashboard-issue.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Things to address:
5353
{{#hasCommands}}
5454
<details><summary>Bot commands</summary>
5555

56-
Reply with `/{{commandSlug}} <command>`. Several commands can be stacked, one per line:
56+
Reply with `@{{commandSlug}} <command>`. Several commands can be stacked, one per line:
5757

5858
{{#commands}}
5959
- `{{name}}` — {{description}}{{permissionNote}}{{exampleSuffix}}

‎src/github/engine/status/templates/dashboard-pr.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ This dashboard automatically updates on every change to this PR and reevaluates
1010

1111
### Skip a check that doesn't apply
1212

13-
If you think a check doesn't apply to your PR (or the rule is bugged), comment `/{{commandSlug}} ignore "<check name>" "<reason>"`. The check name as shown in the table above. This will mark the check as ignored and let you put your PR in 'Ready for review'; `/{{commandSlug}} unignore "<check name>"` restores the rule.
13+
If you think a check doesn't apply to your PR (or the rule is bugged), comment `@{{commandSlug}} ignore "<check name>" "<reason>"`. The check name as shown in the table above. This will mark the check as ignored and let you put your PR in 'Ready for review'; `@{{commandSlug}} unignore "<check name>"` restores the rule.
1414

1515
### Bot commands
1616

1717
{{#hasCommands}}
18-
Reply with `/{{commandSlug}} <command>`. Several commands can be stacked, one per line:
18+
Reply with `@{{commandSlug}} <command>`. Several commands can be stacked, one per line:
1919

2020
{{#commands}}
2121
- `{{name}}` — {{description}}{{permissionNote}}{{exampleSuffix}}

‎src/github/engine/status/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface StatusSection {
1313
status: SectionStatus;
1414
message: string;
1515
/**
16-
* Author waiver (`/<slug> ignore`). Persisted in the section state embedded
16+
* Author waiver (`@<slug> ignore`). Persisted in the section state embedded
1717
* in the status comment, so it sticks across re-emissions: a rule
1818
* re-reporting `fail` on a later push stays waived until an explicit
1919
* `unignore`. Only affects how `fail`/`pending` present and aggregate.

‎src/github/engine/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export interface Rule {
142142
}
143143

144144
/**
145-
* A comment command (`/<slug> <name> [args]`). Like rules, commands return
145+
* A comment command (`@<slug> <name> [args]`). Like rules, commands return
146146
* a {@link RuleOutput} instead of mutating GitHub directly. The declared constraints
147147
* (args, scope, permission) are enforced by the dispatcher, which answers
148148
* with a 👍/👎 reaction on the comment.

0 commit comments

Comments
 (0)