Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

feat(skills/agents): unify card + detail page UI; consolidate ⋯ menu

aiservice85eb736cda2d
diff --git a/src/renderer/index.html b/src/renderer/index.html
index f31e0ffb..d59d58fe 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -163,13 +163,12 @@
<h1 class="skills-doc-title" id="skills-detail-name" data-editable="false"></h1>
<span class="skills-doc-source" id="skills-detail-source"></span>
<div class="skills-doc-actions" id="skills-detail-actions">
- <label class="toggle-switch" id="skill-enabled-toggle-wrap" title="">
- <input type="checkbox" id="skill-enabled-toggle" />
- <span class="toggle-slider"></span>
- <span class="toggle-label" id="skill-enabled-label" data-i18n="component.enabled">已启用</span>
- </label>
- <button class="btn btn-sm" id="skill-use-btn" data-i18n="skills.use">使用</button>
+ <button class="btn-icon-use" id="skill-use-btn" data-i18n-title="skills.use_tooltip" data-i18n-aria-label="skills.use_tooltip" aria-label="使用">
+ <svg class="icon-play" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><polygon points="5,3 5,13 13,8" fill="currentColor"/></svg>
+ </button>
<button class="btn btn-sm" id="skill-edit-btn" data-i18n="skills.edit">编辑</button>
+ <button class="btn btn-sm" id="skill-enabled-btn" data-i18n="component.disable">禁用</button>
+ <button class="btn btn-sm" id="skill-promote-btn" style="display:none" data-i18n="skills.promote_to_builtin">设为内置</button>
<button class="btn btn-sm btn-danger" id="skill-delete-btn" data-i18n="skills.delete">删除</button>
</div>
</div>
@@ -259,13 +258,12 @@
<span class="agents-detail-avatar-slot" id="agents-detail-avatar"></span>
<div class="agents-detail-name" id="agents-detail-name" contenteditable="false"></div>
<div class="detail-actions" id="agents-detail-actions">
- <label class="toggle-switch" id="agent-enabled-toggle-wrap" title="">
- <input type="checkbox" id="agent-enabled-toggle" />
- <span class="toggle-slider"></span>
- <span class="toggle-label" id="agent-enabled-label" data-i18n="component.enabled">已启用</span>
- </label>
- <button class="btn btn-sm" id="agent-use-btn" data-i18n="agents.use">使用</button>
+ <button class="btn-icon-use" id="agent-use-btn" data-i18n-title="agents.use_tooltip" data-i18n-aria-label="agents.use_tooltip" aria-label="使用">
+ <svg class="icon-play" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><polygon points="5,3 5,13 13,8" fill="currentColor"/></svg>
+ </button>
<button class="btn btn-sm" id="agent-edit-btn" data-i18n="agents.edit_btn_edit">编辑</button>
+ <button class="btn btn-sm" id="agent-enabled-btn" data-i18n="component.disable">禁用</button>
+ <button class="btn btn-sm" id="agent-promote-btn" style="display:none" data-i18n="agents.promote_to_builtin">设为内置</button>
<button class="btn btn-sm btn-danger" id="agent-delete-btn" data-i18n="agents.delete">删除</button>
</div>
</div>
diff --git a/src/renderer/locales/en.json b/src/renderer/locales/en.json
index 5b67a002..99f21fcb 100644
--- a/src/renderer/locales/en.json
+++ b/src/renderer/locales/en.json
@@ -190,6 +190,9 @@
"skills.save_failed": "Save failed",
"skills.delete_confirm": "Delete the skill \"{name}\" and all its files?",
"skills.delete_failed_with": "Delete failed: {reason}",
+ "skills.promote_to_builtin": "Make built-in (dev)",
+ "skills.promote_confirm": "Promote the custom skill \"{name}\" to built-in? This writes to both src/builtin and data/builtin and removes the custom copy.",
+ "skills.promote_failed_with": "Promote to built-in failed: {reason}",
"agents.title": "Agents",
"agents.create_btn": "+ Create",
"agents.empty": "No agents yet",
@@ -221,6 +224,9 @@
"agents.delete_confirm": "Delete this agent? Related conversations will also be removed.",
"agents.delete_failed": "Delete failed",
"agents.delete_failed_with": "Delete failed: {reason}",
+ "agents.promote_to_builtin": "Make built-in (dev)",
+ "agents.promote_confirm": "Promote the custom agent \"{name}\" to built-in? Only agent.json is copied to src/builtin and data/builtin (meta/ and self-evolved skills/ are dropped); the custom copy is removed.",
+ "agents.promote_failed_with": "Promote to built-in failed: {reason}",
"agents.edit_chat_empty": "Tell me how you'd like to adjust this agent",
"agents.clear_confirm": "Clear the edit chat for this agent?",
"agents.agent_not_found": "Agent not found",
diff --git a/src/renderer/locales/zh.json b/src/renderer/locales/zh.json
index 03dd3914..f97513b1 100644
--- a/src/renderer/locales/zh.json
+++ b/src/renderer/locales/zh.json
@@ -190,6 +190,9 @@
"skills.save_failed": "保存失败",
"skills.delete_confirm": "确认删除技能 \"{name}\" 及其所有文件?",
"skills.delete_failed_with": "删除失败:{reason}",
+ "skills.promote_to_builtin": "设为内置(开发)",
+ "skills.promote_confirm": "确认把自定义技能 \"{name}\" 提升为内置?会同步写入 src/builtin 与 data/builtin,并删除原自定义目录。",
+ "skills.promote_failed_with": "提升为内置失败:{reason}",
"agents.title": "智能体",
"agents.create_btn": "+ 创建",
"agents.empty": "暂无智能体",
@@ -221,6 +224,9 @@
"agents.delete_confirm": "确认删除这个智能体?相关对话会一并删除。",
"agents.delete_failed": "删除失败",
"agents.delete_failed_with": "删除失败:{reason}",
+ "agents.promote_to_builtin": "设为内置(开发)",
+ "agents.promote_confirm": "确认把自定义智能体 \"{name}\" 提升为内置?只复制 agent.json 到 src/builtin 与 data/builtin(meta/ 与自演化 skills/ 会丢弃),并删除原自定义目录。",
+ "agents.promote_failed_with": "提升为内置失败:{reason}",
"agents.edit_chat_empty": "跟我说你想怎么调整这个智能体",
"agents.clear_confirm": "确认清空当前智能体的编辑对话记录?",
"agents.agent_not_found": "智能体不存在",
diff --git a/src/renderer/modules/agents.js b/src/renderer/modules/agents.js
index 54033cd5..85d31a0f 100644
--- a/src/renderer/modules/agents.js
+++ b/src/renderer/modules/agents.js
@@ -90,26 +90,22 @@ function renderAgentsGrid(agents) {
const desc = pickDesc(a, getLang()).trim();
const descClass = desc ? 'agent-card-desc' : 'agent-card-desc is-empty';
const descText = desc || t('agents.placeholder_unset');
- const sourceLabel = a.source === 'custom' ? t('agents.source_custom') : t('agents.source_builtin');
- const sourceCls = a.source === 'custom' ? 'is-custom' : 'is-builtin';
+ // Source label (custom / builtin) is shown on the detail page only;
+ // the grid cards stay clean and use the ⋯ menu for actions.
const moreBtn = `<button type="button" class="agent-card-more" data-agent-more title="${moreTitle}" aria-label="${moreTitle}">⋯</button>`;
- const toggleTitle = escapeHtml(enabled ? t('component.toggle_disable_hint') : t('component.toggle_enable_hint'));
- const toggle = `<label class="toggle-switch is-compact" data-agent-toggle title="${toggleTitle}" aria-label="${toggleTitle}">
- <input type="checkbox" data-agent-toggle-input ${enabled ? 'checked' : ''} />
- </label>`;
const avatarHtml = renderAvatarHtml(a.icon, a.color, { size: 32, seed: a.agent_id, extraClass: 'agent-card-avatar' });
return `
<div class="agent-card${enabled ? '' : ' is-disabled'}" data-id="${escapeHtml(a.agent_id)}" data-source="${a.source}">
<div class="agent-card-header">
${avatarHtml}
<span class="agent-card-name">${escapeHtml(a.name || t('agents.unnamed'))}</span>
- <span class="agent-card-source ${sourceCls}">${escapeHtml(sourceLabel)}</span>
- ${toggle}
${moreBtn}
</div>
<div class="${descClass}">${escapeHtml(descText)}</div>
<div class="agent-card-actions">
- <button type="button" class="agent-card-use" data-agent-use title="${useTitle}" aria-label="${useTitle}">▶</button>
+ <button type="button" class="agent-card-use" data-agent-use title="${useTitle}" aria-label="${useTitle}">
+ <svg class="icon-play" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><polygon points="5,3 5,13 13,8" fill="currentColor"/></svg>
+ </button>
</div>
</div>
`;
@@ -126,10 +122,6 @@ function renderAgentsGrid(agents) {
for (const card of document.querySelectorAll('.agent-card')) {
const id = card.dataset.id;
card.addEventListener('click', (e) => {
- if (e.target.closest('[data-agent-toggle]')) {
- e.stopPropagation();
- return;
- }
if (e.target.closest('[data-agent-use]')) {
e.stopPropagation();
useAgent(id);
@@ -142,34 +134,29 @@ function renderAgentsGrid(agents) {
}
_showAgentsDetailView(id);
});
- const toggleInput = card.querySelector('[data-agent-toggle-input]');
- toggleInput?.addEventListener('change', async (e) => {
- e.stopPropagation();
- await _flipAgentEnabledFromCard(id, toggleInput);
- });
}
}
-async function _flipAgentEnabledFromCard(agentId, input) {
- const next = input.checked;
- input.disabled = true;
+/** Flip an agent's enabled override (used by both the ⋯ menu's toggle item
+ * and the detail-page enable/disable button). On failure, alerts; on
+ * success, refreshes the grid + detail page. */
+async function _flipAgentEnabled(agentId, nextEnabled) {
try {
- const res = await window.orkas.invoke('agents.setEnabled', { agent_id: agentId, enabled: next });
+ const res = await window.orkas.invoke('agents.setEnabled', { agent_id: agentId, enabled: nextEnabled });
if (!res || !res.ok) {
- input.checked = !next;
await uiAlert(t('component.toggle_failed'));
- return;
+ return false;
}
- const card = input.closest('.agent-card');
- if (card) card.classList.toggle('is-disabled', !next);
const cached = _agentsCache?.find((a) => a.agent_id === agentId);
- if (cached) cached.enabled = next;
+ if (cached) cached.enabled = nextEnabled;
await loadAgents(true);
+ if (_selectedAgent?.id === agentId) {
+ _renderAgentEnabledButton({ id: agentId, enabled: nextEnabled });
+ }
+ return true;
} catch (err) {
- input.checked = !next;
await uiAlert(t('component.toggle_failed'));
- } finally {
- input.disabled = false;
+ return false;
}
}
@@ -290,13 +277,19 @@ function _renderAgentRowMenuItems(menu, agentId) {
const a = _agentsCache?.find((x) => x.agent_id === agentId);
const enabled = a ? a.enabled !== false : true;
const isCustom = a?.source === 'custom';
+ // Dev mode lifts the source guard for built-in edit / delete; custom adds
+ // a "promote to built-in" item too.
+ const canEdit = isCustom || (a?.source === 'builtin' && isDevMode());
const toggleLabel = enabled ? t('component.disable') : t('component.enable');
const items = [];
- if (isCustom) {
+ if (canEdit) {
items.push(`<div class="agent-row-menu-item" data-action="edit">${escapeHtml(t('agents.edit'))}</div>`);
}
+ if (isCustom && isDevMode()) {
+ items.push(`<div class="agent-row-menu-item" data-action="promote">${escapeHtml(t('agents.promote_to_builtin'))}</div>`);
+ }
items.push(`<div class="agent-row-menu-item" data-action="toggle-enabled">${escapeHtml(toggleLabel)}</div>`);
- if (isCustom) {
+ if (canEdit) {
items.push(`<div class="agent-row-menu-item is-danger" data-action="delete">${escapeHtml(t('agents.delete'))}</div>`);
}
menu.innerHTML = items.join('');
@@ -313,6 +306,8 @@ function _renderAgentRowMenuItems(menu, agentId) {
} else if (action === 'delete') {
if (_selectedAgent?.id !== aid) await selectAgent(aid);
await deleteSelectedAgent();
+ } else if (action === 'promote') {
+ await promoteCustomAgent(aid);
} else if (action === 'toggle-enabled') {
await _flipAgentEnabledFromMenu(aid);
}
@@ -320,23 +315,31 @@ function _renderAgentRowMenuItems(menu, agentId) {
}
}
-async function _flipAgentEnabledFromMenu(agentId) {
+/** Dev-only: promote a custom agent to built-in. Copies agent.json to
+ * src+data trees, removes the custom dir (meta/ + skills/ dropped),
+ * refreshes the grid. */
+async function promoteCustomAgent(agentId) {
+ if (!isDevMode()) return;
const cached = _agentsCache?.find((x) => x.agent_id === agentId);
- const next = !(cached?.enabled !== false);
+ if (!(await uiConfirm(t('agents.promote_confirm', { name: cached?.name || agentId })))) return;
try {
- const res = await window.orkas.invoke('agents.setEnabled', { agent_id: agentId, enabled: next });
- if (!res || !res.ok) {
- await uiAlert(t('component.toggle_failed'));
+ const result = await window.orkas.invoke('agents.promoteToBuiltin', { agent_id: agentId });
+ if (!result.ok) {
+ await uiAlert(t('agents.promote_failed_with', { reason: result.error || '' }));
return;
}
- if (cached) cached.enabled = next;
await loadAgents(true);
- } catch (err) {
- _agentsLog.warn('agents.setEnabled failed', err);
- await uiAlert(t('component.toggle_failed'));
+ } catch (e) {
+ await uiAlert(t('agents.promote_failed_with', { reason: e.message || e }));
}
}
+async function _flipAgentEnabledFromMenu(agentId) {
+ const cached = _agentsCache?.find((x) => x.agent_id === agentId);
+ const next = !(cached?.enabled !== false);
+ await _flipAgentEnabled(agentId, next);
+}
+
async function selectAgent(agentId) {
// Discard any uncommitted edit state when switching agents.
if (_agentEditing && _selectedAgent && _selectedAgent.id !== agentId) {
@@ -391,20 +394,24 @@ function _renderAgentDetail(agent, editing) {
}
if (!editing && !localizedDesc) descEl.innerHTML = unsetHtml;
- // Detail header actions: 使用 / 编辑 / 删除 + 启用 toggle. Builtin agents
- // hide 编辑 and 删除 (spec-immutable); 编辑 button doubles as 完成 while
- // in edit mode and 使用/删除 hide so the user can't accidentally launch
- // or destroy a half-edited agent.
+ // Detail header actions, fixed order:
+ // 使用(icon) / 编辑 / 启用-禁用 / 内置(custom+dev) / 删除
+ // Edit mode hides everything except the 完成 button (the relabeled 编辑).
const useBtn = document.getElementById('agent-use-btn');
+ const enableBtn = document.getElementById('agent-enabled-btn');
+ const promoteBtn = document.getElementById('agent-promote-btn');
const delBtn = document.getElementById('agent-delete-btn');
const isCustom = agent.source === 'custom';
+ const canEdit = isCustom || (agent.source === 'builtin' && isDevMode());
if (useBtn) useBtn.style.display = editing ? 'none' : '';
- if (delBtn) delBtn.style.display = (isCustom && !editing) ? '' : 'none';
+ if (enableBtn) enableBtn.style.display = editing ? 'none' : '';
+ if (promoteBtn) promoteBtn.style.display = (isCustom && isDevMode() && !editing) ? '' : 'none';
+ if (delBtn) delBtn.style.display = (canEdit && !editing) ? '' : 'none';
if (editBtn) {
- editBtn.style.display = isCustom ? '' : 'none';
+ editBtn.style.display = canEdit ? '' : 'none';
editBtn.textContent = editing ? t('agents.edit_btn_done') : t('agents.edit_btn_edit');
}
- _renderAgentEnabledToggle({ id: agent.agent_id, enabled: agent.enabled !== false });
+ _renderAgentEnabledButton({ id: agent.agent_id, enabled: agent.enabled !== false });
_toggleAgentFieldEditable(editing);
}
@@ -454,44 +461,25 @@ function _renderAgentDetailAvatar(agent) {
});
}
-function _renderAgentEnabledToggle(agent) {
- const wrap = document.getElementById('agent-enabled-toggle-wrap');
- const oldInput = document.getElementById('agent-enabled-toggle');
- const label = document.getElementById('agent-enabled-label');
- if (!wrap || !oldInput || !label) return;
+/** Per-agent 启用 / 禁用 button in the detail header. Clone-replace to drop
+ * any prior click handler bound to a stale agent id. The button label
+ * flips between 启用 / 禁用 (whichever the click would do). */
+function _renderAgentEnabledButton(agent) {
+ const oldBtn = document.getElementById('agent-enabled-btn');
+ if (!oldBtn) return;
const enabled = agent.enabled !== false;
- // Clone-replace to drop any prior change listener bound for a different agent.
- const input = oldInput.cloneNode(true);
- input.checked = enabled;
- oldInput.parentNode.replaceChild(input, oldInput);
- label.textContent = enabled ? t('component.enabled') : t('component.disabled');
- wrap.classList.toggle('is-disabled', !enabled);
- wrap.title = enabled ? t('component.toggle_disable_hint') : t('component.toggle_enable_hint');
- input.addEventListener('change', async () => {
- const next = input.checked;
- input.disabled = true;
- try {
- const res = await window.orkas.invoke('agents.setEnabled', { agent_id: agent.id, enabled: next });
- if (!res || !res.ok) {
- input.checked = !next;
- await uiAlert(t('component.toggle_failed'));
- return;
- }
- label.textContent = next ? t('component.enabled') : t('component.disabled');
- wrap.classList.toggle('is-disabled', !next);
- wrap.title = next ? t('component.toggle_disable_hint') : t('component.toggle_enable_hint');
- const cached = _agentsCache?.find((a) => a.agent_id === agent.id);
- if (cached) cached.enabled = next;
- await loadAgents(true);
- } catch (err) {
- input.checked = !next;
- await uiAlert(t('component.toggle_failed'));
- } finally {
- input.disabled = false;
- }
+ const btn = oldBtn.cloneNode(true);
+ oldBtn.parentNode.replaceChild(btn, oldBtn);
+ btn.textContent = enabled ? t('component.disable') : t('component.enable');
+ btn.title = enabled ? t('component.toggle_disable_hint') : t('component.toggle_enable_hint');
+ btn.addEventListener('click', async () => {
+ btn.disabled = true;
+ try { await _flipAgentEnabled(agent.id, !enabled); }
+ finally { btn.disabled = false; }
});
}
+
function _toggleAgentFieldEditable(on) {
const nameEl = document.getElementById('agents-detail-name');
const descEl = document.getElementById('agents-detail-desc');
@@ -504,7 +492,8 @@ function _toggleAgentFieldEditable(on) {
async function toggleAgentEditMode() {
if (!_selectedAgent) return;
- if (_selectedAgent.source === 'builtin') return;
+ // Built-in editing is dev-only; lift the source guard accordingly.
+ if (_selectedAgent.source === 'builtin' && !isDevMode()) return;
if (_agentEditing) {
await _exitAgentEditMode();
} else {
diff --git a/src/renderer/modules/boot.js b/src/renderer/modules/boot.js
index c62e5baa..581f294a 100644
--- a/src/renderer/modules/boot.js
+++ b/src/renderer/modules/boot.js
@@ -30,6 +30,13 @@ async function _stampSettingsVersion() {
} catch (_) { /* ignore — non-critical */ }
}
+// Dev-mode editing of built-in skills / agents is stripped from the
+// open-source build (the underlying `isDevEnv()` / built-in dual-write IPC
+// stack lives in the in-app debug panel that's only present in PC).
+// Renderer modules still branch on `isDevMode()` for those entry points,
+// so we stub it to false here.
+function isDevMode() { return false; }
+
// 一次性把带历史品牌前缀的 localStorage key 迁移到无前缀形态。盖章后再
// 启动 no-op,写在 boot 最前免得后面任何模块抢着读旧 key。
function _migrateLegacyLocalStorageKeys() {
diff --git a/src/renderer/modules/skills.js b/src/renderer/modules/skills.js
index e9a505cc..e30541d9 100644
--- a/src/renderer/modules/skills.js
+++ b/src/renderer/modules/skills.js
@@ -117,28 +117,21 @@ function renderSkillsGrid(skills) {
const desc = pickDesc(s, getLang()).trim();
const descClass = desc ? 'skill-card-desc' : 'skill-card-desc is-empty';
const descText = desc || t('skills.no_desc');
- const sourceLabel = s.source === 'custom' ? t('skills.source_custom') : t('skills.source_builtin');
- const sourceCls = s.source === 'custom' ? 'is-custom' : 'is-builtin';
- const moreBtn = s.source === 'custom'
- ? `<button type="button" class="skill-card-more" data-skill-more title="${moreTitle}" aria-label="${moreTitle}">⋯</button>`
- : '';
+ // Source label (custom / builtin) is shown on the detail page only;
+ // the grid cards stay clean and use the ⋯ menu for actions.
+ const moreBtn = `<button type="button" class="skill-card-more" data-skill-more title="${moreTitle}" aria-label="${moreTitle}">⋯</button>`;
const enabled = s.enabled !== false;
- const toggleTitle = escapeHtml(enabled ? t('component.toggle_disable_hint') : t('component.toggle_enable_hint'));
- // Pure switch (no label) per UX spec — full label lives in the detail page.
- const toggle = `<label class="toggle-switch is-compact" data-skill-toggle title="${toggleTitle}" aria-label="${toggleTitle}">
- <input type="checkbox" data-skill-toggle-input ${enabled ? 'checked' : ''} />
- </label>`;
return `
<div class="skill-card${enabled ? '' : ' is-disabled'}" data-id="${escapeHtml(s.id)}" data-source="${s.source}">
<div class="skill-card-header">
<span class="skill-card-name">${escapeHtml(s.name)}</span>
- <span class="skill-card-source ${sourceCls}">${escapeHtml(sourceLabel)}</span>
- ${toggle}
${moreBtn}
</div>
<div class="${descClass}">${escapeHtml(descText)}</div>
<div class="skill-card-actions">
- <button type="button" class="skill-card-use" data-skill-use title="${useTitle}" aria-label="${useTitle}">▶</button>
+ <button type="button" class="skill-card-use" data-skill-use title="${useTitle}" aria-label="${useTitle}">
+ <svg class="icon-play" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><polygon points="5,3 5,13 13,8" fill="currentColor"/></svg>
+ </button>
</div>
</div>
`;
@@ -152,17 +145,12 @@ function renderSkillsGrid(skills) {
renderGroup(custom, customGroup, customGrid);
renderGroup(builtin, builtinGroup, builtinGrid);
- // Wire card / ▶ / ⋯ / toggle click handlers.
+ // Wire card / ▶ / ⋯ click handlers. (Enable/disable lives in the ⋯ menu
+ // now — no toggle switch on the card.)
for (const card of document.querySelectorAll('.skill-card')) {
const id = card.dataset.id;
const source = card.dataset.source;
card.addEventListener('click', (e) => {
- // Toggle and its <input>: swallow card-click navigation. The change
- // event below handles the actual flip.
- if (e.target.closest('[data-skill-toggle]')) {
- e.stopPropagation();
- return;
- }
if (e.target.closest('[data-skill-use]')) {
e.stopPropagation();
const skill = _skillsCache?.find(s => s.id === id && s.source === source);
@@ -176,39 +164,29 @@ function renderSkillsGrid(skills) {
}
_showSkillsDetailView(source, id);
});
- const toggleInput = card.querySelector('[data-skill-toggle-input]');
- toggleInput?.addEventListener('change', async (e) => {
- e.stopPropagation();
- await _flipSkillEnabledFromCard(id, toggleInput);
- });
}
}
-/** Flip a skill's enabled override from the list-card toggle. Mirrors the
- * detail-page toggle helper but doesn't touch any detail DOM — just updates
- * the card class and refreshes the cached list. Failure rolls the input back. */
-async function _flipSkillEnabledFromCard(skillId, input) {
- const next = input.checked;
- input.disabled = true;
+/** Flip a skill's enabled override (used by both the ⋯ menu's toggle item
+ * and the detail-page enable/disable button). On failure, alerts and does
+ * not mutate UI state; on success, refreshes the grid + detail page. */
+async function _flipSkillEnabled(skillId, nextEnabled) {
try {
- const res = await window.orkas.invoke('skills.setEnabled', { id: skillId, enabled: next });
+ const res = await window.orkas.invoke('skills.setEnabled', { id: skillId, enabled: nextEnabled });
if (!res || !res.ok) {
- input.checked = !next;
await uiAlert(t('component.toggle_failed'));
- return;
+ return false;
}
- const card = input.closest('.skill-card');
- if (card) card.classList.toggle('is-disabled', !next);
const cached = _skillsCache?.find((s) => s.id === skillId);
- if (cached) cached.enabled = next;
- // Reload so detail page (if open for this skill) and other consumers see
- // the new state without page refresh.
+ if (cached) cached.enabled = nextEnabled;
await loadSkills();
+ if (_selectedSkill?.id === skillId) {
+ _renderSkillEnabledButton({ id: skillId, enabled: nextEnabled });
+ }
+ return true;
} catch (err) {
- input.checked = !next;
await uiAlert(t('component.toggle_failed'));
- } finally {
- input.disabled = false;
+ return false;
}
}
@@ -304,10 +282,28 @@ function _openSkillRowMenu(anchorBtn, id, source) {
_closeSkillRowMenu();
menu.dataset.skillId = id;
menu.dataset.source = source;
- menu.innerHTML = [
- `<div class="skill-row-menu-item" data-action="edit">${escapeHtml(t('skills.edit'))}</div>`,
- `<div class="skill-row-menu-item is-danger" data-action="delete">${escapeHtml(t('skills.delete'))}</div>`,
- ].join('');
+ // Edit/delete are gated: custom always allowed; built-in only in dev mode.
+ // Enable/disable is always shown (lives in this menu now since cards no
+ // longer carry a toggle).
+ const cached = _skillsCache?.find((s) => s.id === id && s.source === source);
+ const enabled = cached ? cached.enabled !== false : true;
+ const canEdit = source === 'custom' || (source === 'builtin' && isDevMode());
+ const items = [];
+ if (canEdit) {
+ items.push(`<div class="skill-row-menu-item" data-action="edit">${escapeHtml(t('skills.edit'))}</div>`);
+ }
+ items.push(
+ `<div class="skill-row-menu-item" data-action="toggle-enabled">${escapeHtml(enabled ? t('component.disable') : t('component.enable'))}</div>`,
+ );
+ if (source === 'custom' && isDevMode()) {
+ items.push(
+ `<div class="skill-row-menu-item" data-action="promote">${escapeHtml(t('skills.promote_to_builtin'))}</div>`,
+ );
+ }
+ if (canEdit) {
+ items.push(`<div class="skill-row-menu-item is-danger" data-action="delete">${escapeHtml(t('skills.delete'))}</div>`);
+ }
+ menu.innerHTML = items.join('');
// While menu open, force the source card's ⋯ visible.
for (const c of document.querySelectorAll('.skill-card.is-menu-open')) c.classList.remove('is-menu-open');
anchorBtn.closest('.skill-card')?.classList.add('is-menu-open');
@@ -326,6 +322,12 @@ function _openSkillRowMenu(anchorBtn, id, source) {
// Mimic the existing delete flow (from detail page) but for any card.
_selectedSkill = { source, id, filepath: 'SKILL.md', name: '' };
await deleteSelectedSkill();
+ } else if (action === 'promote') {
+ await promoteCustomSkill(id);
+ } else if (action === 'toggle-enabled') {
+ const cur = _skillsCache?.find((s) => s.id === id && s.source === source);
+ const nextEnabled = !(cur ? cur.enabled !== false : true);
+ await _flipSkillEnabled(id, nextEnabled);
}
});
}
@@ -521,7 +523,10 @@ async function selectSkillFile(source, id, filepath, nodeEl) {
nameEl.textContent = skill?.name || id;
nameEl.dataset.skillId = id;
nameEl.dataset.source = source;
- // Only custom skills allow click-to-edit on the name
+ // Click-to-rename stays custom-only — built-in renames in dev would need
+ // a dual-tree dir rename + per-user chat dir migration; out of scope for
+ // dev edit. (LLM-driven SKILL.md edits to the `name:` field are also
+ // ignored for built-ins; see features/skills.ts auto-rename guard.)
if (source === 'custom') {
nameEl.classList.add('editable');
nameEl.setAttribute('title', t('skills.rename_title'));
@@ -542,22 +547,27 @@ async function selectSkillFile(source, id, filepath, nodeEl) {
_renderSkillSections(seedDesc ? [['description', seedDesc]] : []);
// Actions bar: visible when a skill is selected.
- // In edit mode only 完成 (the relabeled 编辑 button) is shown; 使用/删除 hide.
- // Builtin skills never show 编辑/删除.
+ // Order: 使用 (icon) / 编辑 / 启用-禁用 / 内置(custom+dev) / 删除.
+ // In edit mode only 完成 (relabeled 编辑) is shown; everything else hides.
const actions = document.getElementById('skills-detail-actions');
+ const canEditThisSkill = source === 'custom' || (source === 'builtin' && isDevMode());
if (actions) {
actions.classList.remove('is-hidden');
const useBtn = document.getElementById('skill-use-btn');
const editBtn = document.getElementById('skill-edit-btn');
+ const enableBtn = document.getElementById('skill-enabled-btn');
+ const promoteBtn = document.getElementById('skill-promote-btn');
const delBtn = document.getElementById('skill-delete-btn');
- const editingThis = _skillEditMode && _skillEditSkillId === id && source === 'custom';
+ const editingThis = _skillEditMode && _skillEditSkillId === id && canEditThisSkill;
if (useBtn) useBtn.style.display = editingThis ? 'none' : '';
- if (editBtn) editBtn.style.display = source === 'custom' ? '' : 'none';
- if (delBtn) delBtn.style.display = (source === 'custom' && !editingThis) ? '' : 'none';
+ if (editBtn) editBtn.style.display = canEditThisSkill ? '' : 'none';
+ if (enableBtn) enableBtn.style.display = editingThis ? 'none' : '';
+ if (promoteBtn) promoteBtn.style.display = (source === 'custom' && isDevMode() && !editingThis) ? '' : 'none';
+ if (delBtn) delBtn.style.display = (canEditThisSkill && !editingThis) ? '' : 'none';
}
- // Per-user 已启用 / 已禁用 toggle. Available for both custom + builtin.
- _renderSkillEnabledToggle({ id, name: skill?.name || id, enabled: skill?.enabled !== false });
+ // Refresh the per-skill enable/disable button label + click handler.
+ _renderSkillEnabledButton({ id, enabled: skill?.enabled !== false });
const body = document.getElementById('skills-detail-body');
// Don't show a loading placeholder — it would collapse body height
@@ -603,7 +613,7 @@ async function selectSkillFile(source, id, filepath, nodeEl) {
try {
const data = await mainPromise;
if (data.ok) {
- const editable = _skillEditMode && _skillEditSkillId === id && source === 'custom';
+ const editable = _skillEditMode && _skillEditSkillId === id && canEditThisSkill;
if (editable) _renderSkillFileEditor(body, data.content || '', data.ext);
else _renderSkillFileView(body, data.content || '', data.ext);
} else {
@@ -620,7 +630,7 @@ async function selectSkillFile(source, id, filepath, nodeEl) {
// Chat column visibility is driven by edit-mode toggle.
// Selecting a different skill resets edit mode off.
const chatCol = document.getElementById('skills-chat-col');
- if (_skillEditMode && _skillEditSkillId === id && source === 'custom') {
+ if (_skillEditMode && _skillEditSkillId === id && canEditThisSkill) {
chatCol.style.display = 'flex';
} else {
_skillEditMode = false;
@@ -874,7 +884,10 @@ function _updateEditButtonLabel() {
// mode (user clicks "编辑" on an existing skill) no message is sent
// automatically — the user drives the conversation from a blank input.
async function toggleSkillEditMode(opts = {}) {
- if (!_selectedSkill || _selectedSkill.source !== 'custom') return;
+ if (!_selectedSkill) return;
+ // Built-in editing is dev-only; lift the source guard accordingly.
+ if (_selectedSkill.source !== 'custom'
+ && !(_selectedSkill.source === 'builtin' && isDevMode())) return;
if (_skillEditMode && _skillEditSkillId === _selectedSkill.id) {
_skillEditMode = false;
_skillEditSkillId = null;
@@ -1248,15 +1261,18 @@ function editSelectedSkill() {
}
async function deleteSelectedSkill() {
- if (!_selectedSkill || _selectedSkill.source !== 'custom') return;
+ if (!_selectedSkill) return;
+ const src = _selectedSkill.source;
+ if (src !== 'custom' && !(src === 'builtin' && isDevMode())) return;
const sid = _selectedSkill.id;
- const cached = _skillsCache?.find(s => s.id === sid && s.source === 'custom');
+ const cached = _skillsCache?.find(s => s.id === sid && s.source === src);
if (!(await uiConfirm(t('skills.delete_confirm', { name: cached?.name || sid })))) return;
try {
- const res = await apiFetch(`/api/skills/${sid}`, { method: 'DELETE' });
- const data = await res.json();
- if (!data.ok) {
- await uiAlert(t('skills.delete_failed_with', { reason: data.error || '' }));
+ const result = src === 'builtin'
+ ? await window.orkas.invoke('skills.builtin.delete', { id: sid })
+ : await (await apiFetch(`/api/skills/${sid}`, { method: 'DELETE' })).json();
+ if (!result.ok) {
+ await uiAlert(t('skills.delete_failed_with', { reason: result.error || '' }));
return;
}
_selectedSkill = null;
@@ -1271,46 +1287,43 @@ async function deleteSelectedSkill() {
}
}
+/** Dev-only: promote a custom skill to built-in. Copies to src+data trees,
+ * removes the custom dir, refreshes the grid. */
+async function promoteCustomSkill(id) {
+ if (!isDevMode()) return;
+ const cached = _skillsCache?.find(s => s.id === id && s.source === 'custom');
+ if (!(await uiConfirm(t('skills.promote_confirm', { name: cached?.name || id })))) return;
+ try {
+ const result = await window.orkas.invoke('skills.promoteToBuiltin', { id });
+ if (!result.ok) {
+ await uiAlert(t('skills.promote_failed_with', { reason: result.error || '' }));
+ return;
+ }
+ _skillsCache = null;
+ _skillTreeCache.clear();
+ await loadSkills();
+ } catch (e) {
+ await uiAlert(t('skills.promote_failed_with', { reason: e.message || e }));
+ }
+}
+
/**
- * Per-user 已启用 / 已禁用 toggle in the skill detail header. Same shape
- * as agents.js's helper — clone-replace to drop prior listener, then bind
- * a fresh change handler that flips the state and refreshes the list.
+ * Per-skill 启用 / 禁用 button in the detail header. Clone-replace the node
+ * each render to drop any prior click handler bound to a stale skill id.
+ * The button label flips between 启用 / 禁用 (whichever the click would do).
*/
-function _renderSkillEnabledToggle(skill) {
- const wrap = document.getElementById('skill-enabled-toggle-wrap');
- const oldInput = document.getElementById('skill-enabled-toggle');
- const label = document.getElementById('skill-enabled-label');
- if (!wrap || !oldInput || !label) return;
+function _renderSkillEnabledButton(skill) {
+ const oldBtn = document.getElementById('skill-enabled-btn');
+ if (!oldBtn) return;
const enabled = skill.enabled !== false;
- const input = oldInput.cloneNode(true);
- input.checked = enabled;
- oldInput.parentNode.replaceChild(input, oldInput);
- label.textContent = enabled ? t('component.enabled') : t('component.disabled');
- wrap.classList.toggle('is-disabled', !enabled);
- wrap.title = enabled ? t('component.toggle_disable_hint') : t('component.toggle_enable_hint');
- input.addEventListener('change', async () => {
- const next = input.checked;
- input.disabled = true;
- try {
- const res = await window.orkas.invoke('skills.setEnabled', { id: skill.id, enabled: next });
- if (!res || !res.ok) {
- input.checked = !next;
- await uiAlert(t('component.toggle_failed'));
- return;
- }
- label.textContent = next ? t('component.enabled') : t('component.disabled');
- wrap.classList.toggle('is-disabled', !next);
- wrap.title = next ? t('component.toggle_disable_hint') : t('component.toggle_enable_hint');
- // Refresh local cache so subsequent renders reflect new state.
- const cached = _skillsCache?.find((s) => s.id === skill.id);
- if (cached) cached.enabled = next;
- await loadSkills();
- } catch (err) {
- input.checked = !next;
- await uiAlert(t('component.toggle_failed'));
- } finally {
- input.disabled = false;
- }
+ const btn = oldBtn.cloneNode(true);
+ oldBtn.parentNode.replaceChild(btn, oldBtn);
+ btn.textContent = enabled ? t('component.disable') : t('component.enable');
+ btn.title = enabled ? t('component.toggle_disable_hint') : t('component.toggle_enable_hint');
+ btn.addEventListener('click', async () => {
+ btn.disabled = true;
+ try { await _flipSkillEnabled(skill.id, !enabled); }
+ finally { btn.disabled = false; }
});
}
diff --git a/src/renderer/modules/state.js b/src/renderer/modules/state.js
index 614785d3..0fb1fba7 100644
--- a/src/renderer/modules/state.js
+++ b/src/renderer/modules/state.js
@@ -201,6 +201,9 @@ function bindStaticHandlers() {
});
document.getElementById('agent-edit-btn')?.addEventListener('click', toggleAgentEditMode);
document.getElementById('agent-delete-btn')?.addEventListener('click', deleteSelectedAgent);
+ document.getElementById('agent-promote-btn')?.addEventListener('click', () => {
+ if (_selectedAgent?.source === 'custom') promoteCustomAgent(_selectedAgent.id);
+ });
document.getElementById('agent-chat-clear-btn')?.addEventListener('click', clearAgentChat);
// Agent inline chat: only bind auto-grow here. Send/abort/Cmd+Enter are
// wired lazily by createChatController in _ensureAgentChatController.
@@ -229,6 +232,9 @@ function bindStaticHandlers() {
});
document.getElementById('skill-edit-btn')?.addEventListener('click', toggleSkillEditMode);
document.getElementById('skill-delete-btn')?.addEventListener('click', deleteSelectedSkill);
+ document.getElementById('skill-promote-btn')?.addEventListener('click', () => {
+ if (_selectedSkill?.source === 'custom') promoteCustomSkill(_selectedSkill.id);
+ });
document.getElementById('skills-detail-name')?.addEventListener('click', _handleSkillNameClick);
document.getElementById('skill-chat-clear-btn')?.addEventListener('click', clearSkillChat);
diff --git a/src/renderer/style.css b/src/renderer/style.css
index 114b9daf..25cd8962 100644
--- a/src/renderer/style.css
+++ b/src/renderer/style.css
@@ -1075,27 +1075,36 @@ body.model-not-configured .main-content { flex-direction: column; }
justify-content: flex-end;
}
-.skill-card-use {
+.skill-card-use,
+.agent-card-use,
+.btn-icon-use {
flex-shrink: 0;
width: 26px;
height: 26px;
- padding: 0 0 0 1px;
+ padding: 0;
border: none;
border-radius: 50%;
background: rgba(37, 99, 235, 0.1);
color: var(--primary);
- font-size: 10px;
- line-height: 1;
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
transition: background 0.12s, transform 0.12s;
}
-.skill-card-use:hover {
+.skill-card-use:hover,
+.agent-card-use:hover,
+.btn-icon-use:hover {
background: rgba(37, 99, 235, 0.2);
transform: scale(1.05);
}
+/* Centered SVG triangle inside the round play button. The SVG path itself
+ is balanced; the wrapper is plain flex-center, so no padding hacks needed. */
+.skill-card-use .icon-play,
+.agent-card-use .icon-play,
+.btn-icon-use .icon-play {
+ display: block;
+}
/* ─── Per-card ⋯ popover menu ─── */
@@ -3995,27 +4004,7 @@ body.model-not-configured .main-content { flex-direction: column; }
justify-content: flex-end;
}
-.agent-card-use {
- flex-shrink: 0;
- width: 26px;
- height: 26px;
- padding: 0 0 0 1px;
- border: none;
- border-radius: 50%;
- background: rgba(37, 99, 235, 0.1);
- color: var(--primary);
- font-size: 10px;
- line-height: 1;
- cursor: pointer;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- transition: background 0.12s, transform 0.12s;
-}
-.agent-card-use:hover {
- background: rgba(37, 99, 235, 0.2);
- transform: scale(1.05);
-}
+/* `.agent-card-use` shared with `.skill-card-use` / `.btn-icon-use` above. */
/* ─── Agents detail view (replaces grid) ────────────────────────────── */