@agimon-ai/po-skill 0.0.0-alpha.219 → 0.0.0-alpha.220
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/mcp.cjs +1 -0
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.mjs +1 -0
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/server.cjs +17 -8
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +18 -9
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/po-runtime-identity.json +1 -1
- package/package.json +9 -9
- package/src/prompts/help-how-to-author-skill/SKILL.md +3 -1
package/dist/extensions/mcp.cjs
CHANGED
|
@@ -6,6 +6,7 @@ let _agimon_ai_po_core_mcpFacet = require("@agimon-ai/po-core/mcpFacet");
|
|
|
6
6
|
let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
|
|
7
7
|
require("@agimon-ai/po-core/platform");
|
|
8
8
|
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
9
|
+
require("@agimon-ai/po-core/codemode");
|
|
9
10
|
let typebox = require("typebox");
|
|
10
11
|
//#region src/services/mcpSkills/index.ts
|
|
11
12
|
const MCP_SKILLS_SERVICE = "po/discovered-mcp-skills";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.cjs","names":["defineRoutedContribution","defineMcpSkill","readPackageResource","defineMcpSkill","readPackageResource","Type","defineMcpTool","defineMcpTool","defineMcpPlugin","skillDiscovered","skillHelpHowToAuthorSkill","skillHelpHowToSkill","toolLoadSkill","toolSearchSkills"],"sources":["../../src/services/mcpSkills/index.ts","../../src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.ts","../../generated/mcp.ts"],"sourcesContent":["import type { PoMcpPluginContext, PoMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { BACKGROUND_CONTEXT, getOrThrow, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { ServerSkillGroup } from '../serverInventory';\n\nexport const MCP_SKILLS_SERVICE = 'po/discovered-mcp-skills';\n\nexport interface McpSkillProvider {\n list(context: PoMcpPluginContext): readonly PoMcpSkill[];\n}\n\n/** Explicit remote provider, never a projection of the local resource registry. */\nexport function mountMcpSkills(groups: readonly ServerSkillGroup[], fs: FileSystem, signal: AbortSignal) {\n return (context: Context): void => {\n context.provide(MCP_SKILLS_SERVICE, {\n list(remote) {\n signal.throwIfAborted();\n remote.signal.throwIfAborted();\n const domains = remote.selection.read().domains;\n const skills = new Map<string, PoMcpSkill>();\n for (const group of groups) {\n if (group.domains !== undefined && !group.domains.some((domain) => domains.includes(domain))) continue;\n for (const skill of group.skills) {\n // Retain name precedence defensively for remote providers.\n if (skills.has(skill.name)) continue;\n skills.set(skill.name, {\n name: skill.name,\n description: skill.description,\n async read() {\n const readSignal = AbortSignal.any([signal, remote.signal]);\n readSignal.throwIfAborted();\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(readSignal, BACKGROUND_CONTEXT)),\n );\n readSignal.throwIfAborted();\n return text;\n },\n });\n }\n }\n return [...skills.values()];\n },\n } satisfies McpSkillProvider);\n };\n}\n\nexport function bindMcpSkills(context: PoMcpPluginContext): readonly PoMcpSkill[] {\n const provider = context.services.get<McpSkillProvider>(MCP_SKILLS_SERVICE);\n if (!provider) throw new Error('Discovered MCP skills are unavailable.');\n return provider.list(context);\n}\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\n\nimport { bindMcpSkills } from '../../../../../services/mcpSkills';\n\nexport default defineRoutedContribution(bindMcpSkills, { cardinality: 'many' });\n","import { defineMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineMcpSkill({\n name: 'help-how-to-author-skill',\n description:\n 'Author and distribute Po agent skills. Use when creating a SKILL.md, adding supporting references or scripts, contributing a runtime skill directory through Cordis, or publishing activation-gated Help prompts from a Po package.',\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-author-skill/SKILL.md'),\n});\n","import { defineMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineMcpSkill({\n name: 'help-how-to-skill',\n description:\n \"Use Po's skill catalog and deferred discovery. Use when browsing available skills, invoking /skill:name, understanding Help and extension-owned skill groups, or diagnosing why a skill is absent or shadowed.\",\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-skill/SKILL.md'),\n});\n","import { Type } from 'typebox';\n\nexport const searchSkillsParameters = Type.Object({ query: Type.Optional(Type.String()) });\nexport const loadSkillParameters = Type.Object({ name: Type.String() });\n","import type { PoHeadlessHostService, PoHeadlessTool } from '@agimon-ai/po-core/headless';\n\nimport { loadSkillParameters, searchSkillsParameters } from '../../schemas/mcpSkillTools';\n\nfunction text(text: string) {\n return { content: [{ type: 'text' as const, text }] };\n}\n\nfunction skills(context: Parameters<PoHeadlessTool['execute']>[4]) {\n if (context.mcpSkills === undefined) throw new Error('Remote skill access is unavailable.');\n return context.mcpSkills;\n}\n\n/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */\nexport function matchSkills<T extends { name: string; description: string }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n const needle = query?.trim().toLocaleLowerCase();\n if (needle === undefined || needle === '') return [...skills];\n return skills.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\n}\n\nexport function createSearchSkillsTool(): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Discover repository and active-domain skills available to this remote connection.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { query }, _signal, _onUpdate, context) {\n const matches = matchSkills(await skills(context).list(), query);\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionSearchSkillsTool(\n host: Pick<PoHeadlessHostService, 'listSkills'>,\n): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Search available session skills by name or description.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n executionMode: 'parallel',\n async execute(_toolCallId, { query }) {\n const matches = matchSkills(\n host.listSkills().map(({ name, description }) => ({ name, description })),\n query,\n );\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionLoadSkillTool(\n host: Pick<PoHeadlessHostService, 'readSkill'>,\n): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n // PO_LOAD_SKILL_TOOL, spelled out so the renderer rule can read it.\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full instructions of an available session skill by exact name.',\n parameters: loadSkillParameters,\n executionMode: 'parallel',\n async execute(_toolCallId, { name }) {\n const body = host.readSkill(name);\n if (body === undefined) return { ...text(`No skill named ${name} is available in this session.`), isError: true };\n return text(body);\n },\n };\n}\n\nexport function createLoadSkillTool(): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full Markdown instructions for an available remote skill by exact name.',\n parameters: loadSkillParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { name }, _signal, _onUpdate, context) {\n return text(await skills(context).read(name));\n },\n };\n}\n","import { defineMcpTool } from '@agimon-ai/po-core/mcpFacet';\n\nimport { createLoadSkillTool } from '../../../../../services/mcpSkillTools';\n\nexport default defineMcpTool(createLoadSkillTool());\n","import { defineMcpTool } from '@agimon-ai/po-core/mcpFacet';\n\nimport { createSearchSkillsTool } from '../../../../../services/mcpSkillTools';\n\nexport default defineMcpTool(createSearchSkillsTool());\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineMcpPlugin, type PoMcpSessionPlugin } from '@agimon-ai/po-core/mcpFacet';\n\nimport skillDiscovered from '../src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp';\nimport skillHelpHowToAuthorSkill from '../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp';\nimport skillHelpHowToSkill from '../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp';\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp';\nimport toolSearchSkills from '../src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\ntype ManyFactory<T, C> = (context: C) => T | readonly T[];\nconst many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {\n const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\n return Array.isArray(resolved) ? resolved : [resolved as T];\n};\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => {\n if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nconst withWidget = <T>(key: string, value: T): T => value === undefined ? value : ({\n ...value, _meta: { ...(value as { _meta?: object })._meta, [\"po/widget\"]: key },\n});\n\nexport const mcp = defineMcpPlugin({\n name: '@agimon-ai/po-skill',\n session: (context) => ({\n get skills(): PoMcpSessionPlugin['skills'] { return [...many(skillDiscovered, context), at(skillHelpHowToAuthorSkill, context), at(skillHelpHowToSkill, context)]; },\n get tools(): PoMcpSessionPlugin['tools'] { return [withWidget(\"@agimon-ai/po-skill/load_skill\", via({ name: 'load_skill' }, at(toolLoadSkill, context))), withWidget(\"@agimon-ai/po-skill/search_skills\", via({ name: 'search_skills' }, at(toolSearchSkills, context)))]; },\n }) satisfies PoMcpSessionPlugin,\n});\n\nexport default mcp;\n"],"mappings":";;;;;;;;;;AAMA,MAAa,qBAAqB;AAyClC,SAAgB,cAAc,SAAoD;CAChF,MAAM,WAAW,QAAQ,SAAS,IAAsB,kBAAkB;CAC1E,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,wCAAwC;CACvE,OAAO,SAAS,KAAK,OAAO;AAC9B;;;AC/CA,IAAA,0BAAA,GAAeA,iCAAAA,yBAAAA,CAAyB,eAAe,EAAE,aAAa,OAAO,CAAC;;;ACD9E,IAAA,wCAAA,GAAeC,4BAAAA,eAAAA,CAAe;CAC5B,MAAM;CACN,aACE;CACF,aAAA,GAAYC,gCAAAA,oBAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,MAAqC,+CAA+C;AAClG,CAAC;;;ACLD,IAAA,iCAAA,GAAeC,4BAAAA,eAAAA,CAAe;CAC5B,MAAM;CACN,aACE;CACF,aAAA,GAAYC,gCAAAA,oBAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,MAAqC,wCAAwC;AAC3F,CAAC;;;ACND,MAAa,yBAAyBC,QAAAA,KAAK,OAAO,EAAE,OAAOA,QAAAA,KAAK,SAASA,QAAAA,KAAK,OAAO,CAAC,EAAE,CAAC;AACzF,MAAa,sBAAsBA,QAAAA,KAAK,OAAO,EAAE,MAAMA,QAAAA,KAAK,OAAO,EAAE,CAAC;;;ACCtE,SAAS,KAAK,MAAc;CAC1B,OAAO,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MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AAEpE,MAAM,QAAc,OAA6C,YAA6B;CAC5F,MAAM,WAAW,OAAO,UAAU,aAAc,MAA4B,OAAO,IAAI;CACvF,OAAO,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAa;AAC5D;AACA,MAAM,OAAU,UAAmC,UAAsB;CACvE,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,MAAM,cAAc;CACpB,OAAO;EAAE,GAAG;EAAU,GAAG;EAAa,GAAI,YAAY,cAAc,KAAA,IAAY,CAAC,IAAI,EACnF,WAAW,YAAY,UAAU,KAAK,cAAc;GAAE,UAAU;GAAY,GAAG;EAAS,EAAE,EAC5F;CAAG;AACL;AAEA,MAAM,cAAiB,KAAa,UAAgB,UAAU,KAAA,IAAY,QAAS;CACjF,GAAG;CAAO,OAAO;EAAE,GAAI,MAA6B;GAAQ,cAAc;CAAI;AAChF;AAEA,MAAa,OAAA,GAAMC,4BAAAA,gBAAAA,CAAgB;CACjC,MAAM;CACN,UAAU,aAAa;EACrB,IAAI,SAAuC;GAAE,OAAO;IAAC,GAAG,KAAKC,wBAAiB,OAAO;IAAG,GAAGC,sCAA2B,OAAO;IAAG,GAAGC,+BAAqB,OAAO;GAAC;EAAG;EACnK,IAAI,QAAqC;GAAE,OAAO,CAAC,WAAW,kCAAkC,IAAI,EAAE,MAAM,aAAa,GAAG,GAAGC,wBAAe,OAAO,CAAC,CAAC,GAAG,WAAW,qCAAqC,IAAI,EAAE,MAAM,gBAAgB,GAAG,GAAGC,2BAAkB,OAAO,CAAC,CAAC,CAAC;EAAG;CAC7Q;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"mcp.cjs","names":["defineRoutedContribution","defineMcpSkill","readPackageResource","defineMcpSkill","readPackageResource","Type","defineMcpTool","defineMcpTool","defineMcpPlugin","skillDiscovered","skillHelpHowToAuthorSkill","skillHelpHowToSkill","toolLoadSkill","toolSearchSkills"],"sources":["../../src/services/mcpSkills/index.ts","../../src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.ts","../../generated/mcp.ts"],"sourcesContent":["import type { PoMcpPluginContext, PoMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { BACKGROUND_CONTEXT, getOrThrow, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { ServerSkillGroup } from '../serverInventory';\n\nexport const MCP_SKILLS_SERVICE = 'po/discovered-mcp-skills';\n\nexport interface McpSkillProvider {\n list(context: PoMcpPluginContext): readonly PoMcpSkill[];\n}\n\n/** Explicit remote provider, never a projection of the local resource registry. */\nexport function mountMcpSkills(groups: readonly ServerSkillGroup[], fs: FileSystem, signal: AbortSignal) {\n return (context: Context): void => {\n context.provide(MCP_SKILLS_SERVICE, {\n list(remote) {\n signal.throwIfAborted();\n remote.signal.throwIfAborted();\n const domains = remote.selection.read().domains;\n const skills = new Map<string, PoMcpSkill>();\n for (const group of groups) {\n if (group.domains !== undefined && !group.domains.some((domain) => domains.includes(domain))) continue;\n for (const skill of group.skills) {\n // Retain name precedence defensively for remote providers.\n if (skills.has(skill.name)) continue;\n skills.set(skill.name, {\n name: skill.name,\n description: skill.description,\n async read() {\n const readSignal = AbortSignal.any([signal, remote.signal]);\n readSignal.throwIfAborted();\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(readSignal, BACKGROUND_CONTEXT)),\n );\n readSignal.throwIfAborted();\n return text;\n },\n });\n }\n }\n return [...skills.values()];\n },\n } satisfies McpSkillProvider);\n };\n}\n\nexport function bindMcpSkills(context: PoMcpPluginContext): readonly PoMcpSkill[] {\n const provider = context.services.get<McpSkillProvider>(MCP_SKILLS_SERVICE);\n if (!provider) throw new Error('Discovered MCP skills are unavailable.');\n return provider.list(context);\n}\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\n\nimport { bindMcpSkills } from '../../../../../services/mcpSkills';\n\nexport default defineRoutedContribution(bindMcpSkills, { cardinality: 'many' });\n","import { defineMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineMcpSkill({\n name: 'help-how-to-author-skill',\n description:\n 'Author and distribute Po agent skills. Use when creating a SKILL.md, adding supporting references or scripts, contributing a runtime skill directory through Cordis, or publishing activation-gated Help prompts from a Po package.',\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-author-skill/SKILL.md'),\n});\n","import { defineMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineMcpSkill({\n name: 'help-how-to-skill',\n description:\n \"Use Po's skill catalog and deferred discovery. Use when browsing available skills, invoking /skill:name, understanding Help and extension-owned skill groups, or diagnosing why a skill is absent or shadowed.\",\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-skill/SKILL.md'),\n});\n","import { Type } from 'typebox';\n\nexport const searchSkillsParameters = Type.Object({ query: Type.Optional(Type.String()) });\nexport const loadSkillParameters = Type.Object({ name: Type.String() });\n","import { rankText } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessHostService, PoHeadlessTool } from '@agimon-ai/po-core/headless';\n\nimport { loadSkillParameters, searchSkillsParameters } from '../../schemas/mcpSkillTools';\n\nfunction text(text: string) {\n return { content: [{ type: 'text' as const, text }] };\n}\n\nfunction skills(context: Parameters<PoHeadlessTool['execute']>[4]) {\n if (context.mcpSkills === undefined) throw new Error('Remote skill access is unavailable.');\n return context.mcpSkills;\n}\n\n/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */\nexport function matchSkills<T extends { name: string; description: string }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n const needle = query?.trim().toLocaleLowerCase();\n if (needle === undefined || needle === '') return [...skills];\n return skills.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\n}\n\n/** Best match first by name, then description, active before inactive; an empty query keeps everything, in order. */\nexport function rankSkills<T extends { name: string; description: string; active?: boolean }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n if (query === undefined || query.trim() === '') return [...skills];\n const ranked = rankText(\n query,\n skills.map((skill) => ({ id: skill.name, name: skill.name, doc: skill.description, skill })),\n ).map(({ skill }) => skill);\n return [...ranked.filter((skill) => skill.active !== false), ...ranked.filter((skill) => skill.active === false)];\n}\n\n/** Pinned guides are listed in the system prompt, so only a real search needs them. */\nexport function searchesPinned(query: string | undefined): boolean {\n return query !== undefined && query.trim() !== '';\n}\n\nexport function createSearchSkillsTool(): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Discover repository and active-domain skills available to this remote connection.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { query }, _signal, _onUpdate, context) {\n const matches = matchSkills(await skills(context).list(), query);\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionSearchSkillsTool(\n host: Pick<PoHeadlessHostService, 'listSkills'>,\n): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Search available session skills by name or description.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n executionMode: 'parallel',\n async execute(_toolCallId, { query }) {\n const matches = rankSkills(\n host\n .listSkills({ includePinned: searchesPinned(query) })\n .map(({ name, description }) => ({ name, description })),\n query,\n );\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionLoadSkillTool(\n host: Pick<PoHeadlessHostService, 'readSkill'>,\n): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n // PO_LOAD_SKILL_TOOL, spelled out so the renderer rule can read it.\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full instructions of an available session skill by exact name.',\n parameters: loadSkillParameters,\n executionMode: 'parallel',\n async execute(_toolCallId, { name }) {\n const body = host.readSkill(name);\n if (body === undefined) return { ...text(`No skill named ${name} is available in this session.`), isError: true };\n return text(body);\n },\n };\n}\n\nexport function createLoadSkillTool(): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full Markdown instructions for an available remote skill by exact name.',\n parameters: loadSkillParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { name }, _signal, _onUpdate, context) {\n return text(await skills(context).read(name));\n },\n };\n}\n","import { defineMcpTool } from '@agimon-ai/po-core/mcpFacet';\n\nimport { createLoadSkillTool } from '../../../../../services/mcpSkillTools';\n\nexport default defineMcpTool(createLoadSkillTool());\n","import { defineMcpTool } from '@agimon-ai/po-core/mcpFacet';\n\nimport { createSearchSkillsTool } from '../../../../../services/mcpSkillTools';\n\nexport default defineMcpTool(createSearchSkillsTool());\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineMcpPlugin, type PoMcpSessionPlugin } from '@agimon-ai/po-core/mcpFacet';\n\nimport skillDiscovered from '../src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp';\nimport skillHelpHowToAuthorSkill from '../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp';\nimport skillHelpHowToSkill from '../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp';\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp';\nimport toolSearchSkills from '../src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\ntype ManyFactory<T, C> = (context: C) => T | readonly T[];\nconst many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {\n const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\n return Array.isArray(resolved) ? resolved : [resolved as T];\n};\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => {\n if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nconst withWidget = <T>(key: string, value: T): T => value === undefined ? value : ({\n ...value, _meta: { ...(value as { _meta?: object })._meta, [\"po/widget\"]: key },\n});\n\nexport const mcp = defineMcpPlugin({\n name: '@agimon-ai/po-skill',\n session: (context) => ({\n get skills(): PoMcpSessionPlugin['skills'] { return [...many(skillDiscovered, context), at(skillHelpHowToAuthorSkill, context), at(skillHelpHowToSkill, context)]; },\n get tools(): PoMcpSessionPlugin['tools'] { return [withWidget(\"@agimon-ai/po-skill/load_skill\", via({ name: 'load_skill' }, at(toolLoadSkill, context))), withWidget(\"@agimon-ai/po-skill/search_skills\", via({ name: 'search_skills' }, at(toolSearchSkills, context)))]; },\n }) satisfies PoMcpSessionPlugin,\n});\n\nexport default mcp;\n"],"mappings":";;;;;;;;;;;AAMA,MAAa,qBAAqB;AAyClC,SAAgB,cAAc,SAAoD;CAChF,MAAM,WAAW,QAAQ,SAAS,IAAsB,kBAAkB;CAC1E,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,wCAAwC;CACvE,OAAO,SAAS,KAAK,OAAO;AAC9B;;;AC/CA,IAAA,0BAAA,GAAeA,iCAAAA,yBAAAA,CAAyB,eAAe,EAAE,aAAa,OAAO,CAAC;;;ACD9E,IAAA,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AAEA,MAAa,OAAA,GAAMC,4BAAAA,gBAAAA,CAAgB;CACjC,MAAM;CACN,UAAU,aAAa;EACrB,IAAI,SAAuC;GAAE,OAAO;IAAC,GAAG,KAAKC,wBAAiB,OAAO;IAAG,GAAGC,sCAA2B,OAAO;IAAG,GAAGC,+BAAqB,OAAO;GAAC;EAAG;EACnK,IAAI,QAAqC;GAAE,OAAO,CAAC,WAAW,kCAAkC,IAAI,EAAE,MAAM,aAAa,GAAG,GAAGC,wBAAe,OAAO,CAAC,CAAC,GAAG,WAAW,qCAAqC,IAAI,EAAE,MAAM,gBAAgB,GAAG,GAAGC,2BAAkB,OAAO,CAAC,CAAC,CAAC;EAAG;CAC7Q;AACF,CAAC"}
|
package/dist/extensions/mcp.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { defineMcpPlugin, defineMcpSkill, defineMcpTool } from "@agimon-ai/po-co
|
|
|
2
2
|
import { defineRoutedContribution } from "@agimon-ai/po-core/extensionFile";
|
|
3
3
|
import "@agimon-ai/po-core/platform";
|
|
4
4
|
import { readPackageResource } from "@agimon-ai/po-core/serverPlugin";
|
|
5
|
+
import "@agimon-ai/po-core/codemode";
|
|
5
6
|
import { Type } from "typebox";
|
|
6
7
|
//#region src/services/mcpSkills/index.ts
|
|
7
8
|
const MCP_SKILLS_SERVICE = "po/discovered-mcp-skills";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.mjs","names":["skillDiscovered","skillHelpHowToAuthorSkill","skillHelpHowToSkill","toolLoadSkill","toolSearchSkills"],"sources":["../../src/services/mcpSkills/index.ts","../../src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.ts","../../generated/mcp.ts"],"sourcesContent":["import type { PoMcpPluginContext, PoMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { BACKGROUND_CONTEXT, getOrThrow, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { ServerSkillGroup } from '../serverInventory';\n\nexport const MCP_SKILLS_SERVICE = 'po/discovered-mcp-skills';\n\nexport interface McpSkillProvider {\n list(context: PoMcpPluginContext): readonly PoMcpSkill[];\n}\n\n/** Explicit remote provider, never a projection of the local resource registry. */\nexport function mountMcpSkills(groups: readonly ServerSkillGroup[], fs: FileSystem, signal: AbortSignal) {\n return (context: Context): void => {\n context.provide(MCP_SKILLS_SERVICE, {\n list(remote) {\n signal.throwIfAborted();\n remote.signal.throwIfAborted();\n const domains = remote.selection.read().domains;\n const skills = new Map<string, PoMcpSkill>();\n for (const group of groups) {\n if (group.domains !== undefined && !group.domains.some((domain) => domains.includes(domain))) continue;\n for (const skill of group.skills) {\n // Retain name precedence defensively for remote providers.\n if (skills.has(skill.name)) continue;\n skills.set(skill.name, {\n name: skill.name,\n description: skill.description,\n async read() {\n const readSignal = AbortSignal.any([signal, remote.signal]);\n readSignal.throwIfAborted();\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(readSignal, BACKGROUND_CONTEXT)),\n );\n readSignal.throwIfAborted();\n return text;\n },\n });\n }\n }\n return [...skills.values()];\n },\n } satisfies McpSkillProvider);\n };\n}\n\nexport function bindMcpSkills(context: PoMcpPluginContext): readonly PoMcpSkill[] {\n const provider = context.services.get<McpSkillProvider>(MCP_SKILLS_SERVICE);\n if (!provider) throw new Error('Discovered MCP skills are unavailable.');\n return provider.list(context);\n}\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\n\nimport { bindMcpSkills } from '../../../../../services/mcpSkills';\n\nexport default defineRoutedContribution(bindMcpSkills, { cardinality: 'many' });\n","import { defineMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineMcpSkill({\n name: 'help-how-to-author-skill',\n description:\n 'Author and distribute Po agent skills. Use when creating a SKILL.md, adding supporting references or scripts, contributing a runtime skill directory through Cordis, or publishing activation-gated Help prompts from a Po package.',\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-author-skill/SKILL.md'),\n});\n","import { defineMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineMcpSkill({\n name: 'help-how-to-skill',\n description:\n \"Use Po's skill catalog and deferred discovery. Use when browsing available skills, invoking /skill:name, understanding Help and extension-owned skill groups, or diagnosing why a skill is absent or shadowed.\",\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-skill/SKILL.md'),\n});\n","import { Type } from 'typebox';\n\nexport const searchSkillsParameters = Type.Object({ query: Type.Optional(Type.String()) });\nexport const loadSkillParameters = Type.Object({ name: Type.String() });\n","import type { PoHeadlessHostService, PoHeadlessTool } from '@agimon-ai/po-core/headless';\n\nimport { loadSkillParameters, searchSkillsParameters } from '../../schemas/mcpSkillTools';\n\nfunction text(text: string) {\n return { content: [{ type: 'text' as const, text }] };\n}\n\nfunction skills(context: Parameters<PoHeadlessTool['execute']>[4]) {\n if (context.mcpSkills === undefined) throw new Error('Remote skill access is unavailable.');\n return context.mcpSkills;\n}\n\n/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */\nexport function matchSkills<T extends { name: string; description: string }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n const needle = query?.trim().toLocaleLowerCase();\n if (needle === undefined || needle === '') return [...skills];\n return skills.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\n}\n\nexport function createSearchSkillsTool(): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Discover repository and active-domain skills available to this remote connection.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { query }, _signal, _onUpdate, context) {\n const matches = matchSkills(await skills(context).list(), query);\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionSearchSkillsTool(\n host: Pick<PoHeadlessHostService, 'listSkills'>,\n): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Search available session skills by name or description.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n executionMode: 'parallel',\n async execute(_toolCallId, { query }) {\n const matches = matchSkills(\n host.listSkills().map(({ name, description }) => ({ name, description })),\n query,\n );\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionLoadSkillTool(\n host: Pick<PoHeadlessHostService, 'readSkill'>,\n): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n // PO_LOAD_SKILL_TOOL, spelled out so the renderer rule can read it.\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full instructions of an available session skill by exact name.',\n parameters: loadSkillParameters,\n executionMode: 'parallel',\n async execute(_toolCallId, { name }) {\n const body = host.readSkill(name);\n if (body === undefined) return { ...text(`No skill named ${name} is available in this session.`), isError: true };\n return text(body);\n },\n };\n}\n\nexport function createLoadSkillTool(): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full Markdown instructions for an available remote skill by exact name.',\n parameters: loadSkillParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { name }, _signal, _onUpdate, context) {\n return text(await skills(context).read(name));\n },\n };\n}\n","import { defineMcpTool } from '@agimon-ai/po-core/mcpFacet';\n\nimport { createLoadSkillTool } from '../../../../../services/mcpSkillTools';\n\nexport default defineMcpTool(createLoadSkillTool());\n","import { defineMcpTool } from '@agimon-ai/po-core/mcpFacet';\n\nimport { createSearchSkillsTool } from '../../../../../services/mcpSkillTools';\n\nexport default defineMcpTool(createSearchSkillsTool());\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineMcpPlugin, type PoMcpSessionPlugin } from '@agimon-ai/po-core/mcpFacet';\n\nimport skillDiscovered from '../src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp';\nimport skillHelpHowToAuthorSkill from '../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp';\nimport skillHelpHowToSkill from '../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp';\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp';\nimport toolSearchSkills from '../src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\ntype ManyFactory<T, C> = (context: C) => T | readonly T[];\nconst many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {\n const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\n return Array.isArray(resolved) ? resolved : [resolved as T];\n};\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => {\n if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nconst withWidget = <T>(key: string, value: T): T => value === undefined ? value : ({\n ...value, _meta: { ...(value as { _meta?: object })._meta, [\"po/widget\"]: key },\n});\n\nexport const mcp = defineMcpPlugin({\n name: '@agimon-ai/po-skill',\n session: (context) => ({\n get skills(): PoMcpSessionPlugin['skills'] { return [...many(skillDiscovered, context), at(skillHelpHowToAuthorSkill, context), at(skillHelpHowToSkill, context)]; },\n get tools(): PoMcpSessionPlugin['tools'] { return [withWidget(\"@agimon-ai/po-skill/load_skill\", via({ name: 'load_skill' }, at(toolLoadSkill, context))), withWidget(\"@agimon-ai/po-skill/search_skills\", via({ name: 'search_skills' }, at(toolSearchSkills, context)))]; },\n }) satisfies PoMcpSessionPlugin,\n});\n\nexport default mcp;\n"],"mappings":";;;;;;AAMA,MAAa,qBAAqB;AAyClC,SAAgB,cAAc,SAAoD;CAChF,MAAM,WAAW,QAAQ,SAAS,IAAsB,kBAAkB;CAC1E,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,wCAAwC;CACvE,OAAO,SAAS,KAAK,OAAO;AAC9B;;;AC/CA,IAAA,yBAAe,yBAAyB,eAAe,EAAE,aAAa,OAAO,CAAC;;;ACD9E,IAAA,uCAAe,eAAe;CAC5B,MAAM;CACN,aACE;CACF,YAAY,oBAAoB,YAAY,KAAK,+CAA+C;AAClG,CAAC;;;ACLD,IAAA,gCAAe,eAAe;CAC5B,MAAM;CACN,aACE;CACF,YAAY,oBAAoB,YAAY,KAAK,wCAAwC;AAC3F,CAAC;;;ACND,MAAa,yBAAyB,KAAK,OAAO,EAAE,OAAO,KAAK,SAAS,KAAK,OAAO,CAAC,EAAE,CAAC;AACzF,MAAa,sBAAsB,KAAK,OAAO,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;;;ACCtE,SAAS,KAAK,MAAc;CAC1B,OAAO,EAAE,SAAS,CAAC;EAAE,MAAM;EAAiB;CAAK,CAAC,EAAE;AACtD;AAEA,SAAS,OAAO,SAAmD;CACjE,IAAI,QAAQ,cAAc,KAAA,GAAW,MAAM,IAAI,MAAM,qCAAqC;CAC1F,OAAO,QAAQ;AACjB;;AAGA,SAAgB,YACd,QACA,OACK;CACL,MAAM,SAAS,OAAO,KAAK,CAAC,CAAC,kBAAkB;CAC/C,IAAI,WAAW,KAAA,KAAa,WAAW,IAAI,OAAO,CAAC,GAAG,MAAM;CAC5D,OAAO,OAAO,QAAQ,EAAE,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AAY,UAAU,KAAK,cAAc;GAAE,UAAU;GAAY,GAAG;EAAS,EAAE,EAC5F;CAAG;AACL;AAEA,MAAM,cAAiB,KAAa,UAAgB,UAAU,KAAA,IAAY,QAAS;CACjF,GAAG;CAAO,OAAO;EAAE,GAAI,MAA6B;GAAQ,cAAc;CAAI;AAChF;AAEA,MAAa,MAAM,gBAAgB;CACjC,MAAM;CACN,UAAU,aAAa;EACrB,IAAI,SAAuC;GAAE,OAAO;IAAC,GAAG,KAAKA,wBAAiB,OAAO;IAAG,GAAGC,sCAA2B,OAAO;IAAG,GAAGC,+BAAqB,OAAO;GAAC;EAAG;EACnK,IAAI,QAAqC;GAAE,OAAO,CAAC,WAAW,kCAAkC,IAAI,EAAE,MAAM,aAAa,GAAG,GAAGC,wBAAe,OAAO,CAAC,CAAC,GAAG,WAAW,qCAAqC,IAAI,EAAE,MAAM,gBAAgB,GAAG,GAAGC,2BAAkB,OAAO,CAAC,CAAC,CAAC;EAAG;CAC7Q;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"mcp.mjs","names":["skillDiscovered","skillHelpHowToAuthorSkill","skillHelpHowToSkill","toolLoadSkill","toolSearchSkills"],"sources":["../../src/services/mcpSkills/index.ts","../../src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.ts","../../generated/mcp.ts"],"sourcesContent":["import type { PoMcpPluginContext, PoMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { BACKGROUND_CONTEXT, getOrThrow, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { ServerSkillGroup } from '../serverInventory';\n\nexport const MCP_SKILLS_SERVICE = 'po/discovered-mcp-skills';\n\nexport interface McpSkillProvider {\n list(context: PoMcpPluginContext): readonly PoMcpSkill[];\n}\n\n/** Explicit remote provider, never a projection of the local resource registry. */\nexport function mountMcpSkills(groups: readonly ServerSkillGroup[], fs: FileSystem, signal: AbortSignal) {\n return (context: Context): void => {\n context.provide(MCP_SKILLS_SERVICE, {\n list(remote) {\n signal.throwIfAborted();\n remote.signal.throwIfAborted();\n const domains = remote.selection.read().domains;\n const skills = new Map<string, PoMcpSkill>();\n for (const group of groups) {\n if (group.domains !== undefined && !group.domains.some((domain) => domains.includes(domain))) continue;\n for (const skill of group.skills) {\n // Retain name precedence defensively for remote providers.\n if (skills.has(skill.name)) continue;\n skills.set(skill.name, {\n name: skill.name,\n description: skill.description,\n async read() {\n const readSignal = AbortSignal.any([signal, remote.signal]);\n readSignal.throwIfAborted();\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(readSignal, BACKGROUND_CONTEXT)),\n );\n readSignal.throwIfAborted();\n return text;\n },\n });\n }\n }\n return [...skills.values()];\n },\n } satisfies McpSkillProvider);\n };\n}\n\nexport function bindMcpSkills(context: PoMcpPluginContext): readonly PoMcpSkill[] {\n const provider = context.services.get<McpSkillProvider>(MCP_SKILLS_SERVICE);\n if (!provider) throw new Error('Discovered MCP skills are unavailable.');\n return provider.list(context);\n}\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\n\nimport { bindMcpSkills } from '../../../../../services/mcpSkills';\n\nexport default defineRoutedContribution(bindMcpSkills, { cardinality: 'many' });\n","import { defineMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineMcpSkill({\n name: 'help-how-to-author-skill',\n description:\n 'Author and distribute Po agent skills. Use when creating a SKILL.md, adding supporting references or scripts, contributing a runtime skill directory through Cordis, or publishing activation-gated Help prompts from a Po package.',\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-author-skill/SKILL.md'),\n});\n","import { defineMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineMcpSkill({\n name: 'help-how-to-skill',\n description:\n \"Use Po's skill catalog and deferred discovery. Use when browsing available skills, invoking /skill:name, understanding Help and extension-owned skill groups, or diagnosing why a skill is absent or shadowed.\",\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-skill/SKILL.md'),\n});\n","import { Type } from 'typebox';\n\nexport const searchSkillsParameters = Type.Object({ query: Type.Optional(Type.String()) });\nexport const loadSkillParameters = Type.Object({ name: Type.String() });\n","import { rankText } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessHostService, PoHeadlessTool } from '@agimon-ai/po-core/headless';\n\nimport { loadSkillParameters, searchSkillsParameters } from '../../schemas/mcpSkillTools';\n\nfunction text(text: string) {\n return { content: [{ type: 'text' as const, text }] };\n}\n\nfunction skills(context: Parameters<PoHeadlessTool['execute']>[4]) {\n if (context.mcpSkills === undefined) throw new Error('Remote skill access is unavailable.');\n return context.mcpSkills;\n}\n\n/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */\nexport function matchSkills<T extends { name: string; description: string }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n const needle = query?.trim().toLocaleLowerCase();\n if (needle === undefined || needle === '') return [...skills];\n return skills.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\n}\n\n/** Best match first by name, then description, active before inactive; an empty query keeps everything, in order. */\nexport function rankSkills<T extends { name: string; description: string; active?: boolean }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n if (query === undefined || query.trim() === '') return [...skills];\n const ranked = rankText(\n query,\n skills.map((skill) => ({ id: skill.name, name: skill.name, doc: skill.description, skill })),\n ).map(({ skill }) => skill);\n return [...ranked.filter((skill) => skill.active !== false), ...ranked.filter((skill) => skill.active === false)];\n}\n\n/** Pinned guides are listed in the system prompt, so only a real search needs them. */\nexport function searchesPinned(query: string | undefined): boolean {\n return query !== undefined && query.trim() !== '';\n}\n\nexport function createSearchSkillsTool(): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Discover repository and active-domain skills available to this remote connection.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { query }, _signal, _onUpdate, context) {\n const matches = matchSkills(await skills(context).list(), query);\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionSearchSkillsTool(\n host: Pick<PoHeadlessHostService, 'listSkills'>,\n): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Search available session skills by name or description.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n executionMode: 'parallel',\n async execute(_toolCallId, { query }) {\n const matches = rankSkills(\n host\n .listSkills({ includePinned: searchesPinned(query) })\n .map(({ name, description }) => ({ name, description })),\n query,\n );\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionLoadSkillTool(\n host: Pick<PoHeadlessHostService, 'readSkill'>,\n): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n // PO_LOAD_SKILL_TOOL, spelled out so the renderer rule can read it.\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full instructions of an available session skill by exact name.',\n parameters: loadSkillParameters,\n executionMode: 'parallel',\n async execute(_toolCallId, { name }) {\n const body = host.readSkill(name);\n if (body === undefined) return { ...text(`No skill named ${name} is available in this session.`), isError: true };\n return text(body);\n },\n };\n}\n\nexport function createLoadSkillTool(): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full Markdown instructions for an available remote skill by exact name.',\n parameters: loadSkillParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { name }, _signal, _onUpdate, context) {\n return text(await skills(context).read(name));\n },\n };\n}\n","import { defineMcpTool } from '@agimon-ai/po-core/mcpFacet';\n\nimport { createLoadSkillTool } from '../../../../../services/mcpSkillTools';\n\nexport default defineMcpTool(createLoadSkillTool());\n","import { defineMcpTool } from '@agimon-ai/po-core/mcpFacet';\n\nimport { createSearchSkillsTool } from '../../../../../services/mcpSkillTools';\n\nexport default defineMcpTool(createSearchSkillsTool());\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineMcpPlugin, type PoMcpSessionPlugin } from '@agimon-ai/po-core/mcpFacet';\n\nimport skillDiscovered from '../src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp';\nimport skillHelpHowToAuthorSkill from '../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp';\nimport skillHelpHowToSkill from '../src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp';\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp';\nimport toolSearchSkills from '../src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\ntype ManyFactory<T, C> = (context: C) => T | readonly T[];\nconst many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {\n const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\n return Array.isArray(resolved) ? resolved : [resolved as T];\n};\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => {\n if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nconst withWidget = <T>(key: string, value: T): T => value === undefined ? value : ({\n ...value, _meta: { ...(value as { _meta?: object })._meta, [\"po/widget\"]: key },\n});\n\nexport const mcp = defineMcpPlugin({\n name: '@agimon-ai/po-skill',\n session: (context) => ({\n get skills(): PoMcpSessionPlugin['skills'] { return [...many(skillDiscovered, context), at(skillHelpHowToAuthorSkill, context), at(skillHelpHowToSkill, context)]; },\n get tools(): PoMcpSessionPlugin['tools'] { return [withWidget(\"@agimon-ai/po-skill/load_skill\", via({ name: 'load_skill' }, at(toolLoadSkill, context))), withWidget(\"@agimon-ai/po-skill/search_skills\", via({ name: 'search_skills' }, at(toolSearchSkills, context)))]; },\n }) satisfies PoMcpSessionPlugin,\n});\n\nexport default mcp;\n"],"mappings":";;;;;;;AAMA,MAAa,qBAAqB;AAyClC,SAAgB,cAAc,SAAoD;CAChF,MAAM,WAAW,QAAQ,SAAS,IAAsB,kBAAkB;CAC1E,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,wCAAwC;CACvE,OAAO,SAAS,KAAK,OAAO;AAC9B;;;AC/CA,IAAA,yBAAe,yBAAyB,eAAe,EAAE,aAAa,OAAO,CAAC;;;ACD9E,IAAA,uCAAe,eAAe;CAC5B,MAAM;CACN,aACE;CACF,YAAY,oBAAoB,YAAY,KAAK,+CAA+C;AAClG,CAAC;;;ACLD,IAAA,gCAAe,eAAe;CAC5B,MAAM;CACN,aACE;CACF,YAAY,oBAAoB,YAAY,KAAK,wCAAwC;AAC3F,CAAC;;;ACND,MAAa,yBAAyB,KAAK,OAAO,EAAE,OAAO,KAAK,SAAS,KAAK,OAAO,CAAC,EAAE,CAAC;AACzF,MAAa,sBAAsB,KAAK,OAAO,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;;;ACEtE,SAAS,KAAK,MAAc;CAC1B,OAAO,EAAE,SAAS,CAAC;EAAE,MAAM;EAAiB;CAAK,CAAC,EAAE;AACtD;AAEA,SAAS,OAAO,SAAmD;CACjE,IAAI,QAAQ,cAAc,KAAA,GAAW,MAAM,IAAI,MAAM,qCAAq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,CAAC,QAAa;AAC5D;AACA,MAAM,OAAU,UAAmC,UAAsB;CACvE,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,MAAM,cAAc;CACpB,OAAO;EAAE,GAAG;EAAU,GAAG;EAAa,GAAI,YAAY,cAAc,KAAA,IAAY,CAAC,IAAI,EACnF,WAAW,YAAY,UAAU,KAAK,cAAc;GAAE,UAAU;GAAY,GAAG;EAAS,EAAE,EAC5F;CAAG;AACL;AAEA,MAAM,cAAiB,KAAa,UAAgB,UAAU,KAAA,IAAY,QAAS;CACjF,GAAG;CAAO,OAAO;EAAE,GAAI,MAA6B;GAAQ,cAAc;CAAI;AAChF;AAEA,MAAa,MAAM,gBAAgB;CACjC,MAAM;CACN,UAAU,aAAa;EACrB,IAAI,SAAuC;GAAE,OAAO;IAAC,GAAG,KAAKA,wBAAiB,OAAO;IAAG,GAAGC,sCAA2B,OAAO;IAAG,GAAGC,+BAAqB,OAAO;GAAC;EAAG;EACnK,IAAI,QAAqC;GAAE,OAAO,CAAC,WAAW,kCAAkC,IAAI,EAAE,MAAM,aAAa,GAAG,GAAGC,wBAAe,OAAO,CAAC,CAAC,GAAG,WAAW,qCAAqC,IAAI,EAAE,MAAM,gBAAgB,GAAG,GAAGC,2BAAkB,OAAO,CAAC,CAAC,CAAC;EAAG;CAC7Q;AACF,CAAC"}
|
|
@@ -432,11 +432,20 @@ function text(text) {
|
|
|
432
432
|
text
|
|
433
433
|
}] };
|
|
434
434
|
}
|
|
435
|
-
/**
|
|
436
|
-
function
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
435
|
+
/** Best match first by name, then description, active before inactive; an empty query keeps everything, in order. */
|
|
436
|
+
function rankSkills(skills, query) {
|
|
437
|
+
if (query === void 0 || query.trim() === "") return [...skills];
|
|
438
|
+
const ranked = (0, _agimon_ai_po_core_codemode.rankText)(query, skills.map((skill) => ({
|
|
439
|
+
id: skill.name,
|
|
440
|
+
name: skill.name,
|
|
441
|
+
doc: skill.description,
|
|
442
|
+
skill
|
|
443
|
+
}))).map(({ skill }) => skill);
|
|
444
|
+
return [...ranked.filter((skill) => skill.active !== false), ...ranked.filter((skill) => skill.active === false)];
|
|
445
|
+
}
|
|
446
|
+
/** Pinned guides are listed in the system prompt, so only a real search needs them. */
|
|
447
|
+
function searchesPinned(query) {
|
|
448
|
+
return query !== void 0 && query.trim() !== "";
|
|
440
449
|
}
|
|
441
450
|
function createSessionSearchSkillsTool(host) {
|
|
442
451
|
return {
|
|
@@ -451,7 +460,7 @@ function createSessionSearchSkillsTool(host) {
|
|
|
451
460
|
},
|
|
452
461
|
executionMode: "parallel",
|
|
453
462
|
async execute(_toolCallId, { query }) {
|
|
454
|
-
const matches =
|
|
463
|
+
const matches = rankSkills(host.listSkills({ includePinned: searchesPinned(query) }).map(({ name, description }) => ({
|
|
455
464
|
name,
|
|
456
465
|
description
|
|
457
466
|
})), query);
|
|
@@ -523,7 +532,7 @@ function createSkillNamespace(host, inventory, fs) {
|
|
|
523
532
|
check();
|
|
524
533
|
const seen = /* @__PURE__ */ new Set();
|
|
525
534
|
const all = [];
|
|
526
|
-
for (const { name, description } of host.listSkills()) {
|
|
535
|
+
for (const { name, description } of host.listSkills({ includePinned: searchesPinned(query) })) {
|
|
527
536
|
seen.add(name);
|
|
528
537
|
all.push({
|
|
529
538
|
name,
|
|
@@ -536,7 +545,7 @@ function createSkillNamespace(host, inventory, fs) {
|
|
|
536
545
|
description,
|
|
537
546
|
active: false
|
|
538
547
|
});
|
|
539
|
-
return
|
|
548
|
+
return rankSkills(all, query);
|
|
540
549
|
},
|
|
541
550
|
async load(input) {
|
|
542
551
|
const name = nameOf(input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.cjs","names":["getOrThrow","withAbortSignal","BACKGROUND_CONTEXT","path","fileURLToPath","fs","pathToFileURL","getAgentDir","loadSkills","Worker","stripFrontmatter","path","withAbortSignal","BACKGROUND_CONTEXT","readHarnessState","nodeHost","path","loadDomainsAsync","domainNamesOf","materializePluginEntries","resolveManifestPluginEntriesAsync","collectResources","discoverSkillsAsync","sharedSkillsFor","formatSkillsForPrompt","Type","PO_SKILLS_NAMESPACE","getOrThrow","withAbortSignal","BACKGROUND_CONTEXT","PO_CODEMODE_SERVICE","PO_ISOLATE_SERVICE","readPoCodemode","readPoIsolate","SKILL_COMMAND_PREFIX","SKILL_INVOCATION_PREFIX","SKILLS_COMMAND","nodeHost","readHarnessState","getOrThrow","BACKGROUND_CONTEXT","PO_HELP_WHEN","packageResourcePath","readPackageResource","defineRoot","requirePoFs","readPoLang","readPoPersonLocale","defineRoutedContribution","defineResource","packageResourcePath","readPackageResource","defineRoutedContribution","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootInjects","composeRootHooks","commandSkills","resourceCodemodeHowToSkills","resourceSkills"],"sources":["../../src/constants/skillInventory.ts","../../src/services/mcpSkills/index.ts","../../src/services/deferredSkills/index.ts","../../src/services/serverInventory/grouping.ts","../../src/services/serverInventory/index.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/services/skillNamespace/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/skillCommands.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/skills.server.ts","../../generated/server.ts"],"sourcesContent":["/**\n * How long sessions with the same inputs share one skill inventory instead of each reading the disk.\n * ponytail: a skill added on disk reaches new sessions within this window, not at once; watch the\n * skill roots if that lag matters.\n */\nexport const SKILL_INVENTORY_FRESH_MS = 60_000;\n","import type { PoMcpPluginContext, PoMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { BACKGROUND_CONTEXT, getOrThrow, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { ServerSkillGroup } from '../serverInventory';\n\nexport const MCP_SKILLS_SERVICE = 'po/discovered-mcp-skills';\n\nexport interface McpSkillProvider {\n list(context: PoMcpPluginContext): readonly PoMcpSkill[];\n}\n\n/** Explicit remote provider, never a projection of the local resource registry. */\nexport function mountMcpSkills(groups: readonly ServerSkillGroup[], fs: FileSystem, signal: AbortSignal) {\n return (context: Context): void => {\n context.provide(MCP_SKILLS_SERVICE, {\n list(remote) {\n signal.throwIfAborted();\n remote.signal.throwIfAborted();\n const domains = remote.selection.read().domains;\n const skills = new Map<string, PoMcpSkill>();\n for (const group of groups) {\n if (group.domains !== undefined && !group.domains.some((domain) => domains.includes(domain))) continue;\n for (const skill of group.skills) {\n // Retain name precedence defensively for remote providers.\n if (skills.has(skill.name)) continue;\n skills.set(skill.name, {\n name: skill.name,\n description: skill.description,\n async read() {\n const readSignal = AbortSignal.any([signal, remote.signal]);\n readSignal.throwIfAborted();\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(readSignal, BACKGROUND_CONTEXT)),\n );\n readSignal.throwIfAborted();\n return text;\n },\n });\n }\n }\n return [...skills.values()];\n },\n } satisfies McpSkillProvider);\n };\n}\n\nexport function bindMcpSkills(context: PoMcpPluginContext): readonly PoMcpSkill[] {\n const provider = context.services.get<McpSkillProvider>(MCP_SKILLS_SERVICE);\n if (!provider) throw new Error('Discovered MCP skills are unavailable.');\n return provider.list(context);\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { Worker } from 'node:worker_threads';\n\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport {\n type BuildSystemPromptOptions,\n formatSkillsForPrompt,\n getAgentDir,\n loadSkills,\n type Skill,\n stripFrontmatter,\n} from '@earendil-works/pi-coding-agent';\n\nimport type { DeferredSkillLoaderOptions, DeferredSkillSnapshot } from '../../types/skills';\n\nexport type { DeferredSkillLoaderOptions, DeferredSkillSnapshot } from '../../types/skills';\n\nconst PI_PACKAGE = '@earendil-works/pi-coding-agent';\nconst PACKAGE_MANIFEST = 'package.json';\n// A fresh worker takes ~240 ms to import Pi's main entry but ~20 ms for this module alone, and\n// every session spawns one. ponytail: not in Pi's exports map, so a Pi release that moves it\n// falls back to the main entry (slow, still correct); deferredSkills.test.ts pins the path.\nconst PI_SKILLS_MODULE = path.join('dist', 'core', 'skills.js');\nconst SKILL_WORKER_SOURCE = `\nconst { parentPort, workerData } = require('node:worker_threads');\nvoid (async () => {\n try {\n const { loadSkills } = await import(workerData.piModuleUrl);\n parentPort.postMessage({ ok: true, result: loadSkills(workerData.loadOptions) });\n } catch (error) {\n parentPort.postMessage({ ok: false, error: error instanceof Error ? error.message : String(error) });\n }\n})();\n`;\n\nasync function installedPiModuleUrl(): Promise<string> {\n const anchors = [process.argv[1], fileURLToPath(import.meta.url), path.join(process.cwd(), PACKAGE_MANIFEST)];\n for (const anchor of anchors) {\n if (!anchor) continue;\n let directory = path.dirname(path.resolve(anchor));\n while (true) {\n const packageRoot = path.join(directory, 'node_modules', PI_PACKAGE);\n const manifestPath = path.join(packageRoot, PACKAGE_MANIFEST);\n try {\n const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8')) as { main?: unknown };\n if (typeof manifest.main === 'string') {\n const entry = path.resolve(packageRoot, manifest.main);\n const skills = path.join(packageRoot, PI_SKILLS_MODULE);\n for (const candidate of [skills, entry]) {\n try {\n await fs.access(candidate);\n return pathToFileURL(candidate).href;\n } catch {\n // Try the next entry before walking up the module chain.\n }\n }\n }\n } catch {\n // This anchor does not expose Pi at this level; continue up its module chain.\n }\n const parent = path.dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n }\n throw new Error(`Cannot resolve ${PI_PACKAGE} from the Po or host module trees`);\n}\n\ninterface SkillWorkerResult {\n ok: boolean;\n result?: { skills: Skill[]; diagnostics: Array<{ path?: string; message: string }> };\n error?: string;\n}\n\n/**\n * One session's Po-selected skill inventory.\n *\n * Construction is deliberately cheap. `start()` schedules the synchronous Pi\n * walker after session_start returns, while `ready()` is the single promise the\n * first input awaits before Pi expands `/skill:name`.\n */\nexport class DeferredSkillLoader {\n readonly #options: DeferredSkillLoaderOptions;\n #promise: Promise<DeferredSkillSnapshot> | undefined;\n\n constructor(options: DeferredSkillLoaderOptions) {\n this.#options = options;\n }\n\n start(): Promise<DeferredSkillSnapshot> {\n if (this.#promise) return this.#promise;\n\n if (!this.#options.schedule && !this.#options.load) {\n this.#promise = this.#loadInWorker();\n return this.#promise;\n }\n\n const schedule = this.#options.schedule ?? ((load: () => void) => setImmediate(load));\n this.#promise = new Promise((resolve) => {\n const fail = (error: unknown): void => {\n resolve(this.#failure(error));\n };\n try {\n schedule(() => {\n try {\n resolve(this.#load());\n } catch (error) {\n fail(error);\n }\n });\n } catch (error) {\n fail(error);\n }\n });\n return this.#promise;\n }\n\n ready(): Promise<DeferredSkillSnapshot> {\n return this.start();\n }\n\n #loadOptions(): { cwd: string; agentDir: string; skillPaths: string[]; includeDefaults: boolean } {\n return {\n cwd: this.#options.cwd,\n agentDir: this.#options.agentDir ?? getAgentDir(),\n skillPaths: [...this.#options.skillPaths],\n includeDefaults: false,\n };\n }\n\n #snapshot(result: {\n skills: Skill[];\n diagnostics: Array<{ path?: string; message: string }>;\n }): DeferredSkillSnapshot {\n return {\n skills: result.skills,\n diagnostics: result.diagnostics.map(\n (diagnostic) => `${diagnostic.path ?? this.#options.cwd}: ${diagnostic.message}`,\n ),\n };\n }\n\n #failure(error: unknown): DeferredSkillSnapshot {\n return {\n skills: [],\n diagnostics: [`${this.#options.cwd}: ${error instanceof Error ? error.message : String(error)}`],\n };\n }\n\n #load(): DeferredSkillSnapshot {\n return this.#snapshot((this.#options.load ?? loadSkills)(this.#loadOptions()));\n }\n\n async #loadInWorker(): Promise<DeferredSkillSnapshot> {\n let piModuleUrl: string;\n try {\n piModuleUrl = this.#options.piModuleUrl ?? (await installedPiModuleUrl());\n } catch (error) {\n return this.#failure(error);\n }\n return new Promise((resolve) => {\n let settled = false;\n const settle = (snapshot: DeferredSkillSnapshot): void => {\n if (settled) return;\n settled = true;\n resolve(snapshot);\n };\n let worker: Worker;\n try {\n worker = new Worker(SKILL_WORKER_SOURCE, {\n eval: true,\n workerData: {\n piModuleUrl,\n loadOptions: this.#loadOptions(),\n },\n });\n } catch (error) {\n settle(this.#failure(error));\n return;\n }\n worker.unref();\n worker.once('message', (message: SkillWorkerResult) => {\n if (!message.ok || !message.result) {\n settle(this.#failure(message.error ?? 'Skill worker failed'));\n return;\n }\n settle(this.#snapshot(message.result));\n });\n worker.once('error', (error) => settle(this.#failure(error)));\n worker.once('exit', (code) => {\n if (code !== 0) settle(this.#failure(`Skill worker exited with code ${code}`));\n });\n });\n }\n}\n\n/** Appends only the inventory Pi would append for these deferred skills. */\nexport function buildPromptWithDeferredSkills(\n systemPrompt: string,\n options: BuildSystemPromptOptions,\n skills: Skill[],\n): string {\n if (options.selectedTools && !options.selectedTools.includes('read')) return systemPrompt;\n return `${systemPrompt}${formatSkillsForPrompt(skills)}`;\n}\n\n/**\n * Expands a deferred `/skill:name` before Pi consults its synchronous inventory. Node discovered the\n * skill on the host disk, so it reads it there; the edge build reads through `fs` instead.\n */\nexport async function expandDeferredSkillCommand(\n text: string,\n skills: readonly Skill[],\n _fs?: FileSystem,\n): Promise<string> {\n if (!text.startsWith('/skill:')) return text;\n const spaceIndex = text.indexOf(' ');\n const skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);\n const skill = skills.find((candidate) => candidate.name === skillName);\n if (!skill) return text;\n\n try {\n const args = spaceIndex === -1 ? '' : text.slice(spaceIndex + 1).trim();\n const body = stripFrontmatter(await fs.readFile(skill.filePath, 'utf8')).trim();\n const skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n return args ? `${skillBlock}\\n\\n${args}` : skillBlock;\n } catch {\n // Pi uses the same literal-text fallback if a skill disappears between\n // discovery and submission; the agent can still respond to the command.\n return text;\n }\n}\n","import path from 'node:path';\n\nimport type { PluginEntry } from '@agimon-ai/po-config/domains';\nimport type { PoHeadlessCondition } from '@agimon-ai/po-core/headless';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Skill } from '@earendil-works/pi-coding-agent';\n\nimport type { ServerSkillGroup } from '../../types/skills';\n\n/**\n * Each condition that activates a group: its domains, then each plugin turned on for this session only.\n * Declare one contribution per condition; the host keeps one per name once gating has run.\n */\nexport function groupConditions(group: ServerSkillGroup): (PoHeadlessCondition | undefined)[] {\n return [\n group.domains === undefined ? undefined : { domains: group.domains },\n // `plugins` is po-domain's session state key, spelled out so this runs on hosts with an older po-core.\n ...(group.plugins ?? []).map((plugin) => ({ state: { plugins: plugin } })),\n ];\n}\n/**\n * Skill paths one domain admits, or one plugin's session-only activation (`plugin`), or the repository when\n * neither is set.\n */\nexport interface SkillSource {\n readonly domain?: string;\n readonly plugin?: string;\n readonly paths: readonly string[];\n readonly mcpPaths: readonly string[];\n}\n\nconst LOCAL_ONLY_MCP_PACKAGES = new Set([\n '@agimon-ai/po-author',\n '@agimon-ai/po-git',\n '@agimon-ai/po-goal',\n '@agimon-ai/po-help',\n '@agimon-ai/po-calendar',\n '@agimon-ai/po-user-feedback',\n '@agimon-ai/po-voice',\n '@agimon-ai/po-workflow',\n]);\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport async function isMcpSkillPlugin(fs: FileSystem, entry: PluginEntry, context: IoContext): Promise<boolean> {\n if (entry.source?.type === 'npm') return !LOCAL_ONLY_MCP_PACKAGES.has(entry.source.package);\n // A package manifest is optional for catalog plugins, but a present identity\n // that cannot be read or parsed must never make the plugin remotely eligible.\n const source = await fs.readTextFile(path.join(entry.directory, 'package.json'), context);\n if (!source.ok) return source.error.code === 'not_found';\n try {\n const manifest = JSON.parse(source.value) as unknown;\n if (typeof manifest !== 'object' || manifest === null || Array.isArray(manifest)) return false;\n const name = (manifest as { name?: unknown }).name;\n return typeof name === 'string' && name.length > 0 && name.trim() === name && !LOCAL_ONLY_MCP_PACKAGES.has(name);\n } catch {\n return false;\n }\n}\n\n/**\n * Whether a discovered skill came from one of these paths.\n *\n * A source holds exact SKILL.md files for plugin and shared skills, but a bare\n * directory for `.po/skills`, so membership is containment rather than\n * equality.\n */\nexport function within(filePath: string, roots: readonly string[]): boolean {\n const resolved = path.resolve(filePath);\n return roots.some((root) => {\n const base = path.resolve(root);\n return resolved === base || resolved.startsWith(`${base}${path.sep}`);\n });\n}\n\n/**\n * One group per loaded skill, merging every source admitting that exact path.\n * MCP admission is merged separately so local-only sources cannot broaden it.\n */\nexport function groupSkills(\n skills: readonly Skill[],\n sources: readonly SkillSource[],\n key: 'paths' | 'mcpPaths',\n): ServerSkillGroup[] {\n return skills.flatMap((skill) => {\n const admitting = sources.filter((source) => within(skill.filePath, source[key]));\n if (admitting.length === 0) return [];\n const domains = [...new Set(admitting.flatMap((source) => (source.domain === undefined ? [] : [source.domain])))];\n const plugins = [...new Set(admitting.flatMap((source) => (source.plugin === undefined ? [] : [source.plugin])))];\n const repository = admitting.some((source) => source.domain === undefined && source.plugin === undefined);\n return [\n {\n ...(repository ? {} : { domains }),\n ...(repository || plugins.length === 0 ? {} : { plugins }),\n skills: [skill],\n },\n ];\n });\n}\n","import path from 'node:path';\n\nimport {\n domainNamesOf,\n loadDomainsAsync,\n resolveManifestPluginEntriesAsync,\n sharedSkillsFor,\n} from '@agimon-ai/po-config/domains';\nimport { readHarnessState } from '@agimon-ai/po-config/harnessState';\nimport type { PoHeadlessExecutionContext } from '@agimon-ai/po-core/headless';\nimport { BACKGROUND_CONTEXT, nodeHost, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { collectResources, discoverSkillsAsync, type NamedResource } from '@agimon-ai/po-domain/resources';\nimport { formatSkillsForPrompt } from '@earendil-works/pi-coding-agent';\n\nimport type { ServerSkillInventory } from '../../types/skills';\nimport { DeferredSkillLoader } from '../deferredSkills';\nimport { groupSkills, isMcpSkillPlugin, type SkillSource, within } from './grouping';\n\nexport type { ServerSkillGroup, ServerSkillInventory } from '../../types/skills';\n\n/**\n * Every skill the session could reach, grouped by what activates it.\n *\n * A cockpit `/domains` switch reconciles contributions rather than rebuilding\n * the server plugin: the session declaration is mounted once. So enumerating only the\n * launch selection would freeze the command list at whatever was selected when\n * the session host was built. Enumerating every domain up front and tagging\n * each group with its `when` lets the existing kernel refresh do the work, the\n * same way other host contributions follow selection changes.\n */\nexport async function discoverServerSkills(\n execution: PoHeadlessExecutionContext,\n fs: FileSystem,\n signal: AbortSignal,\n): Promise<ServerSkillInventory> {\n signal.throwIfAborted();\n const context = withAbortSignal(signal, BACKGROUND_CONTEXT);\n const state = readHarnessState(execution.environment);\n const home = execution.environment.HOME ?? nodeHost.homeDirectory();\n const repoSkills = path.join(execution.repoRoot, '.po', 'skills');\n const sources: SkillSource[] = [];\n const diagnostics: string[] = [];\n const descriptors = new Map<string, NamedResource>();\n // A malformed domain is a configuration error in one domain, so it must not\n // remove every other domain's skills. Enumerating the whole manifest is new\n // exposure here: reading the launch selection could not fail this way.\n const manifest = await loadDomainsAsync(fs, execution.repoRoot, context, home, execution.environment).catch(\n (error: unknown) => {\n diagnostics.push(`Domain skills are unavailable: ${error instanceof Error ? error.message : String(error)}`);\n return undefined;\n },\n );\n const domains = manifest ? domainNamesOf(manifest) : [];\n\n // Plugin sources precede shared sources, then repository sources.\n // ponytail: Pi globally name-dedupes before domain gating. A loaded plugin\n // shadows a same-name shared fallback even when its domain is off. This is\n // the current ceiling; upgrade to selection-aware loading if collisions arise.\n // Reuse only immutable discovery paths within this invocation. The key keeps\n // plugin ordering and subsets; fs, repo, home and admitted environment are\n // fixed here. No inventory, cleanup handle or session state survives a call.\n const discovered = new Map<\n string,\n Readonly<{ paths: readonly string[]; mcpPaths: readonly string[]; plugins: readonly SkillSource[] }>\n >();\n if (manifest) {\n for (const domain of domains) {\n signal.throwIfAborted();\n try {\n const plugins = await materializePluginEntries(\n await resolveManifestPluginEntriesAsync(fs, manifest, [domain], [], context, home),\n { homeDirectory: home, environment: execution.environment },\n );\n const key = JSON.stringify(\n plugins.map(({ directory, skillDiscovery, skills, source }) => ({\n directory,\n skillDiscovery,\n skills,\n source,\n })),\n );\n const previous = discovered.get(key);\n if (previous) {\n sources.push({ domain, paths: [...previous.paths], mcpPaths: [...previous.mcpPaths] }, ...previous.plugins);\n continue;\n }\n const mcpPluginRoots = (\n await Promise.all(\n plugins.map(async (plugin) =>\n (await isMcpSkillPlugin(fs, plugin, context)) ? path.join(plugin.directory, 'skills') : undefined,\n ),\n )\n ).filter((root): root is string => root !== undefined);\n const collected = await collectResources(execution.repoRoot, plugins, {\n agents: false,\n discoverAgents: false,\n mcp: false,\n sharedSkills: false,\n environment: execution.environment,\n });\n try {\n for (const descriptor of collected.skillSources) descriptors.set(descriptor.path, descriptor);\n const paths = Object.freeze([...collected.skillDirectories]);\n // Exact collected paths retain this domain's per-plugin skill subset.\n // A plugin root would also admit skills loaded for another domain.\n const mcpPaths = Object.freeze(paths.filter((skillPath) => within(skillPath, mcpPluginRoots)));\n // The same skills, admitted one plugin at a time for session-only activation. Never remote: no mcpPaths.\n const pluginSources = plugins.flatMap(({ name, directory }) => {\n const own = paths.filter((skillPath) => within(skillPath, [directory]));\n return name === undefined || own.length === 0 ? [] : [{ plugin: name, paths: own, mcpPaths: [] }];\n });\n discovered.set(key, Object.freeze({ paths, mcpPaths, plugins: pluginSources }));\n if (paths.length > 0) sources.push({ domain, paths: [...paths], mcpPaths: [...mcpPaths] }, ...pluginSources);\n } finally {\n await collected.cleanup();\n }\n } catch (error) {\n diagnostics.push(`Domain '${domain}': ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n }\n\n // Shared skills are admitted by any domain that keeps them.\n signal.throwIfAborted();\n const shared = await discoverSkillsAsync(\n execution.repoRoot,\n path.join(execution.repoRoot, '.claude', 'skills'),\n 'recursive',\n undefined,\n execution.environment,\n );\n for (const descriptor of shared) descriptors.set(descriptor.path, descriptor);\n for (const descriptor of await discoverSkillsAsync(\n execution.repoRoot,\n repoSkills,\n 'recursive',\n undefined,\n execution.environment,\n ))\n descriptors.set(descriptor.path, descriptor);\n if (shared.length > 0 && manifest) {\n const sharedPaths = shared.map((skill) => skill.path);\n for (const domain of domains) {\n if (sharedSkillsFor(manifest, [domain])) {\n sources.push({ domain, paths: sharedPaths, mcpPaths: sharedPaths });\n }\n }\n }\n\n // Repository-local skills belong to the repository, not to a selection.\n sources.push({ paths: [repoSkills], mcpPaths: [repoSkills] });\n\n signal.throwIfAborted();\n // One walk for every group. Pi drops a path it has already loaded, so the\n // loader gets the unique set and each group selects its own skills back out.\n const unique = [...new Set([...sources.flatMap((source) => source.paths), ...(state.skillDirectories ?? [])])];\n const inventory = await new DeferredSkillLoader({ cwd: execution.cwd, skillPaths: unique }).ready();\n signal.throwIfAborted();\n\n for (const descriptor of descriptors.values()) {\n for (const diagnostic of descriptor.diagnostics ?? []) diagnostics.push(`${descriptor.path}: ${diagnostic}`);\n }\n const groups = groupSkills(inventory.skills, sources, 'paths');\n const mcpGroups = groupSkills(inventory.skills, sources, 'mcpPaths');\n\n // The catalog still describes the active selection rather than everything on\n // disk, because it is prompt text rather than a menu.\n const activeSkills = inventory.skills.filter((skill) =>\n within(skill.filePath, [...(state.skillDirectories ?? []), repoSkills]),\n );\n return {\n inventory: { skills: inventory.skills, diagnostics: [...inventory.diagnostics, ...diagnostics] },\n groups,\n mcpGroups,\n relations: Object.fromEntries(\n [...descriptors].map(([filePath, descriptor]) => [filePath, descriptor.relations ?? []]),\n ),\n catalog: formatSkillsForPrompt(activeSkills) || '(no discovered skills)',\n };\n}\n","import { Type } from 'typebox';\n\nexport const searchSkillsParameters = Type.Object({ query: Type.Optional(Type.String()) });\nexport const loadSkillParameters = Type.Object({ name: Type.String() });\n","import type { PoHeadlessHostService, PoHeadlessTool } from '@agimon-ai/po-core/headless';\n\nimport { loadSkillParameters, searchSkillsParameters } from '../../schemas/mcpSkillTools';\n\nfunction text(text: string) {\n return { content: [{ type: 'text' as const, text }] };\n}\n\nfunction skills(context: Parameters<PoHeadlessTool['execute']>[4]) {\n if (context.mcpSkills === undefined) throw new Error('Remote skill access is unavailable.');\n return context.mcpSkills;\n}\n\n/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */\nexport function matchSkills<T extends { name: string; description: string }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n const needle = query?.trim().toLocaleLowerCase();\n if (needle === undefined || needle === '') return [...skills];\n return skills.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\n}\n\nexport function createSearchSkillsTool(): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Discover repository and active-domain skills available to this remote connection.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { query }, _signal, _onUpdate, context) {\n const matches = matchSkills(await skills(context).list(), query);\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionSearchSkillsTool(\n host: Pick<PoHeadlessHostService, 'listSkills'>,\n): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Search available session skills by name or description.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n executionMode: 'parallel',\n async execute(_toolCallId, { query }) {\n const matches = matchSkills(\n host.listSkills().map(({ name, description }) => ({ name, description })),\n query,\n );\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionLoadSkillTool(\n host: Pick<PoHeadlessHostService, 'readSkill'>,\n): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n // PO_LOAD_SKILL_TOOL, spelled out so the renderer rule can read it.\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full instructions of an available session skill by exact name.',\n parameters: loadSkillParameters,\n executionMode: 'parallel',\n async execute(_toolCallId, { name }) {\n const body = host.readSkill(name);\n if (body === undefined) return { ...text(`No skill named ${name} is available in this session.`), isError: true };\n return text(body);\n },\n };\n}\n\nexport function createLoadSkillTool(): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full Markdown instructions for an available remote skill by exact name.',\n parameters: loadSkillParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { name }, _signal, _onUpdate, context) {\n return text(await skills(context).read(name));\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode, type PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\nimport { PO_SKILLS_NAMESPACE, type PoHeadlessHostService } from '@agimon-ai/po-core/headless';\nimport {\n BACKGROUND_CONTEXT,\n getOrThrow,\n PO_ISOLATE_SERVICE,\n readPoIsolate,\n withAbortSignal,\n type FileSystem,\n} from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { DeferredSkillSnapshot } from '../../types/skills';\nimport { createSessionLoadSkillTool, createSessionSearchSkillsTool, matchSkills } from '../mcpSkillTools';\n\nexport const SKILL_NAMESPACE_SOURCE = '@agimon-ai/po-skill';\n\ninterface SkillMatch {\n name: string;\n description: string;\n active: boolean;\n}\n\nfunction queryOf(input: unknown): string | undefined {\n if (input === undefined) return undefined;\n const query = typeof input === 'object' && input !== null ? (input as { query?: unknown }).query : 0;\n if (query === undefined || typeof query === 'string') return query;\n throw new Error('Pass { query?: string }.');\n}\n\nfunction nameOf(input: unknown): string {\n const name = (input as { name?: unknown } | null)?.name;\n if (typeof name !== 'string' || name.trim() === '')\n throw new Error('Pass { name: string }, a name from skills.search.');\n return name;\n}\n\n/**\n * Skills of every domain in domains.yaml, selected or not, plus the session's own. Reading one never selects its\n * domain or plugin, so it grants no tools, hooks or MCP servers. Disabled plugins never reach the inventory.\n */\nexport function createSkillNamespace(\n host: Pick<PoHeadlessHostService, 'listSkills' | 'readSkill' | 'context'>,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem,\n): PoCodemodeNamespace {\n return {\n name: PO_SKILLS_NAMESPACE,\n summary: 'Search and read skills beyond the active set, including unselected domains. Reading enables nothing.',\n declarations: `declare const skills: {\n /** Active skills first, then skills of unselected domains. Omit query to list everything. */\n search(input?: { query?: string }): Promise<{ name: string; description: string; active: boolean }[]>;\n /** Full SKILL.md text by exact name from search. Grants no tools, hooks or MCP servers. */\n load(input: { name: string }): Promise<string>;\n};`,\n bind(run) {\n if (run.sessionId !== host.context.sessionId) throw new Error('Skills namespace belongs to another session.');\n let disposed = false;\n run.onDispose(() => {\n disposed = true;\n });\n const check = () => {\n if (disposed) throw new Error('Skills namespace run is disposed.');\n run.signal.throwIfAborted();\n };\n return {\n async search(input?: unknown): Promise<SkillMatch[]> {\n const query = queryOf(input);\n check();\n const seen = new Set<string>();\n const all: SkillMatch[] = [];\n for (const { name, description } of host.listSkills()) {\n seen.add(name);\n all.push({ name, description, active: true });\n }\n for (const { name, description } of inventory.skills)\n if (!seen.has(name)) all.push({ name, description, active: false });\n return matchSkills(all, query);\n },\n async load(input: unknown): Promise<string> {\n const name = nameOf(input);\n check();\n const active = host.readSkill(name);\n if (active !== undefined) return active;\n // Exact inventory names only, so a script can never steer the read to another path.\n const skill = inventory.skills.find((entry) => entry.name === name);\n if (!skill) throw new Error(`No skill named ${name}. Use skills.search to find one.`);\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(run.signal, BACKGROUND_CONTEXT)),\n );\n check();\n return text;\n },\n };\n },\n };\n}\n\nexport function mountSkillNamespace(\n host: Pick<PoHeadlessHostService, 'listSkills' | 'readSkill' | 'context' | 'registerTool'>,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem,\n) {\n return (context: Context): void => {\n // The direct tools stay only where exec cannot bind this non-portable namespace, which covers both.\n // Registered here rather than restricted, so the remote MCP load_skill and search_skills stay.\n const tools = [\n host.registerTool(createSessionLoadSkillTool(host)),\n host.registerTool(createSessionSearchSkillsTool(host)),\n ];\n const withdraw = () => {\n for (const tool of tools.splice(0)) tool.dispose();\n };\n context.effect(() => withdraw, 'session skill tools');\n context.inject([PO_CODEMODE_SERVICE, PO_ISOLATE_SERVICE], (bound) => {\n const codemode = readPoCodemode(bound);\n if (!codemode) return undefined;\n const registration = codemode.register(SKILL_NAMESPACE_SOURCE, createSkillNamespace(host, inventory, fs));\n // ponytail: the tools do not come back if code mode leaves mid-session; the next session has them.\n if (readPoIsolate(bound)?.liveObjects === true) withdraw();\n return () => registration.dispose();\n });\n };\n}\n","import type { PoHeadlessCommand, PoHeadlessCondition } from '@agimon-ai/po-core/headless';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Skill } from '@earendil-works/pi-coding-agent';\n\nimport { expandDeferredSkillCommand, type DeferredSkillSnapshot } from '../../../../../services/deferredSkills';\nimport type { ServerSkillGroup } from '../../../../../services/serverInventory';\nimport { groupConditions } from '../../../../../services/serverInventory/grouping';\nimport { SKILL_COMMAND_PREFIX, SKILL_INVOCATION_PREFIX, SKILLS_COMMAND } from '../../../../../types/skills';\n\n/**\n * One command per skill, gated by whatever activates that skill.\n *\n * Expansion always reads the full inventory, not the group: a command is only\n * dispatchable while its condition holds, so by the time one runs its skill is\n * active, and looking it up in the union keeps one lookup table instead of one\n * per domain.\n */\nfunction skillCommand(\n skill: Skill,\n when: PoHeadlessCondition | undefined,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem | undefined,\n): PoHeadlessCommand {\n return {\n ...(when === undefined ? {} : { when }),\n name: `${SKILL_COMMAND_PREFIX}${skill.name}`,\n description: skill.description,\n execute: async (args, execution) => {\n const text = `${SKILL_INVOCATION_PREFIX}${skill.name}${args ? ` ${args}` : ''}`;\n const expanded = await expandDeferredSkillCommand(text, inventory.skills, fs);\n if (expanded === text) throw new Error(`Skill '${skill.name}' is no longer readable.`);\n await admit(execution.session, expanded);\n },\n };\n}\n\n/**\n * The dispatching prompt acks when this command returns, so awaiting the whole\n * turn (session.prompt) kept the composer draft until the run ended.\n */\nfunction admit(session: Parameters<PoHeadlessCommand['execute']>[1]['session'], text: string): Promise<void> {\n return session.admitPrompt ? session.admitPrompt(text, 'prompt', 'operator') : session.prompt(text);\n}\nexport function createSkillCommands(\n inventory: DeferredSkillSnapshot,\n catalog: string,\n groups: readonly ServerSkillGroup[],\n fs?: FileSystem,\n t: (key: string, fallback: string) => string = (_key, fallback) => fallback,\n): readonly PoHeadlessCommand[] {\n return [\n {\n name: SKILLS_COMMAND,\n description: 'List discovered skills or invoke one by name.',\n async execute(args, execution) {\n const requested = args.trim();\n if (requested) {\n await admit(\n execution.session,\n await expandDeferredSkillCommand(`${SKILL_INVOCATION_PREFIX}${requested}`, inventory.skills, fs),\n );\n return;\n }\n await execution.client.notify({\n title: t('skill.notification.catalog', 'Po skills'),\n localization: { title: { key: 'skill.notification.catalog', fallback: 'Po skills' } },\n body: catalog,\n level: 'info',\n });\n },\n },\n ...groups.flatMap((group) =>\n groupConditions(group).flatMap((when) => group.skills.map((skill) => skillCommand(skill, when, inventory, fs))),\n ),\n ];\n}\n","import { readHarnessState } from '@agimon-ai/po-config/harnessState';\nimport type { PoHeadlessHostService } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { BACKGROUND_CONTEXT, getOrThrow, nodeHost, type FileSystem } from '@agimon-ai/po-core/platform';\nimport {\n type PoServerResources,\n type PoServerSessionPlugin,\n packageResourcePath,\n readPackageResource,\n} from '@agimon-ai/po-core/serverPlugin';\n\nimport { SKILL_INVENTORY_FRESH_MS } from '../../../../../constants/skillInventory';\nimport { mountMcpSkills } from '../../../../../services/mcpSkills';\nimport { discoverServerSkills } from '../../../../../services/serverInventory';\nimport { groupConditions } from '../../../../../services/serverInventory/grouping';\nimport { mountSkillNamespace } from '../../../../../services/skillNamespace';\nimport { createSkillCommands } from './skillCommands';\n\nexport async function createSkillServer(\n agent: PoHeadlessHostService,\n fs: FileSystem,\n signal: AbortSignal,\n resources: PoServerResources,\n t?: (key: string, fallback: string) => string,\n): Promise<PoServerSessionPlugin> {\n const execution = agent.context;\n // Sessions with the same inputs share one discovery. The key holds every input discoverServerSkills\n // reads besides the disk, so equal keys give equal inventories, and the window bounds how old that\n // read of the disk can be.\n const key = [\n 'inventory',\n execution.repoRoot,\n execution.cwd,\n execution.environment.HOME ?? nodeHost.homeDirectory(),\n ...(readHarnessState(execution.environment).skillDirectories ?? []),\n Math.floor(Date.now() / SKILL_INVENTORY_FRESH_MS),\n ];\n const { inventory, catalog, groups, mcpGroups, relations } = await resources.acquire(key, () =>\n // Every session sharing the discovery waits on it, so none of their signals may abort it.\n discoverServerSkills(execution, fs, new AbortController().signal),\n );\n return {\n commands: createSkillCommands(inventory, catalog, groups, fs, t),\n services: [mountMcpSkills(mcpGroups, fs, signal), mountSkillNamespace(agent, inventory, fs)],\n resources: [\n // Each skill joins the prompt's one <available_skills> list, gated like the rest.\n ...groups.flatMap((group) =>\n groupConditions(group).flatMap((when) =>\n group.skills.map((skill) => ({\n name: skill.name,\n description: skill.description,\n path: skill.filePath,\n kind: 'skill' as const,\n ...(relations?.[skill.filePath] === undefined ? {} : { relations: relations[skill.filePath] }),\n ...(when === undefined ? {} : { when }),\n read: async () => getOrThrow(await fs.readTextFile(skill.filePath, BACKGROUND_CONTEXT)),\n })),\n ),\n ),\n ...[\n {\n name: 'help-how-to-author-skill',\n description:\n 'Author and distribute Po agent skills. Use when creating a SKILL.md, contributing a runtime skill directory, or publishing activation-gated Help prompts and diagnostic tools.',\n },\n {\n name: 'help-how-to-skill',\n description:\n \"Use Po's skill catalog and deferred discovery. Diagnose missing or shadowed skills and invoke the narrowest available guidance.\",\n },\n ].map((skill) => ({\n ...skill,\n when: PO_HELP_WHEN,\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, `src/prompts/${skill.name}/SKILL.md`),\n read: () => readPackageResource(import.meta.url, `src/prompts/${skill.name}/SKILL.md`),\n })),\n ],\n };\n}\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { readPoLang, readPoPersonLocale } from '@agimon-ai/po-core/locale';\nimport { requirePoFs } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createSkillServer } from './_lib/skillServer';\n\nexport default defineRoot(async ({ agent, context: root, signal, resources }: PoServerPluginContext) => {\n const runtime: PoServerSessionPlugin = agent\n ? await createSkillServer(\n agent,\n requirePoFs(root),\n signal,\n resources,\n (key, fallback) => readPoLang(root)?.t(readPoPersonLocale(root)?.read(), key, fallback) ?? fallback,\n )\n : { commands: [], resources: [] };\n return { value: runtime, services: runtime.services };\n});\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.commands!,\n { cardinality: 'many' },\n);\n","// @scaffold-generated\nimport { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n name: 'codemode-how-to-skills',\n description:\n 'Search and load any skill by name through the skills namespace: the listed ones, the rest of the active catalog, and skills of unselected domains. Use before a task that a skill may cover.',\n // A code-mode guide: listed in the system prompt, outside the searchable catalog.\n pinned: true,\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/codemode-how-to-skills/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/codemode-how-to-skills/SKILL.md'),\n});\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.resources!,\n { cardinality: 'many' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandSkills from '../src/extensions/workspaces/sessions/(backend)/command/skills.server';\nimport resourceCodemodeHowToSkills from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server';\nimport resourceSkills from '../src/extensions/workspaces/sessions/(backend)/resource/skills.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\ntype ManyFactory<T, C> = (context: C) => T | readonly T[];\nconst many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {\n const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\n return Array.isArray(resolved) ? resolved : [resolved as T];\n};\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-skill',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return [...many(commandSkills, contextSession)]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceCodemodeHowToSkills, contextSession), ...many(resourceSkills, contextSession)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.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,mBAAW;CAC7D,UAAA,GAASC,iCAAAA,mBAAAA,CAAmB,EAAE,SAAS,CAACD,mBAAW,EAAE,CAAC;CACtD,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAM,QAAQ,UAAU,WAAWA,qBAAa,OAAO;EAC5E,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,IAAA,GAAGE,iCAAAA,iBAAAA,CAAiB,YAAY;GAChC,IAAI,WAA8C;IAAE,OAAO,CAAC,GAAG,KAAKC,yBAAe,cAAc,CAAC;GAAG;GACrG,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGC,uCAA6B,cAAc,GAAG,GAAG,KAAKC,uBAAgB,cAAc,CAAC;GAAG;GACzJ,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.cjs","names":["getOrThrow","withAbortSignal","BACKGROUND_CONTEXT","path","fileURLToPath","fs","pathToFileURL","getAgentDir","loadSkills","Worker","stripFrontmatter","path","withAbortSignal","BACKGROUND_CONTEXT","readHarnessState","nodeHost","path","loadDomainsAsync","domainNamesOf","materializePluginEntries","resolveManifestPluginEntriesAsync","collectResources","discoverSkillsAsync","sharedSkillsFor","formatSkillsForPrompt","Type","rankText","PO_SKILLS_NAMESPACE","getOrThrow","withAbortSignal","BACKGROUND_CONTEXT","PO_CODEMODE_SERVICE","PO_ISOLATE_SERVICE","readPoCodemode","readPoIsolate","SKILL_COMMAND_PREFIX","SKILL_INVOCATION_PREFIX","SKILLS_COMMAND","nodeHost","readHarnessState","getOrThrow","BACKGROUND_CONTEXT","PO_HELP_WHEN","packageResourcePath","readPackageResource","defineRoot","requirePoFs","readPoLang","readPoPersonLocale","defineRoutedContribution","defineResource","packageResourcePath","readPackageResource","defineRoutedContribution","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootInjects","composeRootHooks","commandSkills","resourceCodemodeHowToSkills","resourceSkills"],"sources":["../../src/constants/skillInventory.ts","../../src/services/mcpSkills/index.ts","../../src/services/deferredSkills/index.ts","../../src/services/serverInventory/grouping.ts","../../src/services/serverInventory/index.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/services/skillNamespace/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/skillCommands.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/skills.server.ts","../../generated/server.ts"],"sourcesContent":["/**\n * How long sessions with the same inputs share one skill inventory instead of each reading the disk.\n * ponytail: a skill added on disk reaches new sessions within this window, not at once; watch the\n * skill roots if that lag matters.\n */\nexport const SKILL_INVENTORY_FRESH_MS = 60_000;\n","import type { PoMcpPluginContext, PoMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { BACKGROUND_CONTEXT, getOrThrow, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { ServerSkillGroup } from '../serverInventory';\n\nexport const MCP_SKILLS_SERVICE = 'po/discovered-mcp-skills';\n\nexport interface McpSkillProvider {\n list(context: PoMcpPluginContext): readonly PoMcpSkill[];\n}\n\n/** Explicit remote provider, never a projection of the local resource registry. */\nexport function mountMcpSkills(groups: readonly ServerSkillGroup[], fs: FileSystem, signal: AbortSignal) {\n return (context: Context): void => {\n context.provide(MCP_SKILLS_SERVICE, {\n list(remote) {\n signal.throwIfAborted();\n remote.signal.throwIfAborted();\n const domains = remote.selection.read().domains;\n const skills = new Map<string, PoMcpSkill>();\n for (const group of groups) {\n if (group.domains !== undefined && !group.domains.some((domain) => domains.includes(domain))) continue;\n for (const skill of group.skills) {\n // Retain name precedence defensively for remote providers.\n if (skills.has(skill.name)) continue;\n skills.set(skill.name, {\n name: skill.name,\n description: skill.description,\n async read() {\n const readSignal = AbortSignal.any([signal, remote.signal]);\n readSignal.throwIfAborted();\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(readSignal, BACKGROUND_CONTEXT)),\n );\n readSignal.throwIfAborted();\n return text;\n },\n });\n }\n }\n return [...skills.values()];\n },\n } satisfies McpSkillProvider);\n };\n}\n\nexport function bindMcpSkills(context: PoMcpPluginContext): readonly PoMcpSkill[] {\n const provider = context.services.get<McpSkillProvider>(MCP_SKILLS_SERVICE);\n if (!provider) throw new Error('Discovered MCP skills are unavailable.');\n return provider.list(context);\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { Worker } from 'node:worker_threads';\n\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport {\n type BuildSystemPromptOptions,\n formatSkillsForPrompt,\n getAgentDir,\n loadSkills,\n type Skill,\n stripFrontmatter,\n} from '@earendil-works/pi-coding-agent';\n\nimport type { DeferredSkillLoaderOptions, DeferredSkillSnapshot } from '../../types/skills';\n\nexport type { DeferredSkillLoaderOptions, DeferredSkillSnapshot } from '../../types/skills';\n\nconst PI_PACKAGE = '@earendil-works/pi-coding-agent';\nconst PACKAGE_MANIFEST = 'package.json';\n// A fresh worker takes ~240 ms to import Pi's main entry but ~20 ms for this module alone, and\n// every session spawns one. ponytail: not in Pi's exports map, so a Pi release that moves it\n// falls back to the main entry (slow, still correct); deferredSkills.test.ts pins the path.\nconst PI_SKILLS_MODULE = path.join('dist', 'core', 'skills.js');\nconst SKILL_WORKER_SOURCE = `\nconst { parentPort, workerData } = require('node:worker_threads');\nvoid (async () => {\n try {\n const { loadSkills } = await import(workerData.piModuleUrl);\n parentPort.postMessage({ ok: true, result: loadSkills(workerData.loadOptions) });\n } catch (error) {\n parentPort.postMessage({ ok: false, error: error instanceof Error ? error.message : String(error) });\n }\n})();\n`;\n\nasync function installedPiModuleUrl(): Promise<string> {\n const anchors = [process.argv[1], fileURLToPath(import.meta.url), path.join(process.cwd(), PACKAGE_MANIFEST)];\n for (const anchor of anchors) {\n if (!anchor) continue;\n let directory = path.dirname(path.resolve(anchor));\n while (true) {\n const packageRoot = path.join(directory, 'node_modules', PI_PACKAGE);\n const manifestPath = path.join(packageRoot, PACKAGE_MANIFEST);\n try {\n const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8')) as { main?: unknown };\n if (typeof manifest.main === 'string') {\n const entry = path.resolve(packageRoot, manifest.main);\n const skills = path.join(packageRoot, PI_SKILLS_MODULE);\n for (const candidate of [skills, entry]) {\n try {\n await fs.access(candidate);\n return pathToFileURL(candidate).href;\n } catch {\n // Try the next entry before walking up the module chain.\n }\n }\n }\n } catch {\n // This anchor does not expose Pi at this level; continue up its module chain.\n }\n const parent = path.dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n }\n throw new Error(`Cannot resolve ${PI_PACKAGE} from the Po or host module trees`);\n}\n\ninterface SkillWorkerResult {\n ok: boolean;\n result?: { skills: Skill[]; diagnostics: Array<{ path?: string; message: string }> };\n error?: string;\n}\n\n/**\n * One session's Po-selected skill inventory.\n *\n * Construction is deliberately cheap. `start()` schedules the synchronous Pi\n * walker after session_start returns, while `ready()` is the single promise the\n * first input awaits before Pi expands `/skill:name`.\n */\nexport class DeferredSkillLoader {\n readonly #options: DeferredSkillLoaderOptions;\n #promise: Promise<DeferredSkillSnapshot> | undefined;\n\n constructor(options: DeferredSkillLoaderOptions) {\n this.#options = options;\n }\n\n start(): Promise<DeferredSkillSnapshot> {\n if (this.#promise) return this.#promise;\n\n if (!this.#options.schedule && !this.#options.load) {\n this.#promise = this.#loadInWorker();\n return this.#promise;\n }\n\n const schedule = this.#options.schedule ?? ((load: () => void) => setImmediate(load));\n this.#promise = new Promise((resolve) => {\n const fail = (error: unknown): void => {\n resolve(this.#failure(error));\n };\n try {\n schedule(() => {\n try {\n resolve(this.#load());\n } catch (error) {\n fail(error);\n }\n });\n } catch (error) {\n fail(error);\n }\n });\n return this.#promise;\n }\n\n ready(): Promise<DeferredSkillSnapshot> {\n return this.start();\n }\n\n #loadOptions(): { cwd: string; agentDir: string; skillPaths: string[]; includeDefaults: boolean } {\n return {\n cwd: this.#options.cwd,\n agentDir: this.#options.agentDir ?? getAgentDir(),\n skillPaths: [...this.#options.skillPaths],\n includeDefaults: false,\n };\n }\n\n #snapshot(result: {\n skills: Skill[];\n diagnostics: Array<{ path?: string; message: string }>;\n }): DeferredSkillSnapshot {\n return {\n skills: result.skills,\n diagnostics: result.diagnostics.map(\n (diagnostic) => `${diagnostic.path ?? this.#options.cwd}: ${diagnostic.message}`,\n ),\n };\n }\n\n #failure(error: unknown): DeferredSkillSnapshot {\n return {\n skills: [],\n diagnostics: [`${this.#options.cwd}: ${error instanceof Error ? error.message : String(error)}`],\n };\n }\n\n #load(): DeferredSkillSnapshot {\n return this.#snapshot((this.#options.load ?? loadSkills)(this.#loadOptions()));\n }\n\n async #loadInWorker(): Promise<DeferredSkillSnapshot> {\n let piModuleUrl: string;\n try {\n piModuleUrl = this.#options.piModuleUrl ?? (await installedPiModuleUrl());\n } catch (error) {\n return this.#failure(error);\n }\n return new Promise((resolve) => {\n let settled = false;\n const settle = (snapshot: DeferredSkillSnapshot): void => {\n if (settled) return;\n settled = true;\n resolve(snapshot);\n };\n let worker: Worker;\n try {\n worker = new Worker(SKILL_WORKER_SOURCE, {\n eval: true,\n workerData: {\n piModuleUrl,\n loadOptions: this.#loadOptions(),\n },\n });\n } catch (error) {\n settle(this.#failure(error));\n return;\n }\n worker.unref();\n worker.once('message', (message: SkillWorkerResult) => {\n if (!message.ok || !message.result) {\n settle(this.#failure(message.error ?? 'Skill worker failed'));\n return;\n }\n settle(this.#snapshot(message.result));\n });\n worker.once('error', (error) => settle(this.#failure(error)));\n worker.once('exit', (code) => {\n if (code !== 0) settle(this.#failure(`Skill worker exited with code ${code}`));\n });\n });\n }\n}\n\n/** Appends only the inventory Pi would append for these deferred skills. */\nexport function buildPromptWithDeferredSkills(\n systemPrompt: string,\n options: BuildSystemPromptOptions,\n skills: Skill[],\n): string {\n if (options.selectedTools && !options.selectedTools.includes('read')) return systemPrompt;\n return `${systemPrompt}${formatSkillsForPrompt(skills)}`;\n}\n\n/**\n * Expands a deferred `/skill:name` before Pi consults its synchronous inventory. Node discovered the\n * skill on the host disk, so it reads it there; the edge build reads through `fs` instead.\n */\nexport async function expandDeferredSkillCommand(\n text: string,\n skills: readonly Skill[],\n _fs?: FileSystem,\n): Promise<string> {\n if (!text.startsWith('/skill:')) return text;\n const spaceIndex = text.indexOf(' ');\n const skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);\n const skill = skills.find((candidate) => candidate.name === skillName);\n if (!skill) return text;\n\n try {\n const args = spaceIndex === -1 ? '' : text.slice(spaceIndex + 1).trim();\n const body = stripFrontmatter(await fs.readFile(skill.filePath, 'utf8')).trim();\n const skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n return args ? `${skillBlock}\\n\\n${args}` : skillBlock;\n } catch {\n // Pi uses the same literal-text fallback if a skill disappears between\n // discovery and submission; the agent can still respond to the command.\n return text;\n }\n}\n","import path from 'node:path';\n\nimport type { PluginEntry } from '@agimon-ai/po-config/domains';\nimport type { PoHeadlessCondition } from '@agimon-ai/po-core/headless';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Skill } from '@earendil-works/pi-coding-agent';\n\nimport type { ServerSkillGroup } from '../../types/skills';\n\n/**\n * Each condition that activates a group: its domains, then each plugin turned on for this session only.\n * Declare one contribution per condition; the host keeps one per name once gating has run.\n */\nexport function groupConditions(group: ServerSkillGroup): (PoHeadlessCondition | undefined)[] {\n return [\n group.domains === undefined ? undefined : { domains: group.domains },\n // `plugins` is po-domain's session state key, spelled out so this runs on hosts with an older po-core.\n ...(group.plugins ?? []).map((plugin) => ({ state: { plugins: plugin } })),\n ];\n}\n/**\n * Skill paths one domain admits, or one plugin's session-only activation (`plugin`), or the repository when\n * neither is set.\n */\nexport interface SkillSource {\n readonly domain?: string;\n readonly plugin?: string;\n readonly paths: readonly string[];\n readonly mcpPaths: readonly string[];\n}\n\nconst LOCAL_ONLY_MCP_PACKAGES = new Set([\n '@agimon-ai/po-author',\n '@agimon-ai/po-git',\n '@agimon-ai/po-goal',\n '@agimon-ai/po-help',\n '@agimon-ai/po-calendar',\n '@agimon-ai/po-user-feedback',\n '@agimon-ai/po-voice',\n '@agimon-ai/po-workflow',\n]);\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport async function isMcpSkillPlugin(fs: FileSystem, entry: PluginEntry, context: IoContext): Promise<boolean> {\n if (entry.source?.type === 'npm') return !LOCAL_ONLY_MCP_PACKAGES.has(entry.source.package);\n // A package manifest is optional for catalog plugins, but a present identity\n // that cannot be read or parsed must never make the plugin remotely eligible.\n const source = await fs.readTextFile(path.join(entry.directory, 'package.json'), context);\n if (!source.ok) return source.error.code === 'not_found';\n try {\n const manifest = JSON.parse(source.value) as unknown;\n if (typeof manifest !== 'object' || manifest === null || Array.isArray(manifest)) return false;\n const name = (manifest as { name?: unknown }).name;\n return typeof name === 'string' && name.length > 0 && name.trim() === name && !LOCAL_ONLY_MCP_PACKAGES.has(name);\n } catch {\n return false;\n }\n}\n\n/**\n * Whether a discovered skill came from one of these paths.\n *\n * A source holds exact SKILL.md files for plugin and shared skills, but a bare\n * directory for `.po/skills`, so membership is containment rather than\n * equality.\n */\nexport function within(filePath: string, roots: readonly string[]): boolean {\n const resolved = path.resolve(filePath);\n return roots.some((root) => {\n const base = path.resolve(root);\n return resolved === base || resolved.startsWith(`${base}${path.sep}`);\n });\n}\n\n/**\n * One group per loaded skill, merging every source admitting that exact path.\n * MCP admission is merged separately so local-only sources cannot broaden it.\n */\nexport function groupSkills(\n skills: readonly Skill[],\n sources: readonly SkillSource[],\n key: 'paths' | 'mcpPaths',\n): ServerSkillGroup[] {\n return skills.flatMap((skill) => {\n const admitting = sources.filter((source) => within(skill.filePath, source[key]));\n if (admitting.length === 0) return [];\n const domains = [...new Set(admitting.flatMap((source) => (source.domain === undefined ? [] : [source.domain])))];\n const plugins = [...new Set(admitting.flatMap((source) => (source.plugin === undefined ? [] : [source.plugin])))];\n const repository = admitting.some((source) => source.domain === undefined && source.plugin === undefined);\n return [\n {\n ...(repository ? {} : { domains }),\n ...(repository || plugins.length === 0 ? {} : { plugins }),\n skills: [skill],\n },\n ];\n });\n}\n","import path from 'node:path';\n\nimport {\n domainNamesOf,\n loadDomainsAsync,\n resolveManifestPluginEntriesAsync,\n sharedSkillsFor,\n} from '@agimon-ai/po-config/domains';\nimport { readHarnessState } from '@agimon-ai/po-config/harnessState';\nimport type { PoHeadlessExecutionContext } from '@agimon-ai/po-core/headless';\nimport { BACKGROUND_CONTEXT, nodeHost, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { collectResources, discoverSkillsAsync, type NamedResource } from '@agimon-ai/po-domain/resources';\nimport { formatSkillsForPrompt } from '@earendil-works/pi-coding-agent';\n\nimport type { ServerSkillInventory } from '../../types/skills';\nimport { DeferredSkillLoader } from '../deferredSkills';\nimport { groupSkills, isMcpSkillPlugin, type SkillSource, within } from './grouping';\n\nexport type { ServerSkillGroup, ServerSkillInventory } from '../../types/skills';\n\n/**\n * Every skill the session could reach, grouped by what activates it.\n *\n * A cockpit `/domains` switch reconciles contributions rather than rebuilding\n * the server plugin: the session declaration is mounted once. So enumerating only the\n * launch selection would freeze the command list at whatever was selected when\n * the session host was built. Enumerating every domain up front and tagging\n * each group with its `when` lets the existing kernel refresh do the work, the\n * same way other host contributions follow selection changes.\n */\nexport async function discoverServerSkills(\n execution: PoHeadlessExecutionContext,\n fs: FileSystem,\n signal: AbortSignal,\n): Promise<ServerSkillInventory> {\n signal.throwIfAborted();\n const context = withAbortSignal(signal, BACKGROUND_CONTEXT);\n const state = readHarnessState(execution.environment);\n const home = execution.environment.HOME ?? nodeHost.homeDirectory();\n const repoSkills = path.join(execution.repoRoot, '.po', 'skills');\n const sources: SkillSource[] = [];\n const diagnostics: string[] = [];\n const descriptors = new Map<string, NamedResource>();\n // A malformed domain is a configuration error in one domain, so it must not\n // remove every other domain's skills. Enumerating the whole manifest is new\n // exposure here: reading the launch selection could not fail this way.\n const manifest = await loadDomainsAsync(fs, execution.repoRoot, context, home, execution.environment).catch(\n (error: unknown) => {\n diagnostics.push(`Domain skills are unavailable: ${error instanceof Error ? error.message : String(error)}`);\n return undefined;\n },\n );\n const domains = manifest ? domainNamesOf(manifest) : [];\n\n // Plugin sources precede shared sources, then repository sources.\n // ponytail: Pi globally name-dedupes before domain gating. A loaded plugin\n // shadows a same-name shared fallback even when its domain is off. This is\n // the current ceiling; upgrade to selection-aware loading if collisions arise.\n // Reuse only immutable discovery paths within this invocation. The key keeps\n // plugin ordering and subsets; fs, repo, home and admitted environment are\n // fixed here. No inventory, cleanup handle or session state survives a call.\n const discovered = new Map<\n string,\n Readonly<{ paths: readonly string[]; mcpPaths: readonly string[]; plugins: readonly SkillSource[] }>\n >();\n if (manifest) {\n for (const domain of domains) {\n signal.throwIfAborted();\n try {\n const plugins = await materializePluginEntries(\n await resolveManifestPluginEntriesAsync(fs, manifest, [domain], [], context, home),\n { homeDirectory: home, environment: execution.environment },\n );\n const key = JSON.stringify(\n plugins.map(({ directory, skillDiscovery, skills, source }) => ({\n directory,\n skillDiscovery,\n skills,\n source,\n })),\n );\n const previous = discovered.get(key);\n if (previous) {\n sources.push({ domain, paths: [...previous.paths], mcpPaths: [...previous.mcpPaths] }, ...previous.plugins);\n continue;\n }\n const mcpPluginRoots = (\n await Promise.all(\n plugins.map(async (plugin) =>\n (await isMcpSkillPlugin(fs, plugin, context)) ? path.join(plugin.directory, 'skills') : undefined,\n ),\n )\n ).filter((root): root is string => root !== undefined);\n const collected = await collectResources(execution.repoRoot, plugins, {\n agents: false,\n discoverAgents: false,\n mcp: false,\n sharedSkills: false,\n environment: execution.environment,\n });\n try {\n for (const descriptor of collected.skillSources) descriptors.set(descriptor.path, descriptor);\n const paths = Object.freeze([...collected.skillDirectories]);\n // Exact collected paths retain this domain's per-plugin skill subset.\n // A plugin root would also admit skills loaded for another domain.\n const mcpPaths = Object.freeze(paths.filter((skillPath) => within(skillPath, mcpPluginRoots)));\n // The same skills, admitted one plugin at a time for session-only activation. Never remote: no mcpPaths.\n const pluginSources = plugins.flatMap(({ name, directory }) => {\n const own = paths.filter((skillPath) => within(skillPath, [directory]));\n return name === undefined || own.length === 0 ? [] : [{ plugin: name, paths: own, mcpPaths: [] }];\n });\n discovered.set(key, Object.freeze({ paths, mcpPaths, plugins: pluginSources }));\n if (paths.length > 0) sources.push({ domain, paths: [...paths], mcpPaths: [...mcpPaths] }, ...pluginSources);\n } finally {\n await collected.cleanup();\n }\n } catch (error) {\n diagnostics.push(`Domain '${domain}': ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n }\n\n // Shared skills are admitted by any domain that keeps them.\n signal.throwIfAborted();\n const shared = await discoverSkillsAsync(\n execution.repoRoot,\n path.join(execution.repoRoot, '.claude', 'skills'),\n 'recursive',\n undefined,\n execution.environment,\n );\n for (const descriptor of shared) descriptors.set(descriptor.path, descriptor);\n for (const descriptor of await discoverSkillsAsync(\n execution.repoRoot,\n repoSkills,\n 'recursive',\n undefined,\n execution.environment,\n ))\n descriptors.set(descriptor.path, descriptor);\n if (shared.length > 0 && manifest) {\n const sharedPaths = shared.map((skill) => skill.path);\n for (const domain of domains) {\n if (sharedSkillsFor(manifest, [domain])) {\n sources.push({ domain, paths: sharedPaths, mcpPaths: sharedPaths });\n }\n }\n }\n\n // Repository-local skills belong to the repository, not to a selection.\n sources.push({ paths: [repoSkills], mcpPaths: [repoSkills] });\n\n signal.throwIfAborted();\n // One walk for every group. Pi drops a path it has already loaded, so the\n // loader gets the unique set and each group selects its own skills back out.\n const unique = [...new Set([...sources.flatMap((source) => source.paths), ...(state.skillDirectories ?? [])])];\n const inventory = await new DeferredSkillLoader({ cwd: execution.cwd, skillPaths: unique }).ready();\n signal.throwIfAborted();\n\n for (const descriptor of descriptors.values()) {\n for (const diagnostic of descriptor.diagnostics ?? []) diagnostics.push(`${descriptor.path}: ${diagnostic}`);\n }\n const groups = groupSkills(inventory.skills, sources, 'paths');\n const mcpGroups = groupSkills(inventory.skills, sources, 'mcpPaths');\n\n // The catalog still describes the active selection rather than everything on\n // disk, because it is prompt text rather than a menu.\n const activeSkills = inventory.skills.filter((skill) =>\n within(skill.filePath, [...(state.skillDirectories ?? []), repoSkills]),\n );\n return {\n inventory: { skills: inventory.skills, diagnostics: [...inventory.diagnostics, ...diagnostics] },\n groups,\n mcpGroups,\n relations: Object.fromEntries(\n [...descriptors].map(([filePath, descriptor]) => [filePath, descriptor.relations ?? []]),\n ),\n catalog: formatSkillsForPrompt(activeSkills) || '(no discovered skills)',\n };\n}\n","import { Type } from 'typebox';\n\nexport const searchSkillsParameters = Type.Object({ query: Type.Optional(Type.String()) });\nexport const loadSkillParameters = Type.Object({ name: Type.String() });\n","import { rankText } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessHostService, PoHeadlessTool } from '@agimon-ai/po-core/headless';\n\nimport { loadSkillParameters, searchSkillsParameters } from '../../schemas/mcpSkillTools';\n\nfunction text(text: string) {\n return { content: [{ type: 'text' as const, text }] };\n}\n\nfunction skills(context: Parameters<PoHeadlessTool['execute']>[4]) {\n if (context.mcpSkills === undefined) throw new Error('Remote skill access is unavailable.');\n return context.mcpSkills;\n}\n\n/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */\nexport function matchSkills<T extends { name: string; description: string }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n const needle = query?.trim().toLocaleLowerCase();\n if (needle === undefined || needle === '') return [...skills];\n return skills.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\n}\n\n/** Best match first by name, then description, active before inactive; an empty query keeps everything, in order. */\nexport function rankSkills<T extends { name: string; description: string; active?: boolean }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n if (query === undefined || query.trim() === '') return [...skills];\n const ranked = rankText(\n query,\n skills.map((skill) => ({ id: skill.name, name: skill.name, doc: skill.description, skill })),\n ).map(({ skill }) => skill);\n return [...ranked.filter((skill) => skill.active !== false), ...ranked.filter((skill) => skill.active === false)];\n}\n\n/** Pinned guides are listed in the system prompt, so only a real search needs them. */\nexport function searchesPinned(query: string | undefined): boolean {\n return query !== undefined && query.trim() !== '';\n}\n\nexport function createSearchSkillsTool(): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Discover repository and active-domain skills available to this remote connection.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { query }, _signal, _onUpdate, context) {\n const matches = matchSkills(await skills(context).list(), query);\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionSearchSkillsTool(\n host: Pick<PoHeadlessHostService, 'listSkills'>,\n): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Search available session skills by name or description.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n executionMode: 'parallel',\n async execute(_toolCallId, { query }) {\n const matches = rankSkills(\n host\n .listSkills({ includePinned: searchesPinned(query) })\n .map(({ name, description }) => ({ name, description })),\n query,\n );\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionLoadSkillTool(\n host: Pick<PoHeadlessHostService, 'readSkill'>,\n): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n // PO_LOAD_SKILL_TOOL, spelled out so the renderer rule can read it.\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full instructions of an available session skill by exact name.',\n parameters: loadSkillParameters,\n executionMode: 'parallel',\n async execute(_toolCallId, { name }) {\n const body = host.readSkill(name);\n if (body === undefined) return { ...text(`No skill named ${name} is available in this session.`), isError: true };\n return text(body);\n },\n };\n}\n\nexport function createLoadSkillTool(): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full Markdown instructions for an available remote skill by exact name.',\n parameters: loadSkillParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { name }, _signal, _onUpdate, context) {\n return text(await skills(context).read(name));\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode, type PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\nimport { PO_SKILLS_NAMESPACE, type PoHeadlessHostService } from '@agimon-ai/po-core/headless';\nimport {\n BACKGROUND_CONTEXT,\n getOrThrow,\n PO_ISOLATE_SERVICE,\n readPoIsolate,\n withAbortSignal,\n type FileSystem,\n} from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { DeferredSkillSnapshot } from '../../types/skills';\nimport {\n createSessionLoadSkillTool,\n createSessionSearchSkillsTool,\n rankSkills,\n searchesPinned,\n} from '../mcpSkillTools';\n\nexport const SKILL_NAMESPACE_SOURCE = '@agimon-ai/po-skill';\n\ninterface SkillMatch {\n name: string;\n description: string;\n active: boolean;\n}\n\nfunction queryOf(input: unknown): string | undefined {\n if (input === undefined) return undefined;\n const query = typeof input === 'object' && input !== null ? (input as { query?: unknown }).query : 0;\n if (query === undefined || typeof query === 'string') return query;\n throw new Error('Pass { query?: string }.');\n}\n\nfunction nameOf(input: unknown): string {\n const name = (input as { name?: unknown } | null)?.name;\n if (typeof name !== 'string' || name.trim() === '')\n throw new Error('Pass { name: string }, a name from skills.search.');\n return name;\n}\n\n/**\n * Skills of every domain in domains.yaml, selected or not, plus the session's own. Reading one never selects its\n * domain or plugin, so it grants no tools, hooks or MCP servers. Disabled plugins never reach the inventory.\n */\nexport function createSkillNamespace(\n host: Pick<PoHeadlessHostService, 'listSkills' | 'readSkill' | 'context'>,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem,\n): PoCodemodeNamespace {\n return {\n name: PO_SKILLS_NAMESPACE,\n summary: 'Search and read skills beyond the active set, including unselected domains. Reading enables nothing.',\n declarations: `declare const skills: {\n /** Active skills first, then skills of unselected domains. Omit query to list everything. */\n search(input?: { query?: string }): Promise<{ name: string; description: string; active: boolean }[]>;\n /** Full SKILL.md text by exact name from search. Grants no tools, hooks or MCP servers. */\n load(input: { name: string }): Promise<string>;\n};`,\n bind(run) {\n if (run.sessionId !== host.context.sessionId) throw new Error('Skills namespace belongs to another session.');\n let disposed = false;\n run.onDispose(() => {\n disposed = true;\n });\n const check = () => {\n if (disposed) throw new Error('Skills namespace run is disposed.');\n run.signal.throwIfAborted();\n };\n return {\n async search(input?: unknown): Promise<SkillMatch[]> {\n const query = queryOf(input);\n check();\n const seen = new Set<string>();\n const all: SkillMatch[] = [];\n for (const { name, description } of host.listSkills({ includePinned: searchesPinned(query) })) {\n seen.add(name);\n all.push({ name, description, active: true });\n }\n for (const { name, description } of inventory.skills)\n if (!seen.has(name)) all.push({ name, description, active: false });\n return rankSkills(all, query);\n },\n async load(input: unknown): Promise<string> {\n const name = nameOf(input);\n check();\n const active = host.readSkill(name);\n if (active !== undefined) return active;\n // Exact inventory names only, so a script can never steer the read to another path.\n const skill = inventory.skills.find((entry) => entry.name === name);\n if (!skill) throw new Error(`No skill named ${name}. Use skills.search to find one.`);\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(run.signal, BACKGROUND_CONTEXT)),\n );\n check();\n return text;\n },\n };\n },\n };\n}\n\nexport function mountSkillNamespace(\n host: Pick<PoHeadlessHostService, 'listSkills' | 'readSkill' | 'context' | 'registerTool'>,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem,\n) {\n return (context: Context): void => {\n // The direct tools stay only where exec cannot bind this non-portable namespace, which covers both.\n // Registered here rather than restricted, so the remote MCP load_skill and search_skills stay.\n const tools = [\n host.registerTool(createSessionLoadSkillTool(host)),\n host.registerTool(createSessionSearchSkillsTool(host)),\n ];\n const withdraw = () => {\n for (const tool of tools.splice(0)) tool.dispose();\n };\n context.effect(() => withdraw, 'session skill tools');\n context.inject([PO_CODEMODE_SERVICE, PO_ISOLATE_SERVICE], (bound) => {\n const codemode = readPoCodemode(bound);\n if (!codemode) return undefined;\n const registration = codemode.register(SKILL_NAMESPACE_SOURCE, createSkillNamespace(host, inventory, fs));\n // ponytail: the tools do not come back if code mode leaves mid-session; the next session has them.\n if (readPoIsolate(bound)?.liveObjects === true) withdraw();\n return () => registration.dispose();\n });\n };\n}\n","import type { PoHeadlessCommand, PoHeadlessCondition } from '@agimon-ai/po-core/headless';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Skill } from '@earendil-works/pi-coding-agent';\n\nimport { expandDeferredSkillCommand, type DeferredSkillSnapshot } from '../../../../../services/deferredSkills';\nimport type { ServerSkillGroup } from '../../../../../services/serverInventory';\nimport { groupConditions } from '../../../../../services/serverInventory/grouping';\nimport { SKILL_COMMAND_PREFIX, SKILL_INVOCATION_PREFIX, SKILLS_COMMAND } from '../../../../../types/skills';\n\n/**\n * One command per skill, gated by whatever activates that skill.\n *\n * Expansion always reads the full inventory, not the group: a command is only\n * dispatchable while its condition holds, so by the time one runs its skill is\n * active, and looking it up in the union keeps one lookup table instead of one\n * per domain.\n */\nfunction skillCommand(\n skill: Skill,\n when: PoHeadlessCondition | undefined,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem | undefined,\n): PoHeadlessCommand {\n return {\n ...(when === undefined ? {} : { when }),\n name: `${SKILL_COMMAND_PREFIX}${skill.name}`,\n description: skill.description,\n execute: async (args, execution) => {\n const text = `${SKILL_INVOCATION_PREFIX}${skill.name}${args ? ` ${args}` : ''}`;\n const expanded = await expandDeferredSkillCommand(text, inventory.skills, fs);\n if (expanded === text) throw new Error(`Skill '${skill.name}' is no longer readable.`);\n await admit(execution.session, expanded);\n },\n };\n}\n\n/**\n * The dispatching prompt acks when this command returns, so awaiting the whole\n * turn (session.prompt) kept the composer draft until the run ended.\n */\nfunction admit(session: Parameters<PoHeadlessCommand['execute']>[1]['session'], text: string): Promise<void> {\n return session.admitPrompt ? session.admitPrompt(text, 'prompt', 'operator') : session.prompt(text);\n}\nexport function createSkillCommands(\n inventory: DeferredSkillSnapshot,\n catalog: string,\n groups: readonly ServerSkillGroup[],\n fs?: FileSystem,\n t: (key: string, fallback: string) => string = (_key, fallback) => fallback,\n): readonly PoHeadlessCommand[] {\n return [\n {\n name: SKILLS_COMMAND,\n description: 'List discovered skills or invoke one by name.',\n async execute(args, execution) {\n const requested = args.trim();\n if (requested) {\n await admit(\n execution.session,\n await expandDeferredSkillCommand(`${SKILL_INVOCATION_PREFIX}${requested}`, inventory.skills, fs),\n );\n return;\n }\n await execution.client.notify({\n title: t('skill.notification.catalog', 'Po skills'),\n localization: { title: { key: 'skill.notification.catalog', fallback: 'Po skills' } },\n body: catalog,\n level: 'info',\n });\n },\n },\n ...groups.flatMap((group) =>\n groupConditions(group).flatMap((when) => group.skills.map((skill) => skillCommand(skill, when, inventory, fs))),\n ),\n ];\n}\n","import { readHarnessState } from '@agimon-ai/po-config/harnessState';\nimport type { PoHeadlessHostService } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { BACKGROUND_CONTEXT, getOrThrow, nodeHost, type FileSystem } from '@agimon-ai/po-core/platform';\nimport {\n type PoServerResources,\n type PoServerSessionPlugin,\n packageResourcePath,\n readPackageResource,\n} from '@agimon-ai/po-core/serverPlugin';\n\nimport { SKILL_INVENTORY_FRESH_MS } from '../../../../../constants/skillInventory';\nimport { mountMcpSkills } from '../../../../../services/mcpSkills';\nimport { discoverServerSkills } from '../../../../../services/serverInventory';\nimport { groupConditions } from '../../../../../services/serverInventory/grouping';\nimport { mountSkillNamespace } from '../../../../../services/skillNamespace';\nimport { createSkillCommands } from './skillCommands';\n\nexport async function createSkillServer(\n agent: PoHeadlessHostService,\n fs: FileSystem,\n signal: AbortSignal,\n resources: PoServerResources,\n t?: (key: string, fallback: string) => string,\n): Promise<PoServerSessionPlugin> {\n const execution = agent.context;\n // Sessions with the same inputs share one discovery. The key holds every input discoverServerSkills\n // reads besides the disk, so equal keys give equal inventories, and the window bounds how old that\n // read of the disk can be.\n const key = [\n 'inventory',\n execution.repoRoot,\n execution.cwd,\n execution.environment.HOME ?? nodeHost.homeDirectory(),\n ...(readHarnessState(execution.environment).skillDirectories ?? []),\n Math.floor(Date.now() / SKILL_INVENTORY_FRESH_MS),\n ];\n const { inventory, catalog, groups, mcpGroups, relations } = await resources.acquire(key, () =>\n // Every session sharing the discovery waits on it, so none of their signals may abort it.\n discoverServerSkills(execution, fs, new AbortController().signal),\n );\n return {\n commands: createSkillCommands(inventory, catalog, groups, fs, t),\n services: [mountMcpSkills(mcpGroups, fs, signal), mountSkillNamespace(agent, inventory, fs)],\n resources: [\n // Each skill joins the prompt's one <available_skills> list, gated like the rest.\n ...groups.flatMap((group) =>\n groupConditions(group).flatMap((when) =>\n group.skills.map((skill) => ({\n name: skill.name,\n description: skill.description,\n path: skill.filePath,\n kind: 'skill' as const,\n ...(relations?.[skill.filePath] === undefined ? {} : { relations: relations[skill.filePath] }),\n ...(when === undefined ? {} : { when }),\n read: async () => getOrThrow(await fs.readTextFile(skill.filePath, BACKGROUND_CONTEXT)),\n })),\n ),\n ),\n ...[\n {\n name: 'help-how-to-author-skill',\n description:\n 'Author and distribute Po agent skills. Use when creating a SKILL.md, contributing a runtime skill directory, or publishing activation-gated Help prompts and diagnostic tools.',\n },\n {\n name: 'help-how-to-skill',\n description:\n \"Use Po's skill catalog and deferred discovery. Diagnose missing or shadowed skills and invoke the narrowest available guidance.\",\n },\n ].map((skill) => ({\n ...skill,\n when: PO_HELP_WHEN,\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, `src/prompts/${skill.name}/SKILL.md`),\n read: () => readPackageResource(import.meta.url, `src/prompts/${skill.name}/SKILL.md`),\n })),\n ],\n };\n}\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { readPoLang, readPoPersonLocale } from '@agimon-ai/po-core/locale';\nimport { requirePoFs } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createSkillServer } from './_lib/skillServer';\n\nexport default defineRoot(async ({ agent, context: root, signal, resources }: PoServerPluginContext) => {\n const runtime: PoServerSessionPlugin = agent\n ? await createSkillServer(\n agent,\n requirePoFs(root),\n signal,\n resources,\n (key, fallback) => readPoLang(root)?.t(readPoPersonLocale(root)?.read(), key, fallback) ?? fallback,\n )\n : { commands: [], resources: [] };\n return { value: runtime, services: runtime.services };\n});\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.commands!,\n { cardinality: 'many' },\n);\n","// @scaffold-generated\nimport { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n name: 'codemode-how-to-skills',\n description:\n 'Search and load any skill by name through the skills namespace: the listed ones, the rest of the active catalog, and skills of unselected domains. Use before a task that a skill may cover.',\n // A code-mode guide: listed in the system prompt, outside the searchable catalog.\n pinned: true,\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/codemode-how-to-skills/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/codemode-how-to-skills/SKILL.md'),\n});\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.resources!,\n { cardinality: 'many' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandSkills from '../src/extensions/workspaces/sessions/(backend)/command/skills.server';\nimport resourceCodemodeHowToSkills from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server';\nimport resourceSkills from '../src/extensions/workspaces/sessions/(backend)/resource/skills.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\ntype ManyFactory<T, C> = (context: C) => T | readonly T[];\nconst many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {\n const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\n return Array.isArray(resolved) ? resolved : [resolved as T];\n};\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-skill',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return [...many(commandSkills, contextSession)]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceCodemodeHowToSkills, contextSession), ...many(resourceSkills, contextSession)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAa,2BAA2B;;;ACCxC,MAAa,qBAAqB;;AAOlC,SAAgB,eAAe,QAAqC,IAAgB,QAAqB;CACvG,QAAQ,YAA2B;EACjC,QAAQ,QAAQ,oBAAoB,EAClC,KAAK,QAAQ;GACX,OAAO,eAAe;GACtB,OAAO,OAAO,eAAe;GAC7B,MAAM,UAAU,OAAO,UAAU,KAAK,CAAC,CAAC;GACxC,MAAM,yBAAS,IAAI,IAAwB;GAC3C,KAAK,MAAM,SAAS,QAAQ;IAC1B,IAAI,MAAM,YAAY,KAAA,KAAa,CAAC,MAAM,QAAQ,MAAM,WAAW,QAAQ,SAAS,MAAM,CAAC,GAAG;IAC9F,KAAK,MAAM,SAAS,MAAM,QAAQ;KAEhC,IAAI,OAAO,IAAI,MAAM,IAAI,GAAG;KAC5B,OAAO,IAAI,MAAM,MAAM;MACrB,MAAM,MAAM;MACZ,aAAa,MAAM;MACnB,MAAM,OAAO;OACX,MAAM,aAAa,YAAY,IAAI,CAAC,QAAQ,OAAO,MAAM,CAAC;OAC1D,WAAW,eAAe;OAC1B,MAAM,QAAA,GAAOA,4BAAAA,WAAAA,CACX,MAAM,GAAG,aAAa,MAAM,WAAA,GAAUC,4BAAAA,gBAAAA,CAAgB,YAAYC,4BAAAA,kBAAkB,CAAC,CACvF;OACA,WAAW,eAAe;OAC1B,OAAO;MACT;KACF,CAAC;IACH;GACF;GACA,OAAO,CAAC,GAAG,OAAO,OAAO,CAAC;EAC5B,EACF,CAA4B;CAC9B;AACF;;;AC1BA,MAAM,aAAa;AACnB,MAAM,mBAAmB;AAIzB,MAAM,mBAAmBC,UAAAA,QAAK,KAAK,QAAQ,QAAQ,WAAW;AAC9D,MAAM,sBAAsB;;;;;;;;;;;AAY5B,eAAe,uBAAw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AClF,EAAE,aAAa,OAAO,CACxB;;;ACIA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AAEpE,MAAM,QAAc,OAA6C,YAA6B;CAC5F,MAAM,WAAW,OAAO,UAAU,aAAc,MAA4B,OAAO,IAAI;CACvF,OAAO,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAa;AAC5D;AAEA,MAAa,gBAAA,GAAeC,gCAAAA,mBAAAA,CAAmB;CAC7C,MAAM;CACN,oBAAA,GAAmBC,gCAAAA,+BAAAA,CAA+BC,mBAAW;CAC7D,UAAA,GAASC,iCAAAA,mBAAAA,CAAmB,EAAE,SAAS,CAACD,mBAAW,EAAE,CAAC;CACtD,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAM,QAAQ,UAAU,WAAWA,qBAAa,OAAO;EAC5E,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,IAAA,GAAGE,iCAAAA,iBAAAA,CAAiB,YAAY;GAChC,IAAI,WAA8C;IAAE,OAAO,CAAC,GAAG,KAAKC,yBAAe,cAAc,CAAC;GAAG;GACrG,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGC,uCAA6B,cAAc,GAAG,GAAG,KAAKC,uBAAgB,cAAc,CAAC;GAAG;GACzJ,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
|
|
@@ -13,7 +13,7 @@ import { collectResources, discoverSkillsAsync } from "@agimon-ai/po-domain/reso
|
|
|
13
13
|
import fs from "node:fs/promises";
|
|
14
14
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
15
|
import { Worker } from "node:worker_threads";
|
|
16
|
-
import { PO_CODEMODE_SERVICE, readPoCodemode } from "@agimon-ai/po-core/codemode";
|
|
16
|
+
import { PO_CODEMODE_SERVICE, rankText, readPoCodemode } from "@agimon-ai/po-core/codemode";
|
|
17
17
|
import { PO_SKILLS_NAMESPACE } from "@agimon-ai/po-core/headless";
|
|
18
18
|
import { Type } from "typebox";
|
|
19
19
|
//#region src/constants/skillInventory.ts
|
|
@@ -425,11 +425,20 @@ function text(text) {
|
|
|
425
425
|
text
|
|
426
426
|
}] };
|
|
427
427
|
}
|
|
428
|
-
/**
|
|
429
|
-
function
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
428
|
+
/** Best match first by name, then description, active before inactive; an empty query keeps everything, in order. */
|
|
429
|
+
function rankSkills(skills, query) {
|
|
430
|
+
if (query === void 0 || query.trim() === "") return [...skills];
|
|
431
|
+
const ranked = rankText(query, skills.map((skill) => ({
|
|
432
|
+
id: skill.name,
|
|
433
|
+
name: skill.name,
|
|
434
|
+
doc: skill.description,
|
|
435
|
+
skill
|
|
436
|
+
}))).map(({ skill }) => skill);
|
|
437
|
+
return [...ranked.filter((skill) => skill.active !== false), ...ranked.filter((skill) => skill.active === false)];
|
|
438
|
+
}
|
|
439
|
+
/** Pinned guides are listed in the system prompt, so only a real search needs them. */
|
|
440
|
+
function searchesPinned(query) {
|
|
441
|
+
return query !== void 0 && query.trim() !== "";
|
|
433
442
|
}
|
|
434
443
|
function createSessionSearchSkillsTool(host) {
|
|
435
444
|
return {
|
|
@@ -444,7 +453,7 @@ function createSessionSearchSkillsTool(host) {
|
|
|
444
453
|
},
|
|
445
454
|
executionMode: "parallel",
|
|
446
455
|
async execute(_toolCallId, { query }) {
|
|
447
|
-
const matches =
|
|
456
|
+
const matches = rankSkills(host.listSkills({ includePinned: searchesPinned(query) }).map(({ name, description }) => ({
|
|
448
457
|
name,
|
|
449
458
|
description
|
|
450
459
|
})), query);
|
|
@@ -516,7 +525,7 @@ function createSkillNamespace(host, inventory, fs) {
|
|
|
516
525
|
check();
|
|
517
526
|
const seen = /* @__PURE__ */ new Set();
|
|
518
527
|
const all = [];
|
|
519
|
-
for (const { name, description } of host.listSkills()) {
|
|
528
|
+
for (const { name, description } of host.listSkills({ includePinned: searchesPinned(query) })) {
|
|
520
529
|
seen.add(name);
|
|
521
530
|
all.push({
|
|
522
531
|
name,
|
|
@@ -529,7 +538,7 @@ function createSkillNamespace(host, inventory, fs) {
|
|
|
529
538
|
description,
|
|
530
539
|
active: false
|
|
531
540
|
});
|
|
532
|
-
return
|
|
541
|
+
return rankSkills(all, query);
|
|
533
542
|
},
|
|
534
543
|
async load(input) {
|
|
535
544
|
const name = nameOf(input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","names":["rootSession","commandSkills","resourceCodemodeHowToSkills","resourceSkills"],"sources":["../../src/constants/skillInventory.ts","../../src/services/mcpSkills/index.ts","../../src/services/deferredSkills/index.ts","../../src/services/serverInventory/grouping.ts","../../src/services/serverInventory/index.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/services/skillNamespace/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/skillCommands.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/skills.server.ts","../../generated/server.ts"],"sourcesContent":["/**\n * How long sessions with the same inputs share one skill inventory instead of each reading the disk.\n * ponytail: a skill added on disk reaches new sessions within this window, not at once; watch the\n * skill roots if that lag matters.\n */\nexport const SKILL_INVENTORY_FRESH_MS = 60_000;\n","import type { PoMcpPluginContext, PoMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { BACKGROUND_CONTEXT, getOrThrow, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { ServerSkillGroup } from '../serverInventory';\n\nexport const MCP_SKILLS_SERVICE = 'po/discovered-mcp-skills';\n\nexport interface McpSkillProvider {\n list(context: PoMcpPluginContext): readonly PoMcpSkill[];\n}\n\n/** Explicit remote provider, never a projection of the local resource registry. */\nexport function mountMcpSkills(groups: readonly ServerSkillGroup[], fs: FileSystem, signal: AbortSignal) {\n return (context: Context): void => {\n context.provide(MCP_SKILLS_SERVICE, {\n list(remote) {\n signal.throwIfAborted();\n remote.signal.throwIfAborted();\n const domains = remote.selection.read().domains;\n const skills = new Map<string, PoMcpSkill>();\n for (const group of groups) {\n if (group.domains !== undefined && !group.domains.some((domain) => domains.includes(domain))) continue;\n for (const skill of group.skills) {\n // Retain name precedence defensively for remote providers.\n if (skills.has(skill.name)) continue;\n skills.set(skill.name, {\n name: skill.name,\n description: skill.description,\n async read() {\n const readSignal = AbortSignal.any([signal, remote.signal]);\n readSignal.throwIfAborted();\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(readSignal, BACKGROUND_CONTEXT)),\n );\n readSignal.throwIfAborted();\n return text;\n },\n });\n }\n }\n return [...skills.values()];\n },\n } satisfies McpSkillProvider);\n };\n}\n\nexport function bindMcpSkills(context: PoMcpPluginContext): readonly PoMcpSkill[] {\n const provider = context.services.get<McpSkillProvider>(MCP_SKILLS_SERVICE);\n if (!provider) throw new Error('Discovered MCP skills are unavailable.');\n return provider.list(context);\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { Worker } from 'node:worker_threads';\n\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport {\n type BuildSystemPromptOptions,\n formatSkillsForPrompt,\n getAgentDir,\n loadSkills,\n type Skill,\n stripFrontmatter,\n} from '@earendil-works/pi-coding-agent';\n\nimport type { DeferredSkillLoaderOptions, DeferredSkillSnapshot } from '../../types/skills';\n\nexport type { DeferredSkillLoaderOptions, DeferredSkillSnapshot } from '../../types/skills';\n\nconst PI_PACKAGE = '@earendil-works/pi-coding-agent';\nconst PACKAGE_MANIFEST = 'package.json';\n// A fresh worker takes ~240 ms to import Pi's main entry but ~20 ms for this module alone, and\n// every session spawns one. ponytail: not in Pi's exports map, so a Pi release that moves it\n// falls back to the main entry (slow, still correct); deferredSkills.test.ts pins the path.\nconst PI_SKILLS_MODULE = path.join('dist', 'core', 'skills.js');\nconst SKILL_WORKER_SOURCE = `\nconst { parentPort, workerData } = require('node:worker_threads');\nvoid (async () => {\n try {\n const { loadSkills } = await import(workerData.piModuleUrl);\n parentPort.postMessage({ ok: true, result: loadSkills(workerData.loadOptions) });\n } catch (error) {\n parentPort.postMessage({ ok: false, error: error instanceof Error ? error.message : String(error) });\n }\n})();\n`;\n\nasync function installedPiModuleUrl(): Promise<string> {\n const anchors = [process.argv[1], fileURLToPath(import.meta.url), path.join(process.cwd(), PACKAGE_MANIFEST)];\n for (const anchor of anchors) {\n if (!anchor) continue;\n let directory = path.dirname(path.resolve(anchor));\n while (true) {\n const packageRoot = path.join(directory, 'node_modules', PI_PACKAGE);\n const manifestPath = path.join(packageRoot, PACKAGE_MANIFEST);\n try {\n const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8')) as { main?: unknown };\n if (typeof manifest.main === 'string') {\n const entry = path.resolve(packageRoot, manifest.main);\n const skills = path.join(packageRoot, PI_SKILLS_MODULE);\n for (const candidate of [skills, entry]) {\n try {\n await fs.access(candidate);\n return pathToFileURL(candidate).href;\n } catch {\n // Try the next entry before walking up the module chain.\n }\n }\n }\n } catch {\n // This anchor does not expose Pi at this level; continue up its module chain.\n }\n const parent = path.dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n }\n throw new Error(`Cannot resolve ${PI_PACKAGE} from the Po or host module trees`);\n}\n\ninterface SkillWorkerResult {\n ok: boolean;\n result?: { skills: Skill[]; diagnostics: Array<{ path?: string; message: string }> };\n error?: string;\n}\n\n/**\n * One session's Po-selected skill inventory.\n *\n * Construction is deliberately cheap. `start()` schedules the synchronous Pi\n * walker after session_start returns, while `ready()` is the single promise the\n * first input awaits before Pi expands `/skill:name`.\n */\nexport class DeferredSkillLoader {\n readonly #options: DeferredSkillLoaderOptions;\n #promise: Promise<DeferredSkillSnapshot> | undefined;\n\n constructor(options: DeferredSkillLoaderOptions) {\n this.#options = options;\n }\n\n start(): Promise<DeferredSkillSnapshot> {\n if (this.#promise) return this.#promise;\n\n if (!this.#options.schedule && !this.#options.load) {\n this.#promise = this.#loadInWorker();\n return this.#promise;\n }\n\n const schedule = this.#options.schedule ?? ((load: () => void) => setImmediate(load));\n this.#promise = new Promise((resolve) => {\n const fail = (error: unknown): void => {\n resolve(this.#failure(error));\n };\n try {\n schedule(() => {\n try {\n resolve(this.#load());\n } catch (error) {\n fail(error);\n }\n });\n } catch (error) {\n fail(error);\n }\n });\n return this.#promise;\n }\n\n ready(): Promise<DeferredSkillSnapshot> {\n return this.start();\n }\n\n #loadOptions(): { cwd: string; agentDir: string; skillPaths: string[]; includeDefaults: boolean } {\n return {\n cwd: this.#options.cwd,\n agentDir: this.#options.agentDir ?? getAgentDir(),\n skillPaths: [...this.#options.skillPaths],\n includeDefaults: false,\n };\n }\n\n #snapshot(result: {\n skills: Skill[];\n diagnostics: Array<{ path?: string; message: string }>;\n }): DeferredSkillSnapshot {\n return {\n skills: result.skills,\n diagnostics: result.diagnostics.map(\n (diagnostic) => `${diagnostic.path ?? this.#options.cwd}: ${diagnostic.message}`,\n ),\n };\n }\n\n #failure(error: unknown): DeferredSkillSnapshot {\n return {\n skills: [],\n diagnostics: [`${this.#options.cwd}: ${error instanceof Error ? error.message : String(error)}`],\n };\n }\n\n #load(): DeferredSkillSnapshot {\n return this.#snapshot((this.#options.load ?? loadSkills)(this.#loadOptions()));\n }\n\n async #loadInWorker(): Promise<DeferredSkillSnapshot> {\n let piModuleUrl: string;\n try {\n piModuleUrl = this.#options.piModuleUrl ?? (await installedPiModuleUrl());\n } catch (error) {\n return this.#failure(error);\n }\n return new Promise((resolve) => {\n let settled = false;\n const settle = (snapshot: DeferredSkillSnapshot): void => {\n if (settled) return;\n settled = true;\n resolve(snapshot);\n };\n let worker: Worker;\n try {\n worker = new Worker(SKILL_WORKER_SOURCE, {\n eval: true,\n workerData: {\n piModuleUrl,\n loadOptions: this.#loadOptions(),\n },\n });\n } catch (error) {\n settle(this.#failure(error));\n return;\n }\n worker.unref();\n worker.once('message', (message: SkillWorkerResult) => {\n if (!message.ok || !message.result) {\n settle(this.#failure(message.error ?? 'Skill worker failed'));\n return;\n }\n settle(this.#snapshot(message.result));\n });\n worker.once('error', (error) => settle(this.#failure(error)));\n worker.once('exit', (code) => {\n if (code !== 0) settle(this.#failure(`Skill worker exited with code ${code}`));\n });\n });\n }\n}\n\n/** Appends only the inventory Pi would append for these deferred skills. */\nexport function buildPromptWithDeferredSkills(\n systemPrompt: string,\n options: BuildSystemPromptOptions,\n skills: Skill[],\n): string {\n if (options.selectedTools && !options.selectedTools.includes('read')) return systemPrompt;\n return `${systemPrompt}${formatSkillsForPrompt(skills)}`;\n}\n\n/**\n * Expands a deferred `/skill:name` before Pi consults its synchronous inventory. Node discovered the\n * skill on the host disk, so it reads it there; the edge build reads through `fs` instead.\n */\nexport async function expandDeferredSkillCommand(\n text: string,\n skills: readonly Skill[],\n _fs?: FileSystem,\n): Promise<string> {\n if (!text.startsWith('/skill:')) return text;\n const spaceIndex = text.indexOf(' ');\n const skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);\n const skill = skills.find((candidate) => candidate.name === skillName);\n if (!skill) return text;\n\n try {\n const args = spaceIndex === -1 ? '' : text.slice(spaceIndex + 1).trim();\n const body = stripFrontmatter(await fs.readFile(skill.filePath, 'utf8')).trim();\n const skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n return args ? `${skillBlock}\\n\\n${args}` : skillBlock;\n } catch {\n // Pi uses the same literal-text fallback if a skill disappears between\n // discovery and submission; the agent can still respond to the command.\n return text;\n }\n}\n","import path from 'node:path';\n\nimport type { PluginEntry } from '@agimon-ai/po-config/domains';\nimport type { PoHeadlessCondition } from '@agimon-ai/po-core/headless';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Skill } from '@earendil-works/pi-coding-agent';\n\nimport type { ServerSkillGroup } from '../../types/skills';\n\n/**\n * Each condition that activates a group: its domains, then each plugin turned on for this session only.\n * Declare one contribution per condition; the host keeps one per name once gating has run.\n */\nexport function groupConditions(group: ServerSkillGroup): (PoHeadlessCondition | undefined)[] {\n return [\n group.domains === undefined ? undefined : { domains: group.domains },\n // `plugins` is po-domain's session state key, spelled out so this runs on hosts with an older po-core.\n ...(group.plugins ?? []).map((plugin) => ({ state: { plugins: plugin } })),\n ];\n}\n/**\n * Skill paths one domain admits, or one plugin's session-only activation (`plugin`), or the repository when\n * neither is set.\n */\nexport interface SkillSource {\n readonly domain?: string;\n readonly plugin?: string;\n readonly paths: readonly string[];\n readonly mcpPaths: readonly string[];\n}\n\nconst LOCAL_ONLY_MCP_PACKAGES = new Set([\n '@agimon-ai/po-author',\n '@agimon-ai/po-git',\n '@agimon-ai/po-goal',\n '@agimon-ai/po-help',\n '@agimon-ai/po-calendar',\n '@agimon-ai/po-user-feedback',\n '@agimon-ai/po-voice',\n '@agimon-ai/po-workflow',\n]);\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport async function isMcpSkillPlugin(fs: FileSystem, entry: PluginEntry, context: IoContext): Promise<boolean> {\n if (entry.source?.type === 'npm') return !LOCAL_ONLY_MCP_PACKAGES.has(entry.source.package);\n // A package manifest is optional for catalog plugins, but a present identity\n // that cannot be read or parsed must never make the plugin remotely eligible.\n const source = await fs.readTextFile(path.join(entry.directory, 'package.json'), context);\n if (!source.ok) return source.error.code === 'not_found';\n try {\n const manifest = JSON.parse(source.value) as unknown;\n if (typeof manifest !== 'object' || manifest === null || Array.isArray(manifest)) return false;\n const name = (manifest as { name?: unknown }).name;\n return typeof name === 'string' && name.length > 0 && name.trim() === name && !LOCAL_ONLY_MCP_PACKAGES.has(name);\n } catch {\n return false;\n }\n}\n\n/**\n * Whether a discovered skill came from one of these paths.\n *\n * A source holds exact SKILL.md files for plugin and shared skills, but a bare\n * directory for `.po/skills`, so membership is containment rather than\n * equality.\n */\nexport function within(filePath: string, roots: readonly string[]): boolean {\n const resolved = path.resolve(filePath);\n return roots.some((root) => {\n const base = path.resolve(root);\n return resolved === base || resolved.startsWith(`${base}${path.sep}`);\n });\n}\n\n/**\n * One group per loaded skill, merging every source admitting that exact path.\n * MCP admission is merged separately so local-only sources cannot broaden it.\n */\nexport function groupSkills(\n skills: readonly Skill[],\n sources: readonly SkillSource[],\n key: 'paths' | 'mcpPaths',\n): ServerSkillGroup[] {\n return skills.flatMap((skill) => {\n const admitting = sources.filter((source) => within(skill.filePath, source[key]));\n if (admitting.length === 0) return [];\n const domains = [...new Set(admitting.flatMap((source) => (source.domain === undefined ? [] : [source.domain])))];\n const plugins = [...new Set(admitting.flatMap((source) => (source.plugin === undefined ? [] : [source.plugin])))];\n const repository = admitting.some((source) => source.domain === undefined && source.plugin === undefined);\n return [\n {\n ...(repository ? {} : { domains }),\n ...(repository || plugins.length === 0 ? {} : { plugins }),\n skills: [skill],\n },\n ];\n });\n}\n","import path from 'node:path';\n\nimport {\n domainNamesOf,\n loadDomainsAsync,\n resolveManifestPluginEntriesAsync,\n sharedSkillsFor,\n} from '@agimon-ai/po-config/domains';\nimport { readHarnessState } from '@agimon-ai/po-config/harnessState';\nimport type { PoHeadlessExecutionContext } from '@agimon-ai/po-core/headless';\nimport { BACKGROUND_CONTEXT, nodeHost, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { collectResources, discoverSkillsAsync, type NamedResource } from '@agimon-ai/po-domain/resources';\nimport { formatSkillsForPrompt } from '@earendil-works/pi-coding-agent';\n\nimport type { ServerSkillInventory } from '../../types/skills';\nimport { DeferredSkillLoader } from '../deferredSkills';\nimport { groupSkills, isMcpSkillPlugin, type SkillSource, within } from './grouping';\n\nexport type { ServerSkillGroup, ServerSkillInventory } from '../../types/skills';\n\n/**\n * Every skill the session could reach, grouped by what activates it.\n *\n * A cockpit `/domains` switch reconciles contributions rather than rebuilding\n * the server plugin: the session declaration is mounted once. So enumerating only the\n * launch selection would freeze the command list at whatever was selected when\n * the session host was built. Enumerating every domain up front and tagging\n * each group with its `when` lets the existing kernel refresh do the work, the\n * same way other host contributions follow selection changes.\n */\nexport async function discoverServerSkills(\n execution: PoHeadlessExecutionContext,\n fs: FileSystem,\n signal: AbortSignal,\n): Promise<ServerSkillInventory> {\n signal.throwIfAborted();\n const context = withAbortSignal(signal, BACKGROUND_CONTEXT);\n const state = readHarnessState(execution.environment);\n const home = execution.environment.HOME ?? nodeHost.homeDirectory();\n const repoSkills = path.join(execution.repoRoot, '.po', 'skills');\n const sources: SkillSource[] = [];\n const diagnostics: string[] = [];\n const descriptors = new Map<string, NamedResource>();\n // A malformed domain is a configuration error in one domain, so it must not\n // remove every other domain's skills. Enumerating the whole manifest is new\n // exposure here: reading the launch selection could not fail this way.\n const manifest = await loadDomainsAsync(fs, execution.repoRoot, context, home, execution.environment).catch(\n (error: unknown) => {\n diagnostics.push(`Domain skills are unavailable: ${error instanceof Error ? error.message : String(error)}`);\n return undefined;\n },\n );\n const domains = manifest ? domainNamesOf(manifest) : [];\n\n // Plugin sources precede shared sources, then repository sources.\n // ponytail: Pi globally name-dedupes before domain gating. A loaded plugin\n // shadows a same-name shared fallback even when its domain is off. This is\n // the current ceiling; upgrade to selection-aware loading if collisions arise.\n // Reuse only immutable discovery paths within this invocation. The key keeps\n // plugin ordering and subsets; fs, repo, home and admitted environment are\n // fixed here. No inventory, cleanup handle or session state survives a call.\n const discovered = new Map<\n string,\n Readonly<{ paths: readonly string[]; mcpPaths: readonly string[]; plugins: readonly SkillSource[] }>\n >();\n if (manifest) {\n for (const domain of domains) {\n signal.throwIfAborted();\n try {\n const plugins = await materializePluginEntries(\n await resolveManifestPluginEntriesAsync(fs, manifest, [domain], [], context, home),\n { homeDirectory: home, environment: execution.environment },\n );\n const key = JSON.stringify(\n plugins.map(({ directory, skillDiscovery, skills, source }) => ({\n directory,\n skillDiscovery,\n skills,\n source,\n })),\n );\n const previous = discovered.get(key);\n if (previous) {\n sources.push({ domain, paths: [...previous.paths], mcpPaths: [...previous.mcpPaths] }, ...previous.plugins);\n continue;\n }\n const mcpPluginRoots = (\n await Promise.all(\n plugins.map(async (plugin) =>\n (await isMcpSkillPlugin(fs, plugin, context)) ? path.join(plugin.directory, 'skills') : undefined,\n ),\n )\n ).filter((root): root is string => root !== undefined);\n const collected = await collectResources(execution.repoRoot, plugins, {\n agents: false,\n discoverAgents: false,\n mcp: false,\n sharedSkills: false,\n environment: execution.environment,\n });\n try {\n for (const descriptor of collected.skillSources) descriptors.set(descriptor.path, descriptor);\n const paths = Object.freeze([...collected.skillDirectories]);\n // Exact collected paths retain this domain's per-plugin skill subset.\n // A plugin root would also admit skills loaded for another domain.\n const mcpPaths = Object.freeze(paths.filter((skillPath) => within(skillPath, mcpPluginRoots)));\n // The same skills, admitted one plugin at a time for session-only activation. Never remote: no mcpPaths.\n const pluginSources = plugins.flatMap(({ name, directory }) => {\n const own = paths.filter((skillPath) => within(skillPath, [directory]));\n return name === undefined || own.length === 0 ? [] : [{ plugin: name, paths: own, mcpPaths: [] }];\n });\n discovered.set(key, Object.freeze({ paths, mcpPaths, plugins: pluginSources }));\n if (paths.length > 0) sources.push({ domain, paths: [...paths], mcpPaths: [...mcpPaths] }, ...pluginSources);\n } finally {\n await collected.cleanup();\n }\n } catch (error) {\n diagnostics.push(`Domain '${domain}': ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n }\n\n // Shared skills are admitted by any domain that keeps them.\n signal.throwIfAborted();\n const shared = await discoverSkillsAsync(\n execution.repoRoot,\n path.join(execution.repoRoot, '.claude', 'skills'),\n 'recursive',\n undefined,\n execution.environment,\n );\n for (const descriptor of shared) descriptors.set(descriptor.path, descriptor);\n for (const descriptor of await discoverSkillsAsync(\n execution.repoRoot,\n repoSkills,\n 'recursive',\n undefined,\n execution.environment,\n ))\n descriptors.set(descriptor.path, descriptor);\n if (shared.length > 0 && manifest) {\n const sharedPaths = shared.map((skill) => skill.path);\n for (const domain of domains) {\n if (sharedSkillsFor(manifest, [domain])) {\n sources.push({ domain, paths: sharedPaths, mcpPaths: sharedPaths });\n }\n }\n }\n\n // Repository-local skills belong to the repository, not to a selection.\n sources.push({ paths: [repoSkills], mcpPaths: [repoSkills] });\n\n signal.throwIfAborted();\n // One walk for every group. Pi drops a path it has already loaded, so the\n // loader gets the unique set and each group selects its own skills back out.\n const unique = [...new Set([...sources.flatMap((source) => source.paths), ...(state.skillDirectories ?? [])])];\n const inventory = await new DeferredSkillLoader({ cwd: execution.cwd, skillPaths: unique }).ready();\n signal.throwIfAborted();\n\n for (const descriptor of descriptors.values()) {\n for (const diagnostic of descriptor.diagnostics ?? []) diagnostics.push(`${descriptor.path}: ${diagnostic}`);\n }\n const groups = groupSkills(inventory.skills, sources, 'paths');\n const mcpGroups = groupSkills(inventory.skills, sources, 'mcpPaths');\n\n // The catalog still describes the active selection rather than everything on\n // disk, because it is prompt text rather than a menu.\n const activeSkills = inventory.skills.filter((skill) =>\n within(skill.filePath, [...(state.skillDirectories ?? []), repoSkills]),\n );\n return {\n inventory: { skills: inventory.skills, diagnostics: [...inventory.diagnostics, ...diagnostics] },\n groups,\n mcpGroups,\n relations: Object.fromEntries(\n [...descriptors].map(([filePath, descriptor]) => [filePath, descriptor.relations ?? []]),\n ),\n catalog: formatSkillsForPrompt(activeSkills) || '(no discovered skills)',\n };\n}\n","import { Type } from 'typebox';\n\nexport const searchSkillsParameters = Type.Object({ query: Type.Optional(Type.String()) });\nexport const loadSkillParameters = Type.Object({ name: Type.String() });\n","import type { PoHeadlessHostService, PoHeadlessTool } from '@agimon-ai/po-core/headless';\n\nimport { loadSkillParameters, searchSkillsParameters } from '../../schemas/mcpSkillTools';\n\nfunction text(text: string) {\n return { content: [{ type: 'text' as const, text }] };\n}\n\nfunction skills(context: Parameters<PoHeadlessTool['execute']>[4]) {\n if (context.mcpSkills === undefined) throw new Error('Remote skill access is unavailable.');\n return context.mcpSkills;\n}\n\n/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */\nexport function matchSkills<T extends { name: string; description: string }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n const needle = query?.trim().toLocaleLowerCase();\n if (needle === undefined || needle === '') return [...skills];\n return skills.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\n}\n\nexport function createSearchSkillsTool(): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Discover repository and active-domain skills available to this remote connection.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { query }, _signal, _onUpdate, context) {\n const matches = matchSkills(await skills(context).list(), query);\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionSearchSkillsTool(\n host: Pick<PoHeadlessHostService, 'listSkills'>,\n): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Search available session skills by name or description.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n executionMode: 'parallel',\n async execute(_toolCallId, { query }) {\n const matches = matchSkills(\n host.listSkills().map(({ name, description }) => ({ name, description })),\n query,\n );\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionLoadSkillTool(\n host: Pick<PoHeadlessHostService, 'readSkill'>,\n): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n // PO_LOAD_SKILL_TOOL, spelled out so the renderer rule can read it.\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full instructions of an available session skill by exact name.',\n parameters: loadSkillParameters,\n executionMode: 'parallel',\n async execute(_toolCallId, { name }) {\n const body = host.readSkill(name);\n if (body === undefined) return { ...text(`No skill named ${name} is available in this session.`), isError: true };\n return text(body);\n },\n };\n}\n\nexport function createLoadSkillTool(): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full Markdown instructions for an available remote skill by exact name.',\n parameters: loadSkillParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { name }, _signal, _onUpdate, context) {\n return text(await skills(context).read(name));\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode, type PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\nimport { PO_SKILLS_NAMESPACE, type PoHeadlessHostService } from '@agimon-ai/po-core/headless';\nimport {\n BACKGROUND_CONTEXT,\n getOrThrow,\n PO_ISOLATE_SERVICE,\n readPoIsolate,\n withAbortSignal,\n type FileSystem,\n} from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { DeferredSkillSnapshot } from '../../types/skills';\nimport { createSessionLoadSkillTool, createSessionSearchSkillsTool, matchSkills } from '../mcpSkillTools';\n\nexport const SKILL_NAMESPACE_SOURCE = '@agimon-ai/po-skill';\n\ninterface SkillMatch {\n name: string;\n description: string;\n active: boolean;\n}\n\nfunction queryOf(input: unknown): string | undefined {\n if (input === undefined) return undefined;\n const query = typeof input === 'object' && input !== null ? (input as { query?: unknown }).query : 0;\n if (query === undefined || typeof query === 'string') return query;\n throw new Error('Pass { query?: string }.');\n}\n\nfunction nameOf(input: unknown): string {\n const name = (input as { name?: unknown } | null)?.name;\n if (typeof name !== 'string' || name.trim() === '')\n throw new Error('Pass { name: string }, a name from skills.search.');\n return name;\n}\n\n/**\n * Skills of every domain in domains.yaml, selected or not, plus the session's own. Reading one never selects its\n * domain or plugin, so it grants no tools, hooks or MCP servers. Disabled plugins never reach the inventory.\n */\nexport function createSkillNamespace(\n host: Pick<PoHeadlessHostService, 'listSkills' | 'readSkill' | 'context'>,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem,\n): PoCodemodeNamespace {\n return {\n name: PO_SKILLS_NAMESPACE,\n summary: 'Search and read skills beyond the active set, including unselected domains. Reading enables nothing.',\n declarations: `declare const skills: {\n /** Active skills first, then skills of unselected domains. Omit query to list everything. */\n search(input?: { query?: string }): Promise<{ name: string; description: string; active: boolean }[]>;\n /** Full SKILL.md text by exact name from search. Grants no tools, hooks or MCP servers. */\n load(input: { name: string }): Promise<string>;\n};`,\n bind(run) {\n if (run.sessionId !== host.context.sessionId) throw new Error('Skills namespace belongs to another session.');\n let disposed = false;\n run.onDispose(() => {\n disposed = true;\n });\n const check = () => {\n if (disposed) throw new Error('Skills namespace run is disposed.');\n run.signal.throwIfAborted();\n };\n return {\n async search(input?: unknown): Promise<SkillMatch[]> {\n const query = queryOf(input);\n check();\n const seen = new Set<string>();\n const all: SkillMatch[] = [];\n for (const { name, description } of host.listSkills()) {\n seen.add(name);\n all.push({ name, description, active: true });\n }\n for (const { name, description } of inventory.skills)\n if (!seen.has(name)) all.push({ name, description, active: false });\n return matchSkills(all, query);\n },\n async load(input: unknown): Promise<string> {\n const name = nameOf(input);\n check();\n const active = host.readSkill(name);\n if (active !== undefined) return active;\n // Exact inventory names only, so a script can never steer the read to another path.\n const skill = inventory.skills.find((entry) => entry.name === name);\n if (!skill) throw new Error(`No skill named ${name}. Use skills.search to find one.`);\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(run.signal, BACKGROUND_CONTEXT)),\n );\n check();\n return text;\n },\n };\n },\n };\n}\n\nexport function mountSkillNamespace(\n host: Pick<PoHeadlessHostService, 'listSkills' | 'readSkill' | 'context' | 'registerTool'>,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem,\n) {\n return (context: Context): void => {\n // The direct tools stay only where exec cannot bind this non-portable namespace, which covers both.\n // Registered here rather than restricted, so the remote MCP load_skill and search_skills stay.\n const tools = [\n host.registerTool(createSessionLoadSkillTool(host)),\n host.registerTool(createSessionSearchSkillsTool(host)),\n ];\n const withdraw = () => {\n for (const tool of tools.splice(0)) tool.dispose();\n };\n context.effect(() => withdraw, 'session skill tools');\n context.inject([PO_CODEMODE_SERVICE, PO_ISOLATE_SERVICE], (bound) => {\n const codemode = readPoCodemode(bound);\n if (!codemode) return undefined;\n const registration = codemode.register(SKILL_NAMESPACE_SOURCE, createSkillNamespace(host, inventory, fs));\n // ponytail: the tools do not come back if code mode leaves mid-session; the next session has them.\n if (readPoIsolate(bound)?.liveObjects === true) withdraw();\n return () => registration.dispose();\n });\n };\n}\n","import type { PoHeadlessCommand, PoHeadlessCondition } from '@agimon-ai/po-core/headless';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Skill } from '@earendil-works/pi-coding-agent';\n\nimport { expandDeferredSkillCommand, type DeferredSkillSnapshot } from '../../../../../services/deferredSkills';\nimport type { ServerSkillGroup } from '../../../../../services/serverInventory';\nimport { groupConditions } from '../../../../../services/serverInventory/grouping';\nimport { SKILL_COMMAND_PREFIX, SKILL_INVOCATION_PREFIX, SKILLS_COMMAND } from '../../../../../types/skills';\n\n/**\n * One command per skill, gated by whatever activates that skill.\n *\n * Expansion always reads the full inventory, not the group: a command is only\n * dispatchable while its condition holds, so by the time one runs its skill is\n * active, and looking it up in the union keeps one lookup table instead of one\n * per domain.\n */\nfunction skillCommand(\n skill: Skill,\n when: PoHeadlessCondition | undefined,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem | undefined,\n): PoHeadlessCommand {\n return {\n ...(when === undefined ? {} : { when }),\n name: `${SKILL_COMMAND_PREFIX}${skill.name}`,\n description: skill.description,\n execute: async (args, execution) => {\n const text = `${SKILL_INVOCATION_PREFIX}${skill.name}${args ? ` ${args}` : ''}`;\n const expanded = await expandDeferredSkillCommand(text, inventory.skills, fs);\n if (expanded === text) throw new Error(`Skill '${skill.name}' is no longer readable.`);\n await admit(execution.session, expanded);\n },\n };\n}\n\n/**\n * The dispatching prompt acks when this command returns, so awaiting the whole\n * turn (session.prompt) kept the composer draft until the run ended.\n */\nfunction admit(session: Parameters<PoHeadlessCommand['execute']>[1]['session'], text: string): Promise<void> {\n return session.admitPrompt ? session.admitPrompt(text, 'prompt', 'operator') : session.prompt(text);\n}\nexport function createSkillCommands(\n inventory: DeferredSkillSnapshot,\n catalog: string,\n groups: readonly ServerSkillGroup[],\n fs?: FileSystem,\n t: (key: string, fallback: string) => string = (_key, fallback) => fallback,\n): readonly PoHeadlessCommand[] {\n return [\n {\n name: SKILLS_COMMAND,\n description: 'List discovered skills or invoke one by name.',\n async execute(args, execution) {\n const requested = args.trim();\n if (requested) {\n await admit(\n execution.session,\n await expandDeferredSkillCommand(`${SKILL_INVOCATION_PREFIX}${requested}`, inventory.skills, fs),\n );\n return;\n }\n await execution.client.notify({\n title: t('skill.notification.catalog', 'Po skills'),\n localization: { title: { key: 'skill.notification.catalog', fallback: 'Po skills' } },\n body: catalog,\n level: 'info',\n });\n },\n },\n ...groups.flatMap((group) =>\n groupConditions(group).flatMap((when) => group.skills.map((skill) => skillCommand(skill, when, inventory, fs))),\n ),\n ];\n}\n","import { readHarnessState } from '@agimon-ai/po-config/harnessState';\nimport type { PoHeadlessHostService } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { BACKGROUND_CONTEXT, getOrThrow, nodeHost, type FileSystem } from '@agimon-ai/po-core/platform';\nimport {\n type PoServerResources,\n type PoServerSessionPlugin,\n packageResourcePath,\n readPackageResource,\n} from '@agimon-ai/po-core/serverPlugin';\n\nimport { SKILL_INVENTORY_FRESH_MS } from '../../../../../constants/skillInventory';\nimport { mountMcpSkills } from '../../../../../services/mcpSkills';\nimport { discoverServerSkills } from '../../../../../services/serverInventory';\nimport { groupConditions } from '../../../../../services/serverInventory/grouping';\nimport { mountSkillNamespace } from '../../../../../services/skillNamespace';\nimport { createSkillCommands } from './skillCommands';\n\nexport async function createSkillServer(\n agent: PoHeadlessHostService,\n fs: FileSystem,\n signal: AbortSignal,\n resources: PoServerResources,\n t?: (key: string, fallback: string) => string,\n): Promise<PoServerSessionPlugin> {\n const execution = agent.context;\n // Sessions with the same inputs share one discovery. The key holds every input discoverServerSkills\n // reads besides the disk, so equal keys give equal inventories, and the window bounds how old that\n // read of the disk can be.\n const key = [\n 'inventory',\n execution.repoRoot,\n execution.cwd,\n execution.environment.HOME ?? nodeHost.homeDirectory(),\n ...(readHarnessState(execution.environment).skillDirectories ?? []),\n Math.floor(Date.now() / SKILL_INVENTORY_FRESH_MS),\n ];\n const { inventory, catalog, groups, mcpGroups, relations } = await resources.acquire(key, () =>\n // Every session sharing the discovery waits on it, so none of their signals may abort it.\n discoverServerSkills(execution, fs, new AbortController().signal),\n );\n return {\n commands: createSkillCommands(inventory, catalog, groups, fs, t),\n services: [mountMcpSkills(mcpGroups, fs, signal), mountSkillNamespace(agent, inventory, fs)],\n resources: [\n // Each skill joins the prompt's one <available_skills> list, gated like the rest.\n ...groups.flatMap((group) =>\n groupConditions(group).flatMap((when) =>\n group.skills.map((skill) => ({\n name: skill.name,\n description: skill.description,\n path: skill.filePath,\n kind: 'skill' as const,\n ...(relations?.[skill.filePath] === undefined ? {} : { relations: relations[skill.filePath] }),\n ...(when === undefined ? {} : { when }),\n read: async () => getOrThrow(await fs.readTextFile(skill.filePath, BACKGROUND_CONTEXT)),\n })),\n ),\n ),\n ...[\n {\n name: 'help-how-to-author-skill',\n description:\n 'Author and distribute Po agent skills. Use when creating a SKILL.md, contributing a runtime skill directory, or publishing activation-gated Help prompts and diagnostic tools.',\n },\n {\n name: 'help-how-to-skill',\n description:\n \"Use Po's skill catalog and deferred discovery. Diagnose missing or shadowed skills and invoke the narrowest available guidance.\",\n },\n ].map((skill) => ({\n ...skill,\n when: PO_HELP_WHEN,\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, `src/prompts/${skill.name}/SKILL.md`),\n read: () => readPackageResource(import.meta.url, `src/prompts/${skill.name}/SKILL.md`),\n })),\n ],\n };\n}\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { readPoLang, readPoPersonLocale } from '@agimon-ai/po-core/locale';\nimport { requirePoFs } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createSkillServer } from './_lib/skillServer';\n\nexport default defineRoot(async ({ agent, context: root, signal, resources }: PoServerPluginContext) => {\n const runtime: PoServerSessionPlugin = agent\n ? await createSkillServer(\n agent,\n requirePoFs(root),\n signal,\n resources,\n (key, fallback) => readPoLang(root)?.t(readPoPersonLocale(root)?.read(), key, fallback) ?? fallback,\n )\n : { commands: [], resources: [] };\n return { value: runtime, services: runtime.services };\n});\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.commands!,\n { cardinality: 'many' },\n);\n","// @scaffold-generated\nimport { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n name: 'codemode-how-to-skills',\n description:\n 'Search and load any skill by name through the skills namespace: the listed ones, the rest of the active catalog, and skills of unselected domains. Use before a task that a skill may cover.',\n // A code-mode guide: listed in the system prompt, outside the searchable catalog.\n pinned: true,\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/codemode-how-to-skills/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/codemode-how-to-skills/SKILL.md'),\n});\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.resources!,\n { cardinality: 'many' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandSkills from '../src/extensions/workspaces/sessions/(backend)/command/skills.server';\nimport resourceCodemodeHowToSkills from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server';\nimport resourceSkills from '../src/extensions/workspaces/sessions/(backend)/resource/skills.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\ntype ManyFactory<T, C> = (context: C) => T | readonly T[];\nconst many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {\n const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\n return Array.isArray(resolved) ? resolved : [resolved as T];\n};\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-skill',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return [...many(commandSkills, contextSession)]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceCodemodeHowToSkills, contextSession), ...many(resourceSkills, contextSession)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;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AE,OAAO,CAAC,GAAG,KAAKC,yBAAe,cAAc,CAAC;GAAG;GACrG,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGC,uCAA6B,cAAc,GAAG,GAAG,KAAKC,uBAAgB,cAAc,CAAC;GAAG;GACzJ,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.mjs","names":["rootSession","commandSkills","resourceCodemodeHowToSkills","resourceSkills"],"sources":["../../src/constants/skillInventory.ts","../../src/services/mcpSkills/index.ts","../../src/services/deferredSkills/index.ts","../../src/services/serverInventory/grouping.ts","../../src/services/serverInventory/index.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/services/skillNamespace/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/skillCommands.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/skills.server.ts","../../generated/server.ts"],"sourcesContent":["/**\n * How long sessions with the same inputs share one skill inventory instead of each reading the disk.\n * ponytail: a skill added on disk reaches new sessions within this window, not at once; watch the\n * skill roots if that lag matters.\n */\nexport const SKILL_INVENTORY_FRESH_MS = 60_000;\n","import type { PoMcpPluginContext, PoMcpSkill } from '@agimon-ai/po-core/mcpFacet';\nimport { BACKGROUND_CONTEXT, getOrThrow, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { ServerSkillGroup } from '../serverInventory';\n\nexport const MCP_SKILLS_SERVICE = 'po/discovered-mcp-skills';\n\nexport interface McpSkillProvider {\n list(context: PoMcpPluginContext): readonly PoMcpSkill[];\n}\n\n/** Explicit remote provider, never a projection of the local resource registry. */\nexport function mountMcpSkills(groups: readonly ServerSkillGroup[], fs: FileSystem, signal: AbortSignal) {\n return (context: Context): void => {\n context.provide(MCP_SKILLS_SERVICE, {\n list(remote) {\n signal.throwIfAborted();\n remote.signal.throwIfAborted();\n const domains = remote.selection.read().domains;\n const skills = new Map<string, PoMcpSkill>();\n for (const group of groups) {\n if (group.domains !== undefined && !group.domains.some((domain) => domains.includes(domain))) continue;\n for (const skill of group.skills) {\n // Retain name precedence defensively for remote providers.\n if (skills.has(skill.name)) continue;\n skills.set(skill.name, {\n name: skill.name,\n description: skill.description,\n async read() {\n const readSignal = AbortSignal.any([signal, remote.signal]);\n readSignal.throwIfAborted();\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(readSignal, BACKGROUND_CONTEXT)),\n );\n readSignal.throwIfAborted();\n return text;\n },\n });\n }\n }\n return [...skills.values()];\n },\n } satisfies McpSkillProvider);\n };\n}\n\nexport function bindMcpSkills(context: PoMcpPluginContext): readonly PoMcpSkill[] {\n const provider = context.services.get<McpSkillProvider>(MCP_SKILLS_SERVICE);\n if (!provider) throw new Error('Discovered MCP skills are unavailable.');\n return provider.list(context);\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { Worker } from 'node:worker_threads';\n\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport {\n type BuildSystemPromptOptions,\n formatSkillsForPrompt,\n getAgentDir,\n loadSkills,\n type Skill,\n stripFrontmatter,\n} from '@earendil-works/pi-coding-agent';\n\nimport type { DeferredSkillLoaderOptions, DeferredSkillSnapshot } from '../../types/skills';\n\nexport type { DeferredSkillLoaderOptions, DeferredSkillSnapshot } from '../../types/skills';\n\nconst PI_PACKAGE = '@earendil-works/pi-coding-agent';\nconst PACKAGE_MANIFEST = 'package.json';\n// A fresh worker takes ~240 ms to import Pi's main entry but ~20 ms for this module alone, and\n// every session spawns one. ponytail: not in Pi's exports map, so a Pi release that moves it\n// falls back to the main entry (slow, still correct); deferredSkills.test.ts pins the path.\nconst PI_SKILLS_MODULE = path.join('dist', 'core', 'skills.js');\nconst SKILL_WORKER_SOURCE = `\nconst { parentPort, workerData } = require('node:worker_threads');\nvoid (async () => {\n try {\n const { loadSkills } = await import(workerData.piModuleUrl);\n parentPort.postMessage({ ok: true, result: loadSkills(workerData.loadOptions) });\n } catch (error) {\n parentPort.postMessage({ ok: false, error: error instanceof Error ? error.message : String(error) });\n }\n})();\n`;\n\nasync function installedPiModuleUrl(): Promise<string> {\n const anchors = [process.argv[1], fileURLToPath(import.meta.url), path.join(process.cwd(), PACKAGE_MANIFEST)];\n for (const anchor of anchors) {\n if (!anchor) continue;\n let directory = path.dirname(path.resolve(anchor));\n while (true) {\n const packageRoot = path.join(directory, 'node_modules', PI_PACKAGE);\n const manifestPath = path.join(packageRoot, PACKAGE_MANIFEST);\n try {\n const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8')) as { main?: unknown };\n if (typeof manifest.main === 'string') {\n const entry = path.resolve(packageRoot, manifest.main);\n const skills = path.join(packageRoot, PI_SKILLS_MODULE);\n for (const candidate of [skills, entry]) {\n try {\n await fs.access(candidate);\n return pathToFileURL(candidate).href;\n } catch {\n // Try the next entry before walking up the module chain.\n }\n }\n }\n } catch {\n // This anchor does not expose Pi at this level; continue up its module chain.\n }\n const parent = path.dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n }\n throw new Error(`Cannot resolve ${PI_PACKAGE} from the Po or host module trees`);\n}\n\ninterface SkillWorkerResult {\n ok: boolean;\n result?: { skills: Skill[]; diagnostics: Array<{ path?: string; message: string }> };\n error?: string;\n}\n\n/**\n * One session's Po-selected skill inventory.\n *\n * Construction is deliberately cheap. `start()` schedules the synchronous Pi\n * walker after session_start returns, while `ready()` is the single promise the\n * first input awaits before Pi expands `/skill:name`.\n */\nexport class DeferredSkillLoader {\n readonly #options: DeferredSkillLoaderOptions;\n #promise: Promise<DeferredSkillSnapshot> | undefined;\n\n constructor(options: DeferredSkillLoaderOptions) {\n this.#options = options;\n }\n\n start(): Promise<DeferredSkillSnapshot> {\n if (this.#promise) return this.#promise;\n\n if (!this.#options.schedule && !this.#options.load) {\n this.#promise = this.#loadInWorker();\n return this.#promise;\n }\n\n const schedule = this.#options.schedule ?? ((load: () => void) => setImmediate(load));\n this.#promise = new Promise((resolve) => {\n const fail = (error: unknown): void => {\n resolve(this.#failure(error));\n };\n try {\n schedule(() => {\n try {\n resolve(this.#load());\n } catch (error) {\n fail(error);\n }\n });\n } catch (error) {\n fail(error);\n }\n });\n return this.#promise;\n }\n\n ready(): Promise<DeferredSkillSnapshot> {\n return this.start();\n }\n\n #loadOptions(): { cwd: string; agentDir: string; skillPaths: string[]; includeDefaults: boolean } {\n return {\n cwd: this.#options.cwd,\n agentDir: this.#options.agentDir ?? getAgentDir(),\n skillPaths: [...this.#options.skillPaths],\n includeDefaults: false,\n };\n }\n\n #snapshot(result: {\n skills: Skill[];\n diagnostics: Array<{ path?: string; message: string }>;\n }): DeferredSkillSnapshot {\n return {\n skills: result.skills,\n diagnostics: result.diagnostics.map(\n (diagnostic) => `${diagnostic.path ?? this.#options.cwd}: ${diagnostic.message}`,\n ),\n };\n }\n\n #failure(error: unknown): DeferredSkillSnapshot {\n return {\n skills: [],\n diagnostics: [`${this.#options.cwd}: ${error instanceof Error ? error.message : String(error)}`],\n };\n }\n\n #load(): DeferredSkillSnapshot {\n return this.#snapshot((this.#options.load ?? loadSkills)(this.#loadOptions()));\n }\n\n async #loadInWorker(): Promise<DeferredSkillSnapshot> {\n let piModuleUrl: string;\n try {\n piModuleUrl = this.#options.piModuleUrl ?? (await installedPiModuleUrl());\n } catch (error) {\n return this.#failure(error);\n }\n return new Promise((resolve) => {\n let settled = false;\n const settle = (snapshot: DeferredSkillSnapshot): void => {\n if (settled) return;\n settled = true;\n resolve(snapshot);\n };\n let worker: Worker;\n try {\n worker = new Worker(SKILL_WORKER_SOURCE, {\n eval: true,\n workerData: {\n piModuleUrl,\n loadOptions: this.#loadOptions(),\n },\n });\n } catch (error) {\n settle(this.#failure(error));\n return;\n }\n worker.unref();\n worker.once('message', (message: SkillWorkerResult) => {\n if (!message.ok || !message.result) {\n settle(this.#failure(message.error ?? 'Skill worker failed'));\n return;\n }\n settle(this.#snapshot(message.result));\n });\n worker.once('error', (error) => settle(this.#failure(error)));\n worker.once('exit', (code) => {\n if (code !== 0) settle(this.#failure(`Skill worker exited with code ${code}`));\n });\n });\n }\n}\n\n/** Appends only the inventory Pi would append for these deferred skills. */\nexport function buildPromptWithDeferredSkills(\n systemPrompt: string,\n options: BuildSystemPromptOptions,\n skills: Skill[],\n): string {\n if (options.selectedTools && !options.selectedTools.includes('read')) return systemPrompt;\n return `${systemPrompt}${formatSkillsForPrompt(skills)}`;\n}\n\n/**\n * Expands a deferred `/skill:name` before Pi consults its synchronous inventory. Node discovered the\n * skill on the host disk, so it reads it there; the edge build reads through `fs` instead.\n */\nexport async function expandDeferredSkillCommand(\n text: string,\n skills: readonly Skill[],\n _fs?: FileSystem,\n): Promise<string> {\n if (!text.startsWith('/skill:')) return text;\n const spaceIndex = text.indexOf(' ');\n const skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);\n const skill = skills.find((candidate) => candidate.name === skillName);\n if (!skill) return text;\n\n try {\n const args = spaceIndex === -1 ? '' : text.slice(spaceIndex + 1).trim();\n const body = stripFrontmatter(await fs.readFile(skill.filePath, 'utf8')).trim();\n const skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n return args ? `${skillBlock}\\n\\n${args}` : skillBlock;\n } catch {\n // Pi uses the same literal-text fallback if a skill disappears between\n // discovery and submission; the agent can still respond to the command.\n return text;\n }\n}\n","import path from 'node:path';\n\nimport type { PluginEntry } from '@agimon-ai/po-config/domains';\nimport type { PoHeadlessCondition } from '@agimon-ai/po-core/headless';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Skill } from '@earendil-works/pi-coding-agent';\n\nimport type { ServerSkillGroup } from '../../types/skills';\n\n/**\n * Each condition that activates a group: its domains, then each plugin turned on for this session only.\n * Declare one contribution per condition; the host keeps one per name once gating has run.\n */\nexport function groupConditions(group: ServerSkillGroup): (PoHeadlessCondition | undefined)[] {\n return [\n group.domains === undefined ? undefined : { domains: group.domains },\n // `plugins` is po-domain's session state key, spelled out so this runs on hosts with an older po-core.\n ...(group.plugins ?? []).map((plugin) => ({ state: { plugins: plugin } })),\n ];\n}\n/**\n * Skill paths one domain admits, or one plugin's session-only activation (`plugin`), or the repository when\n * neither is set.\n */\nexport interface SkillSource {\n readonly domain?: string;\n readonly plugin?: string;\n readonly paths: readonly string[];\n readonly mcpPaths: readonly string[];\n}\n\nconst LOCAL_ONLY_MCP_PACKAGES = new Set([\n '@agimon-ai/po-author',\n '@agimon-ai/po-git',\n '@agimon-ai/po-goal',\n '@agimon-ai/po-help',\n '@agimon-ai/po-calendar',\n '@agimon-ai/po-user-feedback',\n '@agimon-ai/po-voice',\n '@agimon-ai/po-workflow',\n]);\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport async function isMcpSkillPlugin(fs: FileSystem, entry: PluginEntry, context: IoContext): Promise<boolean> {\n if (entry.source?.type === 'npm') return !LOCAL_ONLY_MCP_PACKAGES.has(entry.source.package);\n // A package manifest is optional for catalog plugins, but a present identity\n // that cannot be read or parsed must never make the plugin remotely eligible.\n const source = await fs.readTextFile(path.join(entry.directory, 'package.json'), context);\n if (!source.ok) return source.error.code === 'not_found';\n try {\n const manifest = JSON.parse(source.value) as unknown;\n if (typeof manifest !== 'object' || manifest === null || Array.isArray(manifest)) return false;\n const name = (manifest as { name?: unknown }).name;\n return typeof name === 'string' && name.length > 0 && name.trim() === name && !LOCAL_ONLY_MCP_PACKAGES.has(name);\n } catch {\n return false;\n }\n}\n\n/**\n * Whether a discovered skill came from one of these paths.\n *\n * A source holds exact SKILL.md files for plugin and shared skills, but a bare\n * directory for `.po/skills`, so membership is containment rather than\n * equality.\n */\nexport function within(filePath: string, roots: readonly string[]): boolean {\n const resolved = path.resolve(filePath);\n return roots.some((root) => {\n const base = path.resolve(root);\n return resolved === base || resolved.startsWith(`${base}${path.sep}`);\n });\n}\n\n/**\n * One group per loaded skill, merging every source admitting that exact path.\n * MCP admission is merged separately so local-only sources cannot broaden it.\n */\nexport function groupSkills(\n skills: readonly Skill[],\n sources: readonly SkillSource[],\n key: 'paths' | 'mcpPaths',\n): ServerSkillGroup[] {\n return skills.flatMap((skill) => {\n const admitting = sources.filter((source) => within(skill.filePath, source[key]));\n if (admitting.length === 0) return [];\n const domains = [...new Set(admitting.flatMap((source) => (source.domain === undefined ? [] : [source.domain])))];\n const plugins = [...new Set(admitting.flatMap((source) => (source.plugin === undefined ? [] : [source.plugin])))];\n const repository = admitting.some((source) => source.domain === undefined && source.plugin === undefined);\n return [\n {\n ...(repository ? {} : { domains }),\n ...(repository || plugins.length === 0 ? {} : { plugins }),\n skills: [skill],\n },\n ];\n });\n}\n","import path from 'node:path';\n\nimport {\n domainNamesOf,\n loadDomainsAsync,\n resolveManifestPluginEntriesAsync,\n sharedSkillsFor,\n} from '@agimon-ai/po-config/domains';\nimport { readHarnessState } from '@agimon-ai/po-config/harnessState';\nimport type { PoHeadlessExecutionContext } from '@agimon-ai/po-core/headless';\nimport { BACKGROUND_CONTEXT, nodeHost, withAbortSignal, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { collectResources, discoverSkillsAsync, type NamedResource } from '@agimon-ai/po-domain/resources';\nimport { formatSkillsForPrompt } from '@earendil-works/pi-coding-agent';\n\nimport type { ServerSkillInventory } from '../../types/skills';\nimport { DeferredSkillLoader } from '../deferredSkills';\nimport { groupSkills, isMcpSkillPlugin, type SkillSource, within } from './grouping';\n\nexport type { ServerSkillGroup, ServerSkillInventory } from '../../types/skills';\n\n/**\n * Every skill the session could reach, grouped by what activates it.\n *\n * A cockpit `/domains` switch reconciles contributions rather than rebuilding\n * the server plugin: the session declaration is mounted once. So enumerating only the\n * launch selection would freeze the command list at whatever was selected when\n * the session host was built. Enumerating every domain up front and tagging\n * each group with its `when` lets the existing kernel refresh do the work, the\n * same way other host contributions follow selection changes.\n */\nexport async function discoverServerSkills(\n execution: PoHeadlessExecutionContext,\n fs: FileSystem,\n signal: AbortSignal,\n): Promise<ServerSkillInventory> {\n signal.throwIfAborted();\n const context = withAbortSignal(signal, BACKGROUND_CONTEXT);\n const state = readHarnessState(execution.environment);\n const home = execution.environment.HOME ?? nodeHost.homeDirectory();\n const repoSkills = path.join(execution.repoRoot, '.po', 'skills');\n const sources: SkillSource[] = [];\n const diagnostics: string[] = [];\n const descriptors = new Map<string, NamedResource>();\n // A malformed domain is a configuration error in one domain, so it must not\n // remove every other domain's skills. Enumerating the whole manifest is new\n // exposure here: reading the launch selection could not fail this way.\n const manifest = await loadDomainsAsync(fs, execution.repoRoot, context, home, execution.environment).catch(\n (error: unknown) => {\n diagnostics.push(`Domain skills are unavailable: ${error instanceof Error ? error.message : String(error)}`);\n return undefined;\n },\n );\n const domains = manifest ? domainNamesOf(manifest) : [];\n\n // Plugin sources precede shared sources, then repository sources.\n // ponytail: Pi globally name-dedupes before domain gating. A loaded plugin\n // shadows a same-name shared fallback even when its domain is off. This is\n // the current ceiling; upgrade to selection-aware loading if collisions arise.\n // Reuse only immutable discovery paths within this invocation. The key keeps\n // plugin ordering and subsets; fs, repo, home and admitted environment are\n // fixed here. No inventory, cleanup handle or session state survives a call.\n const discovered = new Map<\n string,\n Readonly<{ paths: readonly string[]; mcpPaths: readonly string[]; plugins: readonly SkillSource[] }>\n >();\n if (manifest) {\n for (const domain of domains) {\n signal.throwIfAborted();\n try {\n const plugins = await materializePluginEntries(\n await resolveManifestPluginEntriesAsync(fs, manifest, [domain], [], context, home),\n { homeDirectory: home, environment: execution.environment },\n );\n const key = JSON.stringify(\n plugins.map(({ directory, skillDiscovery, skills, source }) => ({\n directory,\n skillDiscovery,\n skills,\n source,\n })),\n );\n const previous = discovered.get(key);\n if (previous) {\n sources.push({ domain, paths: [...previous.paths], mcpPaths: [...previous.mcpPaths] }, ...previous.plugins);\n continue;\n }\n const mcpPluginRoots = (\n await Promise.all(\n plugins.map(async (plugin) =>\n (await isMcpSkillPlugin(fs, plugin, context)) ? path.join(plugin.directory, 'skills') : undefined,\n ),\n )\n ).filter((root): root is string => root !== undefined);\n const collected = await collectResources(execution.repoRoot, plugins, {\n agents: false,\n discoverAgents: false,\n mcp: false,\n sharedSkills: false,\n environment: execution.environment,\n });\n try {\n for (const descriptor of collected.skillSources) descriptors.set(descriptor.path, descriptor);\n const paths = Object.freeze([...collected.skillDirectories]);\n // Exact collected paths retain this domain's per-plugin skill subset.\n // A plugin root would also admit skills loaded for another domain.\n const mcpPaths = Object.freeze(paths.filter((skillPath) => within(skillPath, mcpPluginRoots)));\n // The same skills, admitted one plugin at a time for session-only activation. Never remote: no mcpPaths.\n const pluginSources = plugins.flatMap(({ name, directory }) => {\n const own = paths.filter((skillPath) => within(skillPath, [directory]));\n return name === undefined || own.length === 0 ? [] : [{ plugin: name, paths: own, mcpPaths: [] }];\n });\n discovered.set(key, Object.freeze({ paths, mcpPaths, plugins: pluginSources }));\n if (paths.length > 0) sources.push({ domain, paths: [...paths], mcpPaths: [...mcpPaths] }, ...pluginSources);\n } finally {\n await collected.cleanup();\n }\n } catch (error) {\n diagnostics.push(`Domain '${domain}': ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n }\n\n // Shared skills are admitted by any domain that keeps them.\n signal.throwIfAborted();\n const shared = await discoverSkillsAsync(\n execution.repoRoot,\n path.join(execution.repoRoot, '.claude', 'skills'),\n 'recursive',\n undefined,\n execution.environment,\n );\n for (const descriptor of shared) descriptors.set(descriptor.path, descriptor);\n for (const descriptor of await discoverSkillsAsync(\n execution.repoRoot,\n repoSkills,\n 'recursive',\n undefined,\n execution.environment,\n ))\n descriptors.set(descriptor.path, descriptor);\n if (shared.length > 0 && manifest) {\n const sharedPaths = shared.map((skill) => skill.path);\n for (const domain of domains) {\n if (sharedSkillsFor(manifest, [domain])) {\n sources.push({ domain, paths: sharedPaths, mcpPaths: sharedPaths });\n }\n }\n }\n\n // Repository-local skills belong to the repository, not to a selection.\n sources.push({ paths: [repoSkills], mcpPaths: [repoSkills] });\n\n signal.throwIfAborted();\n // One walk for every group. Pi drops a path it has already loaded, so the\n // loader gets the unique set and each group selects its own skills back out.\n const unique = [...new Set([...sources.flatMap((source) => source.paths), ...(state.skillDirectories ?? [])])];\n const inventory = await new DeferredSkillLoader({ cwd: execution.cwd, skillPaths: unique }).ready();\n signal.throwIfAborted();\n\n for (const descriptor of descriptors.values()) {\n for (const diagnostic of descriptor.diagnostics ?? []) diagnostics.push(`${descriptor.path}: ${diagnostic}`);\n }\n const groups = groupSkills(inventory.skills, sources, 'paths');\n const mcpGroups = groupSkills(inventory.skills, sources, 'mcpPaths');\n\n // The catalog still describes the active selection rather than everything on\n // disk, because it is prompt text rather than a menu.\n const activeSkills = inventory.skills.filter((skill) =>\n within(skill.filePath, [...(state.skillDirectories ?? []), repoSkills]),\n );\n return {\n inventory: { skills: inventory.skills, diagnostics: [...inventory.diagnostics, ...diagnostics] },\n groups,\n mcpGroups,\n relations: Object.fromEntries(\n [...descriptors].map(([filePath, descriptor]) => [filePath, descriptor.relations ?? []]),\n ),\n catalog: formatSkillsForPrompt(activeSkills) || '(no discovered skills)',\n };\n}\n","import { Type } from 'typebox';\n\nexport const searchSkillsParameters = Type.Object({ query: Type.Optional(Type.String()) });\nexport const loadSkillParameters = Type.Object({ name: Type.String() });\n","import { rankText } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessHostService, PoHeadlessTool } from '@agimon-ai/po-core/headless';\n\nimport { loadSkillParameters, searchSkillsParameters } from '../../schemas/mcpSkillTools';\n\nfunction text(text: string) {\n return { content: [{ type: 'text' as const, text }] };\n}\n\nfunction skills(context: Parameters<PoHeadlessTool['execute']>[4]) {\n if (context.mcpSkills === undefined) throw new Error('Remote skill access is unavailable.');\n return context.mcpSkills;\n}\n\n/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */\nexport function matchSkills<T extends { name: string; description: string }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n const needle = query?.trim().toLocaleLowerCase();\n if (needle === undefined || needle === '') return [...skills];\n return skills.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\n}\n\n/** Best match first by name, then description, active before inactive; an empty query keeps everything, in order. */\nexport function rankSkills<T extends { name: string; description: string; active?: boolean }>(\n skills: readonly T[],\n query?: string,\n): T[] {\n if (query === undefined || query.trim() === '') return [...skills];\n const ranked = rankText(\n query,\n skills.map((skill) => ({ id: skill.name, name: skill.name, doc: skill.description, skill })),\n ).map(({ skill }) => skill);\n return [...ranked.filter((skill) => skill.active !== false), ...ranked.filter((skill) => skill.active === false)];\n}\n\n/** Pinned guides are listed in the system prompt, so only a real search needs them. */\nexport function searchesPinned(query: string | undefined): boolean {\n return query !== undefined && query.trim() !== '';\n}\n\nexport function createSearchSkillsTool(): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Discover repository and active-domain skills available to this remote connection.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { query }, _signal, _onUpdate, context) {\n const matches = matchSkills(await skills(context).list(), query);\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionSearchSkillsTool(\n host: Pick<PoHeadlessHostService, 'listSkills'>,\n): PoHeadlessTool<typeof searchSkillsParameters> {\n return {\n name: 'search_skills',\n label: 'Search skills',\n description: 'Search available session skills by name or description.',\n parameters: searchSkillsParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n executionMode: 'parallel',\n async execute(_toolCallId, { query }) {\n const matches = rankSkills(\n host\n .listSkills({ includePinned: searchesPinned(query) })\n .map(({ name, description }) => ({ name, description })),\n query,\n );\n return { ...text(JSON.stringify(matches)), structuredContent: { skills: matches } };\n },\n };\n}\n\nexport function createSessionLoadSkillTool(\n host: Pick<PoHeadlessHostService, 'readSkill'>,\n): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n // PO_LOAD_SKILL_TOOL, spelled out so the renderer rule can read it.\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full instructions of an available session skill by exact name.',\n parameters: loadSkillParameters,\n executionMode: 'parallel',\n async execute(_toolCallId, { name }) {\n const body = host.readSkill(name);\n if (body === undefined) return { ...text(`No skill named ${name} is available in this session.`), isError: true };\n return text(body);\n },\n };\n}\n\nexport function createLoadSkillTool(): PoHeadlessTool<typeof loadSkillParameters> {\n return {\n name: 'load_skill',\n label: 'Load skill',\n description: 'Load the full Markdown instructions for an available remote skill by exact name.',\n parameters: loadSkillParameters,\n annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },\n async execute(_toolCallId, { name }, _signal, _onUpdate, context) {\n return text(await skills(context).read(name));\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode, type PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\nimport { PO_SKILLS_NAMESPACE, type PoHeadlessHostService } from '@agimon-ai/po-core/headless';\nimport {\n BACKGROUND_CONTEXT,\n getOrThrow,\n PO_ISOLATE_SERVICE,\n readPoIsolate,\n withAbortSignal,\n type FileSystem,\n} from '@agimon-ai/po-core/platform';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport type { DeferredSkillSnapshot } from '../../types/skills';\nimport {\n createSessionLoadSkillTool,\n createSessionSearchSkillsTool,\n rankSkills,\n searchesPinned,\n} from '../mcpSkillTools';\n\nexport const SKILL_NAMESPACE_SOURCE = '@agimon-ai/po-skill';\n\ninterface SkillMatch {\n name: string;\n description: string;\n active: boolean;\n}\n\nfunction queryOf(input: unknown): string | undefined {\n if (input === undefined) return undefined;\n const query = typeof input === 'object' && input !== null ? (input as { query?: unknown }).query : 0;\n if (query === undefined || typeof query === 'string') return query;\n throw new Error('Pass { query?: string }.');\n}\n\nfunction nameOf(input: unknown): string {\n const name = (input as { name?: unknown } | null)?.name;\n if (typeof name !== 'string' || name.trim() === '')\n throw new Error('Pass { name: string }, a name from skills.search.');\n return name;\n}\n\n/**\n * Skills of every domain in domains.yaml, selected or not, plus the session's own. Reading one never selects its\n * domain or plugin, so it grants no tools, hooks or MCP servers. Disabled plugins never reach the inventory.\n */\nexport function createSkillNamespace(\n host: Pick<PoHeadlessHostService, 'listSkills' | 'readSkill' | 'context'>,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem,\n): PoCodemodeNamespace {\n return {\n name: PO_SKILLS_NAMESPACE,\n summary: 'Search and read skills beyond the active set, including unselected domains. Reading enables nothing.',\n declarations: `declare const skills: {\n /** Active skills first, then skills of unselected domains. Omit query to list everything. */\n search(input?: { query?: string }): Promise<{ name: string; description: string; active: boolean }[]>;\n /** Full SKILL.md text by exact name from search. Grants no tools, hooks or MCP servers. */\n load(input: { name: string }): Promise<string>;\n};`,\n bind(run) {\n if (run.sessionId !== host.context.sessionId) throw new Error('Skills namespace belongs to another session.');\n let disposed = false;\n run.onDispose(() => {\n disposed = true;\n });\n const check = () => {\n if (disposed) throw new Error('Skills namespace run is disposed.');\n run.signal.throwIfAborted();\n };\n return {\n async search(input?: unknown): Promise<SkillMatch[]> {\n const query = queryOf(input);\n check();\n const seen = new Set<string>();\n const all: SkillMatch[] = [];\n for (const { name, description } of host.listSkills({ includePinned: searchesPinned(query) })) {\n seen.add(name);\n all.push({ name, description, active: true });\n }\n for (const { name, description } of inventory.skills)\n if (!seen.has(name)) all.push({ name, description, active: false });\n return rankSkills(all, query);\n },\n async load(input: unknown): Promise<string> {\n const name = nameOf(input);\n check();\n const active = host.readSkill(name);\n if (active !== undefined) return active;\n // Exact inventory names only, so a script can never steer the read to another path.\n const skill = inventory.skills.find((entry) => entry.name === name);\n if (!skill) throw new Error(`No skill named ${name}. Use skills.search to find one.`);\n const text = getOrThrow(\n await fs.readTextFile(skill.filePath, withAbortSignal(run.signal, BACKGROUND_CONTEXT)),\n );\n check();\n return text;\n },\n };\n },\n };\n}\n\nexport function mountSkillNamespace(\n host: Pick<PoHeadlessHostService, 'listSkills' | 'readSkill' | 'context' | 'registerTool'>,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem,\n) {\n return (context: Context): void => {\n // The direct tools stay only where exec cannot bind this non-portable namespace, which covers both.\n // Registered here rather than restricted, so the remote MCP load_skill and search_skills stay.\n const tools = [\n host.registerTool(createSessionLoadSkillTool(host)),\n host.registerTool(createSessionSearchSkillsTool(host)),\n ];\n const withdraw = () => {\n for (const tool of tools.splice(0)) tool.dispose();\n };\n context.effect(() => withdraw, 'session skill tools');\n context.inject([PO_CODEMODE_SERVICE, PO_ISOLATE_SERVICE], (bound) => {\n const codemode = readPoCodemode(bound);\n if (!codemode) return undefined;\n const registration = codemode.register(SKILL_NAMESPACE_SOURCE, createSkillNamespace(host, inventory, fs));\n // ponytail: the tools do not come back if code mode leaves mid-session; the next session has them.\n if (readPoIsolate(bound)?.liveObjects === true) withdraw();\n return () => registration.dispose();\n });\n };\n}\n","import type { PoHeadlessCommand, PoHeadlessCondition } from '@agimon-ai/po-core/headless';\nimport type { FileSystem } from '@agimon-ai/po-core/platform';\nimport type { Skill } from '@earendil-works/pi-coding-agent';\n\nimport { expandDeferredSkillCommand, type DeferredSkillSnapshot } from '../../../../../services/deferredSkills';\nimport type { ServerSkillGroup } from '../../../../../services/serverInventory';\nimport { groupConditions } from '../../../../../services/serverInventory/grouping';\nimport { SKILL_COMMAND_PREFIX, SKILL_INVOCATION_PREFIX, SKILLS_COMMAND } from '../../../../../types/skills';\n\n/**\n * One command per skill, gated by whatever activates that skill.\n *\n * Expansion always reads the full inventory, not the group: a command is only\n * dispatchable while its condition holds, so by the time one runs its skill is\n * active, and looking it up in the union keeps one lookup table instead of one\n * per domain.\n */\nfunction skillCommand(\n skill: Skill,\n when: PoHeadlessCondition | undefined,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem | undefined,\n): PoHeadlessCommand {\n return {\n ...(when === undefined ? {} : { when }),\n name: `${SKILL_COMMAND_PREFIX}${skill.name}`,\n description: skill.description,\n execute: async (args, execution) => {\n const text = `${SKILL_INVOCATION_PREFIX}${skill.name}${args ? ` ${args}` : ''}`;\n const expanded = await expandDeferredSkillCommand(text, inventory.skills, fs);\n if (expanded === text) throw new Error(`Skill '${skill.name}' is no longer readable.`);\n await admit(execution.session, expanded);\n },\n };\n}\n\n/**\n * The dispatching prompt acks when this command returns, so awaiting the whole\n * turn (session.prompt) kept the composer draft until the run ended.\n */\nfunction admit(session: Parameters<PoHeadlessCommand['execute']>[1]['session'], text: string): Promise<void> {\n return session.admitPrompt ? session.admitPrompt(text, 'prompt', 'operator') : session.prompt(text);\n}\nexport function createSkillCommands(\n inventory: DeferredSkillSnapshot,\n catalog: string,\n groups: readonly ServerSkillGroup[],\n fs?: FileSystem,\n t: (key: string, fallback: string) => string = (_key, fallback) => fallback,\n): readonly PoHeadlessCommand[] {\n return [\n {\n name: SKILLS_COMMAND,\n description: 'List discovered skills or invoke one by name.',\n async execute(args, execution) {\n const requested = args.trim();\n if (requested) {\n await admit(\n execution.session,\n await expandDeferredSkillCommand(`${SKILL_INVOCATION_PREFIX}${requested}`, inventory.skills, fs),\n );\n return;\n }\n await execution.client.notify({\n title: t('skill.notification.catalog', 'Po skills'),\n localization: { title: { key: 'skill.notification.catalog', fallback: 'Po skills' } },\n body: catalog,\n level: 'info',\n });\n },\n },\n ...groups.flatMap((group) =>\n groupConditions(group).flatMap((when) => group.skills.map((skill) => skillCommand(skill, when, inventory, fs))),\n ),\n ];\n}\n","import { readHarnessState } from '@agimon-ai/po-config/harnessState';\nimport type { PoHeadlessHostService } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { BACKGROUND_CONTEXT, getOrThrow, nodeHost, type FileSystem } from '@agimon-ai/po-core/platform';\nimport {\n type PoServerResources,\n type PoServerSessionPlugin,\n packageResourcePath,\n readPackageResource,\n} from '@agimon-ai/po-core/serverPlugin';\n\nimport { SKILL_INVENTORY_FRESH_MS } from '../../../../../constants/skillInventory';\nimport { mountMcpSkills } from '../../../../../services/mcpSkills';\nimport { discoverServerSkills } from '../../../../../services/serverInventory';\nimport { groupConditions } from '../../../../../services/serverInventory/grouping';\nimport { mountSkillNamespace } from '../../../../../services/skillNamespace';\nimport { createSkillCommands } from './skillCommands';\n\nexport async function createSkillServer(\n agent: PoHeadlessHostService,\n fs: FileSystem,\n signal: AbortSignal,\n resources: PoServerResources,\n t?: (key: string, fallback: string) => string,\n): Promise<PoServerSessionPlugin> {\n const execution = agent.context;\n // Sessions with the same inputs share one discovery. The key holds every input discoverServerSkills\n // reads besides the disk, so equal keys give equal inventories, and the window bounds how old that\n // read of the disk can be.\n const key = [\n 'inventory',\n execution.repoRoot,\n execution.cwd,\n execution.environment.HOME ?? nodeHost.homeDirectory(),\n ...(readHarnessState(execution.environment).skillDirectories ?? []),\n Math.floor(Date.now() / SKILL_INVENTORY_FRESH_MS),\n ];\n const { inventory, catalog, groups, mcpGroups, relations } = await resources.acquire(key, () =>\n // Every session sharing the discovery waits on it, so none of their signals may abort it.\n discoverServerSkills(execution, fs, new AbortController().signal),\n );\n return {\n commands: createSkillCommands(inventory, catalog, groups, fs, t),\n services: [mountMcpSkills(mcpGroups, fs, signal), mountSkillNamespace(agent, inventory, fs)],\n resources: [\n // Each skill joins the prompt's one <available_skills> list, gated like the rest.\n ...groups.flatMap((group) =>\n groupConditions(group).flatMap((when) =>\n group.skills.map((skill) => ({\n name: skill.name,\n description: skill.description,\n path: skill.filePath,\n kind: 'skill' as const,\n ...(relations?.[skill.filePath] === undefined ? {} : { relations: relations[skill.filePath] }),\n ...(when === undefined ? {} : { when }),\n read: async () => getOrThrow(await fs.readTextFile(skill.filePath, BACKGROUND_CONTEXT)),\n })),\n ),\n ),\n ...[\n {\n name: 'help-how-to-author-skill',\n description:\n 'Author and distribute Po agent skills. Use when creating a SKILL.md, contributing a runtime skill directory, or publishing activation-gated Help prompts and diagnostic tools.',\n },\n {\n name: 'help-how-to-skill',\n description:\n \"Use Po's skill catalog and deferred discovery. Diagnose missing or shadowed skills and invoke the narrowest available guidance.\",\n },\n ].map((skill) => ({\n ...skill,\n when: PO_HELP_WHEN,\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, `src/prompts/${skill.name}/SKILL.md`),\n read: () => readPackageResource(import.meta.url, `src/prompts/${skill.name}/SKILL.md`),\n })),\n ],\n };\n}\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { readPoLang, readPoPersonLocale } from '@agimon-ai/po-core/locale';\nimport { requirePoFs } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createSkillServer } from './_lib/skillServer';\n\nexport default defineRoot(async ({ agent, context: root, signal, resources }: PoServerPluginContext) => {\n const runtime: PoServerSessionPlugin = agent\n ? await createSkillServer(\n agent,\n requirePoFs(root),\n signal,\n resources,\n (key, fallback) => readPoLang(root)?.t(readPoPersonLocale(root)?.read(), key, fallback) ?? fallback,\n )\n : { commands: [], resources: [] };\n return { value: runtime, services: runtime.services };\n});\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.commands!,\n { cardinality: 'many' },\n);\n","// @scaffold-generated\nimport { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n name: 'codemode-how-to-skills',\n description:\n 'Search and load any skill by name through the skills namespace: the listed ones, the rest of the active catalog, and skills of unselected domains. Use before a task that a skill may cover.',\n // A code-mode guide: listed in the system prompt, outside the searchable catalog.\n pinned: true,\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/codemode-how-to-skills/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/codemode-how-to-skills/SKILL.md'),\n});\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.resources!,\n { cardinality: 'many' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandSkills from '../src/extensions/workspaces/sessions/(backend)/command/skills.server';\nimport resourceCodemodeHowToSkills from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server';\nimport resourceSkills from '../src/extensions/workspaces/sessions/(backend)/resource/skills.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\ntype ManyFactory<T, C> = (context: C) => T | readonly T[];\nconst many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {\n const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\n return Array.isArray(resolved) ? resolved : [resolved as T];\n};\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-skill',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return [...many(commandSkills, contextSession)]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceCodemodeHowToSkills, contextSession), ...many(resourceSkills, contextSession)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAa,2BAA2B;;;ACCxC,MAAa,qBAAqB;;AAOlC,SAAgB,eAAe,QAAqC,IAAgB,QAAqB;CACvG,QAAQ,YAA2B;EACjC,QAAQ,QAAQ,oBAAoB,EAClC,KAAK,QAAQ;GACX,OAAO,eAAe;GACtB,OAAO,OAAO,eAAe;GAC7B,MAAM,UAAU,OAAO,UAAU,KAAK,CAAC,CAAC;GACxC,MAAM,yBAAS,IAAI,IAAwB;GAC3C,KAAK,MAAM,SAAS,QAAQ;IAC1B,IAAI,MAAM,YAAY,KAAA,KAAa,CAAC,MAAM,QAAQ,MAAM,WAAW,QAAQ,SAAS,MAAM,CAAC,GAAG;IAC9F,KAAK,MAAM,SAAS,MAAM,QAAQ;KAEhC,IAAI,OAAO,IAAI,MAAM,IAAI,GAAG;KAC5B,OAAO,IAAI,MAAM,MAAM;MACrB,MAAM,MAAM;MACZ,aAAa,MAAM;MACnB,MAAM,OAAO;OACX,MAAM,aAAa,YAAY,IAAI,CAAC,QAAQ,OAAO,MAAM,CAAC;OAC1D,WAAW,eAAe;OAC1B,MAAM,OAAO,WACX,MAAM,GAAG,aAAa,MAAM,UAAU,gBAAgB,YAAY,kBAAkB,CAAC,CACvF;OACA,WAAW,eAAe;OAC1B,OAAO;MACT;KACF,CAAC;IACH;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Y,KAAK,6CAA6C;CACxF,YAAY,oBAAoB,YAAY,KAAK,6CAA6C;AAChG,CAAC;;;ACTD,IAAA,wBAAe,0BACZ,YAAoE,QAAQ,KAAK,WAClF,EAAE,aAAa,OAAO,CACxB;;;ACIA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AAEpE,MAAM,QAAc,OAA6C,YAA6B;CAC5F,MAAM,WAAW,OAAO,UAAU,aAAc,MAA4B,OAAO,IAAI;CACvF,OAAO,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAa;AAC5D;AAEA,MAAa,eAAe,mBAAmB;CAC7C,MAAM;CACN,mBAAmB,+BAA+BA,mBAAW;CAC7D,SAAS,mBAAmB,EAAE,SAAS,CAACA,mBAAW,EAAE,CAAC;CACtD,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAM,QAAQ,UAAU,WAAWA,qBAAa,OAAO;EAC5E,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,GAAG,iBAAiB,YAAY;GAChC,IAAI,WAA8C;IAAE,OAAO,CAAC,GAAG,KAAKC,yBAAe,cAAc,CAAC;GAAG;GACrG,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGC,uCAA6B,cAAc,GAAG,GAAG,KAAKC,uBAAgB,cAAc,CAAC;GAAG;GACzJ,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":1,"platformRequirements":{},"sourceFiles":["LICENSE","README.md","generated/mcp-ui.ts","generated/mcp.ts","generated/native.ts","generated/server.ts","generated/web.ts","llms.txt","locales/vi.json","locales/zh-CN.json","package.json","src/constants/skillInventory.ts","src/exports/apiContracts.ts","src/exports/catalog.ts","src/exports/index.ts","src/extensions/workspaces/sessions/(backend)/_lib/skillCommands.ts","src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts","src/extensions/workspaces/sessions/(backend)/command/skills.server.ts","src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server.ts","src/extensions/workspaces/sessions/(backend)/resource/skills.server.ts","src/extensions/workspaces/sessions/(backend)/root.server.ts","src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp.ts","src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.ts","src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.native.ts","src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.web.ts","src/extensions/workspaces/sessions/(frontend)/fill/_lib/helpGuides.ts","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_lib/skillToolView.ts","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.mcp.tsx","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.web.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.mcp.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.web.tsx","src/prompts/codemode-how-to-skills/SKILL.md","src/prompts/help-how-to-author-skill/SKILL.md","src/prompts/help-how-to-skill/SKILL.md","src/schemas/apiContracts.ts","src/schemas/mcpSkillTools.ts","src/services/deferredSkills/index.edge.ts","src/services/deferredSkills/index.ts","src/services/mcpSkillTools/index.ts","src/services/mcpSkills/index.ts","src/services/serverInventory/catalog.ts","src/services/serverInventory/grouping.ts","src/services/serverInventory/index.edge.ts","src/services/serverInventory/index.ts","src/services/skillCatalog/index.ts","src/services/skillNamespace/index.ts","src/types/skills.ts","tsdown.config.ts"],"sourceRevision":"
|
|
1
|
+
{"version":1,"platformRequirements":{},"sourceFiles":["LICENSE","README.md","generated/mcp-ui.ts","generated/mcp.ts","generated/native.ts","generated/server.ts","generated/web.ts","llms.txt","locales/vi.json","locales/zh-CN.json","package.json","src/constants/skillInventory.ts","src/exports/apiContracts.ts","src/exports/catalog.ts","src/exports/index.ts","src/extensions/workspaces/sessions/(backend)/_lib/skillCommands.ts","src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts","src/extensions/workspaces/sessions/(backend)/command/skills.server.ts","src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server.ts","src/extensions/workspaces/sessions/(backend)/resource/skills.server.ts","src/extensions/workspaces/sessions/(backend)/root.server.ts","src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp.ts","src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.ts","src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.native.ts","src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.web.ts","src/extensions/workspaces/sessions/(frontend)/fill/_lib/helpGuides.ts","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_lib/skillToolView.ts","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.mcp.tsx","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.web.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.mcp.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.web.tsx","src/prompts/codemode-how-to-skills/SKILL.md","src/prompts/help-how-to-author-skill/SKILL.md","src/prompts/help-how-to-skill/SKILL.md","src/schemas/apiContracts.ts","src/schemas/mcpSkillTools.ts","src/services/deferredSkills/index.edge.ts","src/services/deferredSkills/index.ts","src/services/mcpSkillTools/index.ts","src/services/mcpSkills/index.ts","src/services/serverInventory/catalog.ts","src/services/serverInventory/grouping.ts","src/services/serverInventory/index.edge.ts","src/services/serverInventory/index.ts","src/services/skillCatalog/index.ts","src/services/skillNamespace/index.ts","src/types/skills.ts","tsdown.config.ts"],"sourceRevision":"a3b90e0fd3c30bee588f551ab7841d62","manifestRevision":"0b994ddb55899c539654d4e8bd2160d8","outputFiles":["LICENSE","README.md","dist/apiContracts.cjs","dist/apiContracts.mjs","dist/catalog.cjs","dist/catalog.mjs","dist/extensions/mcp-ui.mjs","dist/extensions/mcp.cjs","dist/extensions/mcp.mjs","dist/extensions/native.mjs","dist/extensions/server.cjs","dist/extensions/server.mjs","dist/extensions/web.mjs","dist/index.cjs","dist/index.mjs","dist/rolldown-runtime-VH7oDXx4.cjs","dist/skills-Ccvg1Hcz.mjs","dist/skills-ComtgYb1.cjs","llms.txt","locales/vi.json","locales/zh-CN.json","src/prompts/codemode-how-to-skills/SKILL.md","src/prompts/help-how-to-author-skill/SKILL.md","src/prompts/help-how-to-skill/SKILL.md"],"outputRevision":"50f07c35de0b484b31ca9265f888051c"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-skill",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.220",
|
|
4
4
|
"description": "Session skill catalogue, deferred skill discovery, and the skill browser for Po.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-skills",
|
|
@@ -74,18 +74,18 @@
|
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@agimon-ai/po-config": "0.0.0-alpha.
|
|
78
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
79
|
-
"@agimon-ai/po-domain": "0.0.0-alpha.
|
|
80
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
77
|
+
"@agimon-ai/po-config": "0.0.0-alpha.220",
|
|
78
|
+
"@agimon-ai/po-core": "0.0.0-alpha.220",
|
|
79
|
+
"@agimon-ai/po-domain": "0.0.0-alpha.220",
|
|
80
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.220",
|
|
81
81
|
"@deepseek-ai/cordis": "4.0.5",
|
|
82
82
|
"gpt-tokenizer": "4.1.0",
|
|
83
83
|
"typebox": "1.4.2"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
87
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
88
|
-
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.
|
|
86
|
+
"@agimon-ai/po-build": "0.0.0-alpha.220",
|
|
87
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.220",
|
|
88
|
+
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.220",
|
|
89
89
|
"@deepseek-ai/cordis": "4.0.5",
|
|
90
90
|
"@earendil-works/pi-coding-agent": "1.6.1",
|
|
91
91
|
"@types/node": "26.6.5",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"vitest": "5.0.4"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
104
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.220",
|
|
105
105
|
"@earendil-works/pi-coding-agent": "1.6.1",
|
|
106
106
|
"react-native": "0.88.1",
|
|
107
107
|
"react-native-unistyles": "^3.5.3"
|
|
@@ -30,9 +30,11 @@ To relate a skill to another, use one of three explicit forms. Prose and backtic
|
|
|
30
30
|
skill: codemode-how-to-lint
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
- A literal Markdown link to another skill's file, such as `[lint](
|
|
33
|
+
- A literal Markdown link to another skill's file, such as `[lint](<path-to-skill>/SKILL.md)` with the real relative path, recorded as `references`.
|
|
34
34
|
- `@skill:<name>` in the body, for example `@skill:codemode-how-to-lint`, when the skill cannot know where the other is installed. Also recorded as `references`.
|
|
35
35
|
|
|
36
|
+
To point at a code-mode namespace another plugin provides, write `@codemode:<ns>` or `@codemode:<ns>.<member>` in the body, for example `@codemode:lint.check`. Brain links the skill straight to that namespace and reports a namespace this session does not have. It is a pointer only, separate from skill relations.
|
|
37
|
+
|
|
36
38
|
The same rules apply to repository, plugin, and Po package skills: Po parses the text it already read for the session. Relations declared in code come first and the file adds to them; a `requires` hides a link to the same skill. Brain shows every relation and reports malformed frontmatter or a target this session does not have. A relation never loads the target or grants access: the agent loads it with `load_skill` (or `skills.load` in code mode) only when it needs it.
|
|
37
39
|
|
|
38
40
|
## Choose the distribution path
|