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。

feat(skills): 支持在对话中搜索、上传和更新 SkillHub 技能 (#4844)

bobo6210df89d165
diff --git a/apps/desktop/help-knowledge/skills.md b/apps/desktop/help-knowledge/skills.md
index b70576667b..429e72aad1 100644
--- a/apps/desktop/help-knowledge/skills.md
+++ b/apps/desktop/help-knowledge/skills.md
@@ -1,7 +1,7 @@
---
id: skills
title: Skills (reusable agent capabilities)
-summary: Create, browse, install, disable, uninstall, publish, and update agent Skills; Skills appear as "/" slash commands and are shared across Claude Code, Codex, and Pi.
+summary: Create, search, browse, install, disable, uninstall, publish, and update agent Skills; Skills appear as "/" slash commands and are shared across Claude Code, Codex, and Pi.
---
Skills are reusable agent capabilities you package as a folder and load into your sessions. They're managed on the same page as Plugins — **Skills** and **Plugins** are two tabs of one management surface (the Skills tab is the in-app browser for finding, installing, publishing, and updating skills).
@@ -32,6 +32,10 @@ Skills are reusable agent capabilities you package as a folder and load into you
- Cindy includes `/cindy-skill-creator`. Invoke it with a description of the Skill you want, such as `/cindy-skill-creator Create a Skill that checks release notes`. Invoking it without a description asks what you want to create.
- The current Agent creates or updates the Skill directly with its normal file tools. It does not use the `/learn` staging flow.
+- Ask for a Skill in the composer, for example “Find a release-notes Skill” or `/cindy-skill-creator Search our organization's code-review Skills`. The Agent can search SkillHub's public marketplace or your organization's catalog. Without a specified scope, organization identities search both; personal identities search the public marketplace. Results identify their source, including when two Skills share a name. Search alone does not install anything.
+- You can also ask `/cindy-skill-creator` to upload your own Skill to SkillHub or publish a new version directly in the conversation. Give the local Skill folder (or the Skill just created) and, for a first upload, who should be able to access it. Ordinary local creation/editing does not automatically publish it.
+- Uploads use Cindy's signed-in account, which determines ownership; choosing sharing targets does not change that ownership. The Agent can list your published Skills, upload the folder, and check scan/review status. Upload success does not mean public approval. Updating requires confirmed original authorship and management access, and preserves visibility and ownership; a missing authorship flag is not treated as permission. This works in a local desktop task, including when controlled from a phone; SSH files must first be made available on the Cindy host.
+- Each Agent upload or version update follows the task's permission mode: Ask requests approval for that publication, Auto reviews it against your request, and Full Access bypasses operation approval. A previous helper-tool approval does not authorize later publications. Search, listing, and status queries remain automatic.
- Unless you request another location, new Skills go to `~/.agents/skills/<name>/`. Ask for a project-specific Skill to create it under `<working-dir>/.agents/skills/<name>/`.
- Cindy also includes `/learn`. Bare `/learn` distills the current task; `/learn <description>` learns from a described workflow; `/learn hub:<scope>:<slug> [instructions]` learns from a SkillHub Skill. Cindy gathers evidence, runs the distillation in a separate task, and shows a diff for review before saving the proposed Skill.
- The built-in `cindy-skill-creator` and `learn` entries appear in the local Skill list with an Official badge. You can disable or enable either entry there; because they ship with Cindy, they cannot be uninstalled. The setting applies to new or restarted Agent sessions. Disabling `learn` also disables the **Learn this skill** action in SkillHub after the local Skill list has refreshed.
@@ -49,7 +53,7 @@ Skills are reusable agent capabilities you package as a folder and load into you
**Publishing your own skill:**
- Find the publish action on the Skills page and point it at the skill's local folder. It zips the folder and uploads it — reading your directory in place, without copying or moving anything.
-- On first publish, you set the skill's **visibility**: PUBLIC (anyone in the org) or DEPARTMENT_SCOPED (only the departments you choose).
+- On first publish, choose visibility: personal identities support public or private; organization identities support public or organization sharing. Public publication is subject to review.
- The local registry records what you published, so the app knows it's "yours" for future updates.
**Updating an already-published skill:**
diff --git a/apps/desktop/resources/system-skills/cindy-skill-creator/SKILL.md b/apps/desktop/resources/system-skills/cindy-skill-creator/SKILL.md
index 4a112abc3e..95ee248473 100644
--- a/apps/desktop/resources/system-skills/cindy-skill-creator/SKILL.md
+++ b/apps/desktop/resources/system-skills/cindy-skill-creator/SKILL.md
@@ -1,6 +1,6 @@
---
name: cindy-skill-creator
-description: Create or update a Cindy Skill with appropriately scoped instructions and any needed supporting resources.
+description: Create or edit a Cindy Skill, search the SkillHub public marketplace or your organization's Skills, upload your own Skill, or publish a new version of a Skill you authored.
metadata:
short-description: Create or update a skill
---
@@ -9,6 +9,8 @@ metadata:
Create Skills that give the current Agent useful, non-obvious guidance without constraining unrelated work.
+For searching SkillHub, uploading a local Skill, or updating an already-published Skill, read [references/skillhub-publishing.md](references/skillhub-publishing.md) and follow the relevant workflow. Searching, local editing and cloud publication are separate actions; publish when the user requests it. An explicit upload/update request is authorization for that publication; ask only for missing choices such as the target Skill or first-publication visibility.
+
## Core Principles
**Assume the Agent is already capable.** Include only information that changes its decisions or improves its work. Remove generic advice, repeated instructions, speculative edge cases, and examples that do not materially clarify the task.
@@ -151,7 +153,7 @@ These examples illustrate options, not a required structure. Choose the organiza
Adapt the work to the request. Creating a complex new skill may involve understanding realistic use cases, choosing supporting resources, initializing files, writing instructions, and validating the result. A narrow update to an existing skill may require only a focused edit and validation.
-If this Skill is invoked without a concrete creation or update request, ask what Skill the user wants and do not create files yet.
+If this Skill is invoked without a concrete creation, edit, search, or upload request, ask what the user wants to do with a Skill and do not create files yet.
Ask clarifying questions only when the missing information matters and cannot be reasonably inferred. Respect a user-specified location. When the user explicitly asks for a project-specific Skill, create it under `<current-workdir>/.agents/skills`; otherwise create it under `~/.agents/skills`. These shared roots make the Skill available to Cindy's local Claude Code, Codex, and Pi Agents. A newly created or updated Skill is picked up by new or restarted Agent sessions.
diff --git a/apps/desktop/resources/system-skills/cindy-skill-creator/references/skillhub-publishing.md b/apps/desktop/resources/system-skills/cindy-skill-creator/references/skillhub-publishing.md
new file mode 100644
index 0000000000..e3d0c69be1
--- /dev/null
+++ b/apps/desktop/resources/system-skills/cindy-skill-creator/references/skillhub-publishing.md
@@ -0,0 +1,45 @@
+# Searching, uploading and updating Skills in SkillHub
+
+Use the relevant workflow when the user asks to find a Skill in SkillHub, upload their own Skill, or publish changes to their existing Skill. For example: “找一个生成发布说明的技能”, “在组织里搜索代码审查技能”, “把这个 Skill 上传到 SkillHub,只给我自己用” or “把我的 release-notes Skill 更新到线上”. Searching does not install or publish anything. If the user only asks to create or edit local files, finish that work without publishing.
+
+## Discover the host tools
+
+Use the available `cindy_helper` MCP server: call `list_tools` with `category: "skills"`, then invoke the returned tools through `call_tool`. This category includes `search_skills`, `list_my_published_skills`, `publish_skill`, and `get_skill_publish_status`. Use their returned schemas. The host reuses Cindy's signed-in identity, catalog search, packaging, upload, registry and review services; no API key or separate CLI setup is needed.
+
+These tools run on the Cindy desktop hosting the current task. Phone/device-link conversations controlling that task use the same tools. SSH tasks cannot upload remote paths through the local host: make the Skill available on the Cindy host and publish from a local task. If the tools are unavailable, explain that limitation and direct the user to the Skills page; do not invent endpoints or read Cindy's credential files.
+
+## Search the public marketplace or organization
+
+Call `search_skills` with a short `query` describing the requested capability. Use `scope: "market"` for an explicitly public-market request and `scope: "team"` for an organization-only request. When the user has not specified a scope, omit it: the host searches both catalogs for organization identities and only the public marketplace for personal identities. Organization search uses the signed-in organization's existing access permissions, not a user-supplied organization identifier.
+
+Present relevant results with their name, description, author, version and public/organization source. Keep `catalog_scope` with each result: identical names from different catalogs are not interchangeable. Each catalog has its own `next_cursor`; for more results, pass that cursor and its explicit `scope` with the same query. If one catalog fails, show the available results and say which catalog could not be searched; an empty page or a failed catalog does not prove no matching Skill exists elsewhere.
+
+Use `list_my_published_skills`, not catalog search, when locating the user's own publication for an update. Search results alone do not establish authorship. If the user wants to install a result, use an available installation workflow or direct them to the matching source on the Skills page; do not claim search installed it.
+
+## Prepare the local folder
+
+Identify the exact Skill folder from the user’s path, the Skill just created in this task, or the installed local copy. A folder must contain `SKILL.md` with valid YAML `name` and `description`; include the scripts, references and assets it needs. For a supplied ZIP, inspect and extract it with the current Agent's file tools into a task-specific directory first. A lone `SKILL.md` should be placed in its own folder. Inspect the package contents and preserve the user's files.
+
+For a newly authored Skill, validate with this Skill's `scripts/quick_validate.py`. Existing Skills may have additional valid frontmatter such as `version`; preserve that metadata even if the authoring validator flags unsupported keys. The upload tool validates YAML, `name` and `description` against the publishing contract. Check that the folder contains only the intended Skill and its resources; remove credentials or unrelated private files from the upload copy. Pass an absolute folder path and a `name` matching its frontmatter. If changing the published name, update a separate copy when needed rather than silently renaming the user's source.
+
+## First upload
+
+Call `list_my_published_skills` to see the signed-in identity's allowed visibility choices and locate any existing publication; follow `next_cursor` if needed. Choose `mode: "create"` only for a new publication. Ask for visibility if the user's request does not already specify it:
+
+- `private`: only the personal owner; available to personal identities.
+- `shared`: organization sharing; available to organization identities. Ownership comes from the signed-in identity. Supply audience teams/departments only through `visible_slugs` when the user specifies those targets; do not guess identifiers or send owner selectors such as `team_slug`.
+- `public`: public SkillHub publication, subject to review. Never infer public visibility from “upload”.
+
+Call `publish_skill` with `path`, `name`, `mode: "create"`, and `visibility`. Include an appropriate `display_name`, `summary` and `tags` when available. Use the existing user request as authorization; do not ask them to reconfirm a complete request.
+
+## Update a published Skill
+
+Locate the exact publication with `list_my_published_skills`; updates require `is_creator: true` and `can_manage: true`. A listed or manageable Skill is not necessarily authored by this account; missing authorship information is not permission to update it. Edit the intended local folder and validate it, then call `publish_skill` with `mode: "update"`, its existing `name`, the local `path`, and an optional `changelog`, `display_name` or `summary`.
+
+The server assigns the next version. Do not guess a version number or manually increment one for this workflow. Updates preserve visibility, ownership and tags: omit those fields. Managing a team Skill does not necessarily make the user its original author; `NOT_AUTHOR` means the current account cannot upload a new version. Do not evade it by silently creating another publication.
+
+## Report the result
+
+Report the returned name and version. `status: "uploaded"` confirms upload, not review approval or public availability. Use `get_skill_publish_status` with that exact name/version to inspect the scan or review result. If pending, explain that it is awaiting review and stop polling; if rejected, explain the returned reason and address it before publishing again when requested.
+
+On a timeout or uncertain result, first inspect the published list and version status. Do not automatically repeat an upload that may have committed. Sign-in, identity, folder access, manifest and author errors should be resolved for the same intended publication; they are not reasons to broaden visibility or create a duplicate.
diff --git a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts
index 1a8937f72d..81b6d3f249 100644
--- a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts
@@ -451,10 +451,31 @@ describe('Cindy market action authorization', () => {
});
});
-describe('helper task workspace authorization', () => {
+describe('helper task workspace and SkillHub publication authorization', () => {
const policy = (toolName: string | undefined, toolParams?: unknown) =>
getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_helper', toolName, toolParams });
+ it.each([
+ { mode: 'create', visibility: 'public' },
+ { mode: 'create', visibility: 'private' },
+ { mode: 'create', visibility: 'shared', visible_slugs: ['engineering'] },
+ { mode: 'update' },
+ ])('reviews each publication with %j across payload representations', (publication) => {
+ const input = { ...publication, path: 'skills/release-notes', name: 'release-notes' };
+ for (const args of [input, JSON.stringify(input)]) {
+ expect(policy('publish_skill', args)).toBe('prompt-each-time');
+ for (const name of ['publish_skill', ' publish_skill ']) {
+ const params = { name, args };
+ for (const toolName of ['call_tool', undefined]) {
+ expect(policy(toolName, params)).toBe('prompt-each-time');
+ expect(policy(toolName, JSON.stringify(params))).toBe('prompt-each-time');
+ }
+ }
+ }
+ expect(getDesktopClaudeReadOnlyAllowedTools()).not.toContain('mcp__cindy_helper__publish_skill');
+ expect(getDesktopClaudeReadOnlyAllowedTools()).not.toContain('mcp__cindy_helper__call_tool');
+ });
+
it('reviews each move across progressive payload representations', () => {
for (const working_dir of ['/project', null]) {
for (const args of [
@@ -489,8 +510,13 @@ describe('helper task workspace authorization', () => {
'rename_project',
'remove_project',
'send_to_session',
+ 'search_skills',
+ 'list_my_published_skills',
+ 'get_skill_publish_status',
]) {
+ expect(policy(name, {})).toBe('auto-approve');
expect(policy('call_tool', { name, args: {} })).toBe('auto-approve');
+ expect(policy(undefined, JSON.stringify({ name, args: {} }))).toBe('auto-approve');
}
});
});
diff --git a/apps/desktop/src/main/maker-host/built-in-skills.ts b/apps/desktop/src/main/maker-host/built-in-skills.ts
index c8fc4b848a..9f25579445 100644
--- a/apps/desktop/src/main/maker-host/built-in-skills.ts
+++ b/apps/desktop/src/main/maker-host/built-in-skills.ts
@@ -21,7 +21,7 @@ const VERSIONS_DIRECTORY = '.versions';
const ACTIVE_BUNDLE_LINK = '.active';
const BUILT_IN_SKILL_MUTATION_WAIT_MS = 5_000;
/** Increment whenever shipped built-in Skill bytes change between releases. */
-export const BUILT_IN_SKILLS_BUNDLE_VERSION = 10;
+export const BUILT_IN_SKILLS_BUNDLE_VERSION = 12;
export interface BuiltInSkillDescriptor {
name: string;
diff --git a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts
index 7290442d3d..1fe2c8f826 100644
--- a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts
+++ b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts
@@ -237,14 +237,17 @@ export function getDesktopMcpToolApprovalPolicy(
if (canAutoApproveCindyArtGhostCall(context)) {
return 'auto-approve';
}
- // Rebinding another task's workspace delegates its execution root. Review
- // the specific move, never reuse the trusted helper server shortcut/grant.
+ // Rebinding a task's workspace delegates its execution root; publishing a Skill
+ // uploads local files under the signed-in account. Review each action instead
+ // of reusing the trusted helper server shortcut/grant. Session modes still apply.
if (serverName === 'cindy_helper') {
- if (toolName === 'move_session') return 'prompt-each-time';
+ if (toolName === 'move_session' || toolName === 'publish_skill') return 'prompt-each-time';
if (!toolName || toolName === 'call_tool') {
const params = readJsonObject(toolParams);
const innerName = typeof params?.name === 'string' ? params.name.trim() : '';
- if (!innerName || innerName === 'move_session') return 'prompt-each-time';
+ if (!innerName || innerName === 'move_session' || innerName === 'publish_skill') {
+ return 'prompt-each-time';
+ }
}
}
// Choosing a new Worker root delegates filesystem access. Do not let the
diff --git a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
index 16e9c64552..40649b8048 100644
--- a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
+++ b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
@@ -143,8 +143,8 @@ export const HELP_KNOWLEDGE: HelpKnowledgeDoc[] = [
{
id: "skills",
title: "Skills (reusable agent capabilities)",
- summary: "Create, browse, install, disable, uninstall, publish, and update agent Skills; Skills appear as \"/\" slash commands and are shared across Claude Code, Codex, and Pi.",
- content: "Skills are reusable agent capabilities you package as a folder and load into your sessions. They're managed on the same page as Plugins — **Skills** and **Plugins** are two tabs of one management surface (the Skills tab is the in-app browser for finding, installing, publishing, and updating skills).\n\n**Skills work across local agents:**\n\n- Skills are **engine-shared** — the same installed Skill is available to Claude Code, Codex, and Pi, so you install it once.\n\n**Where skills live on disk:**\n\n- Global (available to every session): the shared root `~/.agents/skills/<name>/`, which is cross-linked to `~/.claude/skills/` and `~/.codex/skills/` so every engine sees the same skills. On Windows that's under `C:\\Users\\<you>\\`.\n- Project-scoped (only inside one working directory): `<working-dir>/.agents/skills/<name>/` or `<working-dir>/.claude/skills/<name>/`.\n- Each skill is its own folder with a required `SKILL.md` at the root (the prompt / spec the agent reads). Sibling files and subfolders in that folder are also visible to the agent.\n\n**Importing a local skill:**\n\n- On the Skills page, use **Import skill** (top-right) to pick a `.zip` package or a standalone `SKILL.md` file.\n- A zip must contain a `SKILL.md` (at the package root, or inside a single top-level folder). The YAML frontmatter must include non-empty `name` and `description` fields; `name` must match `^[a-z0-9-]{1,200}$`.\n- You then choose where to install: global, a known project, or another directory. Cindy extracts metadata from the file automatically and lists the skill with that name and description.\n- Imported skills can be uninstalled from the detail page, and you can publish them to SkillHub later if you want.\n\n**Using an installed skill:**\n\n- Hover over a local skill in the `/` suggestions and choose **View skill details** in its information panel to open that exact skill. This does not insert or send the command. Pi package skills remain usable from `/`, but do not show this local detail shortcut; manage them through their package.\n\n- Type `/` in the composer to open the slash-command palette; your installed skills show up there alongside built-in and agent commands. Pick one to run it.\n\n**Creating or learning a Skill from the composer:**\n\n- Cindy includes `/cindy-skill-creator`. Invoke it with a description of the Skill you want, such as `/cindy-skill-creator Create a Skill that checks release notes`. Invoking it without a description asks what you want to create.\n- The current Agent creates or updates the Skill directly with its normal file tools. It does not use the `/learn` staging flow.\n- Unless you request another location, new Skills go to `~/.agents/skills/<name>/`. Ask for a project-specific Skill to create it under `<working-dir>/.agents/skills/<name>/`.\n- Cindy also includes `/learn`. Bare `/learn` distills the current task; `/learn <description>` learns from a described workflow; `/learn hub:<scope>:<slug> [instructions]` learns from a SkillHub Skill. Cindy gathers evidence, runs the distillation in a separate task, and shows a diff for review before saving the proposed Skill.\n- The built-in `cindy-skill-creator` and `learn` entries appear in the local Skill list with an Official badge. You can disable or enable either entry there; because they ship with Cindy, they cannot be uninstalled. The setting applies to new or restarted Agent sessions. Disabling `learn` also disables the **Learn this skill** action in SkillHub after the local Skill list has refreshed.\n\n**Disabling or uninstalling a local skill (Desktop):**\n\n- Open a skill's detail page to use the switch in the top action bar. For a market skill installed in multiple locations, select the local copy from the location dropdown beside the switch. Turning it off keeps the files and removes the skill from new-task command previews. Active tasks retain the skill preference snapshot applied when their Agent started, including their command palette. New or restarted Claude Code, Codex, and Pi agents apply that choice; an already-running agent keeps its existing context.\n- Renaming a local skill while publishing keeps its enabled or disabled setting. If renaming fails, Cindy restores the original folder and content.\n- The switch is local to this device and Cindy profile. It does not edit external CLI settings, sync to other devices, or override a native engine's own disabled state. Enable it again to let the engine discover it normally.\n- In the skill's details, use **… → Uninstall skill**. Confirm the location and shared-file impact. Standalone skills, including locally written skills without a market installation record, move to the system trash. Recovery is through the operating system's trash.\n- External source imports remove only their discovery links and keep the external source files. Package-owned Skills must be removed through their owning package. Cindy's built-in Skills cannot be uninstalled, but they can be disabled. Skills provided by Cindy plugins are managed on the owning plugin's page, including when discovered through shared Skill links.\n- Offline removal of an automatically synced skill is remembered on this device, including after restart or sign-in. Automatic sync skips it until you explicitly install it again.\n- Uninstalling a shared copy affects external CLIs that use it. It does not unpublish a skill or delete other users' copies. If file removal fails, Cindy keeps the installation. If cleanup is interrupted, the notice offers **Retry cleanup**. The unfinished operation survives closing, reloading, and restarting Cindy; reopen Skills in the same Cindy profile and account to continue. Cindy pauses conflicting installations until cleanup completes. Retrying never moves files to the trash a second time and preserves externally restored or replaced content.\n\n**Publishing your own skill:**\n\n- Find the publish action on the Skills page and point it at the skill's local folder. It zips the folder and uploads it — reading your directory in place, without copying or moving anything.\n- On first publish, you set the skill's **visibility**: PUBLIC (anyone in the org) or DEPARTMENT_SCOPED (only the departments you choose).\n- The local registry records what you published, so the app knows it's \"yours\" for future updates.\n\n**Updating an already-published skill:**\n\n- On your own skill's detail page you'll see a **发布新版本** (Publish New Version) button.\n- Edit the local folder however you want and publish — the version is **auto-incremented server-side**, you don't pick a number.\n- **Old versions stay live alongside the new one.** Users who already installed an older version keep it until they choose to update.\n- The display name and description are sent on every republish, so editing those metadata fields just means doing a republish.\n\n**Managing an already-published skill:**\n\n- Change who can see or use your skill from the management menu — public, shared with selected teams / departments, or private to you.\n- **Unpublish** makes it private again and returns ownership to your personal scope; it does not remove copies other users already installed.\n- **Authorship is fixed.** Only the original author's account can publish new versions of a given skill (enforced server-side as `NOT_AUTHOR`).\n\n**Browsing and installing others' skills:**\n\n- The marketplace lets you install skills into your global skills directory. You can request a specific version on install; the local registry tracks which version you have.\n\n**Notes:**\n\n- A skill folder without a `SKILL.md` at its root won't be picked up (lowercase `skill.md` is also accepted).\n- Project-scoped skills only show up in sessions whose working directory matches — useful for skills tied to a particular repo's conventions.\n- Editing files inside an installed skill folder takes effect on the next session start; you don't need to reinstall.\n- Uninstalling only removes your local copy. For your own published skills, use unpublish or manage visibility to change market availability.\n\nIn a new-task draft, the slash hover panel offers detail links for global skills. Project skill detail links are available after creating a task, when SkillHub can include that project in its scan.",
+ summary: "Create, search, browse, install, disable, uninstall, publish, and update agent Skills; Skills appear as \"/\" slash commands and are shared across Claude Code, Codex, and Pi.",
+ content: "Skills are reusable agent capabilities you package as a folder and load into your sessions. They're managed on the same page as Plugins — **Skills** and **Plugins** are two tabs of one management surface (the Skills tab is the in-app browser for finding, installing, publishing, and updating skills).\n\n**Skills work across local agents:**\n\n- Skills are **engine-shared** — the same installed Skill is available to Claude Code, Codex, and Pi, so you install it once.\n\n**Where skills live on disk:**\n\n- Global (available to every session): the shared root `~/.agents/skills/<name>/`, which is cross-linked to `~/.claude/skills/` and `~/.codex/skills/` so every engine sees the same skills. On Windows that's under `C:\\Users\\<you>\\`.\n- Project-scoped (only inside one working directory): `<working-dir>/.agents/skills/<name>/` or `<working-dir>/.claude/skills/<name>/`.\n- Each skill is its own folder with a required `SKILL.md` at the root (the prompt / spec the agent reads). Sibling files and subfolders in that folder are also visible to the agent.\n\n**Importing a local skill:**\n\n- On the Skills page, use **Import skill** (top-right) to pick a `.zip` package or a standalone `SKILL.md` file.\n- A zip must contain a `SKILL.md` (at the package root, or inside a single top-level folder). The YAML frontmatter must include non-empty `name` and `description` fields; `name` must match `^[a-z0-9-]{1,200}$`.\n- You then choose where to install: global, a known project, or another directory. Cindy extracts metadata from the file automatically and lists the skill with that name and description.\n- Imported skills can be uninstalled from the detail page, and you can publish them to SkillHub later if you want.\n\n**Using an installed skill:**\n\n- Hover over a local skill in the `/` suggestions and choose **View skill details** in its information panel to open that exact skill. This does not insert or send the command. Pi package skills remain usable from `/`, but do not show this local detail shortcut; manage them through their package.\n\n- Type `/` in the composer to open the slash-command palette; your installed skills show up there alongside built-in and agent commands. Pick one to run it.\n\n**Creating or learning a Skill from the composer:**\n\n- Cindy includes `/cindy-skill-creator`. Invoke it with a description of the Skill you want, such as `/cindy-skill-creator Create a Skill that checks release notes`. Invoking it without a description asks what you want to create.\n- The current Agent creates or updates the Skill directly with its normal file tools. It does not use the `/learn` staging flow.\n- Ask for a Skill in the composer, for example “Find a release-notes Skill” or `/cindy-skill-creator Search our organization's code-review Skills`. The Agent can search SkillHub's public marketplace or your organization's catalog. Without a specified scope, organization identities search both; personal identities search the public marketplace. Results identify their source, including when two Skills share a name. Search alone does not install anything.\n- You can also ask `/cindy-skill-creator` to upload your own Skill to SkillHub or publish a new version directly in the conversation. Give the local Skill folder (or the Skill just created) and, for a first upload, who should be able to access it. Ordinary local creation/editing does not automatically publish it.\n- Uploads use Cindy's signed-in account, which determines ownership; choosing sharing targets does not change that ownership. The Agent can list your published Skills, upload the folder, and check scan/review status. Upload success does not mean public approval. Updating requires confirmed original authorship and management access, and preserves visibility and ownership; a missing authorship flag is not treated as permission. This works in a local desktop task, including when controlled from a phone; SSH files must first be made available on the Cindy host.\n- Each Agent upload or version update follows the task's permission mode: Ask requests approval for that publication, Auto reviews it against your request, and Full Access bypasses operation approval. A previous helper-tool approval does not authorize later publications. Search, listing, and status queries remain automatic.\n- Unless you request another location, new Skills go to `~/.agents/skills/<name>/`. Ask for a project-specific Skill to create it under `<working-dir>/.agents/skills/<name>/`.\n- Cindy also includes `/learn`. Bare `/learn` distills the current task; `/learn <description>` learns from a described workflow; `/learn hub:<scope>:<slug> [instructions]` learns from a SkillHub Skill. Cindy gathers evidence, runs the distillation in a separate task, and shows a diff for review before saving the proposed Skill.\n- The built-in `cindy-skill-creator` and `learn` entries appear in the local Skill list with an Official badge. You can disable or enable either entry there; because they ship with Cindy, they cannot be uninstalled. The setting applies to new or restarted Agent sessions. Disabling `learn` also disables the **Learn this skill** action in SkillHub after the local Skill list has refreshed.\n\n**Disabling or uninstalling a local skill (Desktop):**\n\n- Open a skill's detail page to use the switch in the top action bar. For a market skill installed in multiple locations, select the local copy from the location dropdown beside the switch. Turning it off keeps the files and removes the skill from new-task command previews. Active tasks retain the skill preference snapshot applied when their Agent started, including their command palette. New or restarted Claude Code, Codex, and Pi agents apply that choice; an already-running agent keeps its existing context.\n- Renaming a local skill while publishing keeps its enabled or disabled setting. If renaming fails, Cindy restores the original folder and content.\n- The switch is local to this device and Cindy profile. It does not edit external CLI settings, sync to other devices, or override a native engine's own disabled state. Enable it again to let the engine discover it normally.\n- In the skill's details, use **… → Uninstall skill**. Confirm the location and shared-file impact. Standalone skills, including locally written skills without a market installation record, move to the system trash. Recovery is through the operating system's trash.\n- External source imports remove only their discovery links and keep the external source files. Package-owned Skills must be removed through their owning package. Cindy's built-in Skills cannot be uninstalled, but they can be disabled. Skills provided by Cindy plugins are managed on the owning plugin's page, including when discovered through shared Skill links.\n- Offline removal of an automatically synced skill is remembered on this device, including after restart or sign-in. Automatic sync skips it until you explicitly install it again.\n- Uninstalling a shared copy affects external CLIs that use it. It does not unpublish a skill or delete other users' copies. If file removal fails, Cindy keeps the installation. If cleanup is interrupted, the notice offers **Retry cleanup**. The unfinished operation survives closing, reloading, and restarting Cindy; reopen Skills in the same Cindy profile and account to continue. Cindy pauses conflicting installations until cleanup completes. Retrying never moves files to the trash a second time and preserves externally restored or replaced content.\n\n**Publishing your own skill:**\n\n- Find the publish action on the Skills page and point it at the skill's local folder. It zips the folder and uploads it — reading your directory in place, without copying or moving anything.\n- On first publish, choose visibility: personal identities support public or private; organization identities support public or organization sharing. Public publication is subject to review.\n- The local registry records what you published, so the app knows it's \"yours\" for future updates.\n\n**Updating an already-published skill:**\n\n- On your own skill's detail page you'll see a **发布新版本** (Publish New Version) button.\n- Edit the local folder however you want and publish — the version is **auto-incremented server-side**, you don't pick a number.\n- **Old versions stay live alongside the new one.** Users who already installed an older version keep it until they choose to update.\n- The display name and description are sent on every republish, so editing those metadata fields just means doing a republish.\n\n**Managing an already-published skill:**\n\n- Change who can see or use your skill from the management menu — public, shared with selected teams / departments, or private to you.\n- **Unpublish** makes it private again and returns ownership to your personal scope; it does not remove copies other users already installed.\n- **Authorship is fixed.** Only the original author's account can publish new versions of a given skill (enforced server-side as `NOT_AUTHOR`).\n\n**Browsing and installing others' skills:**\n\n- The marketplace lets you install skills into your global skills directory. You can request a specific version on install; the local registry tracks which version you have.\n\n**Notes:**\n\n- A skill folder without a `SKILL.md` at its root won't be picked up (lowercase `skill.md` is also accepted).\n- Project-scoped skills only show up in sessions whose working directory matches — useful for skills tied to a particular repo's conventions.\n- Editing files inside an installed skill folder takes effect on the next session start; you don't need to reinstall.\n- Uninstalling only removes your local copy. For your own published skills, use unpublish or manage visibility to change market availability.\n\nIn a new-task draft, the slash hover panel offers detail links for global skills. Project skill detail links are available after creating a task, when SkillHub can include that project in its scan.",
},
{
id: "updates-and-about",
diff --git a/apps/desktop/src/main/mcp-integrations/mcp-providers.ts b/apps/desktop/src/main/mcp-integrations/mcp-providers.ts
index d1af08ab10..8c4a9c84db 100644
--- a/apps/desktop/src/main/mcp-integrations/mcp-providers.ts
+++ b/apps/desktop/src/main/mcp-integrations/mcp-providers.ts
@@ -90,6 +90,7 @@ import { botSessionLinks, sessions } from '../localDb/schema.js';
import { isCindyLearnSkillEnabled } from '../skillhub/activationPreferences.js';
import { getLearnController } from '../learn-host/index.js';
import { consumeLearnInvocationGrant } from '../learn-host/invocationGrant.js';
+import { createSkillhubAgentTools } from '../skillhub/agentTools.js';
export interface DesktopMcpProvidersDeps {
botCapabilities: Pick<ReturnType<typeof createBotCapabilityService>, 'list' | 'select'>;
@@ -765,6 +766,11 @@ export function createDesktopMcpProviders(deps: DesktopMcpProvidersDeps): LiziMc
save: (params) => saveBotSkillForSession(params),
list: (params) => listBotSkillsForSession(params),
},
+ skillhub: createSkillhubAgentTools({
+ isCurrentSession: (context) => !!context.sessionId
+ && deps.isCurrentLocalSessionInstance?.(context.sessionId, context.sessionInstanceId) === true,
+ authorizePath: (request) => authorizeDesktopSessionPath(request, deps.getLiveSessionGrantState),
+ }),
history: {
resolveSessionScope: async ({ callerSessionId, callerMemoryScopeKey }) => {
try {
diff --git a/apps/desktop/src/main/skillhub/__tests__/agentTools.test.ts b/apps/desktop/src/main/skillhub/__tests__/agentTools.test.ts
new file mode 100644
index 0000000000..d701fa8ee8
--- /dev/null
+++ b/apps/desktop/src/main/skillhub/__tests__/agentTools.test.ts
@@ -0,0 +1,189 @@
+import fs from 'node:fs/promises';
+import os from 'node:os';
+import path from 'node:path';
+import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
+import { createSkillhubAgentTools, type SkillhubAgentServices } from '../agentTools';
+import { mapHubSkillInfoToDesktopInfo } from '../infoMapping';
+import type { SkillhubAgentRequest } from '@cindy/mcps';
+
+let root: string;
+let workingDir: string;
+let skillPath: string;
+beforeAll(async () => {
+ root = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), 'skillhub-agent-')));
+ workingDir = path.join(root, 'project');
+ skillPath = path.join(workingDir, 'release-notes');
+ await fs.mkdir(skillPath, { recursive: true });
+ await fs.writeFile(path.join(skillPath, 'SKILL.md'), '---\nname: release-notes\ndescription: Summarize releases\n---\n# Release notes\n');
+});
+afterEach(() => vi.restoreAllMocks());
+afterAll(async () => { await fs.rm(root, { recursive: true, force: true }); });
+
+function fixture() {
+ const state = { owner: 'owner-1' as string | null, current: true };
+ const info = mapHubSkillInfoToDesktopInfo({
+ slug: 'release-notes', version: '1.0.0', owner: { slug: 'author', name: 'Author' },
+ visibility: 'private', updatedAt: '', isCreator: true, isMine: true, canManage: true,
+ });
+ const listMarket = vi.fn(async () => ({ success: true as const, items: [info], nextCursor: '2' }));
+ const getInfo = vi.fn<SkillhubAgentServices['market']['info']>(async () => ({ success: true, deleted: true }));
+ const getScanStatus = vi.fn(async () => ({ success: true as const, status: 'pending' }));
+ const publish = vi.fn<SkillhubAgentServices['publisher']['publish']>(async () => ({ success: true, result: { name: 'release-notes', version: '1.0.1' } }));
+ const host: SkillhubAgentServices = {
+ market: { listMarket, info: getInfo, getScanStatus }, publisher: { publish },
+ ownerScope: () => state.owner,
+ policy: () => ({ canWrite: true, ownerType: 'personal', allowedVisibilities: ['PUBLIC', 'PRIVATE'], readOnlyReason: null }),
+ isManagedPath: vi.fn(() => false),
+ errorCode: (error) => (error as { code?: string })?.code ?? 'INTERNAL',
+ };
+ const authorizePath = vi.fn(async () => ({ allowed: true as const, isCurrent: () => state.current }));
+ const execute = createSkillhubAgentTools({ getServices: () => host, isCurrentSession: () => state.current, authorizePath });
+ const context = { agentKind: 'codex', workingDir, sessionId: 'task', sessionInstanceId: 'instance' };
+ const request: SkillhubAgentRequest = { action: 'publish', input: { path: skillPath, name: 'release-notes', mode: 'create', visibility: 'private' } };
+ return { state, host, execute, context, request, info, listMarket, getInfo, getScanStatus, publish, authorizePath };
+}
+
+describe('SkillHub agent host adapter', () => {
+ it('searches the public market by default for personal identities and rejects organization search', async () => {
+ const f = fixture();
+ expect(await f.execute({ action: 'search', query: 'release' }, f.context)).toMatchObject({
+ ok: true, catalogs: [{ catalog_scope: 'market', skills: [{ name: 'release-notes', catalog_scope: 'market' }], next_cursor: '2' }],
+ });
+ expect(f.listMarket).toHaveBeenCalledExactlyOnceWith({ q: 'release', scope: 'market', cursor: undefined, limit: 24 });
+ expect(await f.execute({ action: 'search', query: 'release', scope: 'team' }, f.context)).toMatchObject({ errorCode: 'UNSUPPORTED_CAPABILITY' });
+ expect(f.listMarket).toHaveBeenCalledTimes(1);
+ expect(f.publish).not.toHaveBeenCalled();
+ });
+ it('searches both catalogs for organization identities without merging equal slugs or page cursors', async () => {
+ const f = fixture();
+ f.host.policy = () => ({ canWrite: true, ownerType: 'organization', allowedVisibilities: ['PUBLIC', 'DEPARTMENT_SCOPED'], readOnlyReason: null });
+ f.listMarket.mockResolvedValueOnce({ success: true, items: [f.info], nextCursor: '3' });
+ expect(await f.execute({ action: 'search', query: 'release' }, f.context)).toMatchObject({
+ ok: true, catalogs: [
+ { catalog_scope: 'market', skills: [{ name: 'release-notes', catalog_scope: 'market' }], next_cursor: '3' },
+ { catalog_scope: 'team', skills: [{ name: 'release-notes', catalog_scope: 'team' }], next_cursor: '2' },
+ ],
+ });
+ await f.execute({ action: 'search', query: 'release', scope: 'team', cursor: '2' }, f.context);
+ expect(f.listMarket).toHaveBeenLastCalledWith({ q: 'release', scope: 'team', cursor: '2', limit: 24 });
+ expect(f.listMarket).toHaveBeenCalledTimes(3);
+ });
+ it('preserves available market results when organization search fails, and discards results after an account switch', async () => {
+ const f = fixture();
+ f.host.policy = () => ({ canWrite: true, ownerType: 'organization', allowedVisibilities: ['PUBLIC', 'DEPARTMENT_SCOPED'], readOnlyReason: null });
+ f.listMarket.mockResolvedValueOnce({ success: true, items: [f.info], nextCursor: '2' }).mockRejectedValueOnce({ code: 'FORBIDDEN' });
+ expect(await f.execute({ action: 'search', query: 'release' }, f.context)).toMatchObject({
+ ok: true, catalogs: [{ catalog_scope: 'market', ok: true }, { catalog_scope: 'team', ok: false, error_code: 'FORBIDDEN' }],
+ });
+ f.listMarket.mockImplementationOnce(async () => { f.state.owner = 'owner-2'; return { success: true, items: [f.info], nextCursor: '2' }; });
+ const result = await f.execute({ action: 'search', query: 'release', scope: 'market' }, f.context);
+ expect(result).toMatchObject({ errorCode: 'CANCELLED' });
+ expect(result).not.toHaveProperty('catalogs');
+ });
+ it('uploads a valid Skill through the shared publisher without a guessed version', async () => {
+ const f = fixture();
+ expect(await f.execute(f.request, f.context)).toMatchObject({ ok: true, name: 'release-notes', version: '1.0.1', status: 'uploaded' });
+ expect(f.authorizePath).not.toHaveBeenCalled();
+ expect(f.publish).toHaveBeenCalledWith(expect.objectContaining({ absolutePath: skillPath, name: 'release-notes', isFirstPublish: true, visibility: 'PRIVATE', description: 'Summarize releases' }), undefined, { isCurrent: expect.any(Function) });
+ expect(f.publish.mock.calls[0]![0]).not.toHaveProperty('version');
+ });
+ it('updates the original author’s publication and preserves visibility/ownership', async () => {
+ const f = fixture();
+ f.getInfo.mockResolvedValue({ success: true, info: f.info });
+ expect(await f.execute({ action: 'publish', input: { path: skillPath, name: 'release-notes', mode: 'update' } }, f.context)).toMatchObject({ ok: true });
+ const params = f.publish.mock.calls[0]![0];
+ expect(params.isFirstPublish).toBe(false);
+ expect(params).not.toHaveProperty('visibility');
+ expect(params).not.toHaveProperty('teamSlug');
+ });
+ it.each([false, undefined])('requires confirmed original authorship before any upload (%s)', async (isCreator) => {
+ const f = fixture();
+ f.getInfo.mockResolvedValue({ success: true, info: { ...f.info, isCreator, isMine: true, canManage: true } });
+ expect(await f.execute({ action: 'publish', input: { path: skillPath, name: 'release-notes', mode: 'update' } }, f.context)).toMatchObject({ ok: false, errorCode: 'NOT_AUTHOR' });
+ expect(f.publish).not.toHaveBeenCalled();
+ });
+ it('requires management permission even for the confirmed original author', async () => {
+ const f = fixture();
+ f.getInfo.mockResolvedValue({ success: true, info: { ...f.info, isCreator: true, canManage: false } });
+ expect(await f.execute({ action: 'publish', input: { path: skillPath, name: 'release-notes', mode: 'update' } }, f.context)).toMatchObject({ ok: false, errorCode: 'PERMISSION_DENIED' });
+ expect(f.publish).not.toHaveBeenCalled();
+ });
+ it.each([false, undefined])('does not advertise mine or management status as authorship (%s)', async (isCreator) => {
+ const f = fixture();
+ f.listMarket.mockResolvedValue({ success: true, items: [{ ...f.info, isCreator, isMine: true, canManage: true }], nextCursor: '2' });
+ expect(await f.execute({ action: 'list' }, f.context)).toMatchObject({
+ ok: true, skills: [{ name: 'release-notes', is_creator: false, can_manage: true }],
+ });
+ });
+ it('keeps organization ownership identity-derived while forwarding only sharing targets', async () => {
+ const f = fixture();
+ f.host.policy = () => ({ canWrite: true, ownerType: 'organization', allowedVisibilities: ['PUBLIC', 'DEPARTMENT_SCOPED'], readOnlyReason: null });
+ expect(await f.execute({ action: 'publish', input: {
+ path: skillPath, name: 'release-notes', mode: 'create', visibility: 'shared', visible_slugs: ['engineering'],
+ } }, f.context)).toMatchObject({ ok: true });
+ const params = f.publish.mock.calls[0]![0];
+ expect(params).toMatchObject({ visibility: 'DEPARTMENT_SCOPED', visibleSlugs: ['engineering'] });
+ expect(params).not.toHaveProperty('teamSlug');
+ expect(params).not.toHaveProperty('deptTeamSlug');
+ });
+ it('does not create over an existing publication or update a missing one', async () => {
+ const f = fixture();
+ f.getInfo.mockResolvedValueOnce({ success: true, info: f.info });
+ expect(await f.execute(f.request, f.context)).toMatchObject({ errorCode: 'NAME_TAKEN' });
+ expect(await f.execute({ action: 'publish', input: { path: skillPath, name: 'release-notes', mode: 'update' } }, f.context)).toMatchObject({ errorCode: 'NOT_FOUND' });
+ expect(f.publish).not.toHaveBeenCalled();
+ });
+ it('allows a first upload after a confirmed not-found response, but not after a network failure', async () => {
+ const f = fixture();
+ f.getInfo.mockRejectedValueOnce({ code: 'NOT_FOUND' }).mockRejectedValueOnce(new Error('private response'));
+ expect(await f.execute(f.request, f.context)).toMatchObject({ ok: true });
+ expect(await f.execute(f.request, f.context)).toMatchObject({ ok: false, errorCode: 'INTERNAL' });
+ expect(f.publish).toHaveBeenCalledTimes(1);
+ });
+ it('stops before upload when the owner changes during a network read', async () => {
+ const f = fixture();
+ f.getInfo.mockImplementation(async () => { f.state.owner = 'owner-2'; return { success: true, deleted: true }; });
+ expect(await f.execute(f.request, f.context)).toMatchObject({ errorCode: 'CANCELLED' });
+ expect(f.publish).not.toHaveBeenCalled();
+ });
+ it('passes task lifetime into the publisher and preserves a committed success', async () => {
+ const f = fixture();
+ f.publish.mockImplementation(async (_params, _progress, execution) => {
+ expect(execution?.isCurrent?.()).toBe(true);
+ f.state.current = false;
+ expect(execution?.isCurrent?.()).toBe(false);
+ return { success: true, result: { name: 'release-notes', version: '1.0.1' } };
+ });
+ expect(await f.execute(f.request, f.context)).toMatchObject({ ok: true, status: 'uploaded' });
+ });
+ it('requests the existing path grant for a folder outside the task workdir', async () => {
+ const f = fixture();
+ const outsideContext = { ...f.context, workingDir: path.join(root, 'another-project') };
+ await fs.mkdir(outsideContext.workingDir, { recursive: true });
+ await f.execute(f.request, outsideContext);
+ expect(f.authorizePath).toHaveBeenCalledWith(expect.objectContaining({ path: skillPath, sessionId: 'task', sessionInstanceId: 'instance', operation: 'read' }));
+ f.state.current = true;
+ f.authorizePath.mockResolvedValue({ allowed: true, isCurrent: () => false });
+ expect(await f.execute(f.request, outsideContext)).toMatchObject({ errorCode: 'CANCELLED' });
+ expect(f.publish).toHaveBeenCalledTimes(1);
+ });
+ it('rejects invalid manifests, managed Skills, unsupported visibility and unavailable contexts', async () => {
+ const f = fixture();
+ vi.spyOn(fs, 'readFile').mockResolvedValueOnce('---\nname: [broken\n---');
+ expect(await f.execute(f.request, f.context)).toMatchObject({ errorCode: 'MANIFEST_INVALID' });
+ vi.mocked(f.host.isManagedPath).mockReturnValueOnce(true);
+ expect(await f.execute(f.request, f.context)).toMatchObject({ errorCode: 'PERMISSION_DENIED' });
+ expect(await f.execute({ action: 'publish', input: { path: skillPath, name: 'release-notes', mode: 'create', visibility: 'shared' } }, f.context)).toMatchObject({ errorCode: 'INVALID_VISIBILITY' });
+ expect(await f.execute(f.request, { ...f.context, remoteHostId: 'ssh' })).toMatchObject({ errorCode: 'NO_SESSION_CONTEXT' });
+ f.state.owner = null;
+ expect(await f.execute(f.request, f.context)).toMatchObject({ errorCode: 'UNAUTHORIZED' });
+ expect(f.publish).not.toHaveBeenCalled();
+ });
+ it('lists own publications with pagination and reports pending review without another upload', async () => {
+ const f = fixture();
+ expect(await f.execute({ action: 'list', query: 'release', cursor: '2' }, f.context)).toMatchObject({ ok: true, skills: [{ name: 'release-notes', is_creator: true }], next_cursor: '2', allowed_visibilities: ['public', 'private'] });
+ expect(f.listMarket).toHaveBeenCalledWith({ mine: true, q: 'release', cursor: '2', limit: 50 });
+ expect(await f.execute({ action: 'status', name: 'release-notes', version: '1.0.1' }, f.context)).toMatchObject({ ok: true, status: 'pending' });
+ expect(f.publish).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/desktop/src/main/skillhub/__tests__/publishServiceOwner.test.ts b/apps/desktop/src/main/skillhub/__tests__/publishServiceOwner.test.ts
index d7c9c53e1b..84f53b29ca 100644
--- a/apps/desktop/src/main/skillhub/__tests__/publishServiceOwner.test.ts
+++ b/apps/desktop/src/main/skillhub/__tests__/publishServiceOwner.test.ts
@@ -55,6 +55,27 @@ describe('publication owner across commit reconciliation', () => {
});
afterEach(() => { vi.clearAllTimers(); vi.useRealTimers(); });
+ it.each(['identity', 'packing', 'init'] as const)('stops an invalidated Agent publication after %s, before upload or commit', async (stage) => {
+ let current = true;
+ if (stage === 'identity') mocks.identity.mockImplementationOnce(async () => {
+ current = false;
+ return { canWrite: true, allowedVisibilities: ['PUBLIC'] };
+ });
+ if (stage === 'packing') mocks.pack.mockImplementationOnce(async () => {
+ current = false;
+ return { buffer: Buffer.from('zip'), size: 3, sha256: 'hash', manifest: { files: [] } };
+ });
+ if (stage === 'init') mocks.api.mockImplementationOnce(async () => {
+ current = false;
+ return { nextVersion: '1.0.0', ossKey: 'object', uploadUrl: 'https://upload.invalid/object' };
+ });
+ const service = new SkillPublishService();
+ await expect(service.publish({ absolutePath: 'virtual-skill', name: 'review-helper', isFirstPublish: false }, undefined, { isCurrent: () => current }))
+ .resolves.toMatchObject({ success: false, errorCode: 'CANCELLED' });
+ expect(mocks.api.mock.calls.some(([apiPath]) => String(apiPath).endsWith('/publish/commit'))).toBe(false);
+ expect(mocks.snapshot).not.toHaveBeenCalled();
+ });
+
it.each((['commit', 'snapshot', 'registry'] as const).flatMap(stage =>
(['unchanged', 'different-owner', 'new-generation', 'boundary-pending'] as const).map(transition => ({ stage, transition })),
))('preserves committed success during $stage / $transition', async ({ stage, transition }) => {
diff --git a/apps/desktop/src/main/skillhub/agentTools.ts b/apps/desktop/src/main/skillhub/agentTools.ts
new file mode 100644
index 0000000000..de4debb0b4
--- /dev/null
+++ b/apps/desktop/src/main/skillhub/agentTools.ts
@@ -0,0 +1,179 @@
+import fs from 'node:fs/promises';
+import { realpathSync, statSync } from 'node:fs';
+import path from 'node:path';
+import matter from 'gray-matter';
+import type { LiziMcpSessionContext, SessionPathAuthorization, SessionPathAuthorizationRequest, SkillhubAgentCallback } from '@cindy/mcps';
+import type { SkillhubIdentityPolicy } from '../../shared/skillhubIdentityPolicy';
+import type { SkillhubMarketService } from './marketService';
+import type { SkillPublishService } from './publishService';
+
+/** Reuse the same publisher, account policy and managed roots as the Skills page. */
+export interface SkillhubAgentServices {
+ market: Pick<SkillhubMarketService, 'listMarket' | 'info' | 'getScanStatus'>;
+ publisher: Pick<SkillPublishService, 'publish'>;
+ ownerScope: () => string | null;
+ policy: () => SkillhubIdentityPolicy;
+ isManagedPath: (absolutePath: string) => boolean;
+ errorCode: (error: unknown) => string;
+}
+let services: SkillhubAgentServices | undefined;
+
+export function configureSkillhubAgentServices(next: SkillhubAgentServices): void {
+ services = next;
+}
+
+const fail = (errorCode: string, message: string) => ({ ok: false as const, errorCode, message });
+function isInside(root: string, target: string): boolean {
+ const relative = path.relative(root, target);
+ return relative === '' || (relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
+}
+
+/** Agent identity comes from the live host context, never from tool arguments. */
+export function createSkillhubAgentTools(deps: {
+ isCurrentSession: (context: LiziMcpSessionContext) => boolean;
+ authorizePath: (request: SessionPathAuthorizationRequest) => Promise<SessionPathAuthorization>;
+ getServices?: () => SkillhubAgentServices | undefined;
+}): SkillhubAgentCallback {
+ return async (request, context) => {
+ if (!context.sessionId || context.remoteHostId || !deps.isCurrentSession(context)) {
+ return fail('NO_SESSION_CONTEXT', 'A current local Cindy task is required.');
+ }
+ const host = (deps.getServices ?? (() => services))();
+ if (!host) return fail('HOST_NOT_READY', 'SkillHub is not ready.');
+ const owner = host.ownerScope();
+ if (!owner) return fail('UNAUTHORIZED', 'Sign in to Cindy to search SkillHub or publish your Skills.');
+ const isCurrent = () => host.ownerScope() === owner && deps.isCurrentSession(context);
+ const changed = () => fail('CANCELLED', 'The active account or task changed. Check the published version before retrying.');
+ try {
+ if (request.action === 'search') {
+ const organization = host.policy().ownerType === 'organization';
+ if (request.scope === 'team' && !organization) return fail('UNSUPPORTED_CAPABILITY', 'Organization Skill search requires an organization identity. Use scope=market for the public marketplace.');
+ const scopes: Array<'market' | 'team'> = request.scope && request.scope !== 'all'
+ ? [request.scope] : organization ? ['market', 'team'] : ['market'];
+ if (request.cursor && (!request.scope || request.scope === 'all')) return fail('INVALID_ARGS', 'Choose one catalog when requesting its next page.');
+ // Keep catalogs separate: identical slugs are different resources, with independent pages.
+ const results = await Promise.allSettled(scopes.map((scope) => host.market.listMarket({
+ q: request.query, scope, cursor: request.cursor, limit: 24,
+ })));
+ if (!isCurrent()) return changed();
+ if (results.every((result) => result.status === 'rejected')) {
+ const first = results[0];
+ return fail(first?.status === 'rejected' ? host.errorCode(first.reason) : 'INTERNAL', 'Skill search is unavailable. Check sign-in and try the public or organization catalog separately.');
+ }
+ return {
+ ok: true,
+ query: request.query,
+ catalogs: results.map((result, index) => result.status === 'fulfilled' ? {
+ catalog_scope: scopes[index], ok: true,
+ skills: result.value.items.map((item) => ({
+ name: item.name, display_name: item.displayName, description: item.description,
+ version: item.latestVersion, author: item.authorName,
+ catalog_scope: scopes[index], visibility: item.publishedVisibility,
+ })),
+ next_cursor: result.value.nextCursor,
+ } : {
+ catalog_scope: scopes[index], ok: false, error_code: host.errorCode(result.reason),
+ guidance: 'This catalog could not be searched. Results from the other catalog are still available.',
+ }),
+ };
+ }
+ if (request.action === 'list') {
+ const result = await host.market.listMarket({ mine: true, q: request.query, cursor: request.cursor, limit: 50 });
+ if (!isCurrent()) return changed();
+ return {
+ ok: true,
+ skills: result.items.map((item) => ({
+ name: item.name, display_name: item.displayName, description: item.description,
+ version: item.latestVersion, is_creator: item.isCreator === true,
+ can_manage: item.canManage === true,
+ visibility: item.publishedVisibility, pending_version: item.pendingVersion,
+ })),
+ next_cursor: result.nextCursor,
+ allowed_visibilities: host.policy().allowedVisibilities.map((value) => value === 'DEPARTMENT_SCOPED' ? 'shared' : value.toLowerCase()),
+ };
+ }
+ if (request.action === 'status') {
+ const result = await host.market.getScanStatus({ slug: request.name, version: request.version });
+ return isCurrent() ? { ...result, ok: true } : changed();
+ }
+
+ const input = request.input;
+ if (!path.isAbsolute(input.path) || input.path.includes('\0')) return fail('INVALID_ARGS', 'path must be an absolute local Skill folder.');
+ const visibility = input.visibility === 'shared' ? 'DEPARTMENT_SCOPED' : input.visibility === 'public' ? 'PUBLIC' : 'PRIVATE';
+ if (input.mode === 'create' && (!input.visibility || !host.policy().allowedVisibilities.includes(visibility))) {
+ return fail('INVALID_VISIBILITY', 'Choose a visibility supported by the signed-in identity; list_my_published_skills returns the available choices.');
+ }
+ if (input.mode === 'update' && (input.visibility || input.visible_slugs || input.tags)) {
+ return fail('INVALID_ARGS', 'Updates preserve the existing visibility, ownership and tags.');
+ }
+ const absolutePath = await fs.realpath(input.path);
+ if (!isCurrent()) return changed();
+ if (host.isManagedPath(absolutePath)) return fail('PERMISSION_DENIED', 'Cindy built-in and plugin-managed Skills cannot be published as your own.');
+ const workingDir = context.workingDir ? await fs.realpath(context.workingDir) : null;
+ if (!workingDir || !isCurrent()) return changed();
+ let authorization: SessionPathAuthorization = { allowed: true };
+ if (!isInside(workingDir, absolutePath)) {
+ authorization = await deps.authorizePath({
+ sessionId: context.sessionId, sessionInstanceId: context.sessionInstanceId,
+ workingDir, path: absolutePath, toolName: 'publish_skill', operation: 'read',
+ });
+ if (!authorization.allowed) return fail('PERMISSION_DENIED', authorization.reason);
+ }
+ const grant = authorization;
+ const directoryIdentity = await fs.stat(absolutePath);
+ const isAuthorized = () => {
+ if (!isCurrent() || grant.isCurrent?.() === false) return false;
+ try {
+ const current = statSync(absolutePath);
+ return realpathSync.native(absolutePath) === absolutePath
+ && current.dev === directoryIdentity.dev && current.ino === directoryIdentity.ino;
+ } catch { return false; }
+ };
+ if (!isAuthorized()) return changed();
+ const skillMdPath = path.join(absolutePath, 'SKILL.md');
+ // The upload is a folder, not an arbitrary file or an external SKILL.md symlink.
+ if (!directoryIdentity.isDirectory() || !(await fs.lstat(skillMdPath)).isFile()) {
+ return fail('MANIFEST_INVALID', 'The Skill folder must contain a regular SKILL.md file.');
+ }
+ const raw = await fs.readFile(skillMdPath, 'utf8');
+ let frontmatter: Record<string, unknown>;
+ try { frontmatter = matter(raw).data; }
+ catch { return fail('MANIFEST_INVALID', 'SKILL.md has invalid YAML frontmatter.'); }
+ if (frontmatter.name !== input.name || typeof frontmatter.description !== 'string' || !frontmatter.description.trim()) {
+ return fail('MANIFEST_INVALID', 'SKILL.md must have a matching name and a non-empty description.');
+ }
+ if (!isAuthorized()) return changed();
+
+ let existing: Awaited<ReturnType<SkillhubMarketService['info']>> | undefined;
+ try { existing = await host.market.info(input.name); }
+ catch (error) {
+ if (!['NOT_FOUND', 'SKILL_NOT_FOUND'].includes(host.errorCode(error))) throw error;
+ }
+ if (!isAuthorized()) return changed();
+ const info = existing && 'info' in existing ? existing.info : undefined;
+ if (input.mode === 'create' && info) return fail('NAME_TAKEN', 'That Skill already exists. Use update only if you are its original author, or choose another name.');
+ if (input.mode === 'update' && !info) return fail('NOT_FOUND', 'The published Skill was not found. Check its exact name.');
+ if (input.mode === 'update' && info?.isCreator !== true) return fail('NOT_AUTHOR', 'Original authorship could not be confirmed. Only the original author can publish a new version of this Skill.');
+ if (input.mode === 'update' && info?.canManage !== true) return fail('PERMISSION_DENIED', 'This account does not have management access to the published Skill.');
+
+ const result = await host.publisher.publish({
+ absolutePath, name: input.name, isFirstPublish: input.mode === 'create',
+ displayName: input.display_name, summary: input.summary,
+ description: frontmatter.description.trim(), changelog: input.changelog,
+ // Ownership comes from the signed-in identity; visibleSlugs only selects the audience.
+ ...(input.mode === 'create' ? { visibility, tags: input.tags, visibleSlugs: input.visible_slugs } : {}),
+ }, undefined, { isCurrent: isAuthorized });
+ // A committed publication remains successful even if the task closes afterwards.
+ if (result.success && result.result) return {
+ ok: true, name: result.result.name, version: result.result.version, status: 'uploaded',
+ guidance: 'The version was uploaded. Use get_skill_publish_status to check scan/review status; upload success does not mean public approval.',
+ };
+ return fail(result.errorCode ?? 'INTERNAL', 'Skill upload did not complete. Check the existing version/status before retrying.');
+ } catch (error) {
+ if (!isCurrent()) return changed();
+ const localCode = (error as NodeJS.ErrnoException)?.code;
+ if (localCode === 'ENOENT' || localCode === 'ENOTDIR') return fail('NOT_FOUND', 'The local Skill folder or SKILL.md was not found.');
+ return fail(host.errorCode(error), 'Could not complete the SkillHub operation. Check sign-in, access and the published version before retrying.');
+ }
+ };
+}
diff --git a/apps/desktop/src/main/skillhub/publishService.ts b/apps/desktop/src/main/skillhub/publishService.ts
index d35f72a70f..f9002d8409 100644
--- a/apps/desktop/src/main/skillhub/publishService.ts
+++ b/apps/desktop/src/main/skillhub/publishService.ts
@@ -235,6 +235,7 @@ export class SkillPublishService {
async publish(
params: PublishParams,
onProgress: ProgressCb = () => {},
+ execution: { isCurrent?: () => boolean } = {},
): Promise<{
success: boolean;
result?: { name: string; version: string };
@@ -248,7 +249,7 @@ export class SkillPublishService {
const isPublishOwnerCurrent = () => !isAppSessionBoundaryPending()
&& activeOwnerScopeKey() === publishOwnerScope;
const emitProgress = (event: PublishProgressEvent) => this.emitProgress(event, onProgress, publishOwnerScope);
- if (!getAppCapabilities().canUseSkillHubCloud) {
+ if (!getAppCapabilities().canUseSkillHubCloud || execution.isCurrent?.() === false) {
emitProgress(
{
phase: 'failed',
@@ -260,7 +261,7 @@ export class SkillPublishService {
return { success: false, errorCode: 'CANCELLED' };
}
const identityPolicy = await currentSkillhubIdentityPolicy();
- if (!isPublishOwnerCurrent()) return { success: false, errorCode: 'CANCELLED' };
+ if (!isPublishOwnerCurrent() || execution.isCurrent?.() === false) return { success: false, errorCode: 'CANCELLED' };
if (!identityPolicy.canWrite) {
emitProgress(
{
@@ -321,6 +322,7 @@ export class SkillPublishService {
const isCancelled = (): boolean =>
signal.aborted ||
!getAppCapabilities().canUseSkillHubCloud ||
+ execution.isCurrent?.() === false ||
!isPublishOwnerCurrent();
let originalSkillMd: string | null = null;
diff --git a/apps/desktop/src/main/skillhub/registerIpc.ts b/apps/desktop/src/main/skillhub/registerIpc.ts
index 17c4050e7d..573ecbb05b 100644
--- a/apps/desktop/src/main/skillhub/registerIpc.ts
+++ b/apps/desktop/src/main/skillhub/registerIpc.ts
@@ -30,6 +30,9 @@ import { ServerApiError } from '../serverApiClient';
import { SkillhubMarketService, skillhubIpcError } from './marketService';
import type { PublishParams, PublishProgressEvent } from './publishService';
import { SkillPublishService } from './publishService';
+import { configureSkillhubAgentServices } from './agentTools';
+import { currentSkillhubIdentityPolicy } from './identityPolicy';
+import { getAppCapabilities } from '../appCapabilities';
import { reconcileMineRegistry } from './reconcileMineRegistry';
import { registryService } from './registry';
import {
@@ -434,6 +437,17 @@ export function registerSkillhubIpc(options: RegisterSkillhubIpcOptions): void {
const publishService = options.publishService ?? new SkillPublishService({
onProgress: broadcastPublishProgress,
});
+ configureSkillhubAgentServices({
+ market: marketService,
+ publisher: publishService,
+ ownerScope: () => !isAppSessionBoundaryPending() && getCurrentDataOwnerId()
+ && getAppCapabilities().canUseSkillHubCloud && currentSkillhubIdentityPolicy().canWrite
+ ? activeOwnerScopeKey() : null,
+ policy: currentSkillhubIdentityPolicy,
+ isManagedPath: (absolutePath) => isBuiltInSkillPath(absolutePath)
+ || isPluginManagedSkillPath(absolutePath, options.getManagedSkillRoots()),
+ errorCode: (error) => error instanceof ServerApiError ? error.code : 'INTERNAL',
+ });
let usageRefreshBroadcastPromise: Promise<void> | null = null;
const captureUsageDbSnapshot = (): CurrentDbClientSnapshot => {
if (isAppSessionBoundaryPending()) {
diff --git a/packages/lizi-mcps/src/__tests__/skillhubTools.test.ts b/packages/lizi-mcps/src/__tests__/skillhubTools.test.ts
new file mode 100644
index 0000000000..06ad3b5e94
--- /dev/null
+++ b/packages/lizi-mcps/src/__tests__/skillhubTools.test.ts
@@ -0,0 +1,97 @@
+import path from 'node:path';
+import { describe, expect, it, vi } from 'vitest';
+import { XdtHelperToolRegistry } from '../lizi_xdtHelperToolRegistry.js';
+import { registerSkillhubTools } from '../xdt-helper/skillhub.js';
+import { createXdtHelperMcpServer } from '../lizi_xdtHelperMcpServer.js';
+import { z } from 'zod';
+import type { LiziMcpSessionContext } from '../types.js';
+
+function fixture(overrides: Partial<LiziMcpSessionContext> = {}) {
+ const registry = new XdtHelperToolRegistry();
+ const context = { agentKind: 'codex', workingDir: path.resolve('project'), sessionId: 'task', sessionInstanceId: 'instance', ...overrides };
+ const execute = vi.fn(async () => ({ ok: true as const, status: 'uploaded', version: '1.0.0' }));
+ registerSkillhubTools(registry, { getSessionContext: () => context, execute });
+ return { registry, context, execute };
+}
+const publication = { path: path.resolve('project', 'release-notes'), name: 'release-notes', mode: 'create', visibility: 'private' };
+
+describe('SkillHub helper tools', () => {
+ it.each(['claude-code', 'codex', 'pi'] as const)('keeps startup schemas stable and discovers/calls SkillHub through %s', async (agentKind) => {
+ const f = fixture({ agentKind });
+ const sessionContext = { ...f.context, agentKind };
+ const base = createXdtHelperMcpServer({}, sessionContext);
+ const enabled = createXdtHelperMcpServer({ skillhub: f.execute }, sessionContext);
+ const tools = (server: unknown) => (server as { _registeredTools: Record<string, { description: string; inputSchema: z.ZodType; handler: (args: unknown) => Promise<{ content: Array<{ type: string; text?: string }> }> }> })._registeredTools;
+ const definitions = (server: unknown) => Object.entries(tools(server)).map(([name, tool]) => ({ name, description: tool.description, inputSchema: z.toJSONSchema(tool.inputSchema) }));
+ const read = (result: { content: Array<{ type: string; text?: string }> }) => JSON.parse(result.content[0]!.text!);
+ try {
+ expect(definitions(enabled)).toEqual(definitions(base));
+ const listing = read(await tools(enabled).list_tools!.handler({ category: 'skills' }));
+ expect(listing.tools.find((tool: { name: string }) => tool.name === 'publish_skill').inputSchema.required).toEqual(['path', 'name', 'mode']);
+ expect(listing.tools.find((tool: { name: string }) => tool.name === 'search_skills').inputSchema.required).toEqual(['query']);
+ await tools(enabled).call_tool!.handler({ name: 'search_skills', args: { query: 'release notes', scope: 'team' } });
+ expect(f.execute).toHaveBeenLastCalledWith({ action: 'search', query: 'release notes', scope: 'team' }, expect.objectContaining({ agentKind, sessionId: 'task', sessionInstanceId: 'instance' }));
+ const result = read(await tools(enabled).call_tool!.handler({ name: 'publish_skill', args: publication }));
+ expect(result).toMatchObject({ ok: true, status: 'uploaded', version: '1.0.0' });
+ expect(f.execute).toHaveBeenCalledWith({ action: 'publish', input: publication }, expect.objectContaining({ agentKind, sessionId: 'task', sessionInstanceId: 'instance' }));
+ } finally {
+ await base.close();
+ await enabled.close();
+ }
+ });
+ it('discovers tools under skills and binds the host context for publication', async () => {
+ const { registry, context, execute } = fixture();
+ expect(registry.list('skills').map((tool) => tool.name)).toEqual(['search_skills', 'list_my_published_skills', 'publish_skill', 'get_skill_publish_status']);
+ const result = await registry.call('publish_skill', publication);
+ expect(result.isError).toBeUndefined();
+ expect(execute).toHaveBeenCalledWith({ action: 'publish', input: publication }, context);
+ execute.mockClear();
+ expect((await registry.call('publish_skill', { ...publication, sessionId: 'forged' })).isError).toBe(true);
+ expect(execute).not.toHaveBeenCalled();
+ });
+ it.each([
+ { ...publication, visibility: undefined },
+ { ...publication, name: '../other' },
+ { ...publication, mode: 'update' },
+ { ...publication, mode: 'update', visibility: undefined, tags: ['tag'] },
+ { ...publication, team_slug: 'some-team' },
+ { ...publication, visibility: 'shared', team_slug: 'some-team' },
+ ])('rejects invalid publication arguments before calling the host: %j', async (input) => {
+ const { registry, execute } = fixture();
+ expect((await registry.call('publish_skill', input)).isError).toBe(true);
+ expect(execute).not.toHaveBeenCalled();
+ });
+ it.each([{ sessionId: undefined }, { remoteHostId: 'ssh-host' }])('rejects unavailable task contexts: %j', async (overrides) => {
+ const { registry, execute } = fixture(overrides);
+ expect((await registry.call('publish_skill', publication)).isError).toBe(true);
+ expect(execute).not.toHaveBeenCalled();
+ });
+ it('discovers sharing targets without owner selectors and forwards them unchanged', async () => {
+ const { registry, execute, context } = fixture();
+ const tool = registry.get('publish_skill')!;
+ expect(tool.inputShape).not.toHaveProperty('team_slug');
+ expect(tool.inputShape).toHaveProperty('visible_slugs');
+ const input = { ...publication, visibility: 'shared', visible_slugs: ['engineering'] };
+ expect((await registry.call('publish_skill', input)).isError).toBeUndefined();
+ expect(execute).toHaveBeenCalledWith({ action: 'publish', input }, context);
+ });
+ it('forwards update, pagination and exact-version status requests without publication defaults', async () => {
+ const { registry, context, execute } = fixture();
+ const input = { path: publication.path, name: publication.name, mode: 'update', changelog: 'Fixed release notes' };
+ await registry.call('publish_skill', input);
+ expect(execute).toHaveBeenLastCalledWith({ action: 'publish', input }, context);
+ await registry.call('list_my_published_skills', { query: 'release', cursor: '2' });
+ expect(execute).toHaveBeenLastCalledWith({ action: 'list', query: 'release', cursor: '2' }, context);
+ await registry.call('get_skill_publish_status', { name: 'release-notes', version: '1.0.1' });
+ expect(execute).toHaveBeenLastCalledWith({ action: 'status', name: 'release-notes', version: '1.0.1' }, context);
+ });
+ it('searches the selected catalog and requires a catalog for pagination', async () => {
+ const { registry, context, execute } = fixture();
+ await registry.call('search_skills', { query: ' release notes ', scope: 'team', cursor: '2' });
+ expect(execute).toHaveBeenLastCalledWith({ action: 'search', query: 'release notes', scope: 'team', cursor: '2' }, context);
+ execute.mockClear();
+ expect((await registry.call('search_skills', { query: 'release', cursor: '2' })).isError).toBe(true);
+ expect((await registry.call('search_skills', { query: ' ' })).isError).toBe(true);
+ expect(execute).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
index e80ccd75ed..039c031ba6 100644
--- a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
+++ b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
@@ -59,8 +59,10 @@ import {
registerSearchChatHistoryTool,
registerSubmitGithubIssueTool,
registerStartSkillLearningTool,
+ registerSkillhubTools,
} from './xdt-helper/index.js';
import type { SubmitGithubIssueDeps } from './xdt-helper/submit_github_issue.js';
+import type { SkillhubAgentCallback } from './xdt-helper/skillhub.js';
import type { SetCurrentSessionTitleDeps } from './xdt-helper/set_current_session_title.js';
import type { RenameSessionsDeps } from './xdt-helper/rename_sessions.js';
import type { ArchiveSessionsDeps } from './xdt-helper/archive_sessions.js';
@@ -226,7 +228,7 @@ function registerListToolsEntry(
tools: tools.map((t) => ({
name: t.name,
description: t.description,
- ...(t.category === 'bots' ? {
+ ...(t.category === 'bots' || t.category === 'skills' ? {
inputSchema: z.toJSONSchema(z.strictObject(registry.get(t.name)!.inputShape)),
} : {}),
})),
@@ -644,6 +646,8 @@ export interface XdtHelperMcpDeps {
sendToSession?: SendToSessionCallback;
/** Cindy-managed Learn flow; registered in the skills category when supplied by the host. */
skillLearning?: StartSkillLearningCallback;
+ /** Search catalogs and publish the current user's Skills through the host's SkillHub service. */
+ skillhub?: SkillhubAgentCallback;
/** Host-owned, one-shot authorization for the current direct Learn invocation. */
authorizeSkillLearning?: AuthorizeSkillLearningCallback;
/** Register an existing local directory as a Cindy project without starting a task. */
@@ -826,6 +830,12 @@ export function createXdtHelperMcpServer(
startSkillLearning: deps.skillLearning,
});
}
+ if (deps.skillhub) {
+ registerSkillhubTools(registry, {
+ getSessionContext: () => resolveLiziMcpSessionContext(sessionCtx),
+ execute: deps.skillhub,
+ });
+ }
// 伙伴消息与 Session 任务控制统一进入 bots 类目,由调用时的任务身份限制发现与执行。
if (deps.botSkills) {
registerBotSkillTools(registry, {
diff --git a/packages/lizi-mcps/src/xdt-helper/index.ts b/packages/lizi-mcps/src/xdt-helper/index.ts
index 5474a21219..46b40fb52a 100644
--- a/packages/lizi-mcps/src/xdt-helper/index.ts
+++ b/packages/lizi-mcps/src/xdt-helper/index.ts
@@ -9,6 +9,7 @@
*/
export { registerGetCapabilitiesTool } from './get_capabilities.js';
+export { registerSkillhubTools, type SkillhubAgentCallback, type SkillhubAgentRequest } from './skillhub.js';
export {
registerGetCurrentSessionIdTool,
type GetCurrentSessionIdDeps,
diff --git a/packages/lizi-mcps/src/xdt-helper/skillhub.ts b/packages/lizi-mcps/src/xdt-helper/skillhub.ts
new file mode 100644
index 0000000000..01508ab6e6
--- /dev/null
+++ b/packages/lizi-mcps/src/xdt-helper/skillhub.ts
@@ -0,0 +1,77 @@
+import { z } from 'zod';
+import type { XdtHelperToolRegistry } from '../lizi_xdtHelperToolRegistry.js';
+import type { ControlResult, LiziMcpSessionContext } from '../types.js';
+import { errorPayload, okPayload } from './_payload.js';
+
+const slug = z.string().trim().regex(/^[a-z0-9][a-z0-9-]{0,127}$/);
+const publishShape = {
+ path: z.string().trim().min(1).max(4096),
+ name: slug,
+ mode: z.enum(['create', 'update']),
+ visibility: z.enum(['public', 'private', 'shared']).optional(),
+ display_name: z.string().trim().min(1).max(200).optional(),
+ summary: z.string().trim().min(1).max(1000).optional(),
+ tags: z.array(slug).max(20).optional(),
+ changelog: z.string().trim().max(5000).optional(),
+ visible_slugs: z.array(slug).max(100).optional(),
+};
+export type SkillhubPublishInput = z.infer<z.ZodObject<typeof publishShape>>;
+export type SkillhubAgentRequest =
+ | { action: 'search'; query: string; scope?: 'market' | 'team' | 'all'; cursor?: string }
+ | { action: 'list'; query?: string; cursor?: string }
+ | { action: 'publish'; input: SkillhubPublishInput }
+ | { action: 'status'; name: string; version: string };
+export type SkillhubAgentCallback = (
+ request: SkillhubAgentRequest,
+ context: LiziMcpSessionContext,
+) => Promise<ControlResult<Record<string, unknown>, string>>;
+
+/** SkillHub uses the existing progressive helper surface; credentials stay in the host. */
+export function registerSkillhubTools(registry: XdtHelperToolRegistry, deps: {
+ getSessionContext: () => LiziMcpSessionContext;
+ execute: SkillhubAgentCallback;
+}): void {
+ const execute = async (request: SkillhubAgentRequest) => {
+ const context = deps.getSessionContext();
+ if (!context.sessionId) return errorPayload('NO_SESSION_CONTEXT', 'No Cindy task is bound to this call.');
+ if (context.remoteHostId) return errorPayload('UNSUPPORTED_CAPABILITY', 'SkillHub tools require a local Cindy task. For uploads, copy remote Skill files to the Cindy host first.');
+ const result = await deps.execute(request, context);
+ return result.ok ? okPayload(result) : errorPayload(result.errorCode, result.message);
+ };
+ registry.register({
+ name: 'search_skills', category: 'skills',
+ description: 'Search Cindy SkillHub by keyword. scope=market searches the public marketplace; scope=team searches the current organization (organization identities only). Omit scope or use all to search both for organization users, or the public market for personal users. Results retain catalog_scope to distinguish same-name Skills. To paginate, specify one scope and its next_cursor. Search does not install or publish anything.',
+ inputShape: {
+ query: z.string().trim().min(1).max(200),
+ scope: z.enum(['market', 'team', 'all']).optional(),
+ cursor: z.string().regex(/^[1-9][0-9]{0,6}$/).optional(),
+ },
+ handler: async ({ query, scope, cursor }) => {
+ if (cursor && (!scope || scope === 'all')) return errorPayload('INVALID_ARGS', 'For pagination, specify market or team and that catalog’s next_cursor.');
+ return execute({ action: 'search', query, scope, cursor });
+ },
+ });
+ registry.register({
+ name: 'list_my_published_skills', category: 'skills',
+ description: 'List the signed-in user’s published Skills and allowed first-publish visibility. Updates require confirmed is_creator and can_manage; being listed here alone does not prove authorship. Follow next_cursor for more results.',
+ inputShape: { query: z.string().trim().max(200).optional(), cursor: z.string().regex(/^[1-9][0-9]{0,6}$/).optional() },
+ handler: ({ query, cursor }) => execute({ action: 'list', query, cursor }),
+ });
+ registry.register({
+ name: 'publish_skill', category: 'skills',
+ description: 'Upload a local Skill folder to SkillHub or publish a new version of your own Skill. Use only when the user requests upload/publication. path must contain SKILL.md; name must match its frontmatter. mode=create requires explicit visibility; ownership comes from the signed-in identity, and visible_slugs selects only the shared audience. mode=update requires confirmed authorship and management access and preserves visibility and ownership. Version is assigned by the server. Success means uploaded, not necessarily approved. If the result is uncertain, check status before retrying.',
+ inputShape: publishShape,
+ handler: async (input) => {
+ if (input.mode === 'create' && !input.visibility) return errorPayload('INVALID_ARGS', 'First publication requires the user’s visibility choice.');
+ if (input.mode === 'update' && (input.visibility || input.visible_slugs || input.tags)) return errorPayload('INVALID_ARGS', 'Updates preserve visibility, ownership and tags. Omit those fields.');
+ if (input.visibility !== 'shared' && input.visible_slugs) return errorPayload('INVALID_ARGS', 'Sharing targets require shared visibility.');
+ return execute({ action: 'publish', input });
+ },
+ });
+ registry.register({
+ name: 'get_skill_publish_status', category: 'skills',
+ description: 'Read the scan/review status for an uploaded Skill version. Report pending review truthfully; do not repeatedly publish or poll while awaiting human review.',
+ inputShape: { name: slug, version: z.string().trim().min(1).max(128).regex(/^[^\u0000-\u001f\u007f]+$/) },
+ handler: ({ name, version }) => execute({ action: 'status', name, version }),
+ });
+}