Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(skillhub): 展示技能发布失败原因和处理建议 (#5276)

bobo184624d13295
diff --git a/apps/desktop/src/main/skillhub/__tests__/publishService.test.ts b/apps/desktop/src/main/skillhub/__tests__/publishService.test.ts
index 5d50dc5037..93e5e0b088 100644
--- a/apps/desktop/src/main/skillhub/__tests__/publishService.test.ts
+++ b/apps/desktop/src/main/skillhub/__tests__/publishService.test.ts
@@ -148,7 +148,7 @@ describe('SkillPublishService', () => {
name: 'read-only',
isFirstPublish: true,
visibility: 'PUBLIC',
- })).resolves.toEqual({ success: false, errorCode: 'CANCELLED' });
+ })).resolves.toEqual({ success: false, errorCode: 'AUTH_REQUIRED' });
});
it('rejects private organization publishing before packing or network access', async () => {
@@ -158,13 +158,17 @@ describe('SkillPublishService', () => {
serverPolicy.allowedVisibilities = ['PUBLIC', 'DEPARTMENT_SCOPED'];
const { SkillPublishService } = await import('../publishService');
const service = new SkillPublishService();
+ const onProgress = vi.fn();
await expect(service.publish({
absolutePath: '/tmp/skill',
name: 'org-private',
isFirstPublish: true,
visibility: 'PRIVATE',
- })).resolves.toEqual({ success: false, errorCode: 'INVALID_VISIBILITY' });
+ }, onProgress)).resolves.toEqual({ success: false, errorCode: 'INVALID_VISIBILITY' });
+ expect(onProgress).toHaveBeenCalledWith(expect.objectContaining({
+ phase: 'failed', errorCode: 'INVALID_VISIBILITY', message: '',
+ }));
});
it('allows version publishes without category metadata and omits category fields from commit', async () => {
@@ -772,9 +776,26 @@ describe('SkillPublishService', () => {
});
it.each([
- ['NAME_TAKEN', 409, '名字已被占用'],
- ['INVALID_VISIBILITY', 400, '当前组织暂不支持组织或私有可见性,请选择公开发布'],
- ])('maps preserved Hub business error %s to an actionable publish error', async (errorCode, statusCode, message) => {
+ ['NAME_TAKEN', 409, '名字已被占用', 'NAME_TAKEN'],
+ ['SKILL_DELETED', 409, '同名 Skill 已删除,但名称仍被占用', 'SKILL_DELETED'],
+ ['FORBIDDEN', 403, '已删除的 Skill 不能继续发布', 'SKILL_DELETED'],
+ ['FORBIDDEN', 403, '当前账号无权发布', 'PERMISSION_DENIED', ''],
+ ['HTTP_403', 403, 'private diagnostic', 'PERMISSION_DENIED', ''],
+ ['HTTP_400', 400, 'private diagnostic', 'REQUEST_REJECTED', ''],
+ ['NOT_AUTHOR', 403, 'private diagnostic', 'NOT_AUTHOR', ''],
+ ['UNAUTHORIZED', 401, 'private diagnostic', 'AUTH_REQUIRED', ''],
+ ['STORAGE_UNAVAILABLE', 503, 'private diagnostic', 'SERVICE_UNAVAILABLE', ''],
+ ['RATE_LIMITED', 429, 'private diagnostic', 'RATE_LIMITED', ''],
+ ['MANIFEST_INVALID', 400, '缺少 description', 'MANIFEST_INVALID'],
+ ['INVALID_PARAMS', 400, '包含不存在的平台标签', 'INVALID_PARAMS'],
+ ['SKILL_FILE_TOO_LARGE', 413, 'SKILL.md 超过 2 MiB', 'SKILL_FILE_TOO_LARGE'],
+ ['SKILL_HUB_READ_ONLY', 403, '当前组织仅支持读取', 'SKILL_HUB_READ_ONLY', ''],
+ ['INVALID_VISIBILITY', 400, '当前组织暂不支持组织或私有可见性,请选择公开发布', 'INVALID_VISIBILITY'],
+ ['FUTURE_BUSINESS_ERROR', 422, '需要修改某个字段', 'REQUEST_REJECTED'],
+ ].flatMap(([wireCode, statusCode, message, expectedCode, expectedMessage]) => ['init', 'commit'].map((stage) => ({
+ wireCode: String(wireCode), statusCode: Number(statusCode), message: String(message), expectedCode: String(expectedCode), stage,
+ expectedMessage: expectedMessage === undefined ? String(message) : String(expectedMessage),
+ }))))('preserves $wireCode and only its public reason during $stage', async ({ wireCode, statusCode, message, expectedCode, expectedMessage, stage }) => {
writeApiKeyFile();
fs.mkdirSync('/tmp/xdt-publish-service-test/skill', { recursive: true });
fs.writeFileSync(
@@ -805,6 +826,9 @@ describe('SkillPublishService', () => {
});
vi.mocked(net.fetch).mockResolvedValue({ ok: true, status: 200 } as Response);
vi.mocked(serverApiFetch).mockImplementation(async (apiPath: string) => {
+ if (apiPath === `/api/skills-hub/skills/publish/${stage}`) {
+ throw new ServerApiError(wireCode, statusCode, message);
+ }
if (apiPath === '/api/skills-hub/skills/publish/init') {
return {
nextVersion: '1.0.0',
@@ -812,9 +836,7 @@ describe('SkillPublishService', () => {
uploadUrl: 'https://oss.example.com/skills/lark-task.zip',
};
}
- if (apiPath === '/api/skills-hub/skills/publish/commit') {
- throw new ServerApiError(errorCode, statusCode, message);
- }
+
throw new Error(`unexpected api path ${apiPath}`);
});
@@ -834,8 +856,8 @@ describe('SkillPublishService', () => {
(event) => events.push(event),
);
- expect(result).toEqual({ success: false, errorCode });
- expect(events.at(-1)).toMatchObject({ phase: 'failed', errorCode });
+ expect(result).toEqual({ success: false, errorCode: expectedCode, error: expectedMessage });
+ expect(events.at(-1)).toMatchObject({ phase: 'failed', errorCode: expectedCode, message: expectedMessage });
});
it('emits a failed progress event when packing throws unexpectedly', async () => {
diff --git a/apps/desktop/src/main/skillhub/publishService.ts b/apps/desktop/src/main/skillhub/publishService.ts
index f9002d8409..247ecac978 100644
--- a/apps/desktop/src/main/skillhub/publishService.ts
+++ b/apps/desktop/src/main/skillhub/publishService.ts
@@ -14,6 +14,7 @@ import fs from 'node:fs';
import path from 'node:path';
import { net } from 'electron';
import { ServerApiError } from '../serverApiClient';
+import { publishErrorDetail, serverPublishErrorCode, type SkillhubPublishErrorCode } from '../../shared/skillhubPublishErrors';
import { skillhubApiFetch } from './hubApi';
import { computeFolderHash } from './folderHash';
import { writeSnapshot } from './snapshot';
@@ -51,24 +52,7 @@ export interface PublishParams {
changelog?: string;
}
-export type PublishErrorCode =
- | 'NAME_TAKEN'
- | 'INVALID_DEPT'
- | 'INVALID_NAME'
- | 'VERSION_RACE'
- | 'CHECKSUM_MISMATCH'
- | 'NOT_AUTHOR'
- | 'PACK_FAILED'
- | 'OSS_PUT_FAILED'
- | 'OSS_PUT_EXPIRED'
- | 'OSS_OBJECT_NOT_FOUND'
- | 'API_KEY_MISSING'
- | 'CATEGORY_REQUIRED'
- | 'MANIFEST_INVALID'
- | 'CANCELLED'
- | 'SKILL_HUB_READ_ONLY'
- | 'INVALID_VISIBILITY'
- | 'INTERNAL';
+export type PublishErrorCode = SkillhubPublishErrorCode;
export type PublishProgressEvent =
| { phase: 'packing' }
@@ -133,21 +117,14 @@ async function updateSkillMdVersion(absolutePath: string, version: string): Prom
// ── errorCode 映射 ────────────────────────────────────────────────────────────
function serverErrorToCode(err: unknown): PublishErrorCode {
- if (err instanceof ServerApiError) {
- const code = err.code;
- if (code === 'NAME_TAKEN') return 'NAME_TAKEN';
- if (code === 'INVALID_DEPT') return 'INVALID_DEPT';
- if (code === 'INVALID_NAME') return 'INVALID_NAME';
- if (code === 'VERSION_RACE') return 'VERSION_RACE';
- if (code === 'CHECKSUM_MISMATCH') return 'CHECKSUM_MISMATCH';
- if (code === 'NOT_AUTHOR') return 'NOT_AUTHOR';
- if (code === 'INVALID_VISIBILITY') return 'INVALID_VISIBILITY';
- if (code === 'OSS_OBJECT_NOT_FOUND') return 'OSS_OBJECT_NOT_FOUND';
- if (err.message.includes('manifest') || err.message.includes('frontmatter'))
- return 'MANIFEST_INVALID';
- return 'INTERNAL';
- }
- return 'INTERNAL';
+ return err instanceof ServerApiError
+ ? serverPublishErrorCode(err.code, err.message, err.statusCode)
+ : 'INTERNAL';
+}
+
+function publicServerErrorMessage(err: unknown, code: PublishErrorCode): string {
+ if (!(err instanceof ServerApiError) || /^HTTP_\d+$/.test(err.code)) return '';
+ return publishErrorDetail(code, err.message);
}
function unhandledPublishErrorToCode(err: unknown): PublishErrorCode {
@@ -267,11 +244,11 @@ export class SkillPublishService {
{
phase: 'failed',
name: params.name,
- errorCode: 'CANCELLED',
- message: 'SkillHub publish requires sign-in',
+ errorCode: 'AUTH_REQUIRED',
+ message: '请登录后再发布 Skill',
},
);
- return { success: false, errorCode: 'CANCELLED' };
+ return { success: false, errorCode: 'AUTH_REQUIRED' };
}
if (
params.isFirstPublish
@@ -283,9 +260,8 @@ export class SkillPublishService {
phase: 'failed',
name: params.name,
errorCode: 'INVALID_VISIBILITY',
- message: identityPolicy.ownerType === 'organization'
- ? 'Organization skills only support public or organization visibility'
- : 'Personal skills only support public or private visibility',
+ // Local policy rejection uses the renderer's localized recovery copy.
+ message: '',
},
);
return { success: false, errorCode: 'INVALID_VISIBILITY' };
@@ -307,11 +283,11 @@ export class SkillPublishService {
{
phase: 'failed',
name: params.name,
- errorCode: 'INTERNAL',
- message: '已有发布任务进行中',
+ errorCode: 'PUBLISH_BUSY',
+ message: '已有发布任务进行中,请等待当前发布结束后重试',
},
);
- return { success: false, errorCode: 'INTERNAL' };
+ return { success: false, errorCode: 'PUBLISH_BUSY' };
}
const abortController = new AbortController();
@@ -427,15 +403,16 @@ export class SkillPublishService {
return { success: false, errorCode: 'CANCELLED' };
}
const code = serverErrorToCode(err);
+ const message = publicServerErrorMessage(err, code);
emitProgress(
{
phase: 'failed',
name: params.name,
errorCode: code,
- message: err instanceof Error ? err.message : String(err),
+ message,
},
);
- return { success: false, errorCode: code };
+ return { success: false, errorCode: code, error: message };
}
}
@@ -627,15 +604,16 @@ export class SkillPublishService {
}
}
const code = serverErrorToCode(err);
+ const message = publicServerErrorMessage(err, code);
emitProgress(
{
phase: 'failed',
name: params.name,
errorCode: code,
- message: err instanceof Error ? err.message : String(err),
+ message,
},
);
- return { success: false, errorCode: code };
+ return { success: false, errorCode: code, error: message };
}
}
} catch (err) {
diff --git a/apps/desktop/src/renderer/__tests__/typographyDiscipline.test.ts b/apps/desktop/src/renderer/__tests__/typographyDiscipline.test.ts
index 3b88635d0f..485c3d867a 100644
--- a/apps/desktop/src/renderer/__tests__/typographyDiscipline.test.ts
+++ b/apps/desktop/src/renderer/__tests__/typographyDiscipline.test.ts
@@ -279,12 +279,6 @@ const EXEMPTIONS: Exemption[] = [
reason: '紧凑代码字号派生值',
signatures: [{ match: 'text-[length:calc(var(--app-code-font-size)_-_1px)]', expected: 1 }],
},
- {
- file: 'src/renderer/features/skillhub/PublishDialog.tsx',
- rule: 'arb-size',
- reason: '紧凑代码字号派生值',
- signatures: [{ match: 'text-[length:calc(var(--app-code-font-size)_-_3px)]', expected: 1 }],
- },
{
file: 'src/renderer/features/skillhub/SkillhubDetailView.tsx',
rule: 'arb-size',
diff --git a/apps/desktop/src/renderer/features/skillhub/PublishDialog.tsx b/apps/desktop/src/renderer/features/skillhub/PublishDialog.tsx
index 287ae4d183..87e2f1c100 100644
--- a/apps/desktop/src/renderer/features/skillhub/PublishDialog.tsx
+++ b/apps/desktop/src/renderer/features/skillhub/PublishDialog.tsx
@@ -513,8 +513,11 @@ export function PublishDialog({
const dialogOwner = useMemo(() => getDataOwnerGeneration(), [open]);
const isDialogOwnerCurrent = isDataOwnerGenerationCurrent(dialogOwner);
- // refresh/sync 延迟到 dialog 关闭后才触发,isFirstPublish 在 dialog 生命周期内不会翻转
- const effectiveFirstPublish = isFirstPublish;
+ // A name conflict can turn an update into a new publication under another name.
+ const [renameAfterFailure, setRenameAfterFailure] = useState(false);
+ const effectiveFirstPublish = isFirstPublish || renameAfterFailure;
+ const canRename = autoCleanName || renameAfterFailure;
+ useEffect(() => { if (!open) setRenameAfterFailure(false); }, [open]);
const { t } = useTranslation();
// 本地改名后保存新 absolutePath / name。Publish 链路里所有引用 skill.absolutePath
@@ -797,17 +800,16 @@ export function PublishDialog({
});
if (!ok || !isDataOwnerGenerationCurrent(dialogOwner)) return;
- // ── autoCleanName(撞名后改名)流程:先在本地改名,再走 publish ──────────
- // 不改名(autoCleanName=false 或新旧名一致)时跳过这一步。
+ // Rename the local folder and manifest together before publishing the new name.
// 一旦本地改名成功,renamedToRef 就被填上新的 path/name,后续整个 publish
// 链路(失败重试、cancel 关闭、done 回调)都从 effectiveSkill() 读,
// 永远不会再回到旧路径。
let publishAbsolutePath = eff.absolutePath;
- if (autoCleanName && !renamedToRef.current && submitName !== eff.name) {
+ if (canRename && submitName !== eff.name) {
const renameRes = await window.electronAPI.skillhub.renameLocal({
// Keep the lexical discovery path for lstat: canonical absolutePath may
// point at a symlink target and would bypass the rename safety gate.
- absolutePath: skill.discoveredPath ?? eff.absolutePath,
+ absolutePath: renamedToRef.current ? eff.absolutePath : skill.discoveredPath ?? eff.absolutePath,
newName: submitName,
});
if (!renameRes.success) {
@@ -838,7 +840,7 @@ export function PublishDialog({
form,
effectiveSkill,
effectiveFirstPublish,
- autoCleanName,
+ canRename,
confirm,
t,
buildCurrentPublishParams,
@@ -923,6 +925,7 @@ export function PublishDialog({
case 'rename':
activePublishNameRef.current = null;
failedProgressNameRef.current = null;
+ setRenameAfterFailure(true);
dispatch({ type: 'REPUBLISH' });
break;
case 'close':
@@ -960,7 +963,7 @@ export function PublishDialog({
// Failure 文案
const errorCopy =
isFailure && pubState.failurePayload
- ? getPublishErrorCopy(pubState.failurePayload.errorCode)
+ ? getPublishErrorCopy(pubState.failurePayload.errorCode, pubState.failurePayload.message)
: null;
// dlg-head subtitle — 优先 frontmatter displayName,fallback 到目录名
@@ -1030,8 +1033,8 @@ export function PublishDialog({
<div
className={cn('flex flex-col gap-4 px-5 pt-5 pb-1', isWorking && 'pointer-events-none opacity-50')}
>
- {/* SkillName — only shown in rename flow (after NAME_TAKEN) */}
- {autoCleanName && (
+ {/* SkillName — available after a name conflict, including a deleted Skill. */}
+ {canRename && (
<div className="flex flex-col gap-1.5">
<FieldLabel>{t('skillhub.publishDialog.skillNameLabel')}</FieldLabel>
<TextInput
@@ -1240,22 +1243,11 @@ export function PublishDialog({
{errorCopy.message}
</span>
)}
- {/*
- * 只在 failurePayload.message 含有明显额外信息时才展示原文
- * (多行,或者比静态文案长很多)
- */}
- {(() => {
- const detail = pubState.failurePayload?.message?.trim();
- if (!detail || detail === errorCopy.message) return null;
- const hasMultiline = detail.includes('\n');
- const isMuchLonger = detail.length > (errorCopy.message?.length ?? 0) + 40;
- if (!hasMultiline && !isMuchLonger) return null;
- return (
- <pre className="mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--content-area))] p-2 font-mono text-[length:calc(var(--app-code-font-size)_-_3px)] leading-[1.4] text-[var(--settings-section-desc)] select-text">
- {detail}
- </pre>
- );
- })()}
+ {errorCopy.detail && errorCopy.detail !== errorCopy.message && (
+ <span className="whitespace-pre-wrap break-words text-xs leading-[1.5] text-[var(--cmd-palette-item-meta)] select-text">
+ {errorCopy.detail}
+ </span>
+ )}
</div>
</div>
</div>
diff --git a/apps/desktop/src/renderer/features/skillhub/ScanResultDialog.tsx b/apps/desktop/src/renderer/features/skillhub/ScanResultDialog.tsx
index 41fda4633e..0a8e05b48f 100644
--- a/apps/desktop/src/renderer/features/skillhub/ScanResultDialog.tsx
+++ b/apps/desktop/src/renderer/features/skillhub/ScanResultDialog.tsx
@@ -14,7 +14,8 @@ import { cn } from '@/lib/utils';
import { toast } from '@/lib/toast';
import type { ScanResultPayload } from './PublishDialog';
import { isPassingScanStatus, isPendingManualReviewStatus } from './lib/scanStatus';
-import { isPublicationProcessingFailure } from './lib/scanResultPresentation';
+import { isPublicationProcessingFailure, publicationProcessingErrorCode, publicationProcessingGateErrorCode, scanPublicationErrorCode } from './lib/scanResultPresentation';
+import { publishErrorDetail } from '../../../shared/skillhubPublishErrors';
interface ScanIssue {
severity?: string;
@@ -45,11 +46,18 @@ function resolveI18nField(value: unknown): string {
return String(value ?? '');
}
-function visibleScanIssues(gate: ScanGate): ScanIssue[] {
+function visibleScanIssues(gate: ScanGate, t: TFunction): ScanIssue[] {
const issues = Array.isArray(gate.issues) ? gate.issues : [];
return (issues as ScanIssue[]).filter(
(issue) => issue.severity === 'warning' || issue.severity === 'error',
- );
+ ).map((issue) => {
+ const code = scanPublicationErrorCode(issue.code, resolveI18nField(issue.message)) ?? publicationProcessingGateErrorCode(gate.name);
+ if (!code) return issue;
+ const message = publishErrorDetail(code, resolveI18nField(issue.message));
+ if (message) return { ...issue, message };
+ // Service/auth diagnostics must not escape through either rendering or copy.
+ return { severity: issue.severity, code: issue.code, message: t(`skillhub.publishError.${code}.message`) };
+ });
}
function normalizeScanCode(value: unknown): string {
@@ -106,6 +114,8 @@ function scanGateLabel(gate: ScanGate, t: TFunction): string {
if (code === 'internal-error') {
return t('skillhub.scanResult.gateLabel.publicationProcessing');
}
+ const errorCode = publicationProcessingErrorCode([gate]);
+ if (errorCode) return t(`skillhub.publishError.${errorCode}.title`);
return gate.name;
}
@@ -154,6 +164,13 @@ export function ScanResultDialog({ open, onClose, result }: ScanResultDialogProp
const failedGates = (result.gates ?? []).filter((g) => !isPassingScanStatus(g.status));
const processingFailure =
!passed && !pendingManualReview && isPublicationProcessingFailure(result.gates);
+ const processingErrorCode = processingFailure ? publicationProcessingErrorCode(result.gates) : undefined;
+ const processingErrorCopy = processingErrorCode && processingErrorCode !== 'INTERNAL'
+ ? {
+ title: t(`skillhub.publishError.${processingErrorCode}.title`),
+ message: t(`skillhub.publishError.${processingErrorCode}.message`),
+ }
+ : undefined;
const title = rejected
? t('skillhub.scanResult.rejectedTitle')
: passed
@@ -161,7 +178,7 @@ export function ScanResultDialog({ open, onClose, result }: ScanResultDialogProp
: pendingManualReview
? t('skillhub.scanResult.pendingTitle')
: processingFailure
- ? t('skillhub.scanResult.processingFailedTitle')
+ ? processingErrorCopy?.title ?? t('skillhub.scanResult.processingFailedTitle')
: t('skillhub.scanResult.failedTitle', { status: result.status });
const statusLabel = scanStatusLabel(result.status, t);
const description = rejected
@@ -173,7 +190,7 @@ export function ScanResultDialog({ open, onClose, result }: ScanResultDialogProp
: pendingManualReview
? t('skillhub.scanResult.pendingDesc')
: processingFailure
- ? t('skillhub.scanResult.processingFailedDesc')
+ ? processingErrorCopy?.message ?? t('skillhub.scanResult.processingFailedDesc')
: t('skillhub.scanResult.failedDesc', { status: statusLabel });
async function handleCopyReviewResult(): Promise<void> {
@@ -194,7 +211,7 @@ export function ScanResultDialog({ open, onClose, result }: ScanResultDialogProp
lines.push(
`- ${withRawCode(label, gate.name)}: ${withRawCode(scanStatusLabel(gate.status, t), gate.status)}`,
);
- for (const issue of visibleScanIssues(gate)) {
+ for (const issue of visibleScanIssues(gate, t)) {
const line = scanIssueCopyLine(issue);
if (line) lines.push(` - ${line}`);
}
@@ -303,9 +320,9 @@ export function ScanResultDialog({ open, onClose, result }: ScanResultDialogProp
{scanStatusLabel(gate.status, t)}
</span>
</div>
- {visibleScanIssues(gate).length > 0 && (
+ {visibleScanIssues(gate, t).length > 0 && (
<div className="mt-2 flex flex-col gap-1.5 pl-5">
- {visibleScanIssues(gate).map((issue, i) => (
+ {visibleScanIssues(gate, t).map((issue, i) => (
<div
key={i}
className="text-xs leading-relaxed text-[var(--cmd-palette-item-meta)]"
diff --git a/apps/desktop/src/renderer/features/skillhub/__tests__/PublishDialog.feedback.test.tsx b/apps/desktop/src/renderer/features/skillhub/__tests__/PublishDialog.feedback.test.tsx
index 8e405c495e..a74952e784 100644
--- a/apps/desktop/src/renderer/features/skillhub/__tests__/PublishDialog.feedback.test.tsx
+++ b/apps/desktop/src/renderer/features/skillhub/__tests__/PublishDialog.feedback.test.tsx
@@ -21,6 +21,7 @@ vi.mock('../hooks/useSkillFolderHash', () => ({ invalidateHash: vi.fn() }));
vi.mock('../components/PlatformTagSelector', () => ({ PlatformTagSelector: () => null }));
import { PublishDialog, type PublishDialogProps } from '../PublishDialog';
+import { getPublishErrorCopy } from '../lib/publishErrorMap';
let progress!: (event: SkillhubPublishProgressEvent) => void;
const feedback: SkillhubPublishProgressEvent = {
@@ -47,22 +48,24 @@ beforeEach(() => {
});
afterEach(() => { cleanup(); vi.unstubAllGlobals(); });
+const skillFixture: PublishDialogProps['skill'] = {
+ id: 'review-helper', urlKey: 'review-helper', engine: 'claude-code', linkedEngines: [],
+ kind: 'skill', scope: 'global', mdPath: '/fixture/review-helper/SKILL.md', files: [], registryEntry: null,
+ name: 'review-helper', absolutePath: '/fixture/review-helper', frontmatter: { version: '1.0.1' },
+};
+
function mountPublication(overrides: Partial<PublishDialogProps> = {}) {
const onScanResult = vi.fn();
const onOpenChange = vi.fn();
const onLocalRenamed = vi.fn();
const props: PublishDialogProps = {
- open: true, onOpenChange, onScanResult, onLocalRenamed, isFirstPublish: false, latestVersion: '1.0.0', skill: {
- id: 'review-helper', urlKey: 'review-helper', engine: 'claude-code', linkedEngines: [],
- kind: 'skill', scope: 'global', mdPath: '/fixture/review-helper/SKILL.md', files: [], registryEntry: null,
- name: 'review-helper', absolutePath: '/fixture/review-helper', frontmatter: { version: '1.0.1' },
- },
+ open: true, onOpenChange, onScanResult, onLocalRenamed, isFirstPublish: false, latestVersion: '1.0.0', skill: skillFixture,
...overrides,
};
const view = render(<PublishDialog {...props} />);
- if (props.isFirstPublish) {
+ if (props.isFirstPublish && props.autoCleanName) {
fireEvent.change(screen.getByPlaceholderText('skillhub.publishDialog.skillNamePlaceholder'), { target: { value: 'renamed-helper' } });
- } else {
+ } else if (!props.isFirstPublish) {
fireEvent.change(screen.getByPlaceholderText('skillhub.publishDialog.changelogPlaceholder'), { target: { value: 'Improve documentation' } });
}
return { onScanResult, onOpenChange, onLocalRenamed, unmount: view.unmount,
@@ -77,6 +80,72 @@ async function startPublication(overrides: Partial<PublishDialogProps> = {}) {
}
describe('PublishDialog result delivery', () => {
+ it.each([true, false])('lets the user rename after deletion when first publication is %s', async (isFirstPublish) => {
+ mocks.publish.mockResolvedValueOnce({ success: false, errorCode: 'SKILL_DELETED', error: '同名技能已删除' });
+ await startPublication({ isFirstPublish });
+ const renameAction = getPublishErrorCopy('SKILL_DELETED').primaryAction.label;
+ fireEvent.click(await screen.findByRole('button', { name: renameAction }));
+ fireEvent.change(screen.getByPlaceholderText('skillhub.publishDialog.skillNamePlaceholder'), { target: { value: 'renamed-helper' } });
+ fireEvent.click(screen.getByRole('button', { name: 'skillhub.publishDialog.startPublish' }));
+ await waitFor(() => expect(mocks.renameLocal).toHaveBeenCalledWith({ absolutePath: '/fixture/review-helper', newName: 'renamed-helper' }));
+ await waitFor(() => expect(mocks.publish).toHaveBeenCalledTimes(2));
+ expect(mocks.publish.mock.calls[1][0]).toMatchObject({
+ name: 'renamed-helper', absolutePath: '/fixture/renamed-helper', isFirstPublish: true,
+ });
+ });
+
+ it('checks the discovered path on the first rename and the current path on a subsequent rename', async () => {
+ mocks.publish.mockResolvedValueOnce({ success: false, errorCode: 'SKILL_DELETED', error: '同名技能已删除' });
+ await startPublication({ isFirstPublish: true, autoCleanName: true,
+ skill: { ...skillFixture, discoveredPath: '/fixture/link-helper' } });
+ expect(mocks.renameLocal).toHaveBeenNthCalledWith(1, {
+ absolutePath: '/fixture/link-helper', newName: 'renamed-helper',
+ });
+ expect(mocks.publish.mock.calls[0][0]).toMatchObject({ absolutePath: '/fixture/renamed-helper' });
+
+ mocks.renameLocal.mockResolvedValueOnce({ success: true, newAbsolutePath: '/fixture/final-helper' });
+ fireEvent.click(await screen.findByRole('button', { name: getPublishErrorCopy('SKILL_DELETED').primaryAction.label }));
+ fireEvent.change(screen.getByPlaceholderText('skillhub.publishDialog.skillNamePlaceholder'), { target: { value: 'final-helper' } });
+ fireEvent.click(screen.getByRole('button', { name: 'skillhub.publishDialog.startPublish' }));
+ await waitFor(() => expect(mocks.renameLocal).toHaveBeenNthCalledWith(2, {
+ absolutePath: '/fixture/renamed-helper', newName: 'final-helper',
+ }));
+ await waitFor(() => expect(mocks.publish).toHaveBeenCalledTimes(2));
+ expect(mocks.publish.mock.calls[1][0]).toMatchObject({
+ name: 'final-helper', absolutePath: '/fixture/final-helper', isFirstPublish: true,
+ });
+ });
+
+ it('shows a short validation reason delivered through the IPC result fallback', async () => {
+ mocks.publish.mockResolvedValue({ success: false, errorCode: 'INVALID_PARAMS', error: '标签不存在' });
+ await startPublication();
+ expect(await screen.findByText('标签不存在')).toBeTruthy();
+ });
+
+ it('uses localized recovery copy when local visibility validation has no server detail', async () => {
+ await startPublication();
+ act(() => progress({ phase: 'failed', name: 'review-helper', errorCode: 'INVALID_VISIBILITY', message: '',
+ ownerStamp: { dataOwnerId: 'owner-a', ownerGeneration: 1 } }));
+ expect(await screen.findByText(getPublishErrorCopy('INVALID_VISIBILITY').message)).toBeTruthy();
+ expect(screen.queryByText('Organization skills only support public or organization visibility')).toBeNull();
+ expect(screen.queryByText('Personal skills only support public or private visibility')).toBeNull();
+ });
+
+ it.each(['PERMISSION_DENIED', 'NOT_AUTHOR', 'API_KEY_MISSING', 'SKILL_HUB_READ_ONLY', 'OSS_PUT_EXPIRED', 'OSS_OBJECT_NOT_FOUND'] as const)('does not expose %s diagnostics or offer to edit the request', async (errorCode) => {
+ mocks.publish.mockResolvedValue({ success: false, errorCode, error: 'private diagnostic' });
+ await startPublication();
+ expect(await screen.findByText(getPublishErrorCopy(errorCode).title)).toBeTruthy();
+ expect(screen.queryByText('private diagnostic')).toBeNull();
+ expect(screen.queryByRole('button', { name: getPublishErrorCopy('INVALID_PARAMS').primaryAction.label })).toBeNull();
+ });
+
+ it('shows a short reason from a failed progress event', async () => {
+ await startPublication();
+ act(() => progress({ phase: 'failed', name: 'review-helper', errorCode: 'MANIFEST_INVALID', message: '缺少 description',
+ ownerStamp: { dataOwnerId: 'owner-a', ownerGeneration: 1 } }));
+ expect(await screen.findByText('缺少 description')).toBeTruthy();
+ });
+
it.each(['unchanged', 'different-owner', 'same-owner-new-generation'] as const)(
'forwards feedback after refresh only when the owner is %s', async (transition) => {
let finishRefresh!: (value: unknown[]) => void;
diff --git a/apps/desktop/src/renderer/features/skillhub/__tests__/ScanResultDialog.test.tsx b/apps/desktop/src/renderer/features/skillhub/__tests__/ScanResultDialog.test.tsx
index af6386ce58..91e60342b0 100644
--- a/apps/desktop/src/renderer/features/skillhub/__tests__/ScanResultDialog.test.tsx
+++ b/apps/desktop/src/renderer/features/skillhub/__tests__/ScanResultDialog.test.tsx
@@ -19,6 +19,76 @@ afterEach(() => {
});
describe('ScanResultDialog pending review presentation', () => {
+ it.each(['MANIFEST_INVALID', 'package-validation'])('shows and copies a package validation reason under gate %s', async (name) => {
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ vi.stubGlobal('navigator', { ...navigator, clipboard: { writeText } });
+ render(<ScanResultDialog open onClose={vi.fn()} result={{
+ status: 'failed', gates: [{ name, status: 'failed',
+ issues: [{ severity: 'error', code: 'MANIFEST_INVALID', message: 'SKILL.md 缺少 description' }] }],
+ }} />);
+ expect(screen.getByText('SKILL.md 缺少 description')).toBeTruthy();
+ expect(screen.getByRole('heading', { name: 'skillhub.publishError.MANIFEST_INVALID.title' })).toBeTruthy();
+ expect(screen.getByText('skillhub.publishError.MANIFEST_INVALID.message')).toBeTruthy();
+ expect(screen.queryByText('skillhub.scanResult.failedDesc')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'skillhub.scanResult.copyReviewResult' }));
+ await waitFor(() => expect(writeText).toHaveBeenCalledWith(expect.stringContaining('SKILL.md 缺少 description')));
+ });
+
+ it.each(['SERVICE_UNAVAILABLE', 'RATE_LIMITED', 'AUTH_REQUIRED', 'PERMISSION_DENIED', 'NOT_AUTHOR', 'API_KEY_MISSING', 'SKILL_HUB_READ_ONLY', 'OSS_PUT_EXPIRED', 'OSS_OBJECT_NOT_FOUND'])('uses recovery copy instead of raw %s diagnostics for display and clipboard', async (code) => {
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ vi.stubGlobal('navigator', { ...navigator, clipboard: { writeText } });
+ render(<ScanResultDialog open onClose={vi.fn()} result={{
+ status: 'failed', gates: [{ name: 'publication', status: 'failed',
+ issues: [{ severity: 'error', code, message: 'private diagnostic', path: '/private/diagnostic', evidence: 'private evidence' }] }],
+ }} />);
+ expect(document.body.textContent).not.toContain('private diagnostic');
+ expect(document.body.textContent).not.toContain('/private/diagnostic');
+ expect(document.body.textContent).not.toContain('private evidence');
+ expect(document.body.textContent).toContain(`skillhub.publishError.${code}.message`);
+ fireEvent.click(screen.getByRole('button', { name: 'skillhub.scanResult.copyReviewResult' }));
+ await waitFor(() => expect(writeText).toHaveBeenCalled());
+ expect(writeText.mock.calls[0][0]).not.toContain('private');
+ expect(writeText.mock.calls[0][0]).toContain(`skillhub.publishError.${code}.message`);
+ });
+
+ it.each(['package-validation', 'publication', 'publication-processing', 'upload-processing'])('redacts an unknown processing failure under %s in display and clipboard', async (name) => {
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ vi.stubGlobal('navigator', { ...navigator, clipboard: { writeText } });
+ render(<ScanResultDialog open onClose={vi.fn()} result={{
+ status: 'failed', gates: [{ name, status: 'failed',
+ issues: [{ severity: 'error', code: 'FUTURE_PROCESSOR_FAILURE', message: 'private diagnostic', path: '/private/diagnostic', evidence: 'private evidence' }] }],
+ }} />);
+ expect(screen.getByRole('heading', { name: 'skillhub.scanResult.processingFailedTitle' })).toBeTruthy();
+ expect(document.body.textContent).not.toContain('private');
+ expect(document.body.textContent).toContain('skillhub.publishError.INTERNAL.message');
+ fireEvent.click(screen.getByRole('button', { name: 'skillhub.scanResult.copyReviewResult' }));
+ await waitFor(() => expect(writeText).toHaveBeenCalled());
+ expect(writeText.mock.calls[0][0]).not.toContain('private');
+ expect(writeText.mock.calls[0][0]).toContain('skillhub.publishError.INTERNAL.message');
+ });
+
+ it('still displays and copies a concrete security finding with an unrelated code', async () => {
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ vi.stubGlobal('navigator', { ...navigator, clipboard: { writeText } });
+ render(<ScanResultDialog open onClose={vi.fn()} result={{
+ status: 'failed', gates: [{ name: 'archive-safety', status: 'failed',
+ issues: [{ severity: 'error', code: 'UNSAFE_PATH', message: 'Unsafe archive path', path: '../unsafe.txt' }] }],
+ }} />);
+ expect(screen.getByText('Unsafe archive path')).toBeTruthy();
+ expect(screen.getByText('../unsafe.txt')).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'skillhub.scanResult.copyReviewResult' }));
+ await waitFor(() => expect(writeText).toHaveBeenCalledWith(expect.stringContaining('../unsafe.txt - Unsafe archive path')));
+ });
+
+ it.each(['warn', 'warning'])('does not present a %s gate as a processing failure', (status) => {
+ render(<ScanResultDialog open onClose={vi.fn()} result={{ status,
+ gates: [{ name: 'MANIFEST_INVALID', status, issues: [{ severity: 'warning', code: 'MANIFEST_INVALID', message: 'Optional field missing' }] }],
+ }} />);
+ expect(screen.queryByRole('heading', { name: 'skillhub.publishError.MANIFEST_INVALID.title' })).toBeNull();
+ expect(document.querySelector('.lucide-shield-alert')).not.toBeNull();
+ expect(screen.getByText('Optional field missing')).toBeTruthy();
+ });
+
it('shows manual feedback even when every machine check passed, and copies the full reason', async () => {
const reason = 'Remove private project notes.\n<script>do not execute</script>';
const writeText = vi.fn().mockResolvedValue(undefined);
diff --git a/apps/desktop/src/renderer/features/skillhub/__tests__/SkillhubMarketDetailView.test.tsx b/apps/desktop/src/renderer/features/skillhub/__tests__/SkillhubMarketDetailView.test.tsx
index 271b62bbf5..65fcdc3c7f 100644
--- a/apps/desktop/src/renderer/features/skillhub/__tests__/SkillhubMarketDetailView.test.tsx
+++ b/apps/desktop/src/renderer/features/skillhub/__tests__/SkillhubMarketDetailView.test.tsx
@@ -150,7 +150,8 @@ describe('published Skill rejection feedback', () => {
render(<SkillhubMarketDetailView skill={{ ...skill, catalogScope, pendingVersion: { version: '1.0.1', status } }} open onClose={vi.fn()} />);
fireEvent.click(screen.getByRole('button', { name: 'skillhub.publishedStatus.rejected' }));
expect(await screen.findByRole('heading', { name: 'skillhub.scanResult.processingFailedTitle' })).toBeTruthy();
- expect(screen.getByText('Unable to process archive')).toBeTruthy();
+ expect(screen.queryByText('Unable to process archive')).toBeNull();
+ expect(screen.getByText('skillhub.publishError.INTERNAL.message')).toBeTruthy();
expect(screen.queryByRole('heading', { name: 'skillhub.scanResult.rejectedTitle' })).toBeNull();
expect(getScanStatus).toHaveBeenCalledWith({ slug: skill.name, version: '1.0.1', catalogScope: undefined });
});
diff --git a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/publishFailureFallback.test.ts b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/publishFailureFallback.test.ts
index 05e463838a..072425142c 100644
--- a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/publishFailureFallback.test.ts
+++ b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/publishFailureFallback.test.ts
@@ -11,6 +11,8 @@ describe('publish failure fallback', () => {
it('preserves known publish error codes', () => {
expect(normalizePublishErrorCode('PACK_FAILED')).toBe('PACK_FAILED');
expect(normalizePublishErrorCode('OSS_PUT_FAILED')).toBe('OSS_PUT_FAILED');
+ expect(normalizePublishErrorCode('SKILL_DELETED')).toBe('SKILL_DELETED');
+ expect(normalizePublishErrorCode('INVALID_PARAMS')).toBe('INVALID_PARAMS');
});
it('falls back unknown error codes to INTERNAL', () => {
diff --git a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/publishProgressFilter.test.ts b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/publishProgressFilter.test.ts
index a0b43b0b89..17d8de403e 100644
--- a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/publishProgressFilter.test.ts
+++ b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/publishProgressFilter.test.ts
@@ -45,7 +45,7 @@ describe('publish progress event filter', () => {
const source = readFileSync(resolve(here, '../../PublishDialog.tsx'), 'utf8')
.replace(/\r\n/g, '\n');
- expect(source).toContain('absolutePath: skill.discoveredPath ?? eff.absolutePath');
+ expect(source).toContain('absolutePath: renamedToRef.current ? eff.absolutePath : skill.discoveredPath ?? eff.absolutePath');
});
it('uses the owner-aware event filter in both result consumers', () => {
diff --git a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/scanResultPresentation.test.ts b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/scanResultPresentation.test.ts
index 3e9e5d12be..4fd1daeb37 100644
--- a/apps/desktop/src/renderer/features/skillhub/lib/__tests__/scanResultPresentation.test.ts
+++ b/apps/desktop/src/renderer/features/skillhub/lib/__tests__/scanResultPresentation.test.ts
@@ -1,10 +1,43 @@
import { describe, expect, it } from 'vitest';
-import { isPublicationProcessingFailure } from '../scanResultPresentation';
+import { isPublicationProcessingFailure, publicationProcessingErrorCode } from '../scanResultPresentation';
describe('scan result presentation', () => {
it('distinguishes a server processing error from a security rejection', () => {
expect(isPublicationProcessingFailure([{ name: 'INTERNAL_ERROR' }])).toBe(true);
+ expect(isPublicationProcessingFailure([{ name: 'MANIFEST_INVALID' }])).toBe(true);
+ expect(isPublicationProcessingFailure([{ name: 'SKILL_DELETED' }])).toBe(true);
expect(isPublicationProcessingFailure([{ name: 'security-scan' }])).toBe(false);
expect(isPublicationProcessingFailure(undefined)).toBe(false);
});
+
+ it('recognizes issue codes under a normal gate name, before the legacy gate fallback', () => {
+ expect(publicationProcessingErrorCode([{ name: 'package-validation', status: 'failed',
+ issues: [{ severity: 'error', code: 'MANIFEST_INVALID' }] }])).toBe('MANIFEST_INVALID');
+ expect(publicationProcessingErrorCode([{ name: 'INTERNAL_ERROR', status: 'failed',
+ issues: [{ code: 'SKILL_DELETED' }] }])).toBe('SKILL_DELETED');
+ expect(publicationProcessingErrorCode([{ name: 'publication', status: 'failed',
+ issues: [{ code: 'FORBIDDEN', message: '已删除的 Skill 不能继续发布' }] }])).toBe('SKILL_DELETED');
+ });
+
+ it('does not turn passed gates or warning findings into a publication failure', () => {
+ expect(isPublicationProcessingFailure([{ name: 'package-validation', status: 'passed',
+ issues: [{ severity: 'error', code: 'MANIFEST_INVALID' }] }])).toBe(false);
+ expect(isPublicationProcessingFailure([{ name: 'security-scan', status: 'failed',
+ issues: [{ severity: 'warning', code: 'MANIFEST_INVALID' }, { severity: 'error', code: 'UNSAFE_PATH' }] }])).toBe(false);
+ expect(publicationProcessingErrorCode([{ name: 'publication', status: 'failed',
+ issues: [null, 'legacy finding', { severity: 'error', code: 'INVALID_PARAMS' }] }])).toBe('INVALID_PARAMS');
+ });
+
+ it.each(['warn', 'warning', ' WARNING ', 'pending', 'scanning'])('excludes non-failing %s gates before reading issue codes or legacy gate names', (status) => {
+ expect(isPublicationProcessingFailure([{ name: 'MANIFEST_INVALID', status }])).toBe(false);
+ expect(isPublicationProcessingFailure([{ name: 'package-validation', status,
+ issues: [{ severity: 'error', code: 'MANIFEST_INVALID' }] }])).toBe(false);
+ });
+
+ it('uses the safe fallback for unknown processing codes while retaining security findings', () => {
+ expect(publicationProcessingErrorCode([{ name: 'package-validation', status: 'failed',
+ issues: [{ severity: 'error', code: 'FUTURE_PROCESSOR_FAILURE' }] }])).toBe('INTERNAL');
+ expect(publicationProcessingErrorCode([{ name: 'archive-safety', status: 'failed',
+ issues: [{ severity: 'error', code: 'UNSAFE_PATH' }] }])).toBeUndefined();
+ });
});
diff --git a/apps/desktop/src/renderer/features/skillhub/lib/publishErrorMap.ts b/apps/desktop/src/renderer/features/skillhub/lib/publishErrorMap.ts
index 38d8f0e863..d46a459148 100644
--- a/apps/desktop/src/renderer/features/skillhub/lib/publishErrorMap.ts
+++ b/apps/desktop/src/renderer/features/skillhub/lib/publishErrorMap.ts
@@ -7,6 +7,7 @@
*/
import { i18n } from '@/i18n';
+import { publishErrorDetail } from '../../../../shared/skillhubPublishErrors';
export type PublishActionType =
| 'retry'
@@ -24,6 +25,7 @@ export interface PublishErrorAction {
export interface PublishErrorCopy {
title: string;
message: string;
+ detail?: string;
primaryAction: PublishErrorAction;
secondaryAction?: PublishErrorAction;
}
@@ -35,7 +37,8 @@ type PublishActionLabelKey =
| 'rename'
| 'fix'
| 'republish'
- | 'abandonPending';
+ | 'abandonPending'
+ | 'editPublication';
interface PublishErrorActionSpec {
labelKey: PublishActionLabelKey;
@@ -61,6 +64,23 @@ const errorMap: Record<SkillhubPublishErrorCode, PublishErrorSpec> = {
NAME_TAKEN: {
primaryAction: { labelKey: 'rename', type: 'rename' },
},
+ SKILL_DELETED: {
+ primaryAction: { labelKey: 'rename', type: 'rename' },
+ secondaryAction: CLOSE_ACTION,
+ },
+ SKILL_UNPUBLISHED: {
+ primaryAction: { labelKey: 'republish', type: 'republish' },
+ secondaryAction: CLOSE_ACTION,
+ },
+ AUTH_REQUIRED: { primaryAction: CLOSE_ACTION },
+ PERMISSION_DENIED: { primaryAction: CLOSE_ACTION },
+ INVALID_PARAMS: { primaryAction: { labelKey: 'editPublication', type: 'republish' } },
+ SKILL_FILE_TOO_LARGE: { primaryAction: CLOSE_ACTION },
+ NETWORK_ERROR: { primaryAction: RETRY_ACTION, secondaryAction: CLOSE_ACTION },
+ RATE_LIMITED: { primaryAction: RETRY_ACTION, secondaryAction: CLOSE_ACTION },
+ SERVICE_UNAVAILABLE: { primaryAction: RETRY_ACTION, secondaryAction: CLOSE_ACTION },
+ PUBLISH_BUSY: { primaryAction: CLOSE_ACTION },
+ REQUEST_REJECTED: { primaryAction: { labelKey: 'editPublication', type: 'republish' }, secondaryAction: CLOSE_ACTION },
INVALID_DEPT: {
primaryAction: CLOSE_ACTION,
},
@@ -76,7 +96,7 @@ const errorMap: Record<SkillhubPublishErrorCode, PublishErrorSpec> = {
secondaryAction: CLOSE_ACTION,
},
VERSION_RACE: {
- primaryAction: RETRY_ACTION,
+ primaryAction: { labelKey: 'editPublication', type: 'republish' },
secondaryAction: CLOSE_ACTION,
},
CHECKSUM_MISMATCH: {
@@ -119,7 +139,7 @@ function toAction(spec: PublishErrorActionSpec): PublishErrorAction {
};
}
-export function getPublishErrorCopy(errorCode: SkillhubPublishErrorCode): PublishErrorCopy {
+export function getPublishErrorCopy(errorCode: SkillhubPublishErrorCode, message?: string): PublishErrorCopy {
const spec = errorMap[errorCode];
if (!spec) {
return {
@@ -132,6 +152,7 @@ export function getPublishErrorCopy(errorCode: SkillhubPublishErrorCode): Publis
return {
title: i18n.t(`skillhub.publishError.${errorCode}.title`),
message: i18n.t(`skillhub.publishError.${errorCode}.message`),
+ detail: publishErrorDetail(errorCode, message),
primaryAction: toAction(spec.primaryAction),
secondaryAction: spec.secondaryAction ? toAction(spec.secondaryAction) : undefined,
};
diff --git a/apps/desktop/src/renderer/features/skillhub/lib/publishFailureFallback.ts b/apps/desktop/src/renderer/features/skillhub/lib/publishFailureFallback.ts
index 88ae60ca29..bbdb6a4784 100644
--- a/apps/desktop/src/renderer/features/skillhub/lib/publishFailureFallback.ts
+++ b/apps/desktop/src/renderer/features/skillhub/lib/publishFailureFallback.ts
@@ -1,26 +1,8 @@
-const PUBLISH_ERROR_CODES = new Set<SkillhubPublishErrorCode>([
- 'NAME_TAKEN',
- 'INVALID_DEPT',
- 'INVALID_NAME',
- 'CATEGORY_REQUIRED',
- 'MANIFEST_INVALID',
- 'VERSION_RACE',
- 'CHECKSUM_MISMATCH',
- 'NOT_AUTHOR',
- 'PACK_FAILED',
- 'OSS_PUT_FAILED',
- 'OSS_PUT_EXPIRED',
- 'OSS_OBJECT_NOT_FOUND',
- 'API_KEY_MISSING',
- 'CANCELLED',
- 'SKILL_HUB_READ_ONLY',
- 'INVALID_VISIBILITY',
- 'INTERNAL',
-]);
+import { isSkillhubPublishErrorCode } from '../../../../shared/skillhubPublishErrors';
export function normalizePublishErrorCode(errorCode: unknown): SkillhubPublishErrorCode {
- return typeof errorCode === 'string' && PUBLISH_ERROR_CODES.has(errorCode as SkillhubPublishErrorCode)
- ? errorCode as SkillhubPublishErrorCode
+ return isSkillhubPublishErrorCode(errorCode)
+ ? errorCode
: 'INTERNAL';
}
diff --git a/apps/desktop/src/renderer/features/skillhub/lib/scanResultPresentation.ts b/apps/desktop/src/renderer/features/skillhub/lib/scanResultPresentation.ts
index 40358ea553..49922d0409 100644
--- a/apps/desktop/src/renderer/features/skillhub/lib/scanResultPresentation.ts
+++ b/apps/desktop/src/renderer/features/skillhub/lib/scanResultPresentation.ts
@@ -1,5 +1,9 @@
+import { isSkillhubPublishErrorCode, serverPublishErrorCode, type SkillhubPublishErrorCode } from '../../../../shared/skillhubPublishErrors';
+
interface ScanGateLike {
name: string;
+ status?: string;
+ issues?: unknown[];
}
function normalizeCode(value: unknown): string {
@@ -7,5 +11,40 @@ function normalizeCode(value: unknown): string {
}
export function isPublicationProcessingFailure(gates: ScanGateLike[] | undefined): boolean {
- return gates?.some((gate) => normalizeCode(gate.name) === 'internal-error') ?? false;
+ return publicationProcessingErrorCode(gates) !== undefined;
+}
+
+export function scanPublicationErrorCode(value: unknown, message?: unknown): SkillhubPublishErrorCode | undefined {
+ const code = normalizeCode(value).replaceAll('-', '_').toUpperCase();
+ if (isSkillhubPublishErrorCode(code)) return code;
+ if (['INTERNAL_ERROR', 'FORBIDDEN', 'UPLOAD_SESSION_EXPIRED', 'STORAGE_UNAVAILABLE'].includes(code)) {
+ return serverPublishErrorCode(code, typeof message === 'string' ? message : '');
+ }
+ return undefined;
+}
+
+/** These processing gates can carry newer issue codes that this client cannot interpret yet. */
+export function publicationProcessingGateErrorCode(name: string): SkillhubPublishErrorCode | undefined {
+ return scanPublicationErrorCode(name) ?? (
+ ['package-validation', 'publication', 'publication-processing', 'upload-processing'].includes(normalizeCode(name))
+ ? 'INTERNAL'
+ : undefined
+ );
+}
+
+/** Processing failures can use an issue code or a legacy error-code gate name. */
+export function publicationProcessingErrorCode(gates: ScanGateLike[] | undefined): SkillhubPublishErrorCode | undefined {
+ for (const gate of gates ?? []) {
+ if (gate.status != null && !['fail', 'failed', 'quarantine', 'rejected', 'blocked', 'error'].includes(normalizeCode(gate.status))) continue;
+ for (const value of gate.issues ?? []) {
+ if (!value || typeof value !== 'object') continue;
+ const issue = value as Record<string, unknown>;
+ if (issue.severity != null && issue.severity !== 'error') continue;
+ const code = scanPublicationErrorCode(issue.code, issue.message);
+ if (code) return code;
+ }
+ const code = publicationProcessingGateErrorCode(gate.name);
+ if (code) return code;
+ }
+ return undefined;
}
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index be22e0411f..79b7da63fc 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -12406,7 +12406,8 @@
"rename": "Rename",
"fix": "Fix",
"republish": "Re-publish",
- "abandonPending": "Stop waiting"
+ "abandonPending": "Stop waiting",
+ "editPublication": "Edit Publication Details"
},
"API_KEY_MISSING": {
"title": "API key not configured",
@@ -12430,15 +12431,15 @@
},
"OSS_PUT_FAILED": {
"title": "Upload failed",
- "message": "Network error, please retry"
+ "message": "The upload service could not receive the file. Check your connection and retry uploading. If it continues, start a new publication."
},
"OSS_PUT_EXPIRED": {
"title": "Upload link expired",
"message": "Upload link expired, please re-publish"
},
"VERSION_RACE": {
- "title": "Version conflict",
- "message": "Auto-retry failed, please retry later"
+ "title": "Version Already Taken",
+ "message": "This version is already published or being processed. Choose an unused version number and publish again."
},
"CHECKSUM_MISMATCH": {
"title": "Checksum failed",
@@ -12450,15 +12451,15 @@
},
"PACK_FAILED": {
"title": "Packaging failed",
- "message": "The skill package was not created. Please retry."
+ "message": "Check that the local Skill files are readable, remove unnecessary large files, and publish again."
},
"OSS_OBJECT_NOT_FOUND": {
"title": "Uploaded file lost",
"message": "Server cannot find the uploaded file, please retry"
},
"MANIFEST_INVALID": {
- "title": "Invalid SKILL.md format",
- "message": "SKILL.md must start with YAML frontmatter and include name and description fields"
+ "title": "Invalid Skill Package",
+ "message": "Check SKILL.md and the package files using the reason below, then fix them and publish again."
},
"CANCELLED": {
"title": "Cancelled",
@@ -12473,12 +12474,56 @@
"message": "Choose a visibility supported by the current publishing identity"
},
"INTERNAL": {
- "title": "Server error",
- "message": "Publish failed, please retry later"
+ "title": "Publication Incomplete",
+ "message": "An unexpected error occurred. Retry later, or contact support if it continues."
},
"UNKNOWN": {
"title": "Unknown error",
"message": "Publish failed ({{code}}), please retry"
+ },
+ "SKILL_DELETED": {
+ "title": "Skill Name Reserved After Deletion",
+ "message": "A Skill with this name was deleted, but its name is still reserved. Rename your Skill and publish again."
+ },
+ "SKILL_UNPUBLISHED": {
+ "title": "Skill Unpublished",
+ "message": "The Skill was unpublished during upload, stopping this publication. Check its publication status and publish again."
+ },
+ "AUTH_REQUIRED": {
+ "title": "Sign-In Required",
+ "message": "You are signed out or your sign-in has expired. Sign in and publish again."
+ },
+ "PERMISSION_DENIED": {
+ "title": "No Permission to Publish",
+ "message": "Switch to an authorized publishing identity, or ask the Skill author or organization administrator to check your access."
+ },
+ "INVALID_PARAMS": {
+ "title": "Invalid Publication Details",
+ "message": "Update the publication details using the reason below, then publish again."
+ },
+ "SKILL_FILE_TOO_LARGE": {
+ "title": "Skill Package Exceeds Limits",
+ "message": "Limits: 32 MiB compressed, 50 MiB unpacked, 2 MiB for SKILL.md, and 2000 archive entries. Reduce the package and publish again."
+ },
+ "NETWORK_ERROR": {
+ "title": "Cannot Connect to Publishing Service",
+ "message": "Check your network connection and retry publishing."
+ },
+ "RATE_LIMITED": {
+ "title": "Too Many Publish Requests",
+ "message": "Wait a moment and retry publishing."
+ },
+ "SERVICE_UNAVAILABLE": {
+ "title": "Publishing Service Unavailable",
+ "message": "Retry publishing later. Contact support if the problem continues."
+ },
+ "PUBLISH_BUSY": {
+ "title": "Another Skill Is Being Published",
+ "message": "Wait for the current publication to finish before publishing this Skill."
+ },
+ "REQUEST_REJECTED": {
+ "title": "Publication Request Rejected",
+ "message": "Check the publication details and publish again. If it keeps failing, contact support."
}
},
"scanResult": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index c52f1633f1..e244e821be 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -12390,7 +12390,8 @@
"rename": "改名へ",
"fix": "修正へ",
"republish": "再公開",
- "abandonPending": "待機をやめる"
+ "abandonPending": "待機をやめる",
+ "editPublication": "公開情報を修正"
},
"API_KEY_MISSING": {
"title": "API key が未設定",
@@ -12414,15 +12415,15 @@
},
"OSS_PUT_FAILED": {
"title": "アップロード失敗",
- "message": "ネットワーク異常、再試行してください"
+ "message": "アップロードサービスがファイルを受信できませんでした。ネットワークを確認してアップロードを再試行してください。問題が続く場合は再公開してください。"
},
"OSS_PUT_EXPIRED": {
"title": "アップロードリンク失効",
"message": "アップロードリンクが失効しました、再公開してください"
},
"VERSION_RACE": {
- "title": "バージョン競合",
- "message": "自動再試行に失敗しました、後ほど再試行してください"
+ "title": "バージョン番号は使用済みです",
+ "message": "このバージョンは公開済みか処理中です。未使用のバージョン番号を指定して再公開してください。"
},
"CHECKSUM_MISMATCH": {
"title": "チェックサム失敗",
@@ -12434,15 +12435,15 @@
},
"PACK_FAILED": {
"title": "パッケージ化に失敗しました",
- "message": "skill のパッケージを作成できませんでした。再試行してください"
+ "message": "ローカルのスキルファイルを読み取れるか確認し、不要な大きいファイルを削除して再公開してください。"
},
"OSS_OBJECT_NOT_FOUND": {
"title": "アップロードファイルが見つかりません",
"message": "サーバーがアップロード済みファイルを見つけられません、再試行してください"
},
"MANIFEST_INVALID": {
- "title": "SKILL.md の形式が正しくありません",
- "message": "SKILL.md は YAML frontmatter で始まり、name と description フィールドを含む必要があります"
+ "title": "スキルパッケージが要件を満たしていません",
+ "message": "以下の理由に従って SKILL.md とパッケージ内のファイルを確認し、修正して再公開してください。"
},
"CANCELLED": {
"title": "キャンセル済み",
@@ -12457,12 +12458,56 @@
"message": "現在の公開者が利用できる公開範囲を選択してください"
},
"INTERNAL": {
- "title": "サーバーエラー",
- "message": "公開失敗、後ほど再試行してください"
+ "title": "公開が完了しませんでした",
+ "message": "予期しないエラーが発生しました。時間をおいて再試行してください。問題が続く場合はサポートにお問い合わせください。"
},
"UNKNOWN": {
"title": "不明なエラー",
"message": "公開失敗 ({{code}})、再試行してください"
+ },
+ "SKILL_DELETED": {
+ "title": "同名のスキルは削除済み",
+ "message": "同名のスキルは削除されていますが、名前は引き続き予約されています。スキル名を変更して再公開してください。"
+ },
+ "SKILL_UNPUBLISHED": {
+ "title": "スキルが公開停止されました",
+ "message": "アップロード中にスキルが公開停止されたため、今回の公開は中止されました。公開状態を確認して再公開してください。"
+ },
+ "AUTH_REQUIRED": {
+ "title": "ログインが必要です",
+ "message": "未ログインか、ログインの有効期限が切れています。ログインして再公開してください。"
+ },
+ "PERMISSION_DENIED": {
+ "title": "公開権限がありません",
+ "message": "公開権限のあるアカウントに切り替えるか、スキルの作者または組織の管理者に権限を確認してください。"
+ },
+ "INVALID_PARAMS": {
+ "title": "公開情報が要件を満たしていません",
+ "message": "以下の理由に従って公開情報を修正し、再公開してください。"
+ },
+ "SKILL_FILE_TOO_LARGE": {
+ "title": "スキルパッケージが上限を超えています",
+ "message": "上限は圧縮時 32 MiB、展開後 50 MiB、SKILL.md は 2 MiB、アーカイブ内は 2000 項目です。内容を減らして再公開してください。"
+ },
+ "NETWORK_ERROR": {
+ "title": "公開サービスに接続できません",
+ "message": "ネットワーク接続を確認して公開を再試行してください。"
+ },
+ "RATE_LIMITED": {
+ "title": "公開リクエストが多すぎます",
+ "message": "少し待ってから公開を再試行してください。"
+ },
+ "SERVICE_UNAVAILABLE": {
+ "title": "公開サービスを利用できません",
+ "message": "時間をおいて公開を再試行してください。問題が続く場合はサポートにお問い合わせください。"
+ },
+ "PUBLISH_BUSY": {
+ "title": "別のスキルを公開中です",
+ "message": "現在の公開処理が完了してから、このスキルを公開してください。"
+ },
+ "REQUEST_REJECTED": {
+ "title": "公開リクエストが拒否されました",
+ "message": "公開情報を確認して再公開してください。繰り返し失敗する場合はサポートにお問い合わせください。"
}
},
"scanResult": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 56cd8a3618..d41250d037 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -12390,7 +12390,8 @@
"rename": "이름 변경",
"fix": "수정",
"republish": "다시 게시",
- "abandonPending": "대기 포기"
+ "abandonPending": "대기 포기",
+ "editPublication": "게시 정보 수정"
},
"API_KEY_MISSING": {
"title": "API key 미설정",
@@ -12414,15 +12415,15 @@
},
"OSS_PUT_FAILED": {
"title": "업로드 실패",
- "message": "네트워크 이상, 재시도하세요"
+ "message": "업로드 서비스가 파일을 받지 못했습니다. 네트워크를 확인한 후 업로드를 다시 시도하세요. 문제가 계속되면 새로 게시하세요."
},
"OSS_PUT_EXPIRED": {
"title": "업로드 링크 만료",
"message": "업로드 링크가 만료되었습니다, 다시 게시하세요"
},
"VERSION_RACE": {
- "title": "버전 충돌",
- "message": "자동 재시도 실패, 잠시 후 재시도하세요"
+ "title": "이미 사용 중인 버전 번호",
+ "message": "이 버전은 이미 게시되었거나 처리 중입니다. 사용하지 않은 버전 번호를 선택한 후 다시 게시하세요."
},
"CHECKSUM_MISMATCH": {
"title": "체크섬 실패",
@@ -12434,15 +12435,15 @@
},
"PACK_FAILED": {
"title": "패키징 실패",
- "message": "skill 패키지를 만들지 못했습니다. 다시 시도하세요"
+ "message": "로컬 스킬 파일을 읽을 수 있는지 확인하고 불필요한 대용량 파일을 제거한 후 다시 게시하세요."
},
"OSS_OBJECT_NOT_FOUND": {
"title": "업로드 파일 손실",
"message": "서버에서 업로드된 파일을 찾을 수 없습니다, 재시도하세요"
},
"MANIFEST_INVALID": {
- "title": "SKILL.md 형식이 올바르지 않습니다",
- "message": "SKILL.md 파일은 YAML frontmatter 로 시작하고 name 및 description 필드를 포함해야 합니다"
+ "title": "스킬 패키지가 요구 사항에 맞지 않음",
+ "message": "아래 원인에 따라 SKILL.md와 패키지 파일을 확인하고 수정한 후 다시 게시하세요."
},
"CANCELLED": {
"title": "취소됨",
@@ -12457,12 +12458,56 @@
"message": "현재 게시자에게 허용된 공개 범위를 선택하세요"
},
"INTERNAL": {
- "title": "서버 오류",
- "message": "게시 실패, 잠시 후 재시도하세요"
+ "title": "게시 미완료",
+ "message": "예기치 않은 오류가 발생했습니다. 나중에 다시 시도하세요. 문제가 계속되면 지원팀에 문의하세요."
},
"UNKNOWN": {
"title": "알 수 없는 오류",
"message": "게시 실패 ({{code}}), 재시도하세요"
+ },
+ "SKILL_DELETED": {
+ "title": "같은 이름의 스킬이 삭제됨",
+ "message": "같은 이름의 스킬이 삭제되었지만 이름은 계속 예약되어 있습니다. 스킬 이름을 변경한 후 다시 게시하세요."
+ },
+ "SKILL_UNPUBLISHED": {
+ "title": "스킬 게시가 중단됨",
+ "message": "업로드 중 스킬 게시가 중단되어 이번 게시가 취소되었습니다. 게시 상태를 확인한 후 다시 게시하세요."
+ },
+ "AUTH_REQUIRED": {
+ "title": "로그인 필요",
+ "message": "로그인하지 않았거나 로그인 상태가 만료되었습니다. 로그인한 후 다시 게시하세요."
+ },
+ "PERMISSION_DENIED": {
+ "title": "게시 권한 없음",
+ "message": "게시 권한이 있는 계정으로 전환하거나 스킬 작성자 또는 조직 관리자에게 권한을 확인하세요."
+ },
+ "INVALID_PARAMS": {
+ "title": "게시 정보가 요구 사항에 맞지 않음",
+ "message": "아래 원인에 따라 게시 정보를 수정한 후 다시 게시하세요."
+ },
+ "SKILL_FILE_TOO_LARGE": {
+ "title": "스킬 패키지가 제한을 초과함",
+ "message": "압축 파일은 32 MiB, 압축 해제 후 50 MiB, SKILL.md는 2 MiB, 파일 및 폴더 항목은 2000개까지 허용됩니다. 패키지를 줄인 후 다시 게시하세요."
+ },
+ "NETWORK_ERROR": {
+ "title": "게시 서비스에 연결할 수 없음",
+ "message": "네트워크 연결을 확인한 후 게시를 다시 시도하세요."
+ },
+ "RATE_LIMITED": {
+ "title": "게시 요청이 너무 많음",
+ "message": "잠시 기다린 후 게시를 다시 시도하세요."
+ },
+ "SERVICE_UNAVAILABLE": {
+ "title": "게시 서비스를 사용할 수 없음",
+ "message": "나중에 게시를 다시 시도하세요. 문제가 계속되면 지원팀에 문의하세요."
+ },
+ "PUBLISH_BUSY": {
+ "title": "다른 스킬을 게시 중",
+ "message": "현재 게시가 끝난 후 이 스킬을 게시하세요."
+ },
+ "REQUEST_REJECTED": {
+ "title": "게시 요청이 거부됨",
+ "message": "게시 정보를 확인한 후 다시 게시하세요. 계속 실패하면 지원팀에 문의하세요."
}
},
"scanResult": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 2cd121d5af..cc0f2f4bbe 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -12390,7 +12390,8 @@
"rename": "去改名",
"fix": "去改",
"republish": "重新发布",
- "abandonPending": "放弃等待"
+ "abandonPending": "放弃等待",
+ "editPublication": "修改发布信息"
},
"API_KEY_MISSING": {
"title": "未配置 API key",
@@ -12414,15 +12415,15 @@
},
"OSS_PUT_FAILED": {
"title": "上传失败",
- "message": "网络异常,请重试"
+ "message": "上传服务未能接收文件。请检查网络后重试上传;持续失败时请重新发布"
},
"OSS_PUT_EXPIRED": {
"title": "上传链接过期",
"message": "上传链接已过期,请重新发布"
},
"VERSION_RACE": {
- "title": "版本冲突",
- "message": "自动重试已失败,请稍后重试"
+ "title": "版本号已被占用",
+ "message": "该版本已发布或正在处理。请选择未使用的版本号后重新发布"
},
"CHECKSUM_MISMATCH": {
"title": "校验失败",
@@ -12434,15 +12435,15 @@
},
"PACK_FAILED": {
"title": "打包失败",
- "message": "未能完成 Skill 打包,请重试"
+ "message": "请确认本地技能文件可以读取,精简不必要的大文件后重新发布"
},
"OSS_OBJECT_NOT_FOUND": {
"title": "上传文件丢失",
"message": "服务器找不到上传的文件,请重试"
},
"MANIFEST_INVALID": {
- "title": "SKILL.md 格式不正确",
- "message": "SKILL.md 文件必须以 YAML frontmatter 开头,并包含 name 和 description 字段"
+ "title": "技能包不符合要求",
+ "message": "请按下方原因检查 SKILL.md 和包内文件,修改后重新发布"
},
"CANCELLED": {
"title": "已取消",
@@ -12457,12 +12458,56 @@
"message": "请选择当前发布身份支持的可见范围"
},
"INTERNAL": {
- "title": "服务器错误",
- "message": "发布失败,请稍后重试"
+ "title": "发布未完成",
+ "message": "发生未预期的异常,请稍后重试;持续失败时请联系支持"
},
"UNKNOWN": {
"title": "未知错误",
"message": "发布失败 ({{code}}),请重试"
+ },
+ "SKILL_DELETED": {
+ "title": "同名技能已删除",
+ "message": "同名技能已被删除,但名称仍被占用。请修改技能名称后重新发布"
+ },
+ "SKILL_UNPUBLISHED": {
+ "title": "技能已下架",
+ "message": "技能在上传期间被下架,本次发布已停止。请确认发布状态后重新发布"
+ },
+ "AUTH_REQUIRED": {
+ "title": "需要登录",
+ "message": "当前登录状态已失效或尚未登录,请登录后重新发布"
+ },
+ "PERMISSION_DENIED": {
+ "title": "当前账号没有发布权限",
+ "message": "请切换到有权限的发布身份,或联系技能作者、组织管理员确认权限"
+ },
+ "INVALID_PARAMS": {
+ "title": "发布信息不符合要求",
+ "message": "请按下方原因修改发布信息后重新发布"
+ },
+ "SKILL_FILE_TOO_LARGE": {
+ "title": "技能包超过限制",
+ "message": "压缩包最多 32 MiB,解压后最多 50 MiB,SKILL.md 最多 2 MiB,包内最多 2000 个条目。请精简后重新发布"
+ },
+ "NETWORK_ERROR": {
+ "title": "无法连接发布服务",
+ "message": "请检查网络连接后重试发布"
+ },
+ "RATE_LIMITED": {
+ "title": "发布请求过于频繁",
+ "message": "请稍等片刻再重试发布"
+ },
+ "SERVICE_UNAVAILABLE": {
+ "title": "发布服务暂不可用",
+ "message": "请稍后重试发布;持续失败时请联系支持"
+ },
+ "PUBLISH_BUSY": {
+ "title": "已有技能正在发布",
+ "message": "请等待当前发布结束后再发布此技能"
+ },
+ "REQUEST_REJECTED": {
+ "title": "发布请求被拒绝",
+ "message": "请检查发布信息后重新发布;持续失败时请联系支持"
}
},
"scanResult": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index a88accd5a5..c504344e3f 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -12390,7 +12390,8 @@
"rename": "去改名",
"fix": "去改",
"republish": "重新發布",
- "abandonPending": "放棄等待"
+ "abandonPending": "放棄等待",
+ "editPublication": "修改發布資訊"
},
"API_KEY_MISSING": {
"title": "未配置 API key",
@@ -12414,15 +12415,15 @@
},
"OSS_PUT_FAILED": {
"title": "上傳失敗",
- "message": "網路異常,請重試"
+ "message": "上傳服務未能接收檔案。請檢查網路後重試上傳;若持續失敗,請重新發布"
},
"OSS_PUT_EXPIRED": {
"title": "上傳連結過期",
"message": "上傳連結已過期,請重新發布"
},
"VERSION_RACE": {
- "title": "版本衝突",
- "message": "自動重試已失敗,請稍後重試"
+ "title": "版本號已被占用",
+ "message": "該版本已發布或正在處理。請選擇未使用的版本號後重新發布"
},
"CHECKSUM_MISMATCH": {
"title": "校驗失敗",
@@ -12434,15 +12435,15 @@
},
"PACK_FAILED": {
"title": "打包失敗",
- "message": "未能完成 Skill 打包,請重試"
+ "message": "請確認本地技能檔案可以讀取,精簡不必要的大型檔案後重新發布"
},
"OSS_OBJECT_NOT_FOUND": {
"title": "上傳檔案丟失",
"message": "伺服器找不到上傳的檔案,請重試"
},
"MANIFEST_INVALID": {
- "title": "SKILL.md 格式不正確",
- "message": "SKILL.md 檔案必須以 YAML frontmatter 開頭,並包含 name 和 description 欄位"
+ "title": "技能套件不符合要求",
+ "message": "請依下方原因檢查 SKILL.md 與套件內檔案,修改後重新發布"
},
"CANCELLED": {
"title": "已取消",
@@ -12457,12 +12458,56 @@
"message": "請選擇目前發佈身分支援的可見範圍"
},
"INTERNAL": {
- "title": "伺服器錯誤",
- "message": "釋出失敗,請稍後重試"
+ "title": "發布未完成",
+ "message": "發生未預期的異常,請稍後重試;若持續失敗,請聯絡支援"
},
"UNKNOWN": {
"title": "未知錯誤",
"message": "釋出失敗 ({{code}}),請重試"
+ },
+ "SKILL_DELETED": {
+ "title": "同名技能已刪除",
+ "message": "同名技能已被刪除,但名稱仍被占用。請修改技能名稱後重新發布"
+ },
+ "SKILL_UNPUBLISHED": {
+ "title": "技能已下架",
+ "message": "技能在上傳期間被下架,本次發布已停止。請確認發布狀態後重新發布"
+ },
+ "AUTH_REQUIRED": {
+ "title": "需要登入",
+ "message": "目前登入狀態已失效或尚未登入,請登入後重新發布"
+ },
+ "PERMISSION_DENIED": {
+ "title": "目前帳號沒有發布權限",
+ "message": "請切換至有權限的發布身分,或聯絡技能作者、組織管理員確認權限"
+ },
+ "INVALID_PARAMS": {
+ "title": "發布資訊不符合要求",
+ "message": "請依下方原因修改發布資訊後重新發布"
+ },
+ "SKILL_FILE_TOO_LARGE": {
+ "title": "技能套件超過限制",
+ "message": "壓縮檔最多 32 MiB,解壓後最多 50 MiB,SKILL.md 最多 2 MiB,套件內最多 2000 個項目。請精簡後重新發布"
+ },
+ "NETWORK_ERROR": {
+ "title": "無法連線至發布服務",
+ "message": "請檢查網路連線後重試發布"
+ },
+ "RATE_LIMITED": {
+ "title": "發布請求過於頻繁",
+ "message": "請稍候再重試發布"
+ },
+ "SERVICE_UNAVAILABLE": {
+ "title": "發布服務暫時無法使用",
+ "message": "請稍後重試發布;若持續失敗,請聯絡支援"
+ },
+ "PUBLISH_BUSY": {
+ "title": "已有技能正在發布",
+ "message": "請等待目前發布結束後再發布此技能"
+ },
+ "REQUEST_REJECTED": {
+ "title": "發布請求遭拒",
+ "message": "請檢查發布資訊後重新發布;若持續失敗,請聯絡支援團隊"
}
},
"scanResult": {
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index f94a378189..8fc5cee452 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -7357,24 +7357,7 @@ interface SkillhubPublishParams {
changelog?: string;
}
-type SkillhubPublishErrorCode =
- | 'NAME_TAKEN'
- | 'INVALID_DEPT'
- | 'INVALID_NAME'
- | 'CATEGORY_REQUIRED'
- | 'MANIFEST_INVALID'
- | 'VERSION_RACE'
- | 'CHECKSUM_MISMATCH'
- | 'NOT_AUTHOR'
- | 'PACK_FAILED'
- | 'OSS_PUT_FAILED'
- | 'OSS_PUT_EXPIRED'
- | 'OSS_OBJECT_NOT_FOUND'
- | 'API_KEY_MISSING'
- | 'CANCELLED'
- | 'SKILL_HUB_READ_ONLY'
- | 'INVALID_VISIBILITY'
- | 'INTERNAL';
+type SkillhubPublishErrorCode = import('../shared/skillhubPublishErrors').SkillhubPublishErrorCode;
type SkillhubPublishProgressEvent = (
| { phase: 'packing' }
diff --git a/apps/desktop/src/shared/__tests__/skillhubPublishErrors.test.ts b/apps/desktop/src/shared/__tests__/skillhubPublishErrors.test.ts
new file mode 100644
index 0000000000..ecafa24684
--- /dev/null
+++ b/apps/desktop/src/shared/__tests__/skillhubPublishErrors.test.ts
@@ -0,0 +1,37 @@
+import { describe, expect, it } from 'vitest';
+import { publishErrorDetail, serverPublishErrorCode } from '../skillhubPublishErrors';
+
+describe('SkillHub publish error classification', () => {
+ it.each([
+ ['SKILL_DELETED', 409, '同名 Skill 已删除', 'SKILL_DELETED'],
+ ['FORBIDDEN', 403, '已删除的 Skill 不能继续发布', 'SKILL_DELETED'],
+ ['FORBIDDEN', 403, '没有权限', 'PERMISSION_DENIED'],
+ ['HTTP_403', 403, 'private diagnostic', 'PERMISSION_DENIED'],
+ ['UNAUTHORIZED', 401, '登录过期', 'AUTH_REQUIRED'],
+ ['INVALID_PARAMS', 400, 'tags 包含不存在的标签', 'INVALID_PARAMS'],
+ ['MANIFEST_INVALID', 400, '缺少 description', 'MANIFEST_INVALID'],
+ ['UPLOAD_SESSION_EXPIRED', 409, '上传会话过期', 'OSS_PUT_EXPIRED'],
+ ['STORAGE_UNAVAILABLE', 503, '存储不可用', 'SERVICE_UNAVAILABLE'],
+ ['ORG_ROUTING_UNAVAILABLE', 503, '无法确认组织路由', 'SERVICE_UNAVAILABLE'],
+ ['NETWORK_ERROR', 0, 'network failure', 'NETWORK_ERROR'],
+ ['RATE_LIMITED', 429, '请求过多', 'RATE_LIMITED'],
+ ['NEW_VALIDATION_ERROR', 422, '业务原因', 'REQUEST_REJECTED'],
+ ['INTERNAL_ERROR', 500, 'private diagnostic', 'INTERNAL'],
+ ['NEW_SERVER_FAILURE', 502, 'private diagnostic', 'INTERNAL'],
+ ])('maps %s without collapsing business failures into INTERNAL', (code, status, message, expected) => {
+ expect(serverPublishErrorCode(String(code), String(message), Number(status))).toBe(expected);
+ });
+
+ it('keeps a short actionable reason', () => {
+ expect(publishErrorDetail('MANIFEST_INVALID', '缺少 description')).toBe('缺少 description');
+ expect(publishErrorDetail('INVALID_PARAMS', ' 标签不存在 ')).toBe('标签不存在');
+ });
+
+ it.each(['INTERNAL', 'PACK_FAILED', 'OSS_PUT_FAILED', 'NETWORK_ERROR', 'CANCELLED',
+ 'SERVICE_UNAVAILABLE', 'RATE_LIMITED', 'AUTH_REQUIRED', 'PERMISSION_DENIED', 'NOT_AUTHOR',
+ 'API_KEY_MISSING', 'SKILL_HUB_READ_ONLY', 'OSS_PUT_EXPIRED', 'OSS_OBJECT_NOT_FOUND', 'PUBLISH_BUSY'] as const)(
+ 'does not display raw diagnostics for %s', (code) => {
+ expect(publishErrorDetail(code, 'private diagnostic')).toBe('');
+ },
+ );
+});
diff --git a/apps/desktop/src/shared/skillhubPublishErrors.ts b/apps/desktop/src/shared/skillhubPublishErrors.ts
new file mode 100644
index 0000000000..34643f2250
--- /dev/null
+++ b/apps/desktop/src/shared/skillhubPublishErrors.ts
@@ -0,0 +1,49 @@
+/** Publish failures shared by the main process, IPC fallback and renderer. */
+export const SKILLHUB_PUBLISH_ERROR_CODES = [
+ 'NAME_TAKEN', 'SKILL_DELETED', 'SKILL_UNPUBLISHED', 'INVALID_DEPT', 'INVALID_NAME',
+ 'CATEGORY_REQUIRED', 'MANIFEST_INVALID', 'INVALID_PARAMS', 'SKILL_FILE_TOO_LARGE',
+ 'VERSION_RACE', 'CHECKSUM_MISMATCH', 'NOT_AUTHOR', 'PERMISSION_DENIED', 'AUTH_REQUIRED',
+ 'PACK_FAILED', 'OSS_PUT_FAILED', 'OSS_PUT_EXPIRED', 'OSS_OBJECT_NOT_FOUND',
+ 'API_KEY_MISSING', 'CANCELLED', 'SKILL_HUB_READ_ONLY', 'INVALID_VISIBILITY',
+ 'NETWORK_ERROR', 'RATE_LIMITED', 'SERVICE_UNAVAILABLE', 'PUBLISH_BUSY',
+ 'REQUEST_REJECTED', 'INTERNAL',
+] as const;
+
+export type SkillhubPublishErrorCode = typeof SKILLHUB_PUBLISH_ERROR_CODES[number];
+
+export function isSkillhubPublishErrorCode(code: unknown): code is SkillhubPublishErrorCode {
+ return typeof code === 'string' && (SKILLHUB_PUBLISH_ERROR_CODES as readonly string[]).includes(code);
+}
+
+/** Older servers used FORBIDDEN for deletion; keep their explicit reason actionable. */
+export function serverPublishErrorCode(code: string, message = '', statusCode?: number): SkillhubPublishErrorCode {
+ if (code === 'FORBIDDEN' && message === '已删除的 Skill 不能继续发布') return 'SKILL_DELETED';
+ if (isSkillhubPublishErrorCode(code)) return code;
+ if (['UNAUTHORIZED', 'TOKEN_EXPIRED', 'INVALID_TOKEN', 'ACCOUNT_UNAVAILABLE'].includes(code)) return 'AUTH_REQUIRED';
+ if (code === 'FORBIDDEN') return 'PERMISSION_DENIED';
+ if (code === 'UPLOAD_SESSION_EXPIRED') return 'OSS_PUT_EXPIRED';
+ if (['STORAGE_UNAVAILABLE', 'CACHE_UNAVAILABLE', 'ORG_ROUTING_UNAVAILABLE', 'UNSUPPORTED_CAPABILITY'].includes(code)) {
+ return 'SERVICE_UNAVAILABLE';
+ }
+ if (code === 'INTERNAL_ERROR') return 'INTERNAL';
+ if (statusCode === 401) return 'AUTH_REQUIRED';
+ if (statusCode === 403) return 'PERMISSION_DENIED';
+ if (statusCode === 429) return 'RATE_LIMITED';
+ if (statusCode === 413) return 'SKILL_FILE_TOO_LARGE';
+ if (statusCode === 0) return 'NETWORK_ERROR';
+ if (statusCode !== undefined && statusCode >= 400 && statusCode < 500) return 'REQUEST_REJECTED';
+ return 'INTERNAL';
+}
+
+const PUBLIC_BUSINESS_ERROR_CODES: readonly SkillhubPublishErrorCode[] = [
+ 'NAME_TAKEN', 'SKILL_DELETED', 'SKILL_UNPUBLISHED', 'INVALID_DEPT', 'INVALID_NAME',
+ 'CATEGORY_REQUIRED', 'MANIFEST_INVALID', 'INVALID_PARAMS', 'SKILL_FILE_TOO_LARGE',
+ 'VERSION_RACE', 'CHECKSUM_MISMATCH',
+ 'INVALID_VISIBILITY', 'REQUEST_REJECTED',
+];
+
+/** Only deliberate business messages are user-facing; service/auth diagnostics use recovery copy. */
+export function publishErrorDetail(code: SkillhubPublishErrorCode, message: unknown): string {
+ if (!PUBLIC_BUSINESS_ERROR_CODES.includes(code)) return '';
+ return typeof message === 'string' ? message.trim() : '';
+}
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index 08ae641756..74a508273c 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -11,6 +11,32 @@
> **增量适用原则**:wire protocol 兼容对所有跨端改动生效,不因是小改而豁免。
+## SkillHub 发布失败原因
+
+发布错误继续使用 `{ error: { code, message } }`,Desktop 保留已知业务码与具体原因,
+同步用于进度事件和 IPC 结果回退;短原因也展示。未知 4xx 错误保留业务原因,网络故障、
+限流和服务不可用各自提供重试建议。缺少标准错误码的 HTTP 403 也归为权限不足,不引导编辑请求。
+只有明确的业务拒绝原因可展示原文;认证、权限不足(含 `NOT_AUTHOR`)、凭证配置、只读能力、限流、
+服务不可用及未预期的内部异常使用恢复文案,不展示原始诊断,包括异步结果与复制内容。
+init/commit 的服务端拒绝在主进程过滤非公开详情;非标准 `HTTP_*` 回退也不透传原始 message,
+未知但符合错误体契约的 4xx 业务码仍保留公开原因,客户端使用固定提示补足空详情。
+主进程的本地可见范围拒绝只返回 `INVALID_VISIBILITY`,由 Renderer 使用当前语言的恢复提示,
+不透传硬编码英文;服务端的可见范围业务原因仍可展示。
+新服务端的 `SKILL_DELETED`(409)表示同名技能已删除但名称仍被占用,客户端引导改名;
+新客户端兼容旧服务端 `FORBIDDEN` + “已删除的 Skill 不能继续发布”。旧客户端遇到新错误码
+仍可按原有通用提示降级,不要求同步发布。
+
+后台处理失败复用扫描结果的 `gates[].issues[]`(severity、code、message),客户端
+同时识别失败项的 issue 错误码与旧版错误码检查项名称,展示具体原因与相应修改建议,
+避免把包校验或名称冲突描述为安全审核失败;只对失败检查项进行该分类,已通过项、
+warn/warning 状态检查项、等待或处理中的检查项和 warning issue
+不参与失败分类。`package-validation`、`publication`、`publication-processing`、`upload-processing`
+表示发布处理检查项,其中未知错误使用内部失败的公开恢复说明,并移除诊断路径与证据;
+普通安全扫描的 findings 继续保留具体原因与相对文件位置。旧客户端本来就能
+展示 issue。服务端只向上传者返回会话原因,公开目录权限不变;未知内部异常仍返回公开的
+重试说明。实现与回归见 `shared/skillhubPublishErrors.ts`、`publishService.test.ts`、
+`PublishDialog.feedback.test.tsx` 和 `ScanResultDialog.test.tsx`。
+
## 电脑互联的消息文件与历史变更
跨电脑任务复制使用同账号业务通道 `maker:task-copy`,受信 Renderer 使用 `task-copy:request`。