feat: add bundled OpenCode skills and refine module flow
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
inman
2026-08-14 18:15:55 +08:00
parent 88f9ee8708
commit c809002180
31 changed files with 1153 additions and 241 deletions

View File

@@ -11,6 +11,7 @@ import { agentAvatarOptions } from '@/lib/agent-avatars';
import { formatModelRefLabel, type ConfiguredModelOption } from '@/lib/model-options';
import { cn } from '@/lib/utils';
import type { ProjectAgentConfig } from '../../../shared/project-config';
import { DEFAULT_PROJECT_AGENT_SKILL_IDS } from '../../../shared/opencode-skills';
export type AgentCreationSkillOption = {
id: string;
@@ -81,6 +82,7 @@ export function AgentCreationDialog({
}: AgentCreationDialogProps) {
const editing = Boolean(agent);
const [input, setInput] = useState<AgentCreationInput>(() => createInitialInput(modelOptions, agent));
const defaultSkillsAppliedRef = useRef(false);
const [submitting, setSubmitting] = useState(false);
const [skillQuery, setSkillQuery] = useState('');
const [avatarPickerOpen, setAvatarPickerOpen] = useState(false);
@@ -88,11 +90,25 @@ export function AgentCreationDialog({
const avatarUploadInputRef = useRef<HTMLInputElement | null>(null);
useEffect(() => {
if (!open) return;
if (!open) {
defaultSkillsAppliedRef.current = false;
return;
}
defaultSkillsAppliedRef.current = editing;
setInput(createInitialInput(modelOptions, agent));
setSkillQuery('');
setAvatarPickerOpen(false);
}, [agent, modelOptions, open]);
}, [agent, editing, modelOptions, open]);
useEffect(() => {
if (!open || editing || defaultSkillsAppliedRef.current) return;
const defaultSkillIds = DEFAULT_PROJECT_AGENT_SKILL_IDS.filter((skillId) => skills.some((skill) => skill.id === skillId));
if (defaultSkillIds.length === 0) return;
setInput((current) => current.skillIds.length > 0
? current
: { ...current, skillIds: [...defaultSkillIds] });
defaultSkillsAppliedRef.current = true;
}, [editing, open, skills]);
const handleAvatarFileChange = async (event: ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0];