Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ BYOK_ENCRYPTION_KEY=
AI_GENERATION_ROUTE=claude-openai

# GitHub App (Frontend - Vite build-time env var)
# Defaults: gitdogbot-dev in development, gitdogbot in production
# Defaults: gitdogbot-dev in development, gitdogai in production
VITE_GITHUB_APP_SLUG=

# Lemon Squeezy (Backend - Convex env vars)
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/deploy-convex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@ jobs:
production_env["$name"]="$value"
done

if [ "${production_env[GITHUB_APP_SLUG]}" != "gitdogbot" ]; then
echo "::error::GITHUB_APP_SLUG must be exactly gitdogbot in production."
exit 1
fi
# gitdogbot is the production app's former name, accepted while the
# rename to gitdogai rolls out.
case "${production_env[GITHUB_APP_SLUG]}" in
Comment thread
hyochan marked this conversation as resolved.
Resolved
gitdogai | gitdogbot) ;;
*)
echo "::error::GITHUB_APP_SLUG must be gitdogai in production."
exit 1
;;
esac

if ! DEPLOY_URL_TO_VALIDATE="${production_env[SITE_URL]}" bun run .github/scripts/validateDeployUrl.ts; then
echo "::error::SITE_URL must exactly match a public HTTPS origin without a trailing slash in production."
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ with the actual code as evidence instead of generic advice.
| **Issue assistant** | Turns rough reports into clear, structured issues and answers questions |
| **Discussion assistant** | Replies to GitHub Discussions with context from your codebase |
| **Pull request reviews** | Reviews changed code against the repository, suggests fixes and approves clean code |
| **Review commands** | `@gitdogbot review`, `full review`, `resolve` and `help` in a pull request, or the CLI |
| **Review commands** | `@gitdogai review`, `full review`, `resolve` and `help` in a pull request, or the CLI |
| **Maintainer tagging** | Notifies the right people when a request needs a code change |
| **Approval first** | With approval on (the default), drafts wait in your queue until you approve them |
| **Your own AI keys** | Run generation on your Anthropic or OpenAI key, encrypted at rest and never shown again |
Expand Down Expand Up @@ -97,21 +97,22 @@ approval until the new commits are reviewed.
Gitdog reviews a pull request once, when it is opened or marked ready for
review. After that, ask for more in a pull request comment or from the CLI:

| Pull request comment | CLI | What it does |
| ------------------------ | ------------------------------------------- | ------------------------------------------------ |
| `@gitdogbot review` | `gitdog reviews request <ticket-id>` | Reviews the commits pushed since the last review |
| `@gitdogbot full review` | `gitdog reviews request <ticket-id> --full` | Reviews the whole pull request again |
| `@gitdogbot resolve` | `gitdog reviews resolve <ticket-id>` | Resolves every Gitdog review thread |
| `@gitdogbot help` | `gitdog reviews --help` | Lists the commands |
| Pull request comment | CLI | What it does |
| ----------------------- | ------------------------------------------- | ------------------------------------------------ |
| `@gitdogai review` | `gitdog reviews request <ticket-id>` | Reviews the commits pushed since the last review |
| `@gitdogai full review` | `gitdog reviews request <ticket-id> --full` | Reviews the whole pull request again |
| `@gitdogai resolve` | `gitdog reviews resolve <ticket-id>` | Resolves every Gitdog review thread |
| `@gitdogai help` | `gitdog reviews --help` | Lists the commands |

- **Where**: a comment line in the pull request conversation that starts with
the mention, or follows another review bot's command on the same line
(`@coderabbitai review @gitdogbot review`). Replies inside a review thread
(`@coderabbitai review @gitdogai review`). Replies inside a review thread
are not read.
- **Who**: collaborators can run every command. The pull request author, who
may work from a fork, can run all but `full review`.
- **`@gitdog`** works as shorthand, but it also notifies the GitHub user of that
name, so `@gitdogbot` is preferred.
- **Other names**: `@gitdogbot`, the app's former name, still works. `@gitdog`
works as shorthand, but it also notifies the GitHub user of that name, so
`@gitdogai` is preferred.
- **Status**: while a review runs, one status comment on the pull request shows
whether it is reviewing, waiting for approval, reviewed, or why it could not
finish. A review that failed or ran out of tokens can be requested again. For
Expand All @@ -121,7 +122,7 @@ review. After that, ask for more in a pull request comment or from the CLI:
one repository is paused there for 24 hours. Pull requests opened by bots
such as Dependabot are not reviewed.

