Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
122 lines
3.8 KiB
TypeScript
122 lines
3.8 KiB
TypeScript
import type { UiLanguage } from "../../../contexts/settings/domain/agentSettings";
|
|
import { labelForSlashCommand } from "../model/agentSlashCommands";
|
|
import type { AgentSessionCommand } from "../../../shared/agentSessionTypes";
|
|
import type { AgentComposerProps } from "./AgentComposer.types";
|
|
|
|
export function slashCommandDescriptionForDisplay(
|
|
command: AgentSessionCommand,
|
|
labels: Pick<
|
|
AgentComposerProps["labels"],
|
|
| "slashCommandPresentation"
|
|
| "slashCommandCompactDescription"
|
|
| "slashCommandContextDescription"
|
|
| "slashCommandFastDescription"
|
|
| "slashCommandGoalDescription"
|
|
| "slashCommandInitDescription"
|
|
| "slashCommandPlanDescription"
|
|
| "slashCommandReviewDescription"
|
|
| "slashCommandStatusDescription"
|
|
| "slashCommandUsageDescription"
|
|
>
|
|
): string | undefined {
|
|
const providerDescription = command.description?.trim()
|
|
? command.description
|
|
: undefined;
|
|
const localizedDescription = labels.slashCommandPresentation?.(
|
|
command.name
|
|
).description;
|
|
if (localizedDescription) {
|
|
return providerDescription ?? localizedDescription;
|
|
}
|
|
switch (command.name.trim().toLowerCase()) {
|
|
case "compact":
|
|
return labels.slashCommandCompactDescription;
|
|
case "context":
|
|
return labels.slashCommandContextDescription;
|
|
case "fast":
|
|
return labels.slashCommandFastDescription;
|
|
case "goal":
|
|
return labels.slashCommandGoalDescription;
|
|
case "init":
|
|
return labels.slashCommandInitDescription;
|
|
case "plan":
|
|
return labels.slashCommandPlanDescription;
|
|
case "review":
|
|
return labels.slashCommandReviewDescription;
|
|
case "status":
|
|
return labels.slashCommandStatusDescription;
|
|
case "usage":
|
|
return labels.slashCommandUsageDescription;
|
|
default:
|
|
return providerDescription;
|
|
}
|
|
}
|
|
|
|
export function slashCommandLabelForDisplay(
|
|
command: AgentSessionCommand,
|
|
labels: Pick<
|
|
AgentComposerProps["labels"],
|
|
| "slashCommandPresentation"
|
|
| "slashCommandCompactLabel"
|
|
| "slashCommandContextLabel"
|
|
| "slashCommandFastLabel"
|
|
| "slashCommandGoalLabel"
|
|
| "slashCommandInitLabel"
|
|
| "slashCommandPlanLabel"
|
|
| "slashCommandReviewLabel"
|
|
| "slashCommandStatusLabel"
|
|
| "slashCommandUsageLabel"
|
|
>,
|
|
uiLanguage: UiLanguage
|
|
): { primaryLabel?: string; secondaryLabel?: string } {
|
|
const canonicalLabel = labelForSlashCommand(command);
|
|
const primaryLabel = localizedSlashCommandLabel(command, labels);
|
|
return uiLanguage === "en" || primaryLabel === canonicalLabel
|
|
? { primaryLabel }
|
|
: { primaryLabel, secondaryLabel: canonicalLabel };
|
|
}
|
|
|
|
function localizedSlashCommandLabel(
|
|
command: AgentSessionCommand,
|
|
labels: Pick<
|
|
AgentComposerProps["labels"],
|
|
| "slashCommandPresentation"
|
|
| "slashCommandCompactLabel"
|
|
| "slashCommandContextLabel"
|
|
| "slashCommandFastLabel"
|
|
| "slashCommandGoalLabel"
|
|
| "slashCommandInitLabel"
|
|
| "slashCommandPlanLabel"
|
|
| "slashCommandReviewLabel"
|
|
| "slashCommandStatusLabel"
|
|
| "slashCommandUsageLabel"
|
|
>
|
|
): string {
|
|
const localizedLabel = labels.slashCommandPresentation?.(command.name).label;
|
|
if (localizedLabel) {
|
|
return localizedLabel;
|
|
}
|
|
switch (command.name.trim().toLowerCase()) {
|
|
case "compact":
|
|
return labels.slashCommandCompactLabel;
|
|
case "context":
|
|
return labels.slashCommandContextLabel;
|
|
case "fast":
|
|
return labels.slashCommandFastLabel;
|
|
case "goal":
|
|
return labels.slashCommandGoalLabel;
|
|
case "init":
|
|
return labels.slashCommandInitLabel;
|
|
case "plan":
|
|
return labels.slashCommandPlanLabel;
|
|
case "review":
|
|
return labels.slashCommandReviewLabel;
|
|
case "status":
|
|
return labels.slashCommandStatusLabel;
|
|
case "usage":
|
|
return labels.slashCommandUsageLabel;
|
|
default:
|
|
return labelForSlashCommand(command);
|
|
}
|
|
}
|