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
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export function SettingsIssueTrackerRouteScreen({
<SettingsSection
title={gt("Projects")}
footer={gt(
"Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one.",
"Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one unless asked for another.",
{ tracker: tracker.displayName, scope: tracker.scopeNoun },
)}
>
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -3734,7 +3734,7 @@
"b725843fd45b74aa": "Anmeldedaten",
"b239ba3ce2899a3e": "Oder verwende deine eigenen Anmeldedaten",
"f0e6397ab4de588e": "Token",
"295392927d5c8a84": "Wähle für jedes Projekt ein oder mehrere {scope}s in {tracker}. Ihre Issues erscheinen neben denen des Repositorys, und Agenten legen neue Issues im ersten an.",
"ed83b25c71c98a20": "Wähle für jedes Projekt ein oder mehrere {scope}s in {tracker}. Ihre Issues erscheinen neben denen des Repositorys, und Agenten legen neue Issues im ersten an, sofern kein anderes verlangt wird.",
"ce2136b36f87b655": "Verbinde diese Umgebung, um ihre Einstellungen zu ändern.",
"a90a441fd0e08de7": "Diese Umgebung",
"32fb83554cfd85b4": "Transkriptionsmodelle",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3736,7 +3736,7 @@
"b725843fd45b74aa": "Credentials",
"b239ba3ce2899a3e": "Or use your own credentials",
"f0e6397ab4de588e": "Token",
"295392927d5c8a84": "Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one.",
"ed83b25c71c98a20": "Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one unless asked for another.",
"ce2136b36f87b655": "Connect this environment to change its settings.",
"a90a441fd0e08de7": "This environment",
"32fb83554cfd85b4": "Transcription models",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -3729,7 +3729,7 @@
"b725843fd45b74aa": "Credenciales",
"b239ba3ce2899a3e": "O usa tus propias credenciales",
"f0e6397ab4de588e": "Token",
"295392927d5c8a84": "Elige uno o más {scope}s de {tracker} para cada proyecto. Sus issues aparecen junto a las del repositorio, y los agentes crean issues nuevas en el primero.",
"ed83b25c71c98a20": "Elige uno o más {scope}s de {tracker} para cada proyecto. Sus issues aparecen junto a las del repositorio, y los agentes crean issues nuevas en el primero, salvo que se les pida otro.",
"ce2136b36f87b655": "Conecta este entorno para cambiar sus ajustes.",
"a90a441fd0e08de7": "Este entorno",
"32fb83554cfd85b4": "Modelos de transcripción",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3729,7 +3729,7 @@
"b725843fd45b74aa": "Identifiants",
"b239ba3ce2899a3e": "Ou utilisez vos propres identifiants",
"f0e6397ab4de588e": "Jeton",
"295392927d5c8a84": "Choisissez un ou plusieurs {scope}s {tracker} pour chaque projet. Leurs tickets s'affichent à côté de ceux du dépôt, et les agents créent les nouveaux tickets dans le premier.",
"ed83b25c71c98a20": "Choisissez un ou plusieurs {scope}s {tracker} pour chaque projet. Leurs tickets s'affichent à côté de ceux du dépôt, et les agents créent les nouveaux tickets dans le premier, sauf si vous leur indiquez une autre destination.",
"ce2136b36f87b655": "Connectez cet environnement pour modifier ses paramètres.",
"a90a441fd0e08de7": "Cet environnement",
"32fb83554cfd85b4": "Modèles de transcription",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -3725,7 +3725,7 @@
"b725843fd45b74aa": "資格情報",
"b239ba3ce2899a3e": "または自分の資格情報を使用",
"f0e6397ab4de588e": "トークン",
"295392927d5c8a84": "各プロジェクトに {tracker} の {scope} を1つ以上選択します。その Issue はリポジトリ自身の Issue と並べて表示され、エージェントは最初の {scope} に新しい Issue を作成します。",
"ed83b25c71c98a20": "各プロジェクトに {tracker} の {scope} を1つ以上選択します。その Issue はリポジトリ自身の Issue と並べて表示され、エージェントは別の {scope} を指定されない限り、最初の {scope} に新しい Issue を作成します。",
"ce2136b36f87b655": "設定を変更するには、この環境に接続してください。",
"a90a441fd0e08de7": "この環境",
"32fb83554cfd85b4": "文字起こしモデル",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -3729,7 +3729,7 @@
"b725843fd45b74aa": "자격 증명",
"b239ba3ce2899a3e": "또는 내 자격 증명 사용",
"f0e6397ab4de588e": "토큰",
"295392927d5c8a84": "각 프로젝트에 {tracker} {scope}을(를) 하나 이상 선택하세요. 해당 이슈는 저장소 자체 이슈와 함께 표시되며, 에이전트는 첫 번째 {scope}에 새 이슈를 만듭니다.",
"ed83b25c71c98a20": "각 프로젝트에 {tracker} {scope}을(를) 하나 이상 선택하세요. 해당 이슈는 저장소 자체 이슈와 함께 표시되며, 에이전트는 다른 {scope}을(를) 지정받지 않으면 첫 번째 {scope}에 새 이슈를 만듭니다.",
"ce2136b36f87b655": "설정을 변경하려면 이 환경에 연결하세요.",
"a90a441fd0e08de7": "이 환경",
"32fb83554cfd85b4": "받아쓰기 모델",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -3729,7 +3729,7 @@
"b725843fd45b74aa": "Credenciais",
"b239ba3ce2899a3e": "Ou use suas próprias credenciais",
"f0e6397ab4de588e": "Token",
"295392927d5c8a84": "Escolha um ou mais {scope}s do {tracker} para cada projeto. As issues deles aparecem ao lado das do repositório, e os agentes criam novas issues no primeiro.",
"ed83b25c71c98a20": "Escolha um ou mais {scope}s do {tracker} para cada projeto. As issues deles aparecem ao lado das do repositório, e os agentes criam novas issues no primeiro, a menos que outro seja pedido.",
"ce2136b36f87b655": "Conecte este ambiente para alterar as configurações dele.",
"a90a441fd0e08de7": "Este ambiente",
"32fb83554cfd85b4": "Modelos de transcrição",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -3783,7 +3783,7 @@
"b725843fd45b74aa": "Учётные данные",
"b239ba3ce2899a3e": "Или используйте свои учётные данные",
"f0e6397ab4de588e": "Токен",
"295392927d5c8a84": "Выберите один или несколько {scope} в {tracker} для каждого проекта. Их issue показываются рядом с issue репозитория, а агенты создают новые issue в первом.",
"ed83b25c71c98a20": "Выберите один или несколько {scope} в {tracker} для каждого проекта. Их issue показываются рядом с issue репозитория, а агенты создают новые issue в первом, если вы не укажете, где их создать.",
"ce2136b36f87b655": "Подключите это окружение, чтобы изменить его настройки.",
"a90a441fd0e08de7": "Это окружение",
"32fb83554cfd85b4": "Модели расшифровки",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -3735,7 +3735,7 @@
"b725843fd45b74aa": "Autentiseringsuppgifter",
"b239ba3ce2899a3e": "Eller använd dina egna autentiseringsuppgifter",
"f0e6397ab4de588e": "Token",
"295392927d5c8a84": "Välj en eller flera {scope} i {tracker} för varje projekt. Deras ärenden listas bredvid repots egna, och agenter skapar nya ärenden i den första.",
"ed83b25c71c98a20": "Välj en eller flera {scope} i {tracker} för varje projekt. Deras ärenden listas bredvid repots egna, och agenter skapar nya ärenden i det första om de inte ombeds välja ett annat.",
"ce2136b36f87b655": "Anslut den här miljön för att ändra dess inställningar.",
"a90a441fd0e08de7": "Den här miljön",
"32fb83554cfd85b4": "Transkriberingsmodeller",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -3731,7 +3731,7 @@
"b725843fd45b74aa": "凭据",
"b239ba3ce2899a3e": "或使用你自己的凭据",
"f0e6397ab4de588e": "token",
"295392927d5c8a84": "为每个项目选择一个或多个 {tracker} {scope}。它们的 issue 会列在仓库自身的 issue 旁,智能体会在第一个中创建新 issue。",
"ed83b25c71c98a20": "为每个项目选择一个或多个 {tracker} {scope}。它们的 issue 会列在仓库自身的 issue 旁;除非另有指定,智能体会在第一个中创建新 issue。",
"ce2136b36f87b655": "连接此环境以更改其设置。",
"a90a441fd0e08de7": "此环境",
"32fb83554cfd85b4": "转写模型",
Expand Down
7 changes: 6 additions & 1 deletion apps/server/src/issue/IssueService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,12 @@ describe("IssueService with a standalone tracker", () => {
writable: false,
});
expect((yield* bound.projectScope("web" as ProjectId)).scope).toBe("ENG");
expect((yield* bound.projectScope("web" as ProjectId, "ops-12")).scope).toBe("OPS");
expect((yield* bound.projectScope("web" as ProjectId, { key: "ops-12" })).scope).toBe("OPS");
expect(yield* bound.projectScope("web" as ProjectId, { scope: "ACME/Web" })).toMatchObject({
tracker: GITHUB,
host: "github.com",
scope: "acme/web",
});
expect(
yield* bound.detail({
projectId: "web" as ProjectId,
Expand Down
27 changes: 20 additions & 7 deletions apps/server/src/issue/IssueService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,13 @@ export class IssueService extends Context.Service<
readonly update: (input: IssueUpdateInput) => Effect.Effect<void, IssueError>;
readonly setState: (input: IssueSetStateInput) => Effect.Effect<void, IssueError>;
readonly react: (input: IssueReactionInput) => Effect.Effect<void, IssueError>;
/** The tracker and container a project's own issues live in, or the one `key` names. */
/**
* The tracker and container a project's own issues live in: the bound `scope` when named, else
* the one `key`'s prefix names, else the project's default.
*/
readonly projectScope: (
projectId: ProjectId,
key?: string,
select?: { readonly key?: string | undefined; readonly scope?: string | undefined },
) => Effect.Effect<IssueScopeRef & { readonly host: string }, IssueError>;
/**
* Resolve through a matching project, preferring `preferredProjectId`; other scopes are read-only.
Expand Down Expand Up @@ -678,14 +681,24 @@ const make = Effect.gen(function* () {

const projectScope: IssueService["Service"]["projectScope"] = Effect.fn(
"IssueService.projectScope",
)(function* (projectId, key) {
)(function* (projectId, select) {
const { supported } = yield* listProjects({ projectId });
const prefix = key?.toLowerCase();
if (supported.length === 0) {
return yield* new IssueUnavailableError({ reason: "tracker-unsupported" });
}
const named = select?.scope?.trim().toLowerCase();
const prefix = select?.key?.toLowerCase();
const own =
supported.find((candidate) => prefix?.startsWith(`${candidate.scope.toLowerCase()}-`)) ??
supported[0];
named === undefined
? (supported.find((candidate) => prefix?.startsWith(`${candidate.scope.toLowerCase()}-`)) ??
supported[0])
: supported.find((candidate) => candidate.scope.toLowerCase() === named);
if (own === undefined) {
return yield* new IssueUnavailableError({ reason: "tracker-unsupported" });
return yield* new IssueOperationError({
operation: "scope",
reason: "not-found",
detail: `This project does not track ${select?.scope?.trim()}. Use one of: ${[...new Set(supported.map((candidate) => candidate.scope))].join(", ")}.`,
});
}
return { projectId, tracker: own.tracker, host: own.host, scope: own.scope };
});
Expand Down
65 changes: 65 additions & 0 deletions apps/server/src/mcp/toolkits/issues/handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,71 @@ describe("issue toolkit handlers", () => {
}),
);

it.effect("files an issue in the bound Linear team an agent names", () =>
Effect.gen(function* () {
const tracker = IssueTrackerKind.make("linear");
const host = "linear.app";
const filedIn = yield* Ref.make<ReadonlyArray<string>>([]);
const linear: StandaloneIssueTrackerApi = {
kind: tracker,
capabilities: detail.capabilities,
standalone: {
tracker,
displayName: "Linear",
host,
scopeNoun: "team",
credential: { label: "Personal API key", helpUrl: null },
},
parseIssueUrl: () => null,
probeCredential: () => Effect.succeed({ account: "user", scopes: [] }),
getViewer: () => Effect.succeed("user"),
listIssues: () => Effect.succeed({ items: [], nextCursor: null }),
getComments: () => Effect.succeed({ comments: [], nextCursor: null }),
getIssue: () => Effect.die("unused"),
create: ({ scope }) =>
Ref.update(filedIn, (teams) => [...teams, scope]).pipe(
Effect.as({
key: `${scope}-1`,
url: `https://linear.app/acme/issue/${scope}-1`,
displayKey: `${scope}-1`,
}),
),
};
const issueLayer = IssueService.layer.pipe(
Layer.provide(
Layer.mergeAll(
projectLayer,
Layer.mock(RepositoryIdentityResolver.RepositoryIdentityResolver)({}),
Layer.mock(IssueTrackerBindings.IssueTrackerBindingsRepository)({
list: Effect.succeed(
new Map([[PROJECT_ID, { tracker, scope: "ENG", additionalScopes: ["OPS"] }]]),
),
}),
Layer.succeed(
IssueTrackerRegistry.IssueTrackerRegistry,
IssueTrackerRegistry.fromTrackers([linear]),
),
),
),
);
const harness = yield* makeHarness([], issueLayer);

expect(
yield* harness.call("create_issue", { title: "Backup ran twice", scope: "ops" }),
).toMatchObject({ tracker, scope: "OPS", key: "OPS-1" });
expect(yield* harness.call("create_issue", { title: "Label typo" })).toMatchObject({
scope: "ENG",
key: "ENG-1",
});
const unbound = yield* harness
.call("create_issue", { title: "Flaky test", scope: "QA" })
.pipe(Effect.flip);
expect(unbound).toMatchObject({ _tag: "IssueOperationError", reason: "not-found" });
expect(unbound.message).toContain("Use one of: ENG, OPS.");
expect(yield* Ref.get(filedIn)).toEqual(["OPS", "ENG"]);
}),
);

it.effect("refuses a credential without the issues capability", () =>
Effect.gen(function* () {
const harness = yield* makeHarness();
Expand Down
14 changes: 8 additions & 6 deletions apps/server/src/mcp/toolkits/issues/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,17 @@ const make = Effect.gen(function* () {
/** Where a key-only reference is read: the named project's tracker, or the caller's thread's. */
const requireProjectScope = Effect.fn("IssuesToolkit.requireProjectScope")(function* (
requested: ProjectId | undefined,
key?: string,
select?: { readonly key?: string | undefined; readonly scope?: string | undefined },
) {
// A named project skips the caller's thread, so the capability is checked here too.
yield* McpInvocationContext.requireMcpCapability("issues");
const projectId = requested ?? (yield* callerThread())?.projectId;
if (projectId === undefined) return yield* new IssueProjectRequiredError();
return yield* issues
.projectScope(projectId, key)
.pipe(Effect.mapError(() => new IssueProjectNotFoundError({ projectId })));
return yield* issues.projectScope(projectId, select).pipe(
Effect.catchTags({
IssueUnavailableError: () => Effect.fail(new IssueProjectNotFoundError({ projectId })),
}),
);
});

/**
Expand All @@ -116,7 +118,7 @@ const make = Effect.gen(function* () {
return { ...resolved, url: input.url } satisfies ResolvedTarget;
}
if (input.key === undefined) return yield* new IssueTargetIncompleteError();
const scope = yield* requireProjectScope(input.projectId, input.key);
const scope = yield* requireProjectScope(input.projectId, { key: input.key });
return {
...scope,
key: input.key,
Expand Down Expand Up @@ -231,7 +233,7 @@ const make = Effect.gen(function* () {
),
create_issue: McpToolAccess.writesWithCapability((input) =>
Effect.gen(function* () {
const scope = yield* requireProjectScope(input.projectId);
const scope = yield* requireProjectScope(input.projectId, { scope: input.scope });
const created = yield* issues.create({
...scope,
title: input.title,
Expand Down
5 changes: 5 additions & 0 deletions apps/server/src/mcp/toolkits/issues/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ const CreateIssueTool = Tool.make("create_issue", {
projectId: Schema.optional(
ProjectId.annotate({ description: "Defaults to this thread's project." }),
),
scope: Schema.optional(
TrimmedNonEmptyString.annotate({
description: "A bound team or repository, such as OPS. Defaults to the project's first.",
}),
),
title: TrimmedNonEmptyString.check(Schema.isMaxLength(1024)),
body: Schema.optional(Schema.String.check(Schema.isMaxLength(65_536))),
labels: Schema.optional(Schema.Array(TrimmedNonEmptyString).check(Schema.isMaxLength(50))),
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/provider/agentContextBudget.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"claudeSystemAppendBytes": 6245,
"codexAdditionalContextBytes": 7639,
"mcpToolListJsonBytes": 59026
"mcpToolListJsonBytes": 59052
Comment thread
shivamhwp marked this conversation as resolved.
Resolved
}
2 changes: 1 addition & 1 deletion apps/web/src/components/settings/IssueTrackerSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function ProjectBindings({
<SettingsRow
title={gt("Projects")}
description={gt(
"Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one.",
"Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one unless asked for another.",
{ tracker: tracker.displayName, scope: tracker.scopeNoun },
)}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -8695,7 +8695,7 @@
"58e0e226493150e7": "Issue-Tracker konnten nicht geladen werden",
"77cfcbde543df32d": "Details zu {tracker} ein-/ausblenden",
"0083f65885c60156": "{tracker} trennen",
"295392927d5c8a84": "Wähle für jedes Projekt ein oder mehrere {scope}s in {tracker}. Ihre Issues erscheinen neben denen des Repositorys, und Agenten legen neue Issues im ersten an.",
"ed83b25c71c98a20": "Wähle für jedes Projekt ein oder mehrere {scope}s in {tracker}. Ihre Issues erscheinen neben denen des Repositorys, und Agenten legen neue Issues im ersten an, sofern kein anderes verlangt wird.",
"19c2d5e81ff8f89a": "{tracker} {scope} für {project}",
"68e061510b765772": "Nicht zugeordnet",
"a2d95d39d3398bda": "Anmeldedaten abgelehnt",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8703,7 +8703,7 @@
"58e0e226493150e7": "Could not load issue trackers",
"77cfcbde543df32d": "Toggle {tracker} details",
"0083f65885c60156": "Disconnect {tracker}",
"295392927d5c8a84": "Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one.",
"ed83b25c71c98a20": "Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one unless asked for another.",
"19c2d5e81ff8f89a": "{tracker} {scope} for {project}",
"68e061510b765772": "Not bound",
"a2d95d39d3398bda": "Credential rejected",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -8693,7 +8693,7 @@
"58e0e226493150e7": "No se pudieron cargar los gestores de issues",
"77cfcbde543df32d": "Mostrar u ocultar detalles de {tracker}",
"0083f65885c60156": "Desconectar {tracker}",
"295392927d5c8a84": "Elige uno o más {scope}s de {tracker} para cada proyecto. Sus issues aparecen junto a las del repositorio, y los agentes crean issues nuevas en el primero.",
"ed83b25c71c98a20": "Elige uno o más {scope}s de {tracker} para cada proyecto. Sus issues aparecen junto a las del repositorio, y los agentes crean issues nuevas en el primero, salvo que se les pida otro.",
"19c2d5e81ff8f89a": "{scope} de {tracker} para {project}",
"68e061510b765772": "Sin vincular",
"a2d95d39d3398bda": "Credencial rechazada",
Expand Down
Loading
Loading