In an issue or discussion, mention `@gitdogbot` with a question to get a reply
In an issue or discussion, mention `@gitdogai` with a question to get a reply
grounded in the repository.

## Plans
Expand Down
7 changes: 5 additions & 2 deletions convex/_ai/issueAnalysis/agenticWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ function isResponseIncomplete(response: string): boolean {
return false;
}

const AGENTIC_SYSTEM_PROMPT = `You are ${getConfiguredGitdogMention() ?? "the Gitdog bot"}, an AI-powered GitHub assistant analyzing issues for THIS SPECIFIC REPOSITORY.
// Built per call so a GITHUB_APP_SLUG change applies without a redeploy.
function agenticSystemPrompt(): string {
return `You are ${getConfiguredGitdogMention() ?? "the Gitdog bot"}, an AI-powered GitHub assistant analyzing issues for THIS SPECIFIC REPOSITORY.

## ⛔ ABSOLUTE PROHIBITION - NEVER VIOLATE ⛔

Expand Down Expand Up @@ -703,6 +705,7 @@ When there is **Previous Conversation** context, you are in a DIALOGUE with the
**Key principle:** Read the conversation flow. If your previous response answered a question and the follow-up is just adding/correcting details, respond briefly. Only use tools when genuinely new information is being requested.

**Note:** Users marked with \`[Maintainer]\` are repository owners/collaborators - they are authoritative about their own codebase.`;
}

