@agimon-ai/po-skill 0.0.0-alpha.201 → 0.0.0-alpha.202
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 +7 -3
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.mjs +7 -3
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/server.cjs +135 -16
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +136 -17
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/po-runtime-identity.json +1 -1
- package/dist/skills-Ccvg1Hcz.mjs.map +1 -1
- package/dist/skills-ComtgYb1.cjs.map +1 -1
- package/llms.txt +1 -0
- package/package.json +9 -9
- package/src/prompts/codemode-how-to-skills/SKILL.md +15 -0
package/dist/extensions/mcp.cjs
CHANGED
|
@@ -47,6 +47,12 @@ function skills(context) {
|
|
|
47
47
|
if (context.mcpSkills === void 0) throw new Error("Remote skill access is unavailable.");
|
|
48
48
|
return context.mcpSkills;
|
|
49
49
|
}
|
|
50
|
+
/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */
|
|
51
|
+
function matchSkills(skills, query) {
|
|
52
|
+
const needle = query?.trim().toLocaleLowerCase();
|
|
53
|
+
if (needle === void 0 || needle === "") return [...skills];
|
|
54
|
+
return skills.filter(({ name, description }) => `${name}\n${description}`.toLocaleLowerCase().includes(needle));
|
|
55
|
+
}
|
|
50
56
|
function createSearchSkillsTool() {
|
|
51
57
|
return {
|
|
52
58
|
name: "search_skills",
|
|
@@ -59,9 +65,7 @@ function createSearchSkillsTool() {
|
|
|
59
65
|
openWorldHint: false
|
|
60
66
|
},
|
|
61
67
|
async execute(_toolCallId, { query }, _signal, _onUpdate, context) {
|
|
62
|
-
const
|
|
63
|
-
const available = await skills(context).list();
|
|
64
|
-
const matches = needle === void 0 || needle === "" ? available : available.filter(({ name, description }) => `${name}\n${description}`.toLocaleLowerCase().includes(needle));
|
|
68
|
+
const matches = matchSkills(await skills(context).list(), query);
|
|
65
69
|
return {
|
|
66
70
|
...text(JSON.stringify(matches)),
|
|
67
71
|
structuredContent: { skills: matches }
|
|
@@ -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\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 needle = query?.trim().toLocaleLowerCase();\n const available = await skills(context).list();\n const matches =\n needle === undefined || needle === ''\n ? available\n : available.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\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 needle = query?.trim().toLocaleLowerCase();\n const available = host.listSkills().map(({ name, description }) => ({ name, description }));\n const matches =\n needle === undefined || needle === ''\n ? available\n : available.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\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 (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\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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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 (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\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,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;GAChE,OAAO,KAAK,MAAM,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;EAC9C;CACF;AACF;;;AClFA,IAAA,0BAAA,GAAeC,4BAAAA,cAAAA,CAAc,oBAAoB,CAAC;;;ACAlD,IAAA,6BAAA,GAAeC,4BAAAA,cAAAA,CAAc,uBAAuB,CAAC;;;ACMrD,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;AACA,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,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"}
|
package/dist/extensions/mcp.mjs
CHANGED
|
@@ -43,6 +43,12 @@ function skills(context) {
|
|
|
43
43
|
if (context.mcpSkills === void 0) throw new Error("Remote skill access is unavailable.");
|
|
44
44
|
return context.mcpSkills;
|
|
45
45
|
}
|
|
46
|
+
/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */
|
|
47
|
+
function matchSkills(skills, query) {
|
|
48
|
+
const needle = query?.trim().toLocaleLowerCase();
|
|
49
|
+
if (needle === void 0 || needle === "") return [...skills];
|
|
50
|
+
return skills.filter(({ name, description }) => `${name}\n${description}`.toLocaleLowerCase().includes(needle));
|
|
51
|
+
}
|
|
46
52
|
function createSearchSkillsTool() {
|
|
47
53
|
return {
|
|
48
54
|
name: "search_skills",
|
|
@@ -55,9 +61,7 @@ function createSearchSkillsTool() {
|
|
|
55
61
|
openWorldHint: false
|
|
56
62
|
},
|
|
57
63
|
async execute(_toolCallId, { query }, _signal, _onUpdate, context) {
|
|
58
|
-
const
|
|
59
|
-
const available = await skills(context).list();
|
|
60
|
-
const matches = needle === void 0 || needle === "" ? available : available.filter(({ name, description }) => `${name}\n${description}`.toLocaleLowerCase().includes(needle));
|
|
64
|
+
const matches = matchSkills(await skills(context).list(), query);
|
|
61
65
|
return {
|
|
62
66
|
...text(JSON.stringify(matches)),
|
|
63
67
|
structuredContent: { skills: matches }
|
|
@@ -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\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 needle = query?.trim().toLocaleLowerCase();\n const available = await skills(context).list();\n const matches =\n needle === undefined || needle === ''\n ? available\n : available.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\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 needle = query?.trim().toLocaleLowerCase();\n const available = host.listSkills().map(({ name, description }) => ({ name, description }));\n const matches =\n needle === undefined || needle === ''\n ? available\n : available.filter(({ name, description }) => `${name}\\n${description}`.toLocaleLowerCase().includes(needle));\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 (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\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,c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AW,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 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 (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\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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,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,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,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"}
|
|
@@ -21,6 +21,7 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
21
21
|
node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises, 1);
|
|
22
22
|
let node_url = require("node:url");
|
|
23
23
|
let node_worker_threads = require("node:worker_threads");
|
|
24
|
+
let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
|
|
24
25
|
//#region src/constants/skillInventory.ts
|
|
25
26
|
/**
|
|
26
27
|
* How long sessions with the same inputs share one skill inventory instead of each reading the disk.
|
|
@@ -72,6 +73,12 @@ function text(text) {
|
|
|
72
73
|
text
|
|
73
74
|
}] };
|
|
74
75
|
}
|
|
76
|
+
/** Case-insensitive substring match on name and description; an empty query keeps everything, in order. */
|
|
77
|
+
function matchSkills(skills, query) {
|
|
78
|
+
const needle = query?.trim().toLocaleLowerCase();
|
|
79
|
+
if (needle === void 0 || needle === "") return [...skills];
|
|
80
|
+
return skills.filter(({ name, description }) => `${name}\n${description}`.toLocaleLowerCase().includes(needle));
|
|
81
|
+
}
|
|
75
82
|
function createSessionSearchSkillsTool(host) {
|
|
76
83
|
return {
|
|
77
84
|
name: "search_skills",
|
|
@@ -85,12 +92,10 @@ function createSessionSearchSkillsTool(host) {
|
|
|
85
92
|
},
|
|
86
93
|
executionMode: "parallel",
|
|
87
94
|
async execute(_toolCallId, { query }) {
|
|
88
|
-
const
|
|
89
|
-
const available = host.listSkills().map(({ name, description }) => ({
|
|
95
|
+
const matches = matchSkills(host.listSkills().map(({ name, description }) => ({
|
|
90
96
|
name,
|
|
91
97
|
description
|
|
92
|
-
}));
|
|
93
|
-
const matches = needle === void 0 || needle === "" ? available : available.filter(({ name, description }) => `${name}\n${description}`.toLocaleLowerCase().includes(needle));
|
|
98
|
+
})), query);
|
|
94
99
|
return {
|
|
95
100
|
...text(JSON.stringify(matches)),
|
|
96
101
|
structuredContent: { skills: matches }
|
|
@@ -288,6 +293,13 @@ async function expandDeferredSkillCommand(text, skills, _fs) {
|
|
|
288
293
|
}
|
|
289
294
|
//#endregion
|
|
290
295
|
//#region src/services/serverInventory/grouping.ts
|
|
296
|
+
/**
|
|
297
|
+
* Each condition that activates a group: its domains, then each plugin turned on for this session only.
|
|
298
|
+
* Declare one contribution per condition; the host keeps one per name once gating has run.
|
|
299
|
+
*/
|
|
300
|
+
function groupConditions(group) {
|
|
301
|
+
return [group.domains === void 0 ? void 0 : { domains: group.domains }, ...(group.plugins ?? []).map((plugin) => ({ state: { plugins: plugin } }))];
|
|
302
|
+
}
|
|
291
303
|
const LOCAL_ONLY_MCP_PACKAGES = /* @__PURE__ */ new Set([
|
|
292
304
|
"@agimon-ai/po-author",
|
|
293
305
|
"@agimon-ai/po-git",
|
|
@@ -334,8 +346,11 @@ function groupSkills(skills, sources, key) {
|
|
|
334
346
|
const admitting = sources.filter((source) => within(skill.filePath, source[key]));
|
|
335
347
|
if (admitting.length === 0) return [];
|
|
336
348
|
const domains = [...new Set(admitting.flatMap((source) => source.domain === void 0 ? [] : [source.domain]))];
|
|
349
|
+
const plugins = [...new Set(admitting.flatMap((source) => source.plugin === void 0 ? [] : [source.plugin]))];
|
|
350
|
+
const repository = admitting.some((source) => source.domain === void 0 && source.plugin === void 0);
|
|
337
351
|
return [{
|
|
338
|
-
...
|
|
352
|
+
...repository ? {} : { domains },
|
|
353
|
+
...repository || plugins.length === 0 ? {} : { plugins },
|
|
339
354
|
skills: [skill]
|
|
340
355
|
}];
|
|
341
356
|
});
|
|
@@ -384,7 +399,7 @@ async function discoverServerSkills(execution, fs, signal) {
|
|
|
384
399
|
domain,
|
|
385
400
|
paths: [...previous.paths],
|
|
386
401
|
mcpPaths: [...previous.mcpPaths]
|
|
387
|
-
});
|
|
402
|
+
}, ...previous.plugins);
|
|
388
403
|
continue;
|
|
389
404
|
}
|
|
390
405
|
const mcpPluginRoots = (await Promise.all(plugins.map(async (plugin) => await isMcpSkillPlugin(fs, plugin, context) ? node_path.default.join(plugin.directory, "skills") : void 0))).filter((root) => root !== void 0);
|
|
@@ -398,15 +413,24 @@ async function discoverServerSkills(execution, fs, signal) {
|
|
|
398
413
|
try {
|
|
399
414
|
const paths = Object.freeze([...collected.skillDirectories]);
|
|
400
415
|
const mcpPaths = Object.freeze(paths.filter((skillPath) => within(skillPath, mcpPluginRoots)));
|
|
416
|
+
const pluginSources = plugins.flatMap(({ name, directory }) => {
|
|
417
|
+
const own = paths.filter((skillPath) => within(skillPath, [directory]));
|
|
418
|
+
return name === void 0 || own.length === 0 ? [] : [{
|
|
419
|
+
plugin: name,
|
|
420
|
+
paths: own,
|
|
421
|
+
mcpPaths: []
|
|
422
|
+
}];
|
|
423
|
+
});
|
|
401
424
|
discovered.set(key, Object.freeze({
|
|
402
425
|
paths,
|
|
403
|
-
mcpPaths
|
|
426
|
+
mcpPaths,
|
|
427
|
+
plugins: pluginSources
|
|
404
428
|
}));
|
|
405
429
|
if (paths.length > 0) sources.push({
|
|
406
430
|
domain,
|
|
407
431
|
paths: [...paths],
|
|
408
432
|
mcpPaths: [...mcpPaths]
|
|
409
|
-
});
|
|
433
|
+
}, ...pluginSources);
|
|
410
434
|
} finally {
|
|
411
435
|
await collected.cleanup();
|
|
412
436
|
}
|
|
@@ -449,6 +473,90 @@ async function discoverServerSkills(execution, fs, signal) {
|
|
|
449
473
|
};
|
|
450
474
|
}
|
|
451
475
|
//#endregion
|
|
476
|
+
//#region src/services/skillNamespace/index.ts
|
|
477
|
+
const SKILL_NAMESPACE_SOURCE = "@agimon-ai/po-skill";
|
|
478
|
+
function queryOf(input) {
|
|
479
|
+
if (input === void 0) return void 0;
|
|
480
|
+
const query = typeof input === "object" && input !== null ? input.query : 0;
|
|
481
|
+
if (query === void 0 || typeof query === "string") return query;
|
|
482
|
+
throw new Error("Pass { query?: string }.");
|
|
483
|
+
}
|
|
484
|
+
function nameOf(input) {
|
|
485
|
+
const name = input?.name;
|
|
486
|
+
if (typeof name !== "string" || name.trim() === "") throw new Error("Pass { name: string }, a name from skills.search.");
|
|
487
|
+
return name;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Skills of every domain in domains.yaml, selected or not, plus the session's own. Reading one never selects its
|
|
491
|
+
* domain or plugin, so it grants no tools, hooks or MCP servers. Disabled plugins never reach the inventory.
|
|
492
|
+
*/
|
|
493
|
+
function createSkillNamespace(host, inventory, fs) {
|
|
494
|
+
return {
|
|
495
|
+
name: "skills",
|
|
496
|
+
summary: "Search and read skills beyond the active set, including unselected domains. Reading enables nothing.",
|
|
497
|
+
declarations: `declare const skills: {
|
|
498
|
+
/** Active skills first, then skills of unselected domains. Omit query to list everything. */
|
|
499
|
+
search(input?: { query?: string }): Promise<{ name: string; description: string; active: boolean }[]>;
|
|
500
|
+
/** Full SKILL.md text by exact name from search. Grants no tools, hooks or MCP servers. */
|
|
501
|
+
load(input: { name: string }): Promise<string>;
|
|
502
|
+
};`,
|
|
503
|
+
bind(run) {
|
|
504
|
+
if (run.sessionId !== host.context.sessionId) throw new Error("Skills namespace belongs to another session.");
|
|
505
|
+
let disposed = false;
|
|
506
|
+
run.onDispose(() => {
|
|
507
|
+
disposed = true;
|
|
508
|
+
});
|
|
509
|
+
const check = () => {
|
|
510
|
+
if (disposed) throw new Error("Skills namespace run is disposed.");
|
|
511
|
+
run.signal.throwIfAborted();
|
|
512
|
+
};
|
|
513
|
+
return {
|
|
514
|
+
async search(input) {
|
|
515
|
+
const query = queryOf(input);
|
|
516
|
+
check();
|
|
517
|
+
const seen = /* @__PURE__ */ new Set();
|
|
518
|
+
const all = [];
|
|
519
|
+
for (const { name, description } of host.listSkills()) {
|
|
520
|
+
seen.add(name);
|
|
521
|
+
all.push({
|
|
522
|
+
name,
|
|
523
|
+
description,
|
|
524
|
+
active: true
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
for (const { name, description } of inventory.skills) if (!seen.has(name)) all.push({
|
|
528
|
+
name,
|
|
529
|
+
description,
|
|
530
|
+
active: false
|
|
531
|
+
});
|
|
532
|
+
return matchSkills(all, query);
|
|
533
|
+
},
|
|
534
|
+
async load(input) {
|
|
535
|
+
const name = nameOf(input);
|
|
536
|
+
check();
|
|
537
|
+
const active = host.readSkill(name);
|
|
538
|
+
if (active !== void 0) return active;
|
|
539
|
+
const skill = inventory.skills.find((entry) => entry.name === name);
|
|
540
|
+
if (!skill) throw new Error(`No skill named ${name}. Use skills.search to find one.`);
|
|
541
|
+
const text = (0, _agimon_ai_po_core_platform.getOrThrow)(await fs.readTextFile(skill.filePath, (0, _agimon_ai_po_core_platform.withAbortSignal)(run.signal, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT)));
|
|
542
|
+
check();
|
|
543
|
+
return text;
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function mountSkillNamespace(host, inventory, fs) {
|
|
550
|
+
return (context) => {
|
|
551
|
+
context.inject([_agimon_ai_po_core_codemode.PO_CODEMODE_SERVICE], (bound) => {
|
|
552
|
+
const codemode = (0, _agimon_ai_po_core_codemode.readPoCodemode)(bound);
|
|
553
|
+
if (!codemode) return void 0;
|
|
554
|
+
const registration = codemode.register(SKILL_NAMESPACE_SOURCE, createSkillNamespace(host, inventory, fs));
|
|
555
|
+
return () => registration.dispose();
|
|
556
|
+
});
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
//#endregion
|
|
452
560
|
//#region src/extensions/workspaces/sessions/(backend)/_lib/skillCommands.ts
|
|
453
561
|
/**
|
|
454
562
|
* One command per skill, gated by whatever activates that skill.
|
|
@@ -458,9 +566,9 @@ async function discoverServerSkills(execution, fs, signal) {
|
|
|
458
566
|
* active, and looking it up in the union keeps one lookup table instead of one
|
|
459
567
|
* per domain.
|
|
460
568
|
*/
|
|
461
|
-
function skillCommand(skill,
|
|
569
|
+
function skillCommand(skill, when, inventory, fs) {
|
|
462
570
|
return {
|
|
463
|
-
...
|
|
571
|
+
...when === void 0 ? {} : { when },
|
|
464
572
|
name: `${require_skills.SKILL_COMMAND_PREFIX}${skill.name}`,
|
|
465
573
|
description: skill.description,
|
|
466
574
|
execute: async (args, execution) => {
|
|
@@ -498,7 +606,7 @@ function createSkillCommands(inventory, catalog, groups, fs, t = (_key, fallback
|
|
|
498
606
|
level: "info"
|
|
499
607
|
});
|
|
500
608
|
}
|
|
501
|
-
}, ...groups.flatMap((group) => group.skills.map((skill) => skillCommand(skill,
|
|
609
|
+
}, ...groups.flatMap((group) => groupConditions(group).flatMap((when) => group.skills.map((skill) => skillCommand(skill, when, inventory, fs))))];
|
|
502
610
|
}
|
|
503
611
|
//#endregion
|
|
504
612
|
//#region src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts
|
|
@@ -516,15 +624,15 @@ async function createSkillServer(agent, fs, signal, resources, t) {
|
|
|
516
624
|
return {
|
|
517
625
|
commands: createSkillCommands(inventory, catalog, groups, fs, t),
|
|
518
626
|
tools: [createSessionLoadSkillTool(agent), createSessionSearchSkillsTool(agent)],
|
|
519
|
-
services: [mountMcpSkills(mcpGroups, fs, signal)],
|
|
520
|
-
resources: [...groups.flatMap((group) => group.skills.map((skill) => ({
|
|
627
|
+
services: [mountMcpSkills(mcpGroups, fs, signal), mountSkillNamespace(agent, inventory, fs)],
|
|
628
|
+
resources: [...groups.flatMap((group) => groupConditions(group).flatMap((when) => group.skills.map((skill) => ({
|
|
521
629
|
name: skill.name,
|
|
522
630
|
description: skill.description,
|
|
523
631
|
path: skill.filePath,
|
|
524
632
|
kind: "skill",
|
|
525
|
-
...
|
|
633
|
+
...when === void 0 ? {} : { when },
|
|
526
634
|
read: async () => (0, _agimon_ai_po_core_platform.getOrThrow)(await fs.readTextFile(skill.filePath, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT))
|
|
527
|
-
}))), ...[{
|
|
635
|
+
})))), ...[{
|
|
528
636
|
name: "help-how-to-author-skill",
|
|
529
637
|
description: "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."
|
|
530
638
|
}, {
|
|
@@ -555,6 +663,16 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async
|
|
|
555
663
|
//#region src/extensions/workspaces/sessions/(backend)/command/skills.server.ts
|
|
556
664
|
var skills_server_default$1 = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.commands, { cardinality: "many" });
|
|
557
665
|
//#endregion
|
|
666
|
+
//#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server.ts
|
|
667
|
+
var codemode_how_to_skills_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
|
|
668
|
+
name: "codemode-how-to-skills",
|
|
669
|
+
description: "Search and read skills outside the active set, including skills of unselected domains, through the skills namespace. Use when no listed skill fits the task.",
|
|
670
|
+
pinned: true,
|
|
671
|
+
kind: "skill",
|
|
672
|
+
path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-skills/SKILL.md"),
|
|
673
|
+
read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-skills/SKILL.md")
|
|
674
|
+
});
|
|
675
|
+
//#endregion
|
|
558
676
|
//#region src/extensions/workspaces/sessions/(backend)/resource/skills.server.ts
|
|
559
677
|
var skills_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.resources, { cardinality: "many" });
|
|
560
678
|
//#endregion
|
|
@@ -563,6 +681,7 @@ var skills_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedCon
|
|
|
563
681
|
var load_skill_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.tools ?? [], { cardinality: "many" });
|
|
564
682
|
//#endregion
|
|
565
683
|
//#region generated/server.ts
|
|
684
|
+
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
566
685
|
const many = (value, context) => {
|
|
567
686
|
const resolved = typeof value === "function" ? value(context) : value;
|
|
568
687
|
return Array.isArray(resolved) ? resolved : [resolved];
|
|
@@ -583,7 +702,7 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
583
702
|
return [...many(skills_server_default$1, contextSession)];
|
|
584
703
|
},
|
|
585
704
|
get resources() {
|
|
586
|
-
return [...many(skills_server_default, contextSession)];
|
|
705
|
+
return [at(codemode_how_to_skills_server_default, contextSession), ...many(skills_server_default, contextSession)];
|
|
587
706
|
},
|
|
588
707
|
get tools() {
|
|
589
708
|
return [...many(load_skill_server_default, contextSession)];
|