g1t/apps/web/app/lib/mention.ts

16 lines626 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API1/** How g1t's agent is mentioned. The same as `AGENT_HANDLE` in the contracts. */
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent2export const AGENT_MENTION = "@g1t";
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API3
4const NAME = AGENT_MENTION.slice(1);
5
6/**
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent7 * The `@…` being typed just before the caret, if it could become `@g1t`:
8 * where it starts. Null otherwise, and once it is `@g1t` already.
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API9 */
10export function partialMention(text: string, caret: number): number | null {
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent11 const match = /(?:^|[\s(])@([\w./-]{0,9})$/.exec(text.slice(0, caret));
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API12 if (!match) return null;
13 const typed = match[1].toLowerCase();
14 if (typed === NAME || !NAME.startsWith(typed)) return null;
15 return caret - typed.length - 1;
16}