const ISSUE_ANALYSIS_TYPES = new Set([
"actionable",
Expand Down Expand Up @@ -1016,7 +1019,7 @@ If the remaining evidence is insufficient, say exactly what could not be verifie
}

// Build system prompt with optional response style and learned context
let systemPrompt = AGENTIC_SYSTEM_PROMPT;
let systemPrompt = agenticSystemPrompt();

// Add AI guide files content if found
if (aiGuides.found && aiGuides.content) {
Expand Down
2 changes: 1 addition & 1 deletion convex/_ai/issueAnalysis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
export { analyzeIssue } from "./workflow";
export type { IssueAnalysisResult, IssueType, IssueInput } from "./types";
export {
ISSUE_ANALYSIS_SYSTEM_PROMPT,
issueAnalysisSystemPrompt,
createIssueAnalysisUserPrompt,
} from "./prompts";
5 changes: 4 additions & 1 deletion convex/_ai/issueAnalysis/prompts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// AI prompts for issue analysis
import { getConfiguredGitdogMention } from "../../github/botIdentity";

export const ISSUE_ANALYSIS_SYSTEM_PROMPT = `You are ${getConfiguredGitdogMention() ?? "the Gitdog bot"}, a GitHub Assistant powered by gitdog.dev.
// Built per call so a GITHUB_APP_SLUG change applies without a redeploy.
export function issueAnalysisSystemPrompt(): string {
Comment thread
hyochan marked this conversation as resolved.
Resolved
return `You are ${getConfiguredGitdogMention() ?? "the Gitdog bot"}, a GitHub Assistant powered by gitdog.dev.

## Your Role
Analyze GitHub issues and provide accurate, code-grounded responses using codebase context.
Expand Down Expand Up @@ -79,6 +81,7 @@ Return ONLY valid JSON (no markdown wrapper):
"reasoning": "Brief classification reason (1-2 sentences)",
"suggestedResponse": "REQUIRED - Your response grounded in codebase context. Include code references where applicable."
}`;
}

export function createIssueAnalysisUserPrompt(
title: string,
Expand Down
4 changes: 2 additions & 2 deletions convex/_ai/issueAnalysis/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Workflow, createChatStep } from "../workflow";
import { parseJsonResponse } from "../utils";
import type { IssueAnalysisResult, IssueInput } from "./types";
import {
ISSUE_ANALYSIS_SYSTEM_PROMPT,
issueAnalysisSystemPrompt,
createIssueAnalysisUserPrompt,
} from "./prompts";

Expand All @@ -23,7 +23,7 @@ export async function analyzeIssue(
.addStep(
"analyze_issue",
createChatStep(
ISSUE_ANALYSIS_SYSTEM_PROMPT,
issueAnalysisSystemPrompt(),
(input: unknown) => {
const { title, body, codebaseContext } = input as IssueInput;
return createIssueAnalysisUserPrompt(title, body, codebaseContext);
Expand Down
17 changes: 17 additions & 0 deletions convex/github/botIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ export function getConfiguredGitHubAppSlug(
return slug && GITHUB_APP_SLUG_PATTERN.test(slug) ? slug : null;
}

// The production app was renamed from gitdogbot to gitdogai. Both names keep
// reaching it, so existing comments, docs and habits still work. Only the
// configured slug is trusted as Gitdog's own bot account.
const PRODUCTION_APP_NAMES = ["gitdogai", "gitdogbot"];

/**
* Names a mention can use to address this deployment's app, configured slug
* first. A development app answers only to its own slug.
*/
export function getGitdogMentionNames(configuredSlug?: string): string[] {
const slug = getConfiguredGitHubAppSlug(configuredSlug);
if (!slug) return [];
return PRODUCTION_APP_NAMES.includes(slug)
? [slug, ...PRODUCTION_APP_NAMES.filter((name) => name !== slug)]
: [slug];
}

export function getConfiguredGitdogMention(
configuredSlug?: string,
): string | null {
Expand Down
12 changes: 9 additions & 3 deletions convex/github/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { SignJWT, importPKCS8 } from "jose";
import { getConfiguredGitHubAppSlug, isGitdogBot } from "./botIdentity";
import {
getConfiguredGitHubAppSlug,
getGitdogMentionNames,
isGitdogBot,
} from "./botIdentity";

const GITHUB_APP_REQUEST_TIMEOUT_MS = 15_000;
const GITHUB_API_REQUEST_TIMEOUT_MS = 30_000;
Expand Down Expand Up @@ -226,8 +230,10 @@ export async function fetchGitHubAppJsonWithRetry<T>(
}

function getGitdogMentionPattern(configuredSlug?: string): RegExp | null {
const slug = getConfiguredGitHubAppSlug(configuredSlug);
return slug ? new RegExp(`@${slug}(?=\\s|[:,]|$)`, "i") : null;
const names = getGitdogMentionNames(configuredSlug);
return names.length
? new RegExp(`@(?:${names.join("|")})(?=\\s|[:,]|$)`, "i")
: null;
}

export function normalizeGitdogMentionBody(
Expand Down
2 changes: 1 addition & 1 deletion convex/pullRequests/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const recheck = action({
});

/**
* The CLI and web counterpart of the "@gitdogbot review", "full review" and
* The CLI and web counterpart of the "@gitdogai review", "full review" and
* "resolve" pull request comments. The command reply is returned instead of
* posted. The review itself, a limit notice if it runs out of tokens, and a
* note when there is nothing new to review are posted as for comments.
Expand Down
19 changes: 15 additions & 4 deletions convex/pullRequests/commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { getConfiguredGitHubAppSlug } from "../github/botIdentity";
import {
getConfiguredGitHubAppSlug,
getGitdogMentionNames,
} from "../github/botIdentity";

export type ReviewCommand = "review" | "full_review" | "resolve" | "help";

Expand Down Expand Up @@ -60,9 +63,9 @@ export function parseReviewCommand(
)
.join("\n");
// A command starts a line, or follows another review bot's command on it,
// as in "@coderabbitai review @gitdogbot review". "@gitdog" is shorthand
// as in "@coderabbitai review @gitdogai review". "@gitdog" is shorthand
// for the production app only, so a development app never answers it.
const names = slug === "gitdogbot" ? `${slug}|gitdog` : slug;
const names = commandNames(slug).join("|");
const match = new RegExp(
`^[ \\t]*((?:@(?:${REVIEW_BOTS})(?:[ \\t]+[a-z-]+){0,2}[ \\t]+){0,3})@(?:${names})(?=\\s|[:,]|$)[:,]?[ \\t]*([^@\\n]*)`,
"im",
Expand Down Expand Up @@ -96,8 +99,16 @@ export function parseReviewCommand(
}
}

function commandNames(slug: string): string[] {
const names = getGitdogMentionNames(slug);
return names.length > 1 ? [...names, "gitdog"] : names;
}

export function helpText(slug: string): string {
const mention = `@${slug}`;
const others = commandNames(slug)
.slice(1)
.map((name) => `\`@${name}\``);
return [
"**Gitdog commands**",
"Gitdog reviews a pull request once when it is opened or marked ready for review. After that, comment:",
Expand All @@ -106,7 +117,7 @@ export function helpText(slug: string): string {
`- \`${mention} resolve\`: resolve every Gitdog review thread`,
`- \`${mention} help\`: show this list`,
"Collaborators can run every command; the pull request author can run all but a full review.",
...(slug === "gitdogbot" ? ["`@gitdog` works as shorthand."] : []),
...(others.length ? [`${others.join(" and ")} work too.`] : []),
].join("\n");
}

Expand Down
4 changes: 2 additions & 2 deletions convex/pullRequests/internalAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ export const dismissStaleApproval = internalAction({
access,
args.number,
stale,
`New commits were pushed after the commit Gitdog approved. Comment @${getConfiguredGitHubAppSlug() ?? "gitdogbot"} review to review them.`,
`New commits were pushed after the commit Gitdog approved. Comment @${getConfiguredGitHubAppSlug() ?? "gitdogai"} review to review them.`,
);
// Remembered until GitHub accepts every dismissal, including any past
// the per-run cap, so a later push retries.
Expand Down Expand Up @@ -1338,7 +1338,7 @@ export function commandReply(
}
}

/** Run one "@gitdogbot <command>" comment on a pull request and answer it. */
/** Run one "@gitdogai <command>" comment on a pull request and answer it. */
export const runCommand = internalAction({
args: {
repositoryId: v.id("repositories"),
Expand Down
2 changes: 1 addition & 1 deletion convex/pullRequests/internalMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ export const propose = internalMutation({
(baseFindings === 0 ||
base.executionResult?.inlineFindings === true)));
// A requested follow-up with nothing new still posts when it can
// approve, so "@gitdogbot review" restores an approval a push such as a
// approve, so "@gitdogai review" restores an approval a push such as a
// base merge withdrew.
const unpublished = verificationOnly || (nothingNew && !coverageComplete);
await ctx.db.patch(action._id, {
Expand Down
2 changes: 1 addition & 1 deletion convex/pullRequests/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function handlePullRequestEvent(
}

/**
* A "@gitdogbot <command>" comment on a pull request. Only the PR author and
* A "@gitdogai <command>" comment on a pull request. Only the PR author and
* repository collaborators can run commands, and a redelivered comment runs
* once.
*/
Expand Down
4 changes: 2 additions & 2 deletions convex/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ const applicationTables = {
}),
),
reviewVerificationOnly: v.optional(v.boolean()),
// Started by a "@gitdogbot review" comment or the CLI.
// Started by a "@gitdogai review" comment or the CLI.
reviewRequested: v.optional(v.boolean()),
// The pull request comment that shows this review's progress and outcome.
statusCommentId: v.optional(v.number()),
Expand Down Expand Up @@ -1699,7 +1699,7 @@ const applicationTables = {
.index("by_repository_and_user", ["repositoryId", "userId"]),

// ============================================
// PULL REQUEST COMMANDS (@gitdogbot review, ...)
// PULL REQUEST COMMANDS (@gitdogai review, ...)
// ============================================
// One row per command comment, kept to drop redeliveries and to pause a
// commenter who sends too many.
Expand Down
4 changes: 1 addition & 3 deletions convex/ticketActions/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
CLAIMED_EXECUTION_RECOVERY_GRACE_MS,
} from "./executionRecovery";

const FOOTER_MESSAGE = getGitdogFollowUpFooter();

/**
* Approve a pending action
*/
Expand Down Expand Up @@ -269,7 +267,7 @@ export const approve = action({
const commentBody = buildMarkedResponseComment(
ticketAction.proposedChanges.suggestedResponse,
typeof authorToMention === "string" ? authorToMention : undefined,
FOOTER_MESSAGE,
getGitdogFollowUpFooter(),
executionClaim.idempotencyKey,
);

Expand Down
4 changes: 1 addition & 3 deletions convex/tickets/internalAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ import {
stripExecutionMarkers,
} from "../ticketActions/executionRecovery";

const FOOTER_MESSAGE = getGitdogFollowUpFooter();

function getProviderRetryAttempt(attempt?: number): number {
return attempt !== undefined && Number.isSafeInteger(attempt) && attempt >= 0
? attempt
Expand Down Expand Up @@ -1662,7 +1660,7 @@ export const executeAutoApprovedAction = internalAction({
const commentBody = buildMarkedResponseComment(
ticketAction.proposedChanges.suggestedResponse,
typeof authorToMention === "string" ? authorToMention : undefined,
FOOTER_MESSAGE,
getGitdogFollowUpFooter(),
executionClaim.idempotencyKey,
);

Expand Down
10 changes: 5 additions & 5 deletions docs/github-app-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ review. Later reviews run when the author or a collaborator comments
`@<app-slug> review` (changes since the last review) or `@<app-slug> full
review`; `@<app-slug> resolve` resolves Gitdog's threads and `@<app-slug> help`
lists the commands; `gitdog reviews request|resolve` runs the same from the CLI.
A command is a comment line that starts with the mention, or follows another review bot's command on the same line; `@gitdog` works as shorthand in production. The pull request
A command is a comment line that starts with the mention, or follows another review bot's command on the same line; in production, `@gitdogbot` (the app's former name) and the `@gitdog` shorthand also work. The pull request
author can run every command except a full review, which needs a collaborator.
These arrive through the **Issue comments** event. A
commenter who sends more than 10 commands an hour or 40 a day to one
Expand Down Expand Up @@ -148,7 +148,7 @@ Set the matching Convex environment variable for each backend deployment:

```bash
# Production Convex deployment
bunx convex env set GITHUB_APP_SLUG gitdogbot --prod
bunx convex env set GITHUB_APP_SLUG gitdogai --prod
```

The backend fails closed for mentions and bot-authorship checks when this value
Expand All @@ -161,7 +161,7 @@ authenticate against or mutate the production Convex deployment. Keep the
production `VITE_CONVEX_URL` secret reserved for the main-branch deployment.

When the frontend `VITE_GITHUB_APP_SLUG` variable is omitted, Gitdog defaults
to `gitdogbot-dev` in development and `gitdogbot` in production. The backend
to `gitdogbot-dev` in development and `gitdogai` in production. The backend
Comment thread
hyochan marked this conversation as resolved.
Resolved
variable has no fallback and must match the frontend deployment exactly.

### Verify Environment Variables
Expand Down Expand Up @@ -203,7 +203,7 @@ Users can install the app on:

Each installation is separate with its own installation ID. All installations can be managed at <https://github.com/settings/installations>

Do not connect the same repository to both `gitdogbot` and `gitdogbot-dev`.
Do not connect the same repository to both `gitdogai` and `gitdogbot-dev`.
Mentions are isolated by `GITHUB_APP_SLUG`, but GitHub sends automatic issue,
discussion, repository, and push events to every App installed on that
repository. Use a dedicated test repository for the development App.
Expand All @@ -225,7 +225,7 @@ For production deployment:
2. Update Convex environment variables for production deployment:

```bash
bunx convex env set GITHUB_APP_SLUG gitdogbot --prod
bunx convex env set GITHUB_APP_SLUG gitdogai --prod
bunx convex env set GITHUB_APP_ID "your_app_id" --prod
bunx convex env set GITHUB_APP_CLIENT_ID "your_client_id" --prod
bunx convex env set GITHUB_APP_CLIENT_SECRET --prod < github-app-client-secret.txt
Expand Down
Loading
Loading