diff --git a/extensions/README.md b/extensions/README.md index 190e5195a..cd6a1fefd 100644 --- a/extensions/README.md +++ b/extensions/README.md @@ -36,9 +36,23 @@ Each reference extension is self-contained. Copy the whole directory when you wa extensions/gemini-commands/ ├── extension.yaml ├── convert.js -└── md-toml.js +├── md-toml.js +└── package.json ``` +The Codex and Gemini converters use CommonJS. Each includes a `package.json` +with `"type": "commonjs"` so both `convert.js` and `md-toml.js` work when installed +inside a project whose own `package.json` declares `"type": "module"`. Keep this +file when copying an extension. OpenCode's converter uses no CommonJS APIs and +works in either module scope. + +Dashboard installation downloads the complete `extensions//` directory +from the `runkids/skillshare` repository via the GitHub contents API. Updating +the Skillshare binary does not update already installed extension files. To +repair an older Codex or Gemini installation, add `package.json` containing +`{"type":"commonjs"}` inside that extension's own directory, preserving any +existing package fields. The project's root `package.json` does not need to change. + `extension.yaml` tells Skillshare how to run the extension: ```yaml diff --git a/extensions/codex-agents/package.json b/extensions/codex-agents/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/extensions/codex-agents/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/extensions/gemini-commands/package.json b/extensions/gemini-commands/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/extensions/gemini-commands/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/internal/sync/extension_test.go b/internal/sync/extension_test.go index f8bf37193..d9c26a649 100644 --- a/internal/sync/extension_test.go +++ b/internal/sync/extension_test.go @@ -590,6 +590,45 @@ func TestBundledOpencodeAgentExtension_RequiresDescription(t *testing.T) { } } +func TestBundledExtensions_InModuleProject(t *testing.T) { + requireNode(t) + root := testRepoRoot(t) + for _, tc := range []struct { + name string + want string + }{ + {"codex-agents", "developer_instructions = \"\"\"\nUse $ARGUMENTS\n\"\"\""}, + {"gemini-commands", "prompt = \"\"\"\nUse {{args}}\n\"\"\""}, + {"opencode-agents", "mode: subagent\n---\nUse $ARGUMENTS\n"}, + } { + t.Run(tc.name, func(t *testing.T) { + project := t.TempDir() + if err := os.WriteFile(filepath.Join(project, "package.json"), []byte(`{"type":"module"}`), 0644); err != nil { + t.Fatal(err) + } + extDir := filepath.Join(project, ".skillshare", "extensions", tc.name) + if err := os.CopyFS(extDir, os.DirFS(filepath.Join(root, "extensions", tc.name))); err != nil { + t.Fatal(err) + } + spec, err := LoadExtensionSpec(extDir, tc.name) + if err != nil { + t.Fatal(err) + } + src := filepath.Join(project, "reviewer.md") + if err := os.WriteFile(src, []byte("---\ndescription: Review code\n---\nUse $ARGUMENTS\n"), 0644); err != nil { + t.Fatal(err) + } + out, err := runExtension(spec, src, map[string]string{"SS_REL_PATH": "reviewer.md"}) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(string(out), tc.want) { + t.Fatalf("output = %q, want %q", out, tc.want) + } + }) + } +} + func runBundledCodexAgentExtension(t *testing.T, input string) (string, error) { t.Helper() return runBundledExtension(t, "codex-agents", input) diff --git a/ui/src/components/sync/SyncError.tsx b/ui/src/components/sync/SyncError.tsx new file mode 100644 index 000000000..7154811ee --- /dev/null +++ b/ui/src/components/sync/SyncError.tsx @@ -0,0 +1,36 @@ +import { useId, useState } from 'react'; +import { ChevronDown, ChevronRight } from 'lucide-react'; +import CopyButton from '../CopyButton'; +import { useT } from '../../i18n'; + +/** Keep external diagnostics intact, but do not inline an entire stack trace. */ +export default function SyncError({ error }: { error: string }) { + const t = useT(); + const id = useId(); + const [open, setOpen] = useState(false); + const lines = error.trim().split(/\r?\n/); + const first = lines.find((line) => /^\s*[\w.]*Error:\s/.test(line))?.trim() || lines[0]; + const summary = first.length > 240 ? `${first.slice(0, 240)}…` : first; + const condensed = summary !== error.trim(); + return ( +
+ {summary} + {condensed && ( + <> + + {open && ( +
+
+ +
+
{error}
+
+ )} + + )} +
+ ); +} diff --git a/ui/src/components/sync/SyncResult.tsx b/ui/src/components/sync/SyncResult.tsx index f273af56f..22665f635 100644 --- a/ui/src/components/sync/SyncResult.tsx +++ b/ui/src/components/sync/SyncResult.tsx @@ -4,6 +4,7 @@ import AgentIcon from '../AgentIcon'; import Button from '../Button'; import { useT } from '../../i18n'; import { failureExplanation, type SyncFailure } from './syncView'; +import SyncError from './SyncError'; const PART_TAG: Record = { skill: 'Skills', agent: 'Agents', extra: 'Extras', config: 'Config' }; @@ -40,7 +41,7 @@ export default function SyncResult({ failures, warnings, synced, force, onForce {f.extra ? `${PART_TAG[f.part]} · ${f.extra}` : PART_TAG[f.part]} - {f.error} + {f.conflict && !force && onForce ? ( diff --git a/ui/src/i18n/locales/de.json b/ui/src/i18n/locales/de.json index 7356d0287..51233a995 100644 --- a/ui/src/i18n/locales/de.json +++ b/ui/src/i18n/locales/de.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "Dateien ersetzen, die in einem Ziel bearbeitet wurden", "sync.folderConflict.text": "{names} synchronisieren Skills mit unterschiedlichen Filtern in denselben Ordner {path}, sodass jede Synchronisierung die andere rückgängig macht.", "sync.folderConflict.stop": "Skills für {name} nicht mehr synchronisieren", - "sync.last.title": "Letzte Synchronisierung", + "sync.error.showDetails": "Diagnose anzeigen", + "sync.error.hideDetails": "Diagnose ausblenden", + "sync.last.title": "Letzte Skills-/Agents-Sync", + "sync.last.scope": "Nur Skills und Agents. Extras, MCP und Hooks haben separate Synchronisierungslogs.", "sync.last.when": "Wann", "sync.last.targets": "Ziele", "sync.last.took": "Dauer", diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.json index 36d9856ee..ffede8796 100644 --- a/ui/src/i18n/locales/en.json +++ b/ui/src/i18n/locales/en.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "Replace files that were edited inside a target", "sync.folderConflict.text": "{names} sync skills to the same folder {path} with different filters, so each sync undoes the other.", "sync.folderConflict.stop": "Stop syncing skills for {name}", - "sync.last.title": "Last sync", + "sync.error.showDetails": "Show diagnostics", + "sync.error.hideDetails": "Hide diagnostics", + "sync.last.title": "Last skills and agents sync", + "sync.last.scope": "Skills and agents only. Extras, MCP and Hooks have separate sync logs.", "sync.last.when": "When", "sync.last.targets": "Targets", "sync.last.took": "Took", diff --git a/ui/src/i18n/locales/es.json b/ui/src/i18n/locales/es.json index f061d5e52..9533ed84f 100644 --- a/ui/src/i18n/locales/es.json +++ b/ui/src/i18n/locales/es.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "Reemplazar archivos editados dentro de un destino", "sync.folderConflict.text": "{names} sincronizan skills en la misma carpeta {path} con filtros distintos, así que cada sincronización deshace la otra.", "sync.folderConflict.stop": "Dejar de sincronizar skills con {name}", - "sync.last.title": "Última sincronización", + "sync.error.showDetails": "Mostrar diagnóstico", + "sync.error.hideDetails": "Ocultar diagnóstico", + "sync.last.title": "Última sync de skills y agents", + "sync.last.scope": "Solo skills y agents. Extras, MCP y Hooks tienen logs de sincronización independientes.", "sync.last.when": "Cuándo", "sync.last.targets": "Destinos", "sync.last.took": "Duración", diff --git a/ui/src/i18n/locales/fa.json b/ui/src/i18n/locales/fa.json index 76f7990eb..2d08c6b02 100644 --- a/ui/src/i18n/locales/fa.json +++ b/ui/src/i18n/locales/fa.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "فایل‌هایی را که داخل هدف ویرایش شده‌اند جایگزین کن", "sync.folderConflict.text": "{names} Skills را با فیلترهای متفاوت در یک پوشه ({path}) همگام‌سازی می‌کنند، بنابراین هر همگام‌سازی کار دیگری را خنثی می‌کند.", "sync.folderConflict.stop": "توقف همگام‌سازی Skills برای {name}", - "sync.last.title": "آخرین همگام‌سازی", + "sync.error.showDetails": "نمایش جزئیات عیب‌یابی", + "sync.error.hideDetails": "پنهان کردن جزئیات عیب‌یابی", + "sync.last.title": "آخرین همگام‌سازی skills و agents", + "sync.last.scope": "فقط Skills و agents. Extras، MCP و Hooks گزارش همگام‌سازی جداگانه دارند.", "sync.last.when": "زمان", "sync.last.targets": "هدف‌ها", "sync.last.took": "مدت", diff --git a/ui/src/i18n/locales/fr.json b/ui/src/i18n/locales/fr.json index f3e77a2f9..ac4076d28 100644 --- a/ui/src/i18n/locales/fr.json +++ b/ui/src/i18n/locales/fr.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "Remplacer les fichiers modifiés dans une cible", "sync.folderConflict.text": "{names} synchronisent les skills dans le même dossier {path} avec des filtres différents : chaque synchronisation annule l’autre.", "sync.folderConflict.stop": "Arrêter de synchroniser les skills vers {name}", - "sync.last.title": "Dernière synchronisation", + "sync.error.showDetails": "Afficher le diagnostic", + "sync.error.hideDetails": "Masquer le diagnostic", + "sync.last.title": "Dernière synchro skills et agents", + "sync.last.scope": "Skills et agents uniquement. Extras, MCP et Hooks ont des logs de synchronisation distincts.", "sync.last.when": "Quand", "sync.last.targets": "Cibles", "sync.last.took": "Durée", diff --git a/ui/src/i18n/locales/id.json b/ui/src/i18n/locales/id.json index 9f20ee2f4..f7632a668 100644 --- a/ui/src/i18n/locales/id.json +++ b/ui/src/i18n/locales/id.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "Ganti file yang diedit di dalam target", "sync.folderConflict.text": "{names} menyinkronkan skill ke folder yang sama {path} dengan filter berbeda, sehingga setiap sinkronisasi membatalkan yang lain.", "sync.folderConflict.stop": "Berhenti menyinkronkan skill ke {name}", - "sync.last.title": "Sinkronisasi terakhir", + "sync.error.showDetails": "Tampilkan diagnostik", + "sync.error.hideDetails": "Sembunyikan diagnostik", + "sync.last.title": "Sync skills dan agents terakhir", + "sync.last.scope": "Hanya skills dan agents. Extras, MCP, dan Hooks memiliki log sinkronisasi terpisah.", "sync.last.when": "Kapan", "sync.last.targets": "Target", "sync.last.took": "Durasi", diff --git a/ui/src/i18n/locales/ja.json b/ui/src/i18n/locales/ja.json index f034ce523..434409795 100644 --- a/ui/src/i18n/locales/ja.json +++ b/ui/src/i18n/locales/ja.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "ターゲット内で編集されたファイルを置き換えます", "sync.folderConflict.text": "{names} は同じフォルダ {path} に異なるフィルターで Skills を同期しているため、同期のたびに互いの結果を打ち消します。", "sync.folderConflict.stop": "{name} の Skills の同期を停止", - "sync.last.title": "前回の同期", + "sync.error.showDetails": "診断情報を表示", + "sync.error.hideDetails": "診断情報を隠す", + "sync.last.title": "前回の skills・agents 同期", + "sync.last.scope": "Skills と agents のみ。Extras、MCP、Hooks の同期ログは別に記録されます。", "sync.last.when": "日時", "sync.last.targets": "ターゲット", "sync.last.took": "所要時間", diff --git a/ui/src/i18n/locales/ko.json b/ui/src/i18n/locales/ko.json index 2b6751dcb..8e8eb0f51 100644 --- a/ui/src/i18n/locales/ko.json +++ b/ui/src/i18n/locales/ko.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "대상 안에서 수정된 파일을 교체합니다", "sync.folderConflict.text": "{names}이(가) 같은 폴더 {path}에 서로 다른 필터로 Skills를 동기화해서, 동기화할 때마다 서로의 결과를 되돌립니다.", "sync.folderConflict.stop": "{name}의 Skills 동기화 중지", - "sync.last.title": "마지막 동기화", + "sync.error.showDetails": "진단 표시", + "sync.error.hideDetails": "진단 숨기기", + "sync.last.title": "마지막 skills 및 agents 동기화", + "sync.last.scope": "Skills와 agents만 포함합니다. Extras, MCP, Hooks에는 별도의 동기화 로그가 있습니다.", "sync.last.when": "시간", "sync.last.targets": "대상", "sync.last.took": "소요 시간", diff --git a/ui/src/i18n/locales/pt-BR.json b/ui/src/i18n/locales/pt-BR.json index 54e559c74..b3428de84 100644 --- a/ui/src/i18n/locales/pt-BR.json +++ b/ui/src/i18n/locales/pt-BR.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "Substituir arquivos editados dentro de um destino", "sync.folderConflict.text": "{names} sincronizam skills na mesma pasta {path} com filtros diferentes, então cada sincronização desfaz a outra.", "sync.folderConflict.stop": "Parar de sincronizar skills com {name}", - "sync.last.title": "Última sincronização", + "sync.error.showDetails": "Mostrar diagnóstico", + "sync.error.hideDetails": "Ocultar diagnóstico", + "sync.last.title": "Última sync de skills e agents", + "sync.last.scope": "Apenas skills e agents. Extras, MCP e Hooks têm logs de sincronização separados.", "sync.last.when": "Quando", "sync.last.targets": "Destinos", "sync.last.took": "Duração", diff --git a/ui/src/i18n/locales/zh-CN.json b/ui/src/i18n/locales/zh-CN.json index 4c4de850b..af1db1b60 100644 --- a/ui/src/i18n/locales/zh-CN.json +++ b/ui/src/i18n/locales/zh-CN.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "替换在目标中修改过的文件", "sync.folderConflict.text": "{names} 同步到同一个文件夹 {path},但筛选不同,每次同步都会互相加回、删掉。", "sync.folderConflict.stop": "停止同步 {name} 的 Skills", - "sync.last.title": "上次同步", + "sync.error.showDetails": "显示诊断信息", + "sync.error.hideDetails": "隐藏诊断信息", + "sync.last.title": "上次 skills 与 agents 同步", + "sync.last.scope": "仅包含 skills 与 agents。Extras、MCP 与 Hooks 各有独立的同步日志。", "sync.last.when": "时间", "sync.last.targets": "目标", "sync.last.took": "耗时", diff --git a/ui/src/i18n/locales/zh-TW.json b/ui/src/i18n/locales/zh-TW.json index 4e8755b06..754b1ad48 100644 --- a/ui/src/i18n/locales/zh-TW.json +++ b/ui/src/i18n/locales/zh-TW.json @@ -1805,7 +1805,10 @@ "sync.forceHint": "取代在目標中修改過的檔案", "sync.folderConflict.text": "{names} 同步到同一個資料夾 {path},但篩選不同,每次同步都會互相加回、刪掉。", "sync.folderConflict.stop": "停止同步 {name} 的 Skills", - "sync.last.title": "上次同步", + "sync.error.showDetails": "顯示診斷資訊", + "sync.error.hideDetails": "隱藏診斷資訊", + "sync.last.title": "上次 skills 與 agents 同步", + "sync.last.scope": "僅包含 skills 與 agents。Extras、MCP 與 Hooks 各有獨立的同步日誌。", "sync.last.when": "時間", "sync.last.targets": "目標", "sync.last.took": "耗時", diff --git a/ui/src/pages/SyncPage.test.tsx b/ui/src/pages/SyncPage.test.tsx index 97406db93..34d350809 100644 --- a/ui/src/pages/SyncPage.test.tsx +++ b/ui/src/pages/SyncPage.test.tsx @@ -13,7 +13,7 @@ import SyncPage from './SyncPage'; vi.mock('../api/client', async (load) => ({ ...await load(), - api: { listTargets: vi.fn(), diff: vi.fn(), diffExtras: vi.fn(), listLog: vi.fn(), skillsOffPreview: vi.fn(), updateTarget: vi.fn() }, + api: { listTargets: vi.fn(), diff: vi.fn(), diffExtras: vi.fn(), listLog: vi.fn(), skillsOffPreview: vi.fn(), updateTarget: vi.fn(), sync: vi.fn(), syncExtras: vi.fn() }, })); vi.mock('../api/mcp', async (load) => ({ ...await load(), mcpApi: { list: vi.fn() } })); vi.mock('../api/hooks', async (load) => ({ ...await load(), hooksApi: { list: vi.fn(() => Promise.reject(new Error('offline'))) } })); @@ -80,6 +80,60 @@ describe('Sync page last sync', () => { }); }); +describe('Sync page failure diagnostics', () => { + beforeEach(() => { + vi.clearAllMocks(); + vi.mocked(api.listTargets).mockResolvedValue({ targets: [target('codex')], sourceSkillCount: 3 }); + vi.mocked(api.diff).mockResolvedValue({ diffs: [], ignored_count: 0, ignored_skills: [], ignore_root: '', ignore_repos: [] }); + vi.mocked(api.diffExtras).mockResolvedValue({ extras: [{ name: 'agents', target: '/home/me/.codex/agents', mode: 'copy', synced: false, items: [{ action: 'create', file: 'one.md', reason: 'missing' }] }] }); + vi.mocked(api.listLog).mockResolvedValue({ entries: [{ ts: '2026-09-30T00:00:00Z', cmd: 'sync', status: 'ok', args: { targets_total: 1 } }] } as never); + vi.mocked(api.sync).mockResolvedValue({ results: [], ignored_count: 0, ignored_skills: [], ignore_root: '', ignore_repos: [] }); + vi.mocked(mcpApi.list).mockResolvedValue({ paths: {}, source: { targets: [], servers: {} } } as never); + vi.mocked(hooksApi.list).mockRejectedValue(new Error('offline')); + }); + + const renderPage = () => render( + + + , + ); + + it('summarizes repeated stacks, expands and copies every diagnostic, and scopes the resource OK', async () => { + const reason = 'ReferenceError: require is not defined in ES module scope'; + const errors = Array.from({ length: 5 }, (_, i) => `${i}.md: extension codex-agents failed: exit status 1\nfile:///extensions/codex-agents:4\nconst fs = require("fs");\n${reason}\n at file:///extensions/codex-agents:4:12\n at ModuleJob.run (node:internal/modules/esm/module_job:343:25)`); + vi.mocked(api.syncExtras).mockResolvedValue({ extras: [{ name: 'agents', targets: [{ target: '/home/me/.codex/agents', mode: 'copy', synced: 0, skipped: 0, pruned: 0, errors }] }] }); + const user = userEvent.setup(); + renderPage(); + await user.click(await screen.findByRole('button', { name: 'Sync 1 change' })); + expect(await screen.findByText(reason)).toBeInTheDocument(); + expect(screen.getByRole('heading', { name: '1 target failed' })).toBeInTheDocument(); + expect(screen.getByRole('heading', { name: 'Last skills and agents sync' }).parentElement).toHaveTextContent('OK'); + expect(screen.getByText(/Skills and agents only/)).toBeInTheDocument(); + const show = screen.getByRole('button', { name: 'Show diagnostics' }); + expect(show).toHaveAttribute('aria-expanded', 'false'); + expect(document.querySelector('pre')).toBeNull(); + await user.click(show); + const detail = screen.getByLabelText('Show diagnostics'); + expect(detail.textContent).toBe(errors.join('; ')); + expect(detail).toHaveClass('max-h-64', 'overflow-auto'); + await user.click(screen.getByRole('button', { name: 'Copy' })); + expect(await navigator.clipboard.readText()).toBe(errors.join('; ')); + await user.click(screen.getByRole('button', { name: 'Hide diagnostics' })); + expect(document.querySelector('pre')).toBeNull(); + expect(screen.getByText(reason)).toBeInTheDocument(); + }); + + it('shows a normal short error without an unnecessary disclosure', async () => { + vi.mocked(api.syncExtras).mockResolvedValue({ extras: [{ name: 'agents', targets: [{ target: '/home/me/.codex/agents', mode: 'copy', synced: 0, skipped: 0, pruned: 0, error: 'permission denied' }] }] }); + const user = userEvent.setup(); + renderPage(); + await user.click(await screen.findByRole('button', { name: 'Sync 1 change' })); + expect(await screen.findByText('permission denied')).toBeInTheDocument(); + expect(screen.getByText(/Check the folder's permissions/)).toBeInTheDocument(); + expect(screen.queryByRole('button', { name: 'Show diagnostics' })).not.toBeInTheDocument(); + }); +}); + describe('Sync page hooks conflicts', () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/ui/src/pages/SyncPage.tsx b/ui/src/pages/SyncPage.tsx index 35300b54b..43cc9ca16 100644 --- a/ui/src/pages/SyncPage.tsx +++ b/ui/src/pages/SyncPage.tsx @@ -16,6 +16,7 @@ import MCPNotices from '../components/mcp/MCPNotices'; import { describeMessage, mcpClient, targetLabel } from '../components/mcp/mcpView'; import { countChanges, countEdited, extraGroups, groupByFolder, groupInSync, HOOKS_CHANGED, hooksGroups, MCP_CHANGED, mcpGroups, otherWarnings, resourceGroups, runSync, type ChangeGroup, type Part, type RowIcon, type SyncFailure } from '../components/sync/syncView'; import SyncResult from '../components/sync/SyncResult'; +import SyncError from '../components/sync/SyncError'; import SkillsOffDialog from '../components/targets/SkillsOffDialog'; import { joinList, refreshTargets } from '../components/targets/targetView'; import { formatDateTime, formatRelativeTime, useI18n, useT } from '../i18n'; @@ -194,7 +195,7 @@ export default function SyncPage() { )} - {runError &&
{runError}
} + {runError &&
} {parts.has('mcp') && plan?.blocked && (
@@ -210,8 +211,8 @@ export default function SyncPage() {
)} {parts.has('mcp') && } - {parts.has('hooks') && hooks.data?.previewError &&
{hooks.data.previewError}
} - {parts.has('mcp') && mcp.data?.previewError &&
{mcp.data.previewError}
} + {parts.has('hooks') && hooks.data?.previewError &&
} + {parts.has('mcp') && mcp.data?.previewError &&
} setForce(true)} /> {!!outcome?.path_overlap && (
@@ -236,7 +237,7 @@ export default function SyncPage() { {loading ? (
{t('sync.checking')}
) : diff.error ? ( -
{diff.error.message}
+
) : diffs.length === 0 && groups.length === 0 ? (
{t('sync.noTargets')} @@ -396,6 +397,7 @@ export default function SyncPage() {

{t('sync.last.title')}

{last && {last.status === 'ok' ? 'OK' : last.status}}
+

{t('sync.last.scope')}

{last ? (
{t('sync.last.when')}
@@ -409,7 +411,7 @@ export default function SyncPage() { )} {typeof last.ms === 'number' && <>
{t('sync.last.took')}
{(last.ms / 1000).toFixed(1)} s
} - {last.msg && <>
{t('sync.last.error')}
{last.msg}
} + {last.msg && <>
{t('sync.last.error')}
}
) : (

{t('sync.last.never')}