feat: project-level prompts for metadata generation (#836)

* feat(server): project-level prompts for metadata generation

Add `metadataGeneration` config to `paseo.json` so projects can customize the
four LLM-generated metadata strings — agent title, worktree branch name, commit
message, and pull request title+body. Each entry takes an `instructions` string
that gets injected as a `<user-instructions>` block between the default rules
and the load-bearing JSON format contract, with wrapper text saying user
instructions override defaults. Missing/empty/invalid config keeps every prompt
byte-identical to today.

* refactor(server): centralize project metadata prompt building

Three near-identical readers and four gate-then-wrap blocks collapsed
into one buildMetadataPrompt helper. wrapWithUserInstructions tightened
to require a non-empty string; its misleading empty fallback is gone.

* feat(app): edit metadata generation prompts in project settings

Adds four textareas (agent title, branch name, commit message, pull
request) under project settings, modeled on the existing setup/teardown
pattern. Round-trips through paseo.json preserving unknown sibling
fields at both the metadataGeneration and entry level.
This commit is contained in:
Mohamed Boudra
2026-05-09 18:36:29 +08:00
committed by GitHub
parent 8b09846f98
commit 030e163fb8
16 changed files with 1240 additions and 39 deletions
@@ -31,7 +31,9 @@ import { confirmDialog } from "@/utils/confirm-dialog";
import {
applyDraftToConfig,
configToDraft,
METADATA_PROMPT_KEYS,
type LifecycleOriginalKind,
type MetadataPromptKey,
type ProjectConfigDraft,
type ProjectScriptDraft,
} from "@/utils/project-config-form";
@@ -42,6 +44,40 @@ const SCRIPT_SERVICE_TYPE = "service";
const ICON_SIZE = 14;
interface MetadataPromptField {
title: string;
placeholder: string;
sectionTestID: string;
inputTestID: string;
}
const METADATA_PROMPT_FIELDS: Record<MetadataPromptKey, MetadataPromptField> = {
agentTitle: {
title: "Agent title prompt",
placeholder: "Keep titles short and action-oriented.",
sectionTestID: "metadata-prompt-agent-title-section",
inputTestID: "metadata-prompt-agent-title-input",
},
branchName: {
title: "Branch name prompt",
placeholder: "Prefix branches with feat/ or fix/.",
sectionTestID: "metadata-prompt-branch-name-section",
inputTestID: "metadata-prompt-branch-name-input",
},
commitMessage: {
title: "Commit message prompt",
placeholder: "Use Conventional Commits.",
sectionTestID: "metadata-prompt-commit-message-section",
inputTestID: "metadata-prompt-commit-message-input",
},
pullRequest: {
title: "Pull request prompt",
placeholder: "Include risk notes and a test plan.",
sectionTestID: "metadata-prompt-pull-request-section",
inputTestID: "metadata-prompt-pull-request-input",
},
};
const NO_TARGET_MESSAGE = "We don't have an editable copy of this project on any connected host.";
const HOST_SWITCHER_LABEL = "Switch host";
@@ -432,6 +468,15 @@ function ProjectConfigForm({
[updateDraft],
);
const handleMetadataPromptChange = useCallback(
(key: MetadataPromptKey, text: string) =>
updateDraft((d) => ({
...d,
metadataPrompts: { ...d.metadataPrompts, [key]: text },
})),
[updateDraft],
);
const handleRemoveScript = useCallback(
async (script: ProjectScriptDraft) => {
const ok = await confirmDialog({
@@ -585,6 +630,15 @@ function ProjectConfigForm({
</View>
</SettingsSection>
{METADATA_PROMPT_KEYS.map((key) => (
<MetadataPromptSection
key={key}
promptKey={key}
value={draft.metadataPrompts[key]}
onChange={handleMetadataPromptChange}
/>
))}
{isStale ? (
<View style={styles.calloutWrap}>
<Alert
@@ -767,6 +821,36 @@ function HostPickerItem({ host, isSelected, onSelectHost }: HostPickerItemProps)
);
}
interface MetadataPromptSectionProps {
promptKey: MetadataPromptKey;
value: string;
onChange: (key: MetadataPromptKey, text: string) => void;
}
function MetadataPromptSection({ promptKey, value, onChange }: MetadataPromptSectionProps) {
const meta = METADATA_PROMPT_FIELDS[promptKey];
const handleChange = useCallback(
(text: string) => onChange(promptKey, text),
[onChange, promptKey],
);
return (
<SettingsSection title={meta.title} testID={meta.sectionTestID}>
<View style={settingsStyles.card}>
<TextInput
testID={meta.inputTestID}
accessibilityLabel={meta.title}
multiline
value={value}
onChangeText={handleChange}
placeholder={meta.placeholder}
placeholderTextColor={styles.placeholderColor.color}
style={styles.lifecycleInput}
/>
</View>
</SettingsSection>
);
}
interface ScriptRowProps {
script: ProjectScriptDraft;
isFirst: boolean;