@agimon-ai/po-skill 0.0.0-alpha.195 → 0.0.0-alpha.197
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-ui.mjs +7 -5
- package/dist/extensions/mcp-ui.mjs.map +1 -1
- package/dist/extensions/native.mjs +7 -5
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +17 -14
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +18 -15
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +11 -8
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/po-runtime-identity.json +1 -1
- package/package.json +9 -9
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { defineMcpWidget } from "@agimon-ai/po-core/web";
|
|
1
|
+
import { defineMcpWidget, useT } from "@agimon-ai/po-core/web";
|
|
2
2
|
import { McpToolFields, McpToolFrame, McpToolOutput } from "@agimon-ai/po-web-components";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region src/extensions/workspaces/sessions/(frontend)/tool/load_skill.mcp.tsx
|
|
5
5
|
function LoadSkillMcpWidget(props) {
|
|
6
|
+
const t = useT();
|
|
6
7
|
return /* @__PURE__ */ jsxs(McpToolFrame, {
|
|
7
8
|
...props,
|
|
8
|
-
title: "Load skill",
|
|
9
|
-
children: [/* @__PURE__ */ jsx(McpToolFields, { fields: [["Skill", props.args.name]] }), /* @__PURE__ */ jsx(McpToolOutput, { result: props.result })]
|
|
9
|
+
title: t("skill.mcp.loadSkill", "Load skill"),
|
|
10
|
+
children: [/* @__PURE__ */ jsx(McpToolFields, { fields: [[t("skill.mcp.skill", "Skill"), props.args.name]] }), /* @__PURE__ */ jsx(McpToolOutput, { result: props.result })]
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
13
|
var load_skill_mcp_default = defineMcpWidget(LoadSkillMcpWidget);
|
|
13
14
|
//#endregion
|
|
14
15
|
//#region src/extensions/workspaces/sessions/(frontend)/tool/search_skills.mcp.tsx
|
|
15
16
|
function SearchSkillsMcpWidget(props) {
|
|
17
|
+
const t = useT();
|
|
16
18
|
return /* @__PURE__ */ jsxs(McpToolFrame, {
|
|
17
19
|
...props,
|
|
18
|
-
title: "Search skills",
|
|
19
|
-
children: [/* @__PURE__ */ jsx(McpToolFields, { fields: [["Query", props.args.query]] }), /* @__PURE__ */ jsx(McpToolOutput, { result: props.result })]
|
|
20
|
+
title: t("skill.mcp.searchSkills", "Search skills"),
|
|
21
|
+
children: [/* @__PURE__ */ jsx(McpToolFields, { fields: [[t("skill.mcp.query", "Query"), props.args.query]] }), /* @__PURE__ */ jsx(McpToolOutput, { result: props.result })]
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-ui.mjs","names":["Widget0","Widget1"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.mcp.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.mcp.tsx","../../generated/mcp-ui.ts"],"sourcesContent":["import { defineMcpWidget, type PoMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport { McpToolFrame, McpToolFields, McpToolOutput } from '@agimon-ai/po-web-components';\n\nfunction LoadSkillMcpWidget(props: PoMcpWidgetProps) {\n return (\n <McpToolFrame {...props} title
|
|
1
|
+
{"version":3,"file":"mcp-ui.mjs","names":["Widget0","Widget1"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.mcp.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.mcp.tsx","../../generated/mcp-ui.ts"],"sourcesContent":["import { defineMcpWidget, useT, type PoMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport { McpToolFrame, McpToolFields, McpToolOutput } from '@agimon-ai/po-web-components';\n\nfunction LoadSkillMcpWidget(props: PoMcpWidgetProps) {\n const t = useT();\n return (\n <McpToolFrame {...props} title={t('skill.mcp.loadSkill', 'Load skill')}>\n <McpToolFields fields={[[t('skill.mcp.skill', 'Skill'), props.args.name]]} />\n <McpToolOutput result={props.result} />\n </McpToolFrame>\n );\n}\n\nexport default defineMcpWidget(LoadSkillMcpWidget);\n","import { defineMcpWidget, useT, type PoMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport { McpToolFrame, McpToolFields, McpToolOutput } from '@agimon-ai/po-web-components';\n\nfunction SearchSkillsMcpWidget(props: PoMcpWidgetProps) {\n const t = useT();\n return (\n <McpToolFrame {...props} title={t('skill.mcp.searchSkills', 'Search skills')}>\n <McpToolFields fields={[[t('skill.mcp.query', 'Query'), props.args.query]]} />\n <McpToolOutput result={props.result} />\n </McpToolFrame>\n );\n}\n\nexport default defineMcpWidget(SearchSkillsMcpWidget);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport type { ComponentType } from 'react';\nimport type { PoMcpWidgetProps } from '@agimon-ai/po-core/mcpWidget';\nimport Widget0 from \"../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.mcp\";\nimport Widget1 from \"../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.mcp\";\n\nexport const widgets: Readonly<Record<string, ComponentType<PoMcpWidgetProps>>> = {\n \"@agimon-ai/po-skill/load_skill\": Widget0,\n \"@agimon-ai/po-skill/search_skills\": Widget1,\n};\n"],"mappings":";;;;AAGA,SAAS,mBAAmB,OAAyB;CACnD,MAAM,IAAI,KAAK;CACf,OACE,qBAAC,cAAD;EAAc,GAAI;EAAO,OAAO,EAAE,uBAAuB,YAAY;EAArE,UAAA,CACE,oBAAC,eAAD,EAAe,QAAQ,CAAC,CAAC,EAAE,mBAAmB,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC,EAAI,CAAA,GAC5E,oBAAC,eAAD,EAAe,QAAQ,MAAM,OAAS,CAAA,CAC1B;;AAElB;AAEA,IAAA,yBAAe,gBAAgB,kBAAkB;;;ACVjD,SAAS,sBAAsB,OAAyB;CACtD,MAAM,IAAI,KAAK;CACf,OACE,qBAAC,cAAD;EAAc,GAAI;EAAO,OAAO,EAAE,0BAA0B,eAAe;EAA3E,UAAA,CACE,oBAAC,eAAD,EAAe,QAAQ,CAAC,CAAC,EAAE,mBAAmB,OAAO,GAAG,MAAM,KAAK,KAAK,CAAC,EAAI,CAAA,GAC7E,oBAAC,eAAD,EAAe,QAAQ,MAAM,OAAS,CAAA,CAC1B;;AAElB;;;ACLA,MAAa,UAAqE;CAChF,kCAAkCA;CAClC,qCDKa,gBAAgB,qBCLQC;AACvC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNativePlugin, defineToolRenderer } from "@agimon-ai/po-core/native";
|
|
1
|
+
import { defineNativePlugin, defineToolRenderer, useT } from "@agimon-ai/po-core/native";
|
|
2
2
|
import { View } from "react-native-unistyles/components/native/View";
|
|
3
3
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
4
4
|
import { Markdown, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, fontOf, toolTone } from "@agimon-ai/po-native-components";
|
|
@@ -57,6 +57,7 @@ function skillMatches(result, output) {
|
|
|
57
57
|
* in the header and, once expanded, the instructions the agent read.
|
|
58
58
|
*/
|
|
59
59
|
function LoadSkillToolMessage({ args, result, output, running, isError }) {
|
|
60
|
+
const t = useT();
|
|
60
61
|
const name = loadSkillName(args);
|
|
61
62
|
const body = result === null || isError ? "" : skillBody(resultText(result, output));
|
|
62
63
|
return /* @__PURE__ */ jsx(MessageItem, {
|
|
@@ -87,7 +88,7 @@ function LoadSkillToolMessage({ args, result, output, running, isError }) {
|
|
|
87
88
|
testID: "tool-result-load_skill",
|
|
88
89
|
children: /* @__PURE__ */ jsx(MessageItemStatus, {
|
|
89
90
|
tone: "running",
|
|
90
|
-
children: "running"
|
|
91
|
+
children: t("skill.ui.running", "running")
|
|
91
92
|
})
|
|
92
93
|
}) : null : body.length === 0 ? null : /* @__PURE__ */ jsx(MessageItemBody, {
|
|
93
94
|
testID: "tool-result-load_skill",
|
|
@@ -131,6 +132,7 @@ var load_skill_native_default = defineToolRenderer({ message: LoadSkillToolMessa
|
|
|
131
132
|
* its description.
|
|
132
133
|
*/
|
|
133
134
|
function SearchSkillsToolMessage({ args, result, output, running, isError }) {
|
|
135
|
+
const t = useT();
|
|
134
136
|
const query = searchQuery(args);
|
|
135
137
|
const matches = result === null || isError ? [] : skillMatches(result, output);
|
|
136
138
|
const count = result === null || isError ? void 0 : `${matches.length} ${matches.length === 1 ? "skill" : "skills"}`;
|
|
@@ -148,7 +150,7 @@ function SearchSkillsToolMessage({ args, result, output, running, isError }) {
|
|
|
148
150
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
149
151
|
numberOfLines: 1,
|
|
150
152
|
style: [styles.sans, query === void 0 ? styles.dim : styles.primary],
|
|
151
|
-
children: query ?? "all skills"
|
|
153
|
+
children: query ?? t("skill.ui.allSkills", "all skills")
|
|
152
154
|
}), count !== void 0 ? /* @__PURE__ */ jsxs(Text, {
|
|
153
155
|
numberOfLines: 1,
|
|
154
156
|
style: [styles.sans, styles.detail],
|
|
@@ -166,13 +168,13 @@ function SearchSkillsToolMessage({ args, result, output, running, isError }) {
|
|
|
166
168
|
testID: "tool-result-search_skills",
|
|
167
169
|
children: /* @__PURE__ */ jsx(MessageItemStatus, {
|
|
168
170
|
tone: "running",
|
|
169
|
-
children: "running"
|
|
171
|
+
children: t("skill.ui.running", "running")
|
|
170
172
|
})
|
|
171
173
|
}) : null : matches.length === 0 ? /* @__PURE__ */ jsx(MessageItemBody, {
|
|
172
174
|
testID: "tool-result-search_skills",
|
|
173
175
|
children: /* @__PURE__ */ jsx(Text, {
|
|
174
176
|
style: [styles.sans, styles.dim],
|
|
175
|
-
children: "No skills match."
|
|
177
|
+
children: t("skill.ui.noSkillsMatch", "No skills match.")
|
|
176
178
|
})
|
|
177
179
|
}) : /* @__PURE__ */ jsx(MessageItemBody, {
|
|
178
180
|
testID: "tool-result-search_skills",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.mjs","names":["ToolMessageRenderProps","fontOf","Markdown","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","toolTone","PoNativeTheme","StyleSheet","loadSkillName","resultText","skillBody","LoadSkillToolMessage","args","result","output","running","isError","name","body","expanded","styles","summary","sans","primary","error","length","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","fontFamily","fontSize","base","lineHeight","flexShrink","color","colors","text","red","styles","ToolMessageRenderProps","fontOf","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","toolTone","PoNativeTheme","StyleSheet","resultText","searchQuery","skillMatches","SearchSkillsToolMessage","args","result","output","running","isError","query","matches","count","undefined","length","expanded","styles","summary","sans","dim","primary","detail","error","list","map","match","name","description","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","fontFamily","fontSize","base","lineHeight","flexShrink","color","colors","text","faint","red","fontWeight","hi","sm","toolLoadSkill","toolSearchSkills"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/skillToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.native.tsx","../../generated/native.ts"],"sourcesContent":["import type { ToolResultView } from '@agimon-ai/po-core/web';\n\nexport interface SkillMatch {\n readonly name: string;\n readonly description: string;\n}\n\n/** The result's text blocks joined, falling back to the streamed output before a result exists. */\nexport function resultText(result: ToolResultView | null, output: string): string {\n if (result === null) return output;\n return result.content\n .flatMap((block) => {\n const record = typeof block === 'object' && block !== null ? (block as { type?: unknown; text?: unknown }) : {};\n return record.type === 'text' && typeof record.text === 'string' ? [record.text] : [];\n })\n .join('\\n');\n}\n\n/** The skill name a load_skill call asked for. */\nexport function loadSkillName(args: Readonly<Record<string, unknown>>): string {\n return typeof args.name === 'string' ? args.name : '';\n}\n\n/**\n * The loaded SKILL.md without its YAML frontmatter, which the header already\n * names; the rest is what the agent read.\n */\nexport function skillBody(text: string): string {\n return text.replace(/^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/, '').trim();\n}\n\n/** How much of a loaded skill the card shows before Show more. */\nexport const SKILL_PREVIEW_LINES = 12;\n\n/**\n * The opening of a long skill, for the card to show before Show more. The cut\n * never lands inside a code fence: a preview that opened one without closing\n * it would render the rest of the card as code, so it backs up to the line\n * before the fence instead.\n */\nexport function skillPreview(body: string, maxLines = SKILL_PREVIEW_LINES): { text: string; hidden: number } {\n const lines = body.split('\\n');\n if (lines.length <= maxLines) return { text: body, hidden: 0 };\n const isFence = lines.slice(0, maxLines).map((line) => line.trimStart().startsWith('```'));\n const fences = isFence.filter(Boolean).length;\n const cut = fences % 2 === 1 ? isFence.lastIndexOf(true) : maxLines;\n // A skill that opens with a fence has no safe cut short of the whole block; show it all.\n if (cut <= 0) return { text: body, hidden: 0 };\n const text = lines.slice(0, cut).join('\\n').trimEnd();\n return { text, hidden: lines.length - cut };\n}\n\n/** The search_skills query, or undefined when the call listed every skill. */\nexport function searchQuery(args: Readonly<Record<string, unknown>>): string | undefined {\n const query = typeof args.query === 'string' ? args.query.trim() : '';\n return query.length > 0 ? query : undefined;\n}\n\n/**\n * The matches a search_skills result carries. The tool returns them as JSON\n * text; anything else (a truncated or foreign result) reads as no matches\n * rather than breaking the card.\n */\nexport function skillMatches(result: ToolResultView | null, output: string): readonly SkillMatch[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(resultText(result, output));\n } catch {\n return [];\n }\n if (!Array.isArray(parsed)) return [];\n return parsed.flatMap((entry: unknown) => {\n const record = typeof entry === 'object' && entry !== null ? (entry as Record<string, unknown>) : {};\n return typeof record.name === 'string'\n ? [{ name: record.name, description: typeof record.description === 'string' ? record.description : '' }]\n : [];\n });\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n Markdown,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { loadSkillName, resultText, skillBody } from '../_lib/skillToolView';\n\n/**\n * The load_skill tool's timeline item on native, as the web's: the skill name\n * in the header and, once expanded, the instructions the agent read.\n */\nexport function LoadSkillToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {\n const name = loadSkillName(args);\n const body = result === null || isError ? '' : skillBody(resultText(result, output));\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => (\n <>\n <MessageItemHeader title=\"load_skill\">\n <View testID=\"tool-call-load_skill\" style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, styles.primary]}>\n {name}\n </Text>\n </View>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody testID=\"tool-result-load_skill\">\n <Text selectable style={[styles.sans, styles.error]}>\n {resultText(result, output)}\n </Text>\n </MessageItemBody>\n ) : result === null ? (\n running ? (\n <MessageItemBody testID=\"tool-result-load_skill\">\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : body.length === 0 ? null : (\n <MessageItemBody testID=\"tool-result-load_skill\">\n <Markdown text={body} />\n </MessageItemBody>\n )}\n </>\n )}\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n primary: { flexShrink: 1, color: theme.colors.text },\n error: { color: theme.colors.red },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { LoadSkillToolMessage } from './_components/LoadSkillToolMessage.native';\n\nexport default defineToolRenderer({ message: LoadSkillToolMessage });\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { resultText, searchQuery, skillMatches } from '../_lib/skillToolView';\n\n/**\n * The search_skills tool's timeline item on native, as the web's: the query\n * and match count in the header and, once expanded, each match by name with\n * its description.\n */\nexport function SearchSkillsToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {\n const query = searchQuery(args);\n const matches = result === null || isError ? [] : skillMatches(result, output);\n const count =\n result === null || isError ? undefined : `${matches.length} ${matches.length === 1 ? 'skill' : 'skills'}`;\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => (\n <>\n <MessageItemHeader title=\"search_skills\">\n <View testID=\"tool-call-search_skills\" style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, query === undefined ? styles.dim : styles.primary]}>\n {query ?? 'all skills'}\n </Text>\n {count !== undefined ? (\n <Text numberOfLines={1} style={[styles.sans, styles.detail]}>\n · {count}\n </Text>\n ) : null}\n </View>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody testID=\"tool-result-search_skills\">\n <Text selectable style={[styles.sans, styles.error]}>\n {resultText(result, output)}\n </Text>\n </MessageItemBody>\n ) : result === null ? (\n running ? (\n <MessageItemBody testID=\"tool-result-search_skills\">\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : matches.length === 0 ? (\n <MessageItemBody testID=\"tool-result-search_skills\">\n <Text style={[styles.sans, styles.dim]}>No skills match.</Text>\n </MessageItemBody>\n ) : (\n <MessageItemBody testID=\"tool-result-search_skills\">\n <View style={styles.list}>\n {matches.map((match) => (\n <View key={match.name}>\n <Text selectable style={[styles.sans, styles.name]}>\n {match.name}\n </Text>\n {match.description.length > 0 ? (\n <Text selectable style={styles.description}>\n {match.description}\n </Text>\n ) : null}\n </View>\n ))}\n </View>\n </MessageItemBody>\n )}\n </>\n )}\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n primary: { flexShrink: 1, color: theme.colors.text },\n dim: { flexShrink: 1, color: theme.colors.dim },\n detail: { flexShrink: 0, color: theme.colors.faint },\n error: { color: theme.colors.red },\n list: { gap: theme.spacing(2) },\n name: { fontWeight: '600', color: theme.colors.hi },\n description: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.dim,\n },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { SearchSkillsToolMessage } from './_components/SearchSkillsToolMessage.native';\n\nexport default defineToolRenderer({ message: SearchSkillsToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.native';\nimport toolSearchSkills from '../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'skill',\n packageName: '@agimon-ai/po-skill',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['load_skill'] }, toolLoadSkill), via({ tools: ['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AK;EAAEsB,YAAY;EAAGC,OAAOb,MAAMc,OAAOxB;EAAGiB,mBAAA,CAAA,CAAA;CAAC;CAC9Cf,QAAQ;EAAEoB,YAAY;EAAGC,OAAOb,MAAMc,OAAOE;EAAKT,mBAAA,CAAA,CAAA;CAAC;CACnDd,OAAO;EAAEoB,OAAOb,MAAMc,OAAOG;EAAGV,mBAAA,CAAA,CAAA;CAAC;CACjCb,MAAM;EAAEU,KAAKJ,MAAMK,QAAQ,CAAC;EAACE,mBAAA,CAAA,CAAA;CAAC;CAC9BV,MAAM;EAAEqB,YAAY;EAAOL,OAAOb,MAAMc,OAAOK;EAAEZ,mBAAA,CAAA,CAAA;CAAC;CAClDT,aAAa;EACXU,YAAY5C,OAAOoC,MAAMQ,WAAWnB,IAAI;EACxCoB,UAAUT,MAAMS,SAASW;EACzBT,YAAYX,MAAMW,WAAWS;EAC7BP,OAAOb,MAAMc,OAAOxB;EAAGiB,mBAAA,CAAA,CAAA;CACzB;AACF,EAAE;;;AChGF,IAAA,+BAAe,mBAAmB,EAAE,SAAS,wBAAwB,CAAC;;;ACEtE,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,aAAa;CACb,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,GAAGc,yBAAa,GAAG,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,GAAGC,4BAAgB,CAAC;CAAG,EAC9K;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"native.mjs","names":["useT","ToolMessageRenderProps","fontOf","Markdown","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","toolTone","PoNativeTheme","StyleSheet","loadSkillName","resultText","skillBody","LoadSkillToolMessage","args","result","output","running","isError","t","name","body","expanded","styles","summary","sans","primary","error","length","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","fontFamily","fontSize","base","lineHeight","flexShrink","color","colors","text","red","styles","useT","ToolMessageRenderProps","fontOf","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","toolTone","PoNativeTheme","StyleSheet","resultText","searchQuery","skillMatches","SearchSkillsToolMessage","args","result","output","running","isError","t","query","matches","count","undefined","length","expanded","styles","summary","sans","dim","primary","detail","error","list","map","match","name","description","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","fontFamily","fontSize","base","lineHeight","flexShrink","color","colors","text","faint","red","fontWeight","hi","sm","toolLoadSkill","toolSearchSkills"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/skillToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.native.tsx","../../generated/native.ts"],"sourcesContent":["import type { ToolResultView } from '@agimon-ai/po-core/web';\n\nexport interface SkillMatch {\n readonly name: string;\n readonly description: string;\n}\n\n/** The result's text blocks joined, falling back to the streamed output before a result exists. */\nexport function resultText(result: ToolResultView | null, output: string): string {\n if (result === null) return output;\n return result.content\n .flatMap((block) => {\n const record = typeof block === 'object' && block !== null ? (block as { type?: unknown; text?: unknown }) : {};\n return record.type === 'text' && typeof record.text === 'string' ? [record.text] : [];\n })\n .join('\\n');\n}\n\n/** The skill name a load_skill call asked for. */\nexport function loadSkillName(args: Readonly<Record<string, unknown>>): string {\n return typeof args.name === 'string' ? args.name : '';\n}\n\n/**\n * The loaded SKILL.md without its YAML frontmatter, which the header already\n * names; the rest is what the agent read.\n */\nexport function skillBody(text: string): string {\n return text.replace(/^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/, '').trim();\n}\n\n/** How much of a loaded skill the card shows before Show more. */\nexport const SKILL_PREVIEW_LINES = 12;\n\n/**\n * The opening of a long skill, for the card to show before Show more. The cut\n * never lands inside a code fence: a preview that opened one without closing\n * it would render the rest of the card as code, so it backs up to the line\n * before the fence instead.\n */\nexport function skillPreview(body: string, maxLines = SKILL_PREVIEW_LINES): { text: string; hidden: number } {\n const lines = body.split('\\n');\n if (lines.length <= maxLines) return { text: body, hidden: 0 };\n const isFence = lines.slice(0, maxLines).map((line) => line.trimStart().startsWith('```'));\n const fences = isFence.filter(Boolean).length;\n const cut = fences % 2 === 1 ? isFence.lastIndexOf(true) : maxLines;\n // A skill that opens with a fence has no safe cut short of the whole block; show it all.\n if (cut <= 0) return { text: body, hidden: 0 };\n const text = lines.slice(0, cut).join('\\n').trimEnd();\n return { text, hidden: lines.length - cut };\n}\n\n/** The search_skills query, or undefined when the call listed every skill. */\nexport function searchQuery(args: Readonly<Record<string, unknown>>): string | undefined {\n const query = typeof args.query === 'string' ? args.query.trim() : '';\n return query.length > 0 ? query : undefined;\n}\n\n/**\n * The matches a search_skills result carries. The tool returns them as JSON\n * text; anything else (a truncated or foreign result) reads as no matches\n * rather than breaking the card.\n */\nexport function skillMatches(result: ToolResultView | null, output: string): readonly SkillMatch[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(resultText(result, output));\n } catch {\n return [];\n }\n if (!Array.isArray(parsed)) return [];\n return parsed.flatMap((entry: unknown) => {\n const record = typeof entry === 'object' && entry !== null ? (entry as Record<string, unknown>) : {};\n return typeof record.name === 'string'\n ? [{ name: record.name, description: typeof record.description === 'string' ? record.description : '' }]\n : [];\n });\n}\n","import { useT } from '@agimon-ai/po-core/native';\nimport type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n Markdown,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { loadSkillName, resultText, skillBody } from '../_lib/skillToolView';\n\n/**\n * The load_skill tool's timeline item on native, as the web's: the skill name\n * in the header and, once expanded, the instructions the agent read.\n */\nexport function LoadSkillToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {\n const t = useT();\n const name = loadSkillName(args);\n const body = result === null || isError ? '' : skillBody(resultText(result, output));\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => (\n <>\n {/* no-untranslated-jsx: ignore - Preserve the technical tool identifier. */}\n <MessageItemHeader title=\"load_skill\">\n <View testID=\"tool-call-load_skill\" style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, styles.primary]}>\n {name}\n </Text>\n </View>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody testID=\"tool-result-load_skill\">\n <Text selectable style={[styles.sans, styles.error]}>\n {resultText(result, output)}\n </Text>\n </MessageItemBody>\n ) : result === null ? (\n running ? (\n <MessageItemBody testID=\"tool-result-load_skill\">\n <MessageItemStatus tone=\"running\">{t('skill.ui.running', 'running')}</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : body.length === 0 ? null : (\n <MessageItemBody testID=\"tool-result-load_skill\">\n <Markdown text={body} />\n </MessageItemBody>\n )}\n </>\n )}\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n primary: { flexShrink: 1, color: theme.colors.text },\n error: { color: theme.colors.red },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { LoadSkillToolMessage } from './_components/LoadSkillToolMessage.native';\n\nexport default defineToolRenderer({ message: LoadSkillToolMessage });\n","import { useT } from '@agimon-ai/po-core/native';\nimport type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { resultText, searchQuery, skillMatches } from '../_lib/skillToolView';\n\n/**\n * The search_skills tool's timeline item on native, as the web's: the query\n * and match count in the header and, once expanded, each match by name with\n * its description.\n */\nexport function SearchSkillsToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {\n const t = useT();\n const query = searchQuery(args);\n const matches = result === null || isError ? [] : skillMatches(result, output);\n const count =\n result === null || isError ? undefined : `${matches.length} ${matches.length === 1 ? 'skill' : 'skills'}`;\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => (\n <>\n {/* no-untranslated-jsx: ignore - Preserve the technical tool identifier. */}\n <MessageItemHeader title=\"search_skills\">\n <View testID=\"tool-call-search_skills\" style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, query === undefined ? styles.dim : styles.primary]}>\n {query ?? t('skill.ui.allSkills', 'all skills')}\n </Text>\n {count !== undefined ? (\n <Text numberOfLines={1} style={[styles.sans, styles.detail]}>\n · {count}\n </Text>\n ) : null}\n </View>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody testID=\"tool-result-search_skills\">\n <Text selectable style={[styles.sans, styles.error]}>\n {resultText(result, output)}\n </Text>\n </MessageItemBody>\n ) : result === null ? (\n running ? (\n <MessageItemBody testID=\"tool-result-search_skills\">\n <MessageItemStatus tone=\"running\">{t('skill.ui.running', 'running')}</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : matches.length === 0 ? (\n <MessageItemBody testID=\"tool-result-search_skills\">\n <Text style={[styles.sans, styles.dim]}>{t('skill.ui.noSkillsMatch', 'No skills match.')}</Text>\n </MessageItemBody>\n ) : (\n <MessageItemBody testID=\"tool-result-search_skills\">\n <View style={styles.list}>\n {matches.map((match) => (\n <View key={match.name}>\n <Text selectable style={[styles.sans, styles.name]}>\n {match.name}\n </Text>\n {match.description.length > 0 ? (\n <Text selectable style={styles.description}>\n {match.description}\n </Text>\n ) : null}\n </View>\n ))}\n </View>\n </MessageItemBody>\n )}\n </>\n )}\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n primary: { flexShrink: 1, color: theme.colors.text },\n dim: { flexShrink: 1, color: theme.colors.dim },\n detail: { flexShrink: 0, color: theme.colors.faint },\n error: { color: theme.colors.red },\n list: { gap: theme.spacing(2) },\n name: { fontWeight: '600', color: theme.colors.hi },\n description: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.dim,\n },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { SearchSkillsToolMessage } from './_components/SearchSkillsToolMessage.native';\n\nexport default defineToolRenderer({ message: SearchSkillsToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.native';\nimport toolSearchSkills from '../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'skill',\n packageName: '@agimon-ai/po-skill',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['load_skill'] }, toolLoadSkill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ain/plugins");
|
|
|
12
12
|
let _earendil_works_pi_coding_agent = require("@earendil-works/pi-coding-agent");
|
|
13
13
|
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
14
14
|
let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
|
|
15
|
+
let _agimon_ai_po_core_locale = require("@agimon-ai/po-core/locale");
|
|
15
16
|
let _agimon_ai_po_config_harnessState = require("@agimon-ai/po-config/harnessState");
|
|
16
17
|
let _agimon_ai_po_core_help = require("@agimon-ai/po-core/help");
|
|
17
18
|
let typebox = require("typebox");
|
|
@@ -359,17 +360,15 @@ async function discoverServerSkills(execution, fs, signal) {
|
|
|
359
360
|
const repoSkills = node_path.default.join(execution.repoRoot, ".po", "skills");
|
|
360
361
|
const sources = [];
|
|
361
362
|
const diagnostics = [];
|
|
362
|
-
const
|
|
363
|
-
try {
|
|
364
|
-
domains.push(...await (0, _agimon_ai_po_config_domains.listDomainNamesAsync)(fs, execution.repoRoot, context, home, execution.environment));
|
|
365
|
-
} catch (error) {
|
|
363
|
+
const manifest = await (0, _agimon_ai_po_config_domains.loadDomainsAsync)(fs, execution.repoRoot, context, home, execution.environment).catch((error) => {
|
|
366
364
|
diagnostics.push(`Domain skills are unavailable: ${error instanceof Error ? error.message : String(error)}`);
|
|
367
|
-
}
|
|
365
|
+
});
|
|
366
|
+
const domains = manifest ? (0, _agimon_ai_po_config_domains.domainNamesOf)(manifest) : [];
|
|
368
367
|
const discovered = /* @__PURE__ */ new Map();
|
|
369
|
-
for (const domain of domains) {
|
|
368
|
+
if (manifest) for (const domain of domains) {
|
|
370
369
|
signal.throwIfAborted();
|
|
371
370
|
try {
|
|
372
|
-
const plugins = await (0, _agimon_ai_po_domain_plugins.materializePluginEntries)(await (0, _agimon_ai_po_config_domains.
|
|
371
|
+
const plugins = await (0, _agimon_ai_po_domain_plugins.materializePluginEntries)(await (0, _agimon_ai_po_config_domains.resolveManifestPluginEntriesAsync)(fs, manifest, [domain], [], context, home), {
|
|
373
372
|
homeDirectory: home,
|
|
374
373
|
environment: execution.environment
|
|
375
374
|
});
|
|
@@ -417,9 +416,9 @@ async function discoverServerSkills(execution, fs, signal) {
|
|
|
417
416
|
}
|
|
418
417
|
signal.throwIfAborted();
|
|
419
418
|
const shared = await (0, _agimon_ai_po_domain_resources.discoverSkillsAsync)(execution.repoRoot, node_path.default.join(execution.repoRoot, ".claude", "skills"), "recursive", void 0, execution.environment);
|
|
420
|
-
if (shared.length > 0) {
|
|
419
|
+
if (shared.length > 0 && manifest) {
|
|
421
420
|
const sharedPaths = shared.map((skill) => skill.path);
|
|
422
|
-
for (const domain of domains) if (
|
|
421
|
+
for (const domain of domains) if ((0, _agimon_ai_po_config_domains.sharedSkillsFor)(manifest, [domain])) sources.push({
|
|
423
422
|
domain,
|
|
424
423
|
paths: sharedPaths,
|
|
425
424
|
mcpPaths: sharedPaths
|
|
@@ -479,7 +478,7 @@ function skillCommand(skill, domains, inventory, fs) {
|
|
|
479
478
|
function admit(session, text) {
|
|
480
479
|
return session.admitPrompt ? session.admitPrompt(text, "prompt", "operator") : session.prompt(text);
|
|
481
480
|
}
|
|
482
|
-
function createSkillCommands(inventory, catalog, groups, fs) {
|
|
481
|
+
function createSkillCommands(inventory, catalog, groups, fs, t = (_key, fallback) => fallback) {
|
|
483
482
|
return [{
|
|
484
483
|
name: require_skills.SKILLS_COMMAND,
|
|
485
484
|
description: "List discovered skills or invoke one by name.",
|
|
@@ -490,7 +489,11 @@ function createSkillCommands(inventory, catalog, groups, fs) {
|
|
|
490
489
|
return;
|
|
491
490
|
}
|
|
492
491
|
await execution.client.notify({
|
|
493
|
-
title: "Po skills",
|
|
492
|
+
title: t("skill.notification.catalog", "Po skills"),
|
|
493
|
+
localization: { title: {
|
|
494
|
+
key: "skill.notification.catalog",
|
|
495
|
+
fallback: "Po skills"
|
|
496
|
+
} },
|
|
494
497
|
body: catalog,
|
|
495
498
|
level: "info"
|
|
496
499
|
});
|
|
@@ -499,7 +502,7 @@ function createSkillCommands(inventory, catalog, groups, fs) {
|
|
|
499
502
|
}
|
|
500
503
|
//#endregion
|
|
501
504
|
//#region src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts
|
|
502
|
-
async function createSkillServer(agent, fs, signal, resources) {
|
|
505
|
+
async function createSkillServer(agent, fs, signal, resources, t) {
|
|
503
506
|
const execution = agent.context;
|
|
504
507
|
const key = [
|
|
505
508
|
"inventory",
|
|
@@ -511,7 +514,7 @@ async function createSkillServer(agent, fs, signal, resources) {
|
|
|
511
514
|
];
|
|
512
515
|
const { inventory, catalog, groups, mcpGroups } = await resources.acquire(key, () => discoverServerSkills(execution, fs, new AbortController().signal));
|
|
513
516
|
return {
|
|
514
|
-
commands: createSkillCommands(inventory, catalog, groups, fs),
|
|
517
|
+
commands: createSkillCommands(inventory, catalog, groups, fs, t),
|
|
515
518
|
tools: [createSessionLoadSkillTool(agent), createSessionSearchSkillsTool(agent)],
|
|
516
519
|
services: [mountMcpSkills(mcpGroups, fs, signal)],
|
|
517
520
|
resources: [...groups.flatMap((group) => group.skills.map((skill) => ({
|
|
@@ -539,7 +542,7 @@ async function createSkillServer(agent, fs, signal, resources) {
|
|
|
539
542
|
//#endregion
|
|
540
543
|
//#region src/extensions/workspaces/sessions/(backend)/root.server.ts
|
|
541
544
|
var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ agent, context: root, signal, resources }) => {
|
|
542
|
-
const runtime = agent ? await createSkillServer(agent, (0, _agimon_ai_po_core_platform.requirePoFs)(root), signal, resources) : {
|
|
545
|
+
const runtime = agent ? await createSkillServer(agent, (0, _agimon_ai_po_core_platform.requirePoFs)(root), signal, resources, (key, fallback) => (0, _agimon_ai_po_core_locale.readPoLang)(root)?.t((0, _agimon_ai_po_core_locale.readPoPersonLocale)(root)?.read(), key, fallback) ?? fallback) : {
|
|
543
546
|
commands: [],
|
|
544
547
|
resources: []
|
|
545
548
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.cjs","names":["getOrThrow","withAbortSignal","BACKGROUND_CONTEXT","Type","path","fileURLToPath","fs","pathToFileURL","getAgentDir","loadSkills","Worker","stripFrontmatter","path","withAbortSignal","BACKGROUND_CONTEXT","readHarnessState","nodeHost","path","listDomainNamesAsync","materializePluginEntries","resolvePluginEntriesAsync","collectResources","discoverSkillsAsync","resolveSharedSkillsAsync","formatSkillsForPrompt","SKILL_COMMAND_PREFIX","SKILL_INVOCATION_PREFIX","SKILLS_COMMAND","nodeHost","readHarnessState","getOrThrow","BACKGROUND_CONTEXT","PO_HELP_WHEN","packageResourcePath","readPackageResource","defineRoot","requirePoFs","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootInjects","composeRootHooks","commandSkills","resourceSkills","toolLoadSkill"],"sources":["../../src/constants/skillInventory.ts","../../src/services/mcpSkills/index.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/services/deferredSkills/index.ts","../../src/services/serverInventory/grouping.ts","../../src/services/serverInventory/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/skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/load_skill.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 { 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 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 { 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/** Skill paths one domain (or the repository, when `domain` is absent) admits. */\nexport interface SkillSource {\n readonly domain?: 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 return [\n {\n ...(admitting.some((source) => source.domain === undefined) ? {} : { domains }),\n skills: [skill],\n },\n ];\n });\n}\n","import path from 'node:path';\n\nimport {\n listDomainNamesAsync,\n resolvePluginEntriesAsync,\n resolveSharedSkillsAsync,\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 } 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 // 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 domains: string[] = [];\n try {\n domains.push(...(await listDomainNamesAsync(fs, execution.repoRoot, context, home, execution.environment)));\n } catch (error) {\n diagnostics.push(`Domain skills are unavailable: ${error instanceof Error ? error.message : String(error)}`);\n }\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<string, Readonly<{ paths: readonly string[]; mcpPaths: readonly string[] }>>();\n for (const domain of domains) {\n signal.throwIfAborted();\n try {\n const plugins = await materializePluginEntries(\n await resolvePluginEntriesAsync(fs, execution.repoRoot, [domain], [], context, home, execution.environment),\n { homeDirectory: home, environment: execution.environment },\n );\n const key = JSON.stringify(\n plugins.map(({ directory, skillDiscovery, skills, source }) => ({ directory, skillDiscovery, skills, source })),\n );\n const previous = discovered.get(key);\n if (previous) {\n sources.push({ domain, paths: [...previous.paths], mcpPaths: [...previous.mcpPaths] });\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 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 discovered.set(key, Object.freeze({ paths, mcpPaths }));\n if (paths.length > 0) sources.push({ domain, paths: [...paths], mcpPaths: [...mcpPaths] });\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 // 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 if (shared.length > 0) {\n const sharedPaths = shared.map((skill) => skill.path);\n for (const domain of domains) {\n if (await resolveSharedSkillsAsync(fs, execution.repoRoot, [domain], context, home, execution.environment)) {\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 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 catalog: formatSkillsForPrompt(activeSkills) || '(no discovered skills)',\n };\n}\n","import type { PoHeadlessCommand } 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 { 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 domains: readonly string[] | undefined,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem | undefined,\n): PoHeadlessCommand {\n return {\n ...(domains === undefined ? {} : { when: { domains } }),\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): 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: 'Po skills',\n body: catalog,\n level: 'info',\n });\n },\n },\n ...groups.flatMap((group) => group.skills.map((skill) => skillCommand(skill, group.domains, inventory, fs))),\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 { createSessionLoadSkillTool, createSessionSearchSkillsTool } from '../../../../../services/mcpSkillTools';\nimport { discoverServerSkills } from '../../../../../services/serverInventory';\nimport { createSkillCommands } from './skillCommands';\n\nexport async function createSkillServer(\n agent: PoHeadlessHostService,\n fs: FileSystem,\n signal: AbortSignal,\n resources: PoServerResources,\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 } = 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),\n tools: [createSessionLoadSkillTool(agent), createSessionSearchSkillsTool(agent)],\n services: [mountMcpSkills(mcpGroups, fs, signal)],\n resources: [\n // Each skill joins the prompt's one <available_skills> list, gated like the rest.\n ...groups.flatMap((group) =>\n group.skills.map((skill) => ({\n name: skill.name,\n description: skill.description,\n path: skill.filePath,\n kind: 'skill' as const,\n ...(group.domains === undefined ? {} : { when: { domains: group.domains } }),\n read: async () => getOrThrow(await fs.readTextFile(skill.filePath, BACKGROUND_CONTEXT)),\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 { 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(agent, requirePoFs(root), signal, resources)\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","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","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\n/** The session agent's skill tools; the Pi CLI keeps Pi's own skill handling. */\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.tools ?? [],\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 resourceSkills from '../src/extensions/workspaces/sessions/(backend)/resource/skills.server';\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(backend)/tool/load_skill.server';\n\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 [...many(resourceSkills, contextSession)]; },\n get tools(): PoServerSessionPlugin['tools'] { return [...many(toolLoadSkill, 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,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AA,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,GAAG,KAAKC,uBAAgB,cAAc,CAAC;GAAG;GACxG,IAAI,QAAwC;IAAE,OAAO,CAAC,GAAG,KAAKC,2BAAe,cAAc,CAAC;GAAG;GAC/F,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","Type","path","fileURLToPath","fs","pathToFileURL","getAgentDir","loadSkills","Worker","stripFrontmatter","path","withAbortSignal","BACKGROUND_CONTEXT","readHarnessState","nodeHost","path","loadDomainsAsync","domainNamesOf","materializePluginEntries","resolveManifestPluginEntriesAsync","collectResources","discoverSkillsAsync","sharedSkillsFor","formatSkillsForPrompt","SKILL_COMMAND_PREFIX","SKILL_INVOCATION_PREFIX","SKILLS_COMMAND","nodeHost","readHarnessState","getOrThrow","BACKGROUND_CONTEXT","PO_HELP_WHEN","packageResourcePath","readPackageResource","defineRoot","requirePoFs","readPoLang","readPoPersonLocale","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootInjects","composeRootHooks","commandSkills","resourceSkills","toolLoadSkill"],"sources":["../../src/constants/skillInventory.ts","../../src/services/mcpSkills/index.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/services/deferredSkills/index.ts","../../src/services/serverInventory/grouping.ts","../../src/services/serverInventory/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/skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/load_skill.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 { 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 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 { 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/** Skill paths one domain (or the repository, when `domain` is absent) admits. */\nexport interface SkillSource {\n readonly domain?: 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 return [\n {\n ...(admitting.some((source) => source.domain === undefined) ? {} : { domains }),\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 } 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 // 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<string, Readonly<{ paths: readonly string[]; mcpPaths: readonly string[] }>>();\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] });\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 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 discovered.set(key, Object.freeze({ paths, mcpPaths }));\n if (paths.length > 0) sources.push({ domain, paths: [...paths], mcpPaths: [...mcpPaths] });\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 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 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 catalog: formatSkillsForPrompt(activeSkills) || '(no discovered skills)',\n };\n}\n","import type { PoHeadlessCommand } 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 { 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 domains: readonly string[] | undefined,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem | undefined,\n): PoHeadlessCommand {\n return {\n ...(domains === undefined ? {} : { when: { domains } }),\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) => group.skills.map((skill) => skillCommand(skill, group.domains, inventory, fs))),\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 { createSessionLoadSkillTool, createSessionSearchSkillsTool } from '../../../../../services/mcpSkillTools';\nimport { discoverServerSkills } from '../../../../../services/serverInventory';\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 } = 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 tools: [createSessionLoadSkillTool(agent), createSessionSearchSkillsTool(agent)],\n services: [mountMcpSkills(mcpGroups, fs, signal)],\n resources: [\n // Each skill joins the prompt's one <available_skills> list, gated like the rest.\n ...groups.flatMap((group) =>\n group.skills.map((skill) => ({\n name: skill.name,\n description: skill.description,\n path: skill.filePath,\n kind: 'skill' as const,\n ...(group.domains === undefined ? {} : { when: { domains: group.domains } }),\n read: async () => getOrThrow(await fs.readTextFile(skill.filePath, BACKGROUND_CONTEXT)),\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","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","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\n/** The session agent's skill tools; the Pi CLI keeps Pi's own skill handling. */\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.tools ?? [],\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 resourceSkills from '../src/extensions/workspaces/sessions/(backend)/resource/skills.server';\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(backend)/tool/load_skill.server';\n\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 [...many(resourceSkills, contextSession)]; },\n get tools(): PoServerSessionPlugin['tools'] { return [...many(toolLoadSkill, 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,OAA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,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,GAAG,KAAKC,uBAAgB,cAAc,CAAC;GAAG;GACxG,IAAI,QAAwC;IAAE,OAAO,CAAC,GAAG,KAAKC,2BAAe,cAAc,CAAC;GAAG;GAC/F,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { n as SKILL_COMMAND_PREFIX, r as SKILL_INVOCATION_PREFIX, t as SKILLS_COMMAND } from "../skills-Ccvg1Hcz.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { domainNamesOf, loadDomainsAsync, resolveManifestPluginEntriesAsync, sharedSkillsFor } from "@agimon-ai/po-config/domains";
|
|
4
4
|
import { BACKGROUND_CONTEXT, getOrThrow, nodeHost, requirePoFs, withAbortSignal } from "@agimon-ai/po-core/platform";
|
|
5
5
|
import { materializePluginEntries } from "@agimon-ai/po-domain/plugins";
|
|
6
6
|
import { formatSkillsForPrompt, getAgentDir, loadSkills, stripFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import { composeServerProviderOverrides, defineServerPlugin, packageResourcePath, readPackageResource } from "@agimon-ai/po-core/serverPlugin";
|
|
8
8
|
import { composeRootHooks, composeRootInjects, defineRoot, defineRoutedContribution } from "@agimon-ai/po-core/extensionFile";
|
|
9
|
+
import { readPoLang, readPoPersonLocale } from "@agimon-ai/po-core/locale";
|
|
9
10
|
import { readHarnessState } from "@agimon-ai/po-config/harnessState";
|
|
10
11
|
import { PO_HELP_WHEN } from "@agimon-ai/po-core/help";
|
|
11
12
|
import { Type } from "typebox";
|
|
@@ -352,17 +353,15 @@ async function discoverServerSkills(execution, fs, signal) {
|
|
|
352
353
|
const repoSkills = path.join(execution.repoRoot, ".po", "skills");
|
|
353
354
|
const sources = [];
|
|
354
355
|
const diagnostics = [];
|
|
355
|
-
const
|
|
356
|
-
try {
|
|
357
|
-
domains.push(...await listDomainNamesAsync(fs, execution.repoRoot, context, home, execution.environment));
|
|
358
|
-
} catch (error) {
|
|
356
|
+
const manifest = await loadDomainsAsync(fs, execution.repoRoot, context, home, execution.environment).catch((error) => {
|
|
359
357
|
diagnostics.push(`Domain skills are unavailable: ${error instanceof Error ? error.message : String(error)}`);
|
|
360
|
-
}
|
|
358
|
+
});
|
|
359
|
+
const domains = manifest ? domainNamesOf(manifest) : [];
|
|
361
360
|
const discovered = /* @__PURE__ */ new Map();
|
|
362
|
-
for (const domain of domains) {
|
|
361
|
+
if (manifest) for (const domain of domains) {
|
|
363
362
|
signal.throwIfAborted();
|
|
364
363
|
try {
|
|
365
|
-
const plugins = await materializePluginEntries(await
|
|
364
|
+
const plugins = await materializePluginEntries(await resolveManifestPluginEntriesAsync(fs, manifest, [domain], [], context, home), {
|
|
366
365
|
homeDirectory: home,
|
|
367
366
|
environment: execution.environment
|
|
368
367
|
});
|
|
@@ -410,9 +409,9 @@ async function discoverServerSkills(execution, fs, signal) {
|
|
|
410
409
|
}
|
|
411
410
|
signal.throwIfAborted();
|
|
412
411
|
const shared = await discoverSkillsAsync(execution.repoRoot, path.join(execution.repoRoot, ".claude", "skills"), "recursive", void 0, execution.environment);
|
|
413
|
-
if (shared.length > 0) {
|
|
412
|
+
if (shared.length > 0 && manifest) {
|
|
414
413
|
const sharedPaths = shared.map((skill) => skill.path);
|
|
415
|
-
for (const domain of domains) if (
|
|
414
|
+
for (const domain of domains) if (sharedSkillsFor(manifest, [domain])) sources.push({
|
|
416
415
|
domain,
|
|
417
416
|
paths: sharedPaths,
|
|
418
417
|
mcpPaths: sharedPaths
|
|
@@ -472,7 +471,7 @@ function skillCommand(skill, domains, inventory, fs) {
|
|
|
472
471
|
function admit(session, text) {
|
|
473
472
|
return session.admitPrompt ? session.admitPrompt(text, "prompt", "operator") : session.prompt(text);
|
|
474
473
|
}
|
|
475
|
-
function createSkillCommands(inventory, catalog, groups, fs) {
|
|
474
|
+
function createSkillCommands(inventory, catalog, groups, fs, t = (_key, fallback) => fallback) {
|
|
476
475
|
return [{
|
|
477
476
|
name: SKILLS_COMMAND,
|
|
478
477
|
description: "List discovered skills or invoke one by name.",
|
|
@@ -483,7 +482,11 @@ function createSkillCommands(inventory, catalog, groups, fs) {
|
|
|
483
482
|
return;
|
|
484
483
|
}
|
|
485
484
|
await execution.client.notify({
|
|
486
|
-
title: "Po skills",
|
|
485
|
+
title: t("skill.notification.catalog", "Po skills"),
|
|
486
|
+
localization: { title: {
|
|
487
|
+
key: "skill.notification.catalog",
|
|
488
|
+
fallback: "Po skills"
|
|
489
|
+
} },
|
|
487
490
|
body: catalog,
|
|
488
491
|
level: "info"
|
|
489
492
|
});
|
|
@@ -492,7 +495,7 @@ function createSkillCommands(inventory, catalog, groups, fs) {
|
|
|
492
495
|
}
|
|
493
496
|
//#endregion
|
|
494
497
|
//#region src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts
|
|
495
|
-
async function createSkillServer(agent, fs, signal, resources) {
|
|
498
|
+
async function createSkillServer(agent, fs, signal, resources, t) {
|
|
496
499
|
const execution = agent.context;
|
|
497
500
|
const key = [
|
|
498
501
|
"inventory",
|
|
@@ -504,7 +507,7 @@ async function createSkillServer(agent, fs, signal, resources) {
|
|
|
504
507
|
];
|
|
505
508
|
const { inventory, catalog, groups, mcpGroups } = await resources.acquire(key, () => discoverServerSkills(execution, fs, new AbortController().signal));
|
|
506
509
|
return {
|
|
507
|
-
commands: createSkillCommands(inventory, catalog, groups, fs),
|
|
510
|
+
commands: createSkillCommands(inventory, catalog, groups, fs, t),
|
|
508
511
|
tools: [createSessionLoadSkillTool(agent), createSessionSearchSkillsTool(agent)],
|
|
509
512
|
services: [mountMcpSkills(mcpGroups, fs, signal)],
|
|
510
513
|
resources: [...groups.flatMap((group) => group.skills.map((skill) => ({
|
|
@@ -532,7 +535,7 @@ async function createSkillServer(agent, fs, signal, resources) {
|
|
|
532
535
|
//#endregion
|
|
533
536
|
//#region src/extensions/workspaces/sessions/(backend)/root.server.ts
|
|
534
537
|
var root_server_default = defineRoot(async ({ agent, context: root, signal, resources }) => {
|
|
535
|
-
const runtime = agent ? await createSkillServer(agent, requirePoFs(root), signal, resources) : {
|
|
538
|
+
const runtime = agent ? await createSkillServer(agent, requirePoFs(root), signal, resources, (key, fallback) => readPoLang(root)?.t(readPoPersonLocale(root)?.read(), key, fallback) ?? fallback) : {
|
|
536
539
|
commands: [],
|
|
537
540
|
resources: []
|
|
538
541
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","names":["rootSession","commandSkills","resourceSkills","toolLoadSkill"],"sources":["../../src/constants/skillInventory.ts","../../src/services/mcpSkills/index.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/services/deferredSkills/index.ts","../../src/services/serverInventory/grouping.ts","../../src/services/serverInventory/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/skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/load_skill.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 { 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 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 { 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/** Skill paths one domain (or the repository, when `domain` is absent) admits. */\nexport interface SkillSource {\n readonly domain?: 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 return [\n {\n ...(admitting.some((source) => source.domain === undefined) ? {} : { domains }),\n skills: [skill],\n },\n ];\n });\n}\n","import path from 'node:path';\n\nimport {\n listDomainNamesAsync,\n resolvePluginEntriesAsync,\n resolveSharedSkillsAsync,\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 } 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 // 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 domains: string[] = [];\n try {\n domains.push(...(await listDomainNamesAsync(fs, execution.repoRoot, context, home, execution.environment)));\n } catch (error) {\n diagnostics.push(`Domain skills are unavailable: ${error instanceof Error ? error.message : String(error)}`);\n }\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<string, Readonly<{ paths: readonly string[]; mcpPaths: readonly string[] }>>();\n for (const domain of domains) {\n signal.throwIfAborted();\n try {\n const plugins = await materializePluginEntries(\n await resolvePluginEntriesAsync(fs, execution.repoRoot, [domain], [], context, home, execution.environment),\n { homeDirectory: home, environment: execution.environment },\n );\n const key = JSON.stringify(\n plugins.map(({ directory, skillDiscovery, skills, source }) => ({ directory, skillDiscovery, skills, source })),\n );\n const previous = discovered.get(key);\n if (previous) {\n sources.push({ domain, paths: [...previous.paths], mcpPaths: [...previous.mcpPaths] });\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 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 discovered.set(key, Object.freeze({ paths, mcpPaths }));\n if (paths.length > 0) sources.push({ domain, paths: [...paths], mcpPaths: [...mcpPaths] });\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 // 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 if (shared.length > 0) {\n const sharedPaths = shared.map((skill) => skill.path);\n for (const domain of domains) {\n if (await resolveSharedSkillsAsync(fs, execution.repoRoot, [domain], context, home, execution.environment)) {\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 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 catalog: formatSkillsForPrompt(activeSkills) || '(no discovered skills)',\n };\n}\n","import type { PoHeadlessCommand } 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 { 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 domains: readonly string[] | undefined,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem | undefined,\n): PoHeadlessCommand {\n return {\n ...(domains === undefined ? {} : { when: { domains } }),\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): 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: 'Po skills',\n body: catalog,\n level: 'info',\n });\n },\n },\n ...groups.flatMap((group) => group.skills.map((skill) => skillCommand(skill, group.domains, inventory, fs))),\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 { createSessionLoadSkillTool, createSessionSearchSkillsTool } from '../../../../../services/mcpSkillTools';\nimport { discoverServerSkills } from '../../../../../services/serverInventory';\nimport { createSkillCommands } from './skillCommands';\n\nexport async function createSkillServer(\n agent: PoHeadlessHostService,\n fs: FileSystem,\n signal: AbortSignal,\n resources: PoServerResources,\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 } = 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),\n tools: [createSessionLoadSkillTool(agent), createSessionSearchSkillsTool(agent)],\n services: [mountMcpSkills(mcpGroups, fs, signal)],\n resources: [\n // Each skill joins the prompt's one <available_skills> list, gated like the rest.\n ...groups.flatMap((group) =>\n group.skills.map((skill) => ({\n name: skill.name,\n description: skill.description,\n path: skill.filePath,\n kind: 'skill' as const,\n ...(group.domains === undefined ? {} : { when: { domains: group.domains } }),\n read: async () => getOrThrow(await fs.readTextFile(skill.filePath, BACKGROUND_CONTEXT)),\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 { 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(agent, requirePoFs(root), signal, resources)\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","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","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\n/** The session agent's skill tools; the Pi CLI keeps Pi's own skill handling. */\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.tools ?? [],\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 resourceSkills from '../src/extensions/workspaces/sessions/(backend)/resource/skills.server';\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(backend)/tool/load_skill.server';\n\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 [...many(resourceSkills, contextSession)]; },\n get tools(): PoServerSessionPlugin['tools'] { return [...many(toolLoadSkill, contextSession)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA,MA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;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.mjs","names":["rootSession","commandSkills","resourceSkills","toolLoadSkill"],"sources":["../../src/constants/skillInventory.ts","../../src/services/mcpSkills/index.ts","../../src/schemas/mcpSkillTools.ts","../../src/services/mcpSkillTools/index.ts","../../src/services/deferredSkills/index.ts","../../src/services/serverInventory/grouping.ts","../../src/services/serverInventory/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/skills.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/load_skill.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 { 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 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 { 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/** Skill paths one domain (or the repository, when `domain` is absent) admits. */\nexport interface SkillSource {\n readonly domain?: 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 return [\n {\n ...(admitting.some((source) => source.domain === undefined) ? {} : { domains }),\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 } 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 // 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<string, Readonly<{ paths: readonly string[]; mcpPaths: readonly string[] }>>();\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] });\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 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 discovered.set(key, Object.freeze({ paths, mcpPaths }));\n if (paths.length > 0) sources.push({ domain, paths: [...paths], mcpPaths: [...mcpPaths] });\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 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 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 catalog: formatSkillsForPrompt(activeSkills) || '(no discovered skills)',\n };\n}\n","import type { PoHeadlessCommand } 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 { 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 domains: readonly string[] | undefined,\n inventory: DeferredSkillSnapshot,\n fs: FileSystem | undefined,\n): PoHeadlessCommand {\n return {\n ...(domains === undefined ? {} : { when: { domains } }),\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) => group.skills.map((skill) => skillCommand(skill, group.domains, inventory, fs))),\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 { createSessionLoadSkillTool, createSessionSearchSkillsTool } from '../../../../../services/mcpSkillTools';\nimport { discoverServerSkills } from '../../../../../services/serverInventory';\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 } = 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 tools: [createSessionLoadSkillTool(agent), createSessionSearchSkillsTool(agent)],\n services: [mountMcpSkills(mcpGroups, fs, signal)],\n resources: [\n // Each skill joins the prompt's one <available_skills> list, gated like the rest.\n ...groups.flatMap((group) =>\n group.skills.map((skill) => ({\n name: skill.name,\n description: skill.description,\n path: skill.filePath,\n kind: 'skill' as const,\n ...(group.domains === undefined ? {} : { when: { domains: group.domains } }),\n read: async () => getOrThrow(await fs.readTextFile(skill.filePath, BACKGROUND_CONTEXT)),\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","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","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\n/** The session agent's skill tools; the Pi CLI keeps Pi's own skill handling. */\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, PoServerSessionPlugin>) => context.root.tools ?? [],\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 resourceSkills from '../src/extensions/workspaces/sessions/(backend)/resource/skills.server';\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(backend)/tool/load_skill.server';\n\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 [...many(resourceSkills, contextSession)]; },\n get tools(): PoServerSessionPlugin['tools'] { return [...many(toolLoadSkill, 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,M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,CACxB;;;;ACHA,IAAA,4BAAe,0BACZ,YAAoE,QAAQ,KAAK,SAAS,CAAC,GAC5F,EAAE,aAAa,OAAO,CACxB;;;ACIA,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,GAAG,KAAKC,uBAAgB,cAAc,CAAC;GAAG;GACxG,IAAI,QAAwC;IAAE,OAAO,CAAC,GAAG,KAAKC,2BAAe,cAAc,CAAC;GAAG;GAC/F,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
|
package/dist/extensions/web.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineToolRenderer, defineWebPlugin } from "@agimon-ai/po-core/web";
|
|
1
|
+
import { defineToolRenderer, defineWebPlugin, useT } from "@agimon-ai/po-core/web";
|
|
2
2
|
import { Button, Markdown, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, toolTone } from "@agimon-ai/po-web-components";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -79,6 +79,7 @@ function skillMatches(result, output) {
|
|
|
79
79
|
* lines; dropping all of them into the transcript at once buries the turn.
|
|
80
80
|
*/
|
|
81
81
|
function SkillBody({ body }) {
|
|
82
|
+
const t = useT();
|
|
82
83
|
const [full, setFull] = useState(false);
|
|
83
84
|
const preview = skillPreview(body);
|
|
84
85
|
const showAll = full || preview.hidden === 0;
|
|
@@ -87,14 +88,14 @@ function SkillBody({ body }) {
|
|
|
87
88
|
className: "flex flex-col gap-2",
|
|
88
89
|
children: [/* @__PURE__ */ jsx(Markdown, { text: showAll ? body : preview.text }), showAll ? null : /* @__PURE__ */ jsxs("span", {
|
|
89
90
|
className: "flex items-center gap-2",
|
|
90
|
-
children: [/* @__PURE__ */
|
|
91
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
91
92
|
className: "text-sm text-po-dim",
|
|
92
|
-
children:
|
|
93
|
+
children: t("skill.ui.moreLines", "{count} more lines", { count: preview.hidden })
|
|
93
94
|
}), /* @__PURE__ */ jsx(Button, {
|
|
94
95
|
variant: "ghost",
|
|
95
96
|
size: "sm",
|
|
96
97
|
onClick: () => setFull(true),
|
|
97
|
-
children: "Show more"
|
|
98
|
+
children: t("skill.ui.showMore", "Show more")
|
|
98
99
|
})]
|
|
99
100
|
})]
|
|
100
101
|
});
|
|
@@ -105,6 +106,7 @@ function SkillBody({ body }) {
|
|
|
105
106
|
* skill shows the tool's message in red instead.
|
|
106
107
|
*/
|
|
107
108
|
function LoadSkillToolMessage({ args, result, output, running, isError }) {
|
|
109
|
+
const t = useT();
|
|
108
110
|
const name = loadSkillName(args);
|
|
109
111
|
const body = result === null || isError ? "" : skillBody(resultText(result, output));
|
|
110
112
|
return /* @__PURE__ */ jsx(MessageItem, {
|
|
@@ -134,7 +136,7 @@ function LoadSkillToolMessage({ args, result, output, running, isError }) {
|
|
|
134
136
|
"data-testid": "tool-result-load_skill",
|
|
135
137
|
children: /* @__PURE__ */ jsx(MessageItemStatus, {
|
|
136
138
|
tone: "running",
|
|
137
|
-
children: "running"
|
|
139
|
+
children: t("skill.ui.running", "running")
|
|
138
140
|
})
|
|
139
141
|
}) : null : body.length === 0 ? null : /* @__PURE__ */ jsx(SkillBody, { body })] })
|
|
140
142
|
});
|
|
@@ -150,6 +152,7 @@ var load_skill_web_default = defineToolRenderer({ message: LoadSkillToolMessage
|
|
|
150
152
|
* description.
|
|
151
153
|
*/
|
|
152
154
|
function SearchSkillsToolMessage({ args, result, output, running, isError }) {
|
|
155
|
+
const t = useT();
|
|
153
156
|
const query = searchQuery(args);
|
|
154
157
|
const matches = result === null || isError ? [] : skillMatches(result, output);
|
|
155
158
|
const count = result === null || isError ? void 0 : `${matches.length} ${matches.length === 1 ? "skill" : "skills"}`;
|
|
@@ -166,7 +169,7 @@ function SearchSkillsToolMessage({ args, result, output, running, isError }) {
|
|
|
166
169
|
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
167
170
|
children: [query === void 0 ? /* @__PURE__ */ jsx("span", {
|
|
168
171
|
className: "truncate text-po-dim",
|
|
169
|
-
children: "all skills"
|
|
172
|
+
children: t("skill.ui.allSkills", "all skills")
|
|
170
173
|
}) : /* @__PURE__ */ jsx("span", {
|
|
171
174
|
className: "truncate text-po-text",
|
|
172
175
|
children: query
|
|
@@ -186,13 +189,13 @@ function SearchSkillsToolMessage({ args, result, output, running, isError }) {
|
|
|
186
189
|
"data-testid": "tool-result-search_skills",
|
|
187
190
|
children: /* @__PURE__ */ jsx(MessageItemStatus, {
|
|
188
191
|
tone: "running",
|
|
189
|
-
children: "running"
|
|
192
|
+
children: t("skill.ui.running", "running")
|
|
190
193
|
})
|
|
191
194
|
}) : null : matches.length === 0 ? /* @__PURE__ */ jsx(MessageItemBody, {
|
|
192
195
|
"data-testid": "tool-result-search_skills",
|
|
193
196
|
children: /* @__PURE__ */ jsx("span", {
|
|
194
197
|
className: "text-po-dim",
|
|
195
|
-
children: "No skills match."
|
|
198
|
+
children: t("skill.ui.noSkillsMatch", "No skills match.")
|
|
196
199
|
})
|
|
197
200
|
}) : /* @__PURE__ */ jsx(MessageItemBody, {
|
|
198
201
|
"data-testid": "tool-result-search_skills",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.mjs","names":["toolLoadSkill","toolSearchSkills"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/skillToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.web.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.web.tsx","../../generated/web.ts"],"sourcesContent":["import type { ToolResultView } from '@agimon-ai/po-core/web';\n\nexport interface SkillMatch {\n readonly name: string;\n readonly description: string;\n}\n\n/** The result's text blocks joined, falling back to the streamed output before a result exists. */\nexport function resultText(result: ToolResultView | null, output: string): string {\n if (result === null) return output;\n return result.content\n .flatMap((block) => {\n const record = typeof block === 'object' && block !== null ? (block as { type?: unknown; text?: unknown }) : {};\n return record.type === 'text' && typeof record.text === 'string' ? [record.text] : [];\n })\n .join('\\n');\n}\n\n/** The skill name a load_skill call asked for. */\nexport function loadSkillName(args: Readonly<Record<string, unknown>>): string {\n return typeof args.name === 'string' ? args.name : '';\n}\n\n/**\n * The loaded SKILL.md without its YAML frontmatter, which the header already\n * names; the rest is what the agent read.\n */\nexport function skillBody(text: string): string {\n return text.replace(/^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/, '').trim();\n}\n\n/** How much of a loaded skill the card shows before Show more. */\nexport const SKILL_PREVIEW_LINES = 12;\n\n/**\n * The opening of a long skill, for the card to show before Show more. The cut\n * never lands inside a code fence: a preview that opened one without closing\n * it would render the rest of the card as code, so it backs up to the line\n * before the fence instead.\n */\nexport function skillPreview(body: string, maxLines = SKILL_PREVIEW_LINES): { text: string; hidden: number } {\n const lines = body.split('\\n');\n if (lines.length <= maxLines) return { text: body, hidden: 0 };\n const isFence = lines.slice(0, maxLines).map((line) => line.trimStart().startsWith('```'));\n const fences = isFence.filter(Boolean).length;\n const cut = fences % 2 === 1 ? isFence.lastIndexOf(true) : maxLines;\n // A skill that opens with a fence has no safe cut short of the whole block; show it all.\n if (cut <= 0) return { text: body, hidden: 0 };\n const text = lines.slice(0, cut).join('\\n').trimEnd();\n return { text, hidden: lines.length - cut };\n}\n\n/** The search_skills query, or undefined when the call listed every skill. */\nexport function searchQuery(args: Readonly<Record<string, unknown>>): string | undefined {\n const query = typeof args.query === 'string' ? args.query.trim() : '';\n return query.length > 0 ? query : undefined;\n}\n\n/**\n * The matches a search_skills result carries. The tool returns them as JSON\n * text; anything else (a truncated or foreign result) reads as no matches\n * rather than breaking the card.\n */\nexport function skillMatches(result: ToolResultView | null, output: string): readonly SkillMatch[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(resultText(result, output));\n } catch {\n return [];\n }\n if (!Array.isArray(parsed)) return [];\n return parsed.flatMap((entry: unknown) => {\n const record = typeof entry === 'object' && entry !== null ? (entry as Record<string, unknown>) : {};\n return typeof record.name === 'string'\n ? [{ name: record.name, description: typeof record.description === 'string' ? record.description : '' }]\n : [];\n });\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\nimport {\n Button,\n Markdown,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-web-components';\nimport { useState } from 'react';\n\nimport { loadSkillName, resultText, skillBody, skillPreview } from '../_lib/skillToolView';\n\n/**\n * The instructions, opened on their first lines with an explicit Show more,\n * as the phone's Markdown pages a long body. A skill runs to hundreds of\n * lines; dropping all of them into the transcript at once buries the turn.\n */\nfunction SkillBody({ body }: { body: string }) {\n const [full, setFull] = useState(false);\n const preview = skillPreview(body);\n const showAll = full || preview.hidden === 0;\n return (\n <MessageItemBody data-testid=\"tool-result-load_skill\" className=\"flex flex-col gap-2\">\n <Markdown text={showAll ? body : preview.text} />\n {showAll ? null : (\n <span className=\"flex items-center gap-2\">\n <span className=\"text-sm text-po-dim\">{preview.hidden} more lines</span>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => setFull(true)}>\n Show more\n </Button>\n </span>\n )}\n </MessageItemBody>\n );\n}\n\n/**\n * The load_skill tool's timeline item: the skill name in the header and, once\n * expanded, the instructions the agent read, frontmatter dropped. A missing\n * skill shows the tool's message in red instead.\n */\nexport function LoadSkillToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {\n const name = loadSkillName(args);\n const body = result === null || isError ? '' : skillBody(resultText(result, output));\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => (\n <>\n <MessageItemHeader title=\"load_skill\">\n <span data-testid=\"tool-call-load_skill\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"truncate text-po-text\">{name}</span>\n </span>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody data-testid=\"tool-result-load_skill\" className=\"flex flex-col\">\n <span className=\"whitespace-pre-wrap break-words text-po-red\">{resultText(result, output)}</span>\n </MessageItemBody>\n ) : result === null ? (\n running ? (\n <MessageItemBody data-testid=\"tool-result-load_skill\">\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : body.length === 0 ? null : (\n <SkillBody body={body} />\n )}\n </>\n )}\n </MessageItem>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { LoadSkillToolMessage } from './_components/LoadSkillToolMessage';\n\nexport default defineToolRenderer({ message: LoadSkillToolMessage });\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\nimport {\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-web-components';\n\nimport { resultText, searchQuery, skillMatches } from '../_lib/skillToolView';\n\n/**\n * The search_skills tool's timeline item: the query (or \"all skills\") and the\n * match count in the header and, once expanded, each match by name with its\n * description.\n */\nexport function SearchSkillsToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {\n const query = searchQuery(args);\n const matches = result === null || isError ? [] : skillMatches(result, output);\n const count =\n result === null || isError ? undefined : `${matches.length} ${matches.length === 1 ? 'skill' : 'skills'}`;\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => (\n <>\n <MessageItemHeader title=\"search_skills\">\n <span data-testid=\"tool-call-search_skills\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n {query === undefined ? (\n <span className=\"truncate text-po-dim\">all skills</span>\n ) : (\n <span className=\"truncate text-po-text\">{query}</span>\n )}\n {count !== undefined ? <span className=\"shrink-0 text-po-faint\">· {count}</span> : null}\n </span>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody data-testid=\"tool-result-search_skills\" className=\"flex flex-col\">\n <span className=\"whitespace-pre-wrap break-words text-po-red\">{resultText(result, output)}</span>\n </MessageItemBody>\n ) : result === null ? (\n running ? (\n <MessageItemBody data-testid=\"tool-result-search_skills\">\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : matches.length === 0 ? (\n <MessageItemBody data-testid=\"tool-result-search_skills\">\n <span className=\"text-po-dim\">No skills match.</span>\n </MessageItemBody>\n ) : (\n <MessageItemBody data-testid=\"tool-result-search_skills\" className=\"flex flex-col gap-2\">\n {matches.map((match) => (\n <span key={match.name} className=\"flex flex-col\">\n <span className=\"font-semibold text-po-hi\">{match.name}</span>\n {match.description.length > 0 ? (\n <span className=\"text-sm text-po-dim\">{match.description}</span>\n ) : null}\n </span>\n ))}\n </MessageItemBody>\n )}\n </>\n )}\n </MessageItem>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { SearchSkillsToolMessage } from './_components/SearchSkillsToolMessage';\n\nexport default defineToolRenderer({ message: SearchSkillsToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineWebPlugin, type WebPluginContributions } from '@agimon-ai/po-core/web';\n\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.web';\nimport toolSearchSkills from '../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.web';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const webPlugin = defineWebPlugin({\n id: 'skill',\n packageName: '@agimon-ai/po-skill',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['load_skill'] }, toolLoadSkill), via({ tools: ['search_skills'] }, toolSearchSkills)]; },\n },\n});\n"],"mappings":";;;;;;AAQA,SAAgB,WAAW,QAA+B,QAAwB;CAChF,IAAI,WAAW,MAAM,OAAO;CAC5B,OAAO,OAAO,QACX,SAAS,UAAU;EAClB,MAAM,SAAS,OAAO,UAAU,YAAY,UAAU,OAAQ,QAA+C,CAAC;EAC9G,OAAO,OAAO,SAAS,UAAU,OAAO,OAAO,SAAS,WAAW,CAAC,OAAO,IAAI,IAAI,CAAC;CACtF,CAAC,CAAC,CACD,KAAK,IAAI;AACd;;AAGA,SAAgB,cAAc,MAAiD;CAC7E,OAAO,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACrD;;;;;AAMA,SAAgB,UAAU,MAAsB;CAC9C,OAAO,KAAK,QAAQ,mCAAmC,EAAE,CAAC,CAAC,KAAK;AAClE;;;;;;;AAWA,SAAgB,aAAa,MAAc,WAAA,IAAkE;CAC3G,MAAM,QAAQ,KAAK,MAAM,IAAI;CAC7B,IAAI,MAAM,UAAU,UAAU,OAAO;EAAE,MAAM;EAAM,QAAQ;CAAE;CAC7D,MAAM,UAAU,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,KAAK,SAAS,KAAK,UAAU,CAAC,CAAC,WAAW,KAAK,CAAC;CAEzF,MAAM,MADS,QAAQ,OAAO,OAAO,CAAC,CAAC,SAClB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D;KAAM,WAAU;KAAuB,UAAA,MAAM;IAAkB,CAAA,IAC7D,IACA;GALK,GAAA,MAAM,IAKX,CACP;EACc,CAAA,CAEnB,EAAA,CAAA;CAEO,CAAA;AAEjB;;;AC7DA,IAAA,4BAAe,mBAAmB,EAAE,SAAS,wBAAwB,CAAC;;;ACEtE,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,YAAY,gBAAgB;CACvC,IAAI;CACJ,aAAa;CACb,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,GAAGA,sBAAa,GAAG,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,GAAGC,yBAAgB,CAAC;CAAG,EAC9K;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"web.mjs","names":["toolLoadSkill","toolSearchSkills"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/skillToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.web.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.web.tsx","../../generated/web.ts"],"sourcesContent":["import type { ToolResultView } from '@agimon-ai/po-core/web';\n\nexport interface SkillMatch {\n readonly name: string;\n readonly description: string;\n}\n\n/** The result's text blocks joined, falling back to the streamed output before a result exists. */\nexport function resultText(result: ToolResultView | null, output: string): string {\n if (result === null) return output;\n return result.content\n .flatMap((block) => {\n const record = typeof block === 'object' && block !== null ? (block as { type?: unknown; text?: unknown }) : {};\n return record.type === 'text' && typeof record.text === 'string' ? [record.text] : [];\n })\n .join('\\n');\n}\n\n/** The skill name a load_skill call asked for. */\nexport function loadSkillName(args: Readonly<Record<string, unknown>>): string {\n return typeof args.name === 'string' ? args.name : '';\n}\n\n/**\n * The loaded SKILL.md without its YAML frontmatter, which the header already\n * names; the rest is what the agent read.\n */\nexport function skillBody(text: string): string {\n return text.replace(/^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/, '').trim();\n}\n\n/** How much of a loaded skill the card shows before Show more. */\nexport const SKILL_PREVIEW_LINES = 12;\n\n/**\n * The opening of a long skill, for the card to show before Show more. The cut\n * never lands inside a code fence: a preview that opened one without closing\n * it would render the rest of the card as code, so it backs up to the line\n * before the fence instead.\n */\nexport function skillPreview(body: string, maxLines = SKILL_PREVIEW_LINES): { text: string; hidden: number } {\n const lines = body.split('\\n');\n if (lines.length <= maxLines) return { text: body, hidden: 0 };\n const isFence = lines.slice(0, maxLines).map((line) => line.trimStart().startsWith('```'));\n const fences = isFence.filter(Boolean).length;\n const cut = fences % 2 === 1 ? isFence.lastIndexOf(true) : maxLines;\n // A skill that opens with a fence has no safe cut short of the whole block; show it all.\n if (cut <= 0) return { text: body, hidden: 0 };\n const text = lines.slice(0, cut).join('\\n').trimEnd();\n return { text, hidden: lines.length - cut };\n}\n\n/** The search_skills query, or undefined when the call listed every skill. */\nexport function searchQuery(args: Readonly<Record<string, unknown>>): string | undefined {\n const query = typeof args.query === 'string' ? args.query.trim() : '';\n return query.length > 0 ? query : undefined;\n}\n\n/**\n * The matches a search_skills result carries. The tool returns them as JSON\n * text; anything else (a truncated or foreign result) reads as no matches\n * rather than breaking the card.\n */\nexport function skillMatches(result: ToolResultView | null, output: string): readonly SkillMatch[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(resultText(result, output));\n } catch {\n return [];\n }\n if (!Array.isArray(parsed)) return [];\n return parsed.flatMap((entry: unknown) => {\n const record = typeof entry === 'object' && entry !== null ? (entry as Record<string, unknown>) : {};\n return typeof record.name === 'string'\n ? [{ name: record.name, description: typeof record.description === 'string' ? record.description : '' }]\n : [];\n });\n}\n","import { useT } from '@agimon-ai/po-core/web';\nimport type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\nimport {\n Button,\n Markdown,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-web-components';\nimport { useState } from 'react';\n\nimport { loadSkillName, resultText, skillBody, skillPreview } from '../_lib/skillToolView';\n\n/**\n * The instructions, opened on their first lines with an explicit Show more,\n * as the phone's Markdown pages a long body. A skill runs to hundreds of\n * lines; dropping all of them into the transcript at once buries the turn.\n */\nfunction SkillBody({ body }: { body: string }) {\n const t = useT();\n const [full, setFull] = useState(false);\n const preview = skillPreview(body);\n const showAll = full || preview.hidden === 0;\n return (\n <MessageItemBody data-testid=\"tool-result-load_skill\" className=\"flex flex-col gap-2\">\n <Markdown text={showAll ? body : preview.text} />\n {showAll ? null : (\n <span className=\"flex items-center gap-2\">\n <span className=\"text-sm text-po-dim\">\n {t('skill.ui.moreLines', '{count} more lines', { count: preview.hidden })}\n </span>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => setFull(true)}>\n {t('skill.ui.showMore', 'Show more')}\n </Button>\n </span>\n )}\n </MessageItemBody>\n );\n}\n\n/**\n * The load_skill tool's timeline item: the skill name in the header and, once\n * expanded, the instructions the agent read, frontmatter dropped. A missing\n * skill shows the tool's message in red instead.\n */\nexport function LoadSkillToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {\n const t = useT();\n const name = loadSkillName(args);\n const body = result === null || isError ? '' : skillBody(resultText(result, output));\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => (\n <>\n {/* no-untranslated-jsx: ignore - Preserve the technical tool identifier. */}\n <MessageItemHeader title=\"load_skill\">\n <span data-testid=\"tool-call-load_skill\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"truncate text-po-text\">{name}</span>\n </span>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody data-testid=\"tool-result-load_skill\" className=\"flex flex-col\">\n <span className=\"whitespace-pre-wrap break-words text-po-red\">{resultText(result, output)}</span>\n </MessageItemBody>\n ) : result === null ? (\n running ? (\n <MessageItemBody data-testid=\"tool-result-load_skill\">\n <MessageItemStatus tone=\"running\">{t('skill.ui.running', 'running')}</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : body.length === 0 ? null : (\n <SkillBody body={body} />\n )}\n </>\n )}\n </MessageItem>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { LoadSkillToolMessage } from './_components/LoadSkillToolMessage';\n\nexport default defineToolRenderer({ message: LoadSkillToolMessage });\n","import { useT } from '@agimon-ai/po-core/web';\nimport type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\nimport {\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-web-components';\n\nimport { resultText, searchQuery, skillMatches } from '../_lib/skillToolView';\n\n/**\n * The search_skills tool's timeline item: the query (or \"all skills\") and the\n * match count in the header and, once expanded, each match by name with its\n * description.\n */\nexport function SearchSkillsToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {\n const t = useT();\n const query = searchQuery(args);\n const matches = result === null || isError ? [] : skillMatches(result, output);\n const count =\n result === null || isError ? undefined : `${matches.length} ${matches.length === 1 ? 'skill' : 'skills'}`;\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => (\n <>\n {/* no-untranslated-jsx: ignore - Preserve the technical tool identifier. */}\n <MessageItemHeader title=\"search_skills\">\n <span data-testid=\"tool-call-search_skills\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n {query === undefined ? (\n <span className=\"truncate text-po-dim\">{t('skill.ui.allSkills', 'all skills')}</span>\n ) : (\n <span className=\"truncate text-po-text\">{query}</span>\n )}\n {count !== undefined ? <span className=\"shrink-0 text-po-faint\">· {count}</span> : null}\n </span>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody data-testid=\"tool-result-search_skills\" className=\"flex flex-col\">\n <span className=\"whitespace-pre-wrap break-words text-po-red\">{resultText(result, output)}</span>\n </MessageItemBody>\n ) : result === null ? (\n running ? (\n <MessageItemBody data-testid=\"tool-result-search_skills\">\n <MessageItemStatus tone=\"running\">{t('skill.ui.running', 'running')}</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : matches.length === 0 ? (\n <MessageItemBody data-testid=\"tool-result-search_skills\">\n <span className=\"text-po-dim\">{t('skill.ui.noSkillsMatch', 'No skills match.')}</span>\n </MessageItemBody>\n ) : (\n <MessageItemBody data-testid=\"tool-result-search_skills\" className=\"flex flex-col gap-2\">\n {matches.map((match) => (\n <span key={match.name} className=\"flex flex-col\">\n <span className=\"font-semibold text-po-hi\">{match.name}</span>\n {match.description.length > 0 ? (\n <span className=\"text-sm text-po-dim\">{match.description}</span>\n ) : null}\n </span>\n ))}\n </MessageItemBody>\n )}\n </>\n )}\n </MessageItem>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { SearchSkillsToolMessage } from './_components/SearchSkillsToolMessage';\n\nexport default defineToolRenderer({ message: SearchSkillsToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineWebPlugin, type WebPluginContributions } from '@agimon-ai/po-core/web';\n\nimport toolLoadSkill from '../src/extensions/workspaces/sessions/(frontend)/tool/load_skill.web';\nimport toolSearchSkills from '../src/extensions/workspaces/sessions/(frontend)/tool/search_skills.web';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const webPlugin = defineWebPlugin({\n id: 'skill',\n packageName: '@agimon-ai/po-skill',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['load_skill'] }, toolLoadSkill), via({ tools: ['search_skills'] }, toolSearchSkills)]; },\n },\n});\n"],"mappings":";;;;;;AAQA,SAAgB,WAAW,QAA+B,QAAwB;CAChF,IAAI,WAAW,MAAM,OAAO;CAC5B,OAAO,OAAO,QACX,SAAS,UAA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AS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,GAAGA,sBAAa,GAAG,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,GAAGC,yBAAgB,CAAC;CAAG,EAC9K;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","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/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/load_skill.server.ts","src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.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/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/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","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/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/load_skill.server.ts","src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.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/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/types/skills.ts","tsdown.config.ts"],"sourceRevision":"1465385e5cf4aa11a43ed0e12d8197b5","manifestRevision":"9bb45c0de040095ad9e8edf6f4b48acb","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","src/prompts/help-how-to-author-skill/SKILL.md","src/prompts/help-how-to-skill/SKILL.md"],"outputRevision":"683988105fded332d2b1b45a7ef4cc94"}
|
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.197",
|
|
4
4
|
"description": "Session skill catalogue, deferred skill discovery, and the skill browser for Po.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-skills",
|
|
@@ -71,18 +71,18 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@agimon-ai/po-config": "0.0.0-alpha.
|
|
75
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
76
|
-
"@agimon-ai/po-domain": "0.0.0-alpha.
|
|
77
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
74
|
+
"@agimon-ai/po-config": "0.0.0-alpha.197",
|
|
75
|
+
"@agimon-ai/po-core": "0.0.0-alpha.197",
|
|
76
|
+
"@agimon-ai/po-domain": "0.0.0-alpha.197",
|
|
77
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.197",
|
|
78
78
|
"@deepseek-ai/cordis": "4.0.5",
|
|
79
79
|
"gpt-tokenizer": "4.1.0",
|
|
80
80
|
"typebox": "1.4.2"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
84
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
85
|
-
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.
|
|
83
|
+
"@agimon-ai/po-build": "0.0.0-alpha.197",
|
|
84
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.197",
|
|
85
|
+
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.197",
|
|
86
86
|
"@deepseek-ai/cordis": "4.0.5",
|
|
87
87
|
"@earendil-works/pi-coding-agent": "1.6.1",
|
|
88
88
|
"@types/node": "26.6.5",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"vitest": "5.0.4"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
101
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.197",
|
|
102
102
|
"@earendil-works/pi-coding-agent": "1.6.1",
|
|
103
103
|
"react-native": "0.88.1",
|
|
104
104
|
"react-native-unistyles": "^3.5.3"
|