@agimon-ai/po-skill 0.0.0-alpha.215 → 0.0.0-alpha.216
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/catalog.cjs +3 -13
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.mts +3 -1
- package/dist/catalog.d.mts.map +1 -1
- package/dist/catalog.mjs +3 -13
- package/dist/catalog.mjs.map +1 -1
- package/dist/extensions/native.mjs +18 -6
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/web.mjs +18 -6
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/po-runtime-identity.json +1 -1
- package/llms.txt +2 -2
- package/locales/vi.json +2 -2
- package/locales/zh-CN.json +2 -2
- package/package.json +9 -9
- package/src/prompts/help-how-to-author-skill/SKILL.md +24 -7
- package/src/prompts/help-how-to-skill/SKILL.md +2 -2
package/dist/catalog.cjs
CHANGED
|
@@ -4,25 +4,15 @@ let node_path = require("node:path");
|
|
|
4
4
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
5
5
|
let _agimon_ai_po_config_domains = require("@agimon-ai/po-config/domains");
|
|
6
6
|
let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
|
|
7
|
+
let _agimon_ai_po_core_tokenCount = require("@agimon-ai/po-core/tokenCount");
|
|
7
8
|
let _agimon_ai_po_domain_plugins = require("@agimon-ai/po-domain/plugins");
|
|
8
9
|
let _earendil_works_pi_coding_agent = require("@earendil-works/pi-coding-agent");
|
|
9
10
|
//#region src/services/skillCatalog/index.ts
|
|
10
11
|
const SKILLS_DIRECTORY = "skills";
|
|
11
12
|
const SHARED_SKILLS_OWNER = ".claude/skills";
|
|
12
13
|
const bodyTokenCache = /* @__PURE__ */ new WeakMap();
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* `gpt-tokenizer` carries its whole vocabulary and costs about a tenth of a
|
|
17
|
-
* second to load. This module is reachable from the skills extension, which Pi
|
|
18
|
-
* loads at session start, so a top-level import would charge every session for
|
|
19
|
-
* a surface most of them never open.
|
|
20
|
-
*/
|
|
21
|
-
let tokenizer;
|
|
22
|
-
async function counter() {
|
|
23
|
-
tokenizer ??= import("gpt-tokenizer");
|
|
24
|
-
return (await tokenizer).countTokens;
|
|
25
|
-
}
|
|
14
|
+
/** Load the runtime's token counter on first use. */
|
|
15
|
+
const counter = _agimon_ai_po_core_tokenCount.loadTokenCounter;
|
|
26
16
|
/**
|
|
27
17
|
* Matches a directory against the active set.
|
|
28
18
|
*
|
package/dist/catalog.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.cjs","names":["path","loadSkillsFromDir","BACKGROUND_CONTEXT","materializePluginEntries","resolvePluginEntriesAsync","listDomainNamesAsync","formatSkillsForPrompt","getOrThrow"],"sources":["../src/services/skillCatalog/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport {\n listDomainNamesAsync,\n type PluginSkillDiscovery,\n resolvePluginEntriesAsync,\n} from '@agimon-ai/po-config/domains';\nimport { BACKGROUND_CONTEXT, type FileSystem, getOrThrow } from '@agimon-ai/po-core/platform';\nimport type { SkillSourceContribution } from '@agimon-ai/po-core/skills';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { formatSkillsForPrompt, loadSkillsFromDir, type Skill } from '@earendil-works/pi-coding-agent';\n\nconst SKILLS_DIRECTORY = 'skills';\nconst SHARED_SKILLS_OWNER = '.claude/skills';\n\n// Per capability so remote filesystems never share counts with local paths.\nconst bodyTokenCache = new WeakMap<FileSystem, Map<string, { mtimeMs: number; size: number; tokens: number }>>();\n\nexport type SkillGroupKey = 'extensions' | 'help' | 'plugins' | 'default';\n\nexport interface SkillEntry {\n name: string;\n description: string;\n filePath: string;\n baseDir: string;\n group: SkillGroupKey;\n /** Package name for an extension, plugin directory name, or `.claude/skills`. */\n owner: string;\n modelInvocable: boolean;\n /**\n * What removing this skill would save from the `<available_skills>` block.\n *\n * Marginal rather than proportional: the block has fixed framing that no\n * single skill pays for, so the useful figure is what actually goes away.\n * Bodies are excluded because they load on demand and are not a resting cost.\n */\n promptTokens?: number;\n}\n\nexport interface SkillOwnerNode {\n owner: string;\n skills: SkillEntry[];\n}\n\nexport interface SkillGroup {\n key: SkillGroupKey;\n label: string;\n owners: SkillOwnerNode[];\n}\n\nexport interface SkillCatalog {\n groups: SkillGroup[];\n skillCount: number;\n /** Tokens the `<available_skills>` prompt block costs on every request. */\n promptTokens: number;\n /** Tokens every loaded SKILL.md costs in full, if all of them were read. */\n bodyTokens: number;\n /** Frontmatter and read failures, surfaced instead of thrown. */\n diagnostics: string[];\n}\n\nexport interface SkillCatalogOptions {\n repoRoot: string;\n /** The host's fs; Pi's skill walker below still reads the local disk directly. */\n fs: FileSystem;\n /** Exact files the current selection resolved to, from `HarnessState.skillDirectories`. */\n activeSkillDirectories: readonly string[];\n extensionSources: readonly SkillSourceContribution[];\n /** Accepted Pi discovery snapshot. Reused without walking or parsing bodies again. */\n discoveredSkills?: readonly Skill[];\n /** Activation-gated wrappers already accepted by the merged active-skill view. */\n helpSkills?: readonly Skill[];\n /** Bounded Help activation and collision diagnostics. */\n helpDiagnostics?: readonly string[];\n /** Home and admitted environment that locate the Po home (`PO_HOME`) and its plugin store. */\n homeDirectory?: string;\n environment?: Readonly<Record<string, string | undefined>>;\n}\n\n/**\n * The tokenizer, loaded on first use rather than at import.\n *\n * `gpt-tokenizer` carries its whole vocabulary and costs about a tenth of a\n * second to load. This module is reachable from the skills extension, which Pi\n * loads at session start, so a top-level import would charge every session for\n * a surface most of them never open.\n */\nlet tokenizer: Promise<typeof import('gpt-tokenizer')> | undefined;\n\nexport async function counter(): Promise<(text: string) => number> {\n tokenizer ??= import('gpt-tokenizer');\n return (await tokenizer).countTokens;\n}\n\n/**\n * Matches a directory against the active set.\n *\n * A domain that lists a plugin subset puts individual skill directories in the\n * set rather than the plugin's `skills` root, so containment has to be checked\n * both ways: the set may hold an ancestor of the directory, or a descendant of\n * it.\n */\nfunction createActiveMatcher(directories: readonly string[]): (directory: string) => boolean {\n const active = directories.map((directory) => path.resolve(directory));\n return (directory) => {\n const resolved = path.resolve(directory);\n return active.some(\n (entry) =>\n entry === resolved || entry.startsWith(`${resolved}${path.sep}`) || resolved.startsWith(`${entry}${path.sep}`),\n );\n };\n}\n\nfunction collect(\n directory: string,\n group: SkillGroupKey,\n owner: string,\n isActive: (directory: string) => boolean,\n loaded: Skill[],\n diagnostics: string[],\n discovery: PluginSkillDiscovery = 'recursive',\n descriptors?: readonly Skill[],\n): SkillEntry[] {\n const result =\n descriptors === undefined\n ? loadSkillsFromDir({ dir: directory, source: owner })\n : {\n skills: descriptors.filter((skill) => skill.filePath.startsWith(`${path.resolve(directory)}${path.sep}`)),\n diagnostics: [],\n };\n for (const diagnostic of result.diagnostics) {\n diagnostics.push(`${diagnostic.path ?? directory}: ${diagnostic.message}`);\n }\n // Checked per skill, not per root: a subset domain selects some of a plugin's\n // skills and leaves the rest on disk, unloaded and therefore not listed.\n const root = path.resolve(directory);\n const kept = result.skills.filter((skill) => {\n const skillDirectory = path.dirname(skill.filePath);\n if (discovery === 'direct-children' && path.dirname(skillDirectory) !== root) return false;\n return isActive(skillDirectory);\n });\n // Kept in their loaded form as well, because the prompt-block cost is measured\n // by handing them back to Pi's own formatter.\n loaded.push(...kept);\n return kept\n .map((skill) => ({\n name: skill.name,\n description: skill.description,\n filePath: skill.filePath,\n baseDir: skill.baseDir,\n group,\n owner,\n modelInvocable: !skill.disableModelInvocation,\n }))\n .sort((left, right) => left.name.localeCompare(right.name));\n}\n\nfunction sortOwners(owners: SkillOwnerNode[]): SkillOwnerNode[] {\n return owners.sort((left, right) => left.owner.localeCompare(right.owner));\n}\n\nfunction collectHelpSkills(skills: readonly Skill[], loaded: Skill[], diagnostics: string[]): SkillOwnerNode[] {\n const occupiedNames = new Set(loaded.map((skill) => skill.name));\n const owners = new Map<string, SkillEntry[]>();\n const candidates = [...skills].sort(\n (left, right) =>\n left.sourceInfo.source.localeCompare(right.sourceInfo.source) ||\n left.name.localeCompare(right.name) ||\n left.filePath.localeCompare(right.filePath),\n );\n for (const skill of candidates) {\n if (occupiedNames.has(skill.name)) {\n diagnostics.push(\n `Help ${skill.sourceInfo.source} [HELP_SKILL_COLLISION]: '${skill.name}' was ignored because a normal skill wins.`,\n );\n continue;\n }\n occupiedNames.add(skill.name);\n loaded.push(skill);\n const owner = skill.sourceInfo.source;\n const entries = owners.get(owner) ?? [];\n entries.push({\n name: skill.name,\n description: skill.description,\n filePath: skill.filePath,\n baseDir: skill.baseDir,\n group: 'help',\n owner,\n modelInvocable: !skill.disableModelInvocation,\n });\n owners.set(owner, entries);\n }\n return sortOwners(\n [...owners.entries()].map(([owner, entries]) => ({\n owner,\n skills: entries.sort((left, right) => left.name.localeCompare(right.name)),\n })),\n );\n}\n\n/**\n * Every skill this session actually loaded, grouped by where it comes from,\n * priced in tokens.\n *\n * Discovery runs over `loadSkillsFromDir` from Pi rather than the harness's own\n * walker so the listing matches what Pi would load, including its ignore-file\n * handling; the same skills are then handed to Pi's `formatSkillsForPrompt` so\n * the always-on figure is the real prompt block rather than a reconstruction of\n * it.\n */\nexport async function buildSkillCatalog(options: SkillCatalogOptions): Promise<SkillCatalog> {\n const { fs, repoRoot } = options;\n const isActive = createActiveMatcher(options.activeSkillDirectories);\n const diagnostics: string[] = [...(options.helpDiagnostics ?? [])];\n const loaded: Skill[] = [];\n\n const extensionOwners: SkillOwnerNode[] = [];\n for (const entry of options.extensionSources) {\n const skills = entry.directories.flatMap((directory) =>\n collect(\n directory,\n 'extensions',\n entry.source,\n () => true,\n loaded,\n diagnostics,\n 'recursive',\n options.discoveredSkills,\n ),\n );\n if (skills.length > 0) extensionOwners.push({ owner: entry.source, skills });\n }\n\n const context = BACKGROUND_CONTEXT;\n const pluginOwners: SkillOwnerNode[] = [];\n const { homeDirectory, environment } = options;\n const domainPlugins = await materializePluginEntries(\n await resolvePluginEntriesAsync(\n fs,\n repoRoot,\n await listDomainNamesAsync(fs, repoRoot, context, homeDirectory, environment),\n [],\n context,\n homeDirectory,\n environment,\n ),\n { homeDirectory, environment },\n );\n for (const entry of domainPlugins) {\n const directory = path.join(entry.directory, SKILLS_DIRECTORY);\n const present = await fs.exists(directory, context);\n if (!present.ok || !present.value) continue;\n const owner = path.basename(entry.directory);\n const skills = collect(\n directory,\n 'plugins',\n owner,\n isActive,\n loaded,\n diagnostics,\n entry.skillDiscovery,\n options.discoveredSkills,\n );\n if (skills.length > 0) pluginOwners.push({ owner, skills });\n }\n\n const sharedDirectory = path.join(repoRoot, '.claude', SKILLS_DIRECTORY);\n const sharedSkills = collect(\n sharedDirectory,\n 'default',\n SHARED_SKILLS_OWNER,\n isActive,\n loaded,\n diagnostics,\n 'recursive',\n options.discoveredSkills,\n );\n const defaultOwners = sharedSkills.length > 0 ? [{ owner: SHARED_SKILLS_OWNER, skills: sharedSkills }] : [];\n const helpOwners = collectHelpSkills(options.helpSkills ?? [], loaded, diagnostics);\n\n const groups: SkillGroup[] = [\n { key: 'extensions', label: 'extensions', owners: sortOwners(extensionOwners) },\n { key: 'help', label: 'Help', owners: helpOwners },\n { key: 'plugins', label: 'plugins', owners: sortOwners(pluginOwners) },\n { key: 'default', label: 'default', owners: defaultOwners },\n ];\n\n const countTokens = await counter();\n const prompt = formatSkillsForPrompt(loaded);\n const framingTokens = countTokens(formatSkillsForPrompt([]));\n const marginal = new Map<string, number>();\n for (const skill of loaded) {\n marginal.set(skill.name, Math.max(0, countTokens(formatSkillsForPrompt([skill])) - framingTokens));\n }\n for (const group of groups) {\n for (const owner of group.owners) {\n for (const skill of owner.skills) {\n const tokens = marginal.get(skill.name);\n if (tokens !== undefined) skill.promptTokens = tokens;\n }\n }\n }\n let bodyTokens = 0;\n let cachedCounts = bodyTokenCache.get(fs);\n if (!cachedCounts) {\n cachedCounts = new Map();\n bodyTokenCache.set(fs, cachedCounts);\n }\n for (const skill of loaded) {\n try {\n const info = getOrThrow(await fs.fileInfo(skill.filePath, context));\n let cached = cachedCounts.get(skill.filePath);\n if (!cached || cached.mtimeMs !== info.mtimeMs || cached.size !== info.size) {\n cached = {\n mtimeMs: info.mtimeMs,\n size: info.size,\n tokens: countTokens(getOrThrow(await fs.readTextFile(skill.filePath, context))),\n };\n cachedCounts.set(skill.filePath, cached);\n }\n bodyTokens += cached.tokens;\n } catch (error) {\n diagnostics.push(`${skill.filePath}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n return {\n groups,\n skillCount: loaded.length,\n promptTokens: prompt ? countTokens(prompt) : 0,\n bodyTokens,\n diagnostics,\n };\n}\n\n/** The skills a name resolves to, used to decide what `enter` can invoke. */\nexport function findSkill(catalog: SkillCatalog, name: string): SkillEntry | undefined {\n for (const group of catalog.groups) {\n for (const owner of group.owners) {\n const match = owner.skills.find((skill) => skill.name === name);\n if (match) return match;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;AAYA,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAG5B,MAAM,iCAAiB,IAAI,QAAoF;;;;;;;;;AAuE/G,IAAI;AAEJ,eAAsB,UAA6C;CACjE,cAAc,OAAO;CACrB,QAAQ,MAAM,UAAA,CAAW;AAC3B;;;;;;;;;AAUA,SAAS,oBAAoB,aAAgE;CAC3F,MAAM,SAAS,YAAY,KAAK,cAAcA,UAAAA,QAAK,QAAQ,SAAS,CAAC;CACrE,QAAQ,cAAc;EACpB,MAAM,WAAWA,UAAAA,QAAK,QAAQ,SAAS;EACvC,OAAO,OAAO,MACX,UACC,UAAU,YAAY,MAAM,WAAW,GAAG,WAAWA,UAAAA,QAAK,KAAK,KAAK,SAAS,WAAW,GAAG,QAAQA,UAAAA,QAAK,KAAK,CACjH;CACF;AACF;AAEA,SAAS,QACP,WACA,OACA,OACA,UACA,QACA,aACA,YAAkC,aAClC,aACc;CACd,MAAM,SACJ,gBAAgB,KAAA,KAAA,GACZC,gCAAAA,kBAAAA,CAAkB;EAAE,KAAK;E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adSkillsFromDir","BACKGROUND_CONTEXT","materializePluginEntries","resolvePluginEntriesAsync","listDomainNamesAsync","formatSkillsForPrompt","getOrThrow"],"sources":["../src/services/skillCatalog/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport {\n listDomainNamesAsync,\n type PluginSkillDiscovery,\n resolvePluginEntriesAsync,\n} from '@agimon-ai/po-config/domains';\nimport { BACKGROUND_CONTEXT, type FileSystem, getOrThrow } from '@agimon-ai/po-core/platform';\nimport type { SkillSourceContribution } from '@agimon-ai/po-core/skills';\nimport { loadTokenCounter } from '@agimon-ai/po-core/tokenCount';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { formatSkillsForPrompt, loadSkillsFromDir, type Skill } from '@earendil-works/pi-coding-agent';\n\nconst SKILLS_DIRECTORY = 'skills';\nconst SHARED_SKILLS_OWNER = '.claude/skills';\n\n// Per capability so remote filesystems never share counts with local paths.\nconst bodyTokenCache = new WeakMap<FileSystem, Map<string, { mtimeMs: number; size: number; tokens: number }>>();\n\nexport type SkillGroupKey = 'extensions' | 'help' | 'plugins' | 'default';\n\nexport interface SkillEntry {\n name: string;\n description: string;\n filePath: string;\n baseDir: string;\n group: SkillGroupKey;\n /** Package name for an extension, plugin directory name, or `.claude/skills`. */\n owner: string;\n modelInvocable: boolean;\n /**\n * What removing this skill would save from the `<available_skills>` block.\n *\n * Marginal rather than proportional: the block has fixed framing that no\n * single skill pays for, so the useful figure is what actually goes away.\n * Bodies are excluded because they load on demand and are not a resting cost.\n */\n promptTokens?: number;\n}\n\nexport interface SkillOwnerNode {\n owner: string;\n skills: SkillEntry[];\n}\n\nexport interface SkillGroup {\n key: SkillGroupKey;\n label: string;\n owners: SkillOwnerNode[];\n}\n\nexport interface SkillCatalog {\n groups: SkillGroup[];\n skillCount: number;\n /** Tokens the `<available_skills>` prompt block costs on every request. */\n promptTokens: number;\n /** Tokens every loaded SKILL.md costs in full, if all of them were read. */\n bodyTokens: number;\n /** Frontmatter and read failures, surfaced instead of thrown. */\n diagnostics: string[];\n}\n\nexport interface SkillCatalogOptions {\n repoRoot: string;\n /** The host's fs; Pi's skill walker below still reads the local disk directly. */\n fs: FileSystem;\n /** Exact files the current selection resolved to, from `HarnessState.skillDirectories`. */\n activeSkillDirectories: readonly string[];\n extensionSources: readonly SkillSourceContribution[];\n /** Accepted Pi discovery snapshot. Reused without walking or parsing bodies again. */\n discoveredSkills?: readonly Skill[];\n /** Activation-gated wrappers already accepted by the merged active-skill view. */\n helpSkills?: readonly Skill[];\n /** Bounded Help activation and collision diagnostics. */\n helpDiagnostics?: readonly string[];\n /** Home and admitted environment that locate the Po home (`PO_HOME`) and its plugin store. */\n homeDirectory?: string;\n environment?: Readonly<Record<string, string | undefined>>;\n}\n\n/** Load the runtime's token counter on first use. */\nexport const counter = loadTokenCounter;\n\n/**\n * Matches a directory against the active set.\n *\n * A domain that lists a plugin subset puts individual skill directories in the\n * set rather than the plugin's `skills` root, so containment has to be checked\n * both ways: the set may hold an ancestor of the directory, or a descendant of\n * it.\n */\nfunction createActiveMatcher(directories: readonly string[]): (directory: string) => boolean {\n const active = directories.map((directory) => path.resolve(directory));\n return (directory) => {\n const resolved = path.resolve(directory);\n return active.some(\n (entry) =>\n entry === resolved || entry.startsWith(`${resolved}${path.sep}`) || resolved.startsWith(`${entry}${path.sep}`),\n );\n };\n}\n\nfunction collect(\n directory: string,\n group: SkillGroupKey,\n owner: string,\n isActive: (directory: string) => boolean,\n loaded: Skill[],\n diagnostics: string[],\n discovery: PluginSkillDiscovery = 'recursive',\n descriptors?: readonly Skill[],\n): SkillEntry[] {\n const result =\n descriptors === undefined\n ? loadSkillsFromDir({ dir: directory, source: owner })\n : {\n skills: descriptors.filter((skill) => skill.filePath.startsWith(`${path.resolve(directory)}${path.sep}`)),\n diagnostics: [],\n };\n for (const diagnostic of result.diagnostics) {\n diagnostics.push(`${diagnostic.path ?? directory}: ${diagnostic.message}`);\n }\n // Checked per skill, not per root: a subset domain selects some of a plugin's\n // skills and leaves the rest on disk, unloaded and therefore not listed.\n const root = path.resolve(directory);\n const kept = result.skills.filter((skill) => {\n const skillDirectory = path.dirname(skill.filePath);\n if (discovery === 'direct-children' && path.dirname(skillDirectory) !== root) return false;\n return isActive(skillDirectory);\n });\n // Kept in their loaded form as well, because the prompt-block cost is measured\n // by handing them back to Pi's own formatter.\n loaded.push(...kept);\n return kept\n .map((skill) => ({\n name: skill.name,\n description: skill.description,\n filePath: skill.filePath,\n baseDir: skill.baseDir,\n group,\n owner,\n modelInvocable: !skill.disableModelInvocation,\n }))\n .sort((left, right) => left.name.localeCompare(right.name));\n}\n\nfunction sortOwners(owners: SkillOwnerNode[]): SkillOwnerNode[] {\n return owners.sort((left, right) => left.owner.localeCompare(right.owner));\n}\n\nfunction collectHelpSkills(skills: readonly Skill[], loaded: Skill[], diagnostics: string[]): SkillOwnerNode[] {\n const occupiedNames = new Set(loaded.map((skill) => skill.name));\n const owners = new Map<string, SkillEntry[]>();\n const candidates = [...skills].sort(\n (left, right) =>\n left.sourceInfo.source.localeCompare(right.sourceInfo.source) ||\n left.name.localeCompare(right.name) ||\n left.filePath.localeCompare(right.filePath),\n );\n for (const skill of candidates) {\n if (occupiedNames.has(skill.name)) {\n diagnostics.push(\n `Help ${skill.sourceInfo.source} [HELP_SKILL_COLLISION]: '${skill.name}' was ignored because a normal skill wins.`,\n );\n continue;\n }\n occupiedNames.add(skill.name);\n loaded.push(skill);\n const owner = skill.sourceInfo.source;\n const entries = owners.get(owner) ?? [];\n entries.push({\n name: skill.name,\n description: skill.description,\n filePath: skill.filePath,\n baseDir: skill.baseDir,\n group: 'help',\n owner,\n modelInvocable: !skill.disableModelInvocation,\n });\n owners.set(owner, entries);\n }\n return sortOwners(\n [...owners.entries()].map(([owner, entries]) => ({\n owner,\n skills: entries.sort((left, right) => left.name.localeCompare(right.name)),\n })),\n );\n}\n\n/**\n * Every skill this session actually loaded, grouped by where it comes from,\n * priced in tokens.\n *\n * Discovery runs over `loadSkillsFromDir` from Pi rather than the harness's own\n * walker so the listing matches what Pi would load, including its ignore-file\n * handling; the same skills are then handed to Pi's `formatSkillsForPrompt` so\n * the always-on figure is the real prompt block rather than a reconstruction of\n * it.\n */\nexport async function buildSkillCatalog(options: SkillCatalogOptions): Promise<SkillCatalog> {\n const { fs, repoRoot } = options;\n const isActive = createActiveMatcher(options.activeSkillDirectories);\n const diagnostics: string[] = [...(options.helpDiagnostics ?? [])];\n const loaded: Skill[] = [];\n\n const extensionOwners: SkillOwnerNode[] = [];\n for (const entry of options.extensionSources) {\n const skills = entry.directories.flatMap((directory) =>\n collect(\n directory,\n 'extensions',\n entry.source,\n () => true,\n loaded,\n diagnostics,\n 'recursive',\n options.discoveredSkills,\n ),\n );\n if (skills.length > 0) extensionOwners.push({ owner: entry.source, skills });\n }\n\n const context = BACKGROUND_CONTEXT;\n const pluginOwners: SkillOwnerNode[] = [];\n const { homeDirectory, environment } = options;\n const domainPlugins = await materializePluginEntries(\n await resolvePluginEntriesAsync(\n fs,\n repoRoot,\n await listDomainNamesAsync(fs, repoRoot, context, homeDirectory, environment),\n [],\n context,\n homeDirectory,\n environment,\n ),\n { homeDirectory, environment },\n );\n for (const entry of domainPlugins) {\n const directory = path.join(entry.directory, SKILLS_DIRECTORY);\n const present = await fs.exists(directory, context);\n if (!present.ok || !present.value) continue;\n const owner = path.basename(entry.directory);\n const skills = collect(\n directory,\n 'plugins',\n owner,\n isActive,\n loaded,\n diagnostics,\n entry.skillDiscovery,\n options.discoveredSkills,\n );\n if (skills.length > 0) pluginOwners.push({ owner, skills });\n }\n\n const sharedDirectory = path.join(repoRoot, '.claude', SKILLS_DIRECTORY);\n const sharedSkills = collect(\n sharedDirectory,\n 'default',\n SHARED_SKILLS_OWNER,\n isActive,\n loaded,\n diagnostics,\n 'recursive',\n options.discoveredSkills,\n );\n const defaultOwners = sharedSkills.length > 0 ? [{ owner: SHARED_SKILLS_OWNER, skills: sharedSkills }] : [];\n const helpOwners = collectHelpSkills(options.helpSkills ?? [], loaded, diagnostics);\n\n const groups: SkillGroup[] = [\n { key: 'extensions', label: 'extensions', owners: sortOwners(extensionOwners) },\n { key: 'help', label: 'Help', owners: helpOwners },\n { key: 'plugins', label: 'plugins', owners: sortOwners(pluginOwners) },\n { key: 'default', label: 'default', owners: defaultOwners },\n ];\n\n const countTokens = await counter();\n const prompt = formatSkillsForPrompt(loaded);\n const framingTokens = countTokens(formatSkillsForPrompt([]));\n const marginal = new Map<string, number>();\n for (const skill of loaded) {\n marginal.set(skill.name, Math.max(0, countTokens(formatSkillsForPrompt([skill])) - framingTokens));\n }\n for (const group of groups) {\n for (const owner of group.owners) {\n for (const skill of owner.skills) {\n const tokens = marginal.get(skill.name);\n if (tokens !== undefined) skill.promptTokens = tokens;\n }\n }\n }\n let bodyTokens = 0;\n let cachedCounts = bodyTokenCache.get(fs);\n if (!cachedCounts) {\n cachedCounts = new Map();\n bodyTokenCache.set(fs, cachedCounts);\n }\n for (const skill of loaded) {\n try {\n const info = getOrThrow(await fs.fileInfo(skill.filePath, context));\n let cached = cachedCounts.get(skill.filePath);\n if (!cached || cached.mtimeMs !== info.mtimeMs || cached.size !== info.size) {\n cached = {\n mtimeMs: info.mtimeMs,\n size: info.size,\n tokens: countTokens(getOrThrow(await fs.readTextFile(skill.filePath, context))),\n };\n cachedCounts.set(skill.filePath, cached);\n }\n bodyTokens += cached.tokens;\n } catch (error) {\n diagnostics.push(`${skill.filePath}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n return {\n groups,\n skillCount: loaded.length,\n promptTokens: prompt ? countTokens(prompt) : 0,\n bodyTokens,\n diagnostics,\n };\n}\n\n/** The skills a name resolves to, used to decide what `enter` can invoke. */\nexport function findSkill(catalog: SkillCatalog, name: string): SkillEntry | undefined {\n for (const group of catalog.groups) {\n for (const owner of group.owners) {\n const match = owner.skills.find((skill) => skill.name === name);\n if (match) return match;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAM,mBAAmB;AACzB,MAAM,sB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AAQ;EAC5C,IAAI,CAAC,UAAU,OAAO,YAAY,KAAK,WAAW,OAAO,SAAS,KAAK,MAAM;GAC3E,SAAS;IACP,SAAS,KAAK;IACd,MAAM,KAAK;IACX,QAAQ,aAAA,GAAYA,4BAAAA,WAAAA,CAAW,MAAM,GAAG,aAAa,MAAM,UAAU,OAAO,CAAC,CAAC;GAChF;GACA,aAAa,IAAI,MAAM,UAAU,MAAM;EACzC;EACA,cAAc,OAAO;CACvB,SAAS,OAAO;EACd,YAAY,KAAK,GAAG,MAAM,SAAS,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;CACjG;CAGF,OAAO;EACL;EACA,YAAY,OAAO;EACnB,cAAc,SAAS,YAAY,MAAM,IAAI;EAC7C;EACA;CACF;AACF"}
|
package/dist/catalog.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FileSystem } from "@agimon-ai/po-core/platform";
|
|
2
|
+
import { loadTokenCounter } from "@agimon-ai/po-core/tokenCount";
|
|
2
3
|
import { Skill } from "@earendil-works/pi-coding-agent";
|
|
3
4
|
import { SkillSourceContribution } from "@agimon-ai/po-core/skills";
|
|
4
5
|
//#region src/services/skillCatalog/index.d.ts
|
|
@@ -57,7 +58,8 @@ interface SkillCatalogOptions {
|
|
|
57
58
|
homeDirectory?: string;
|
|
58
59
|
environment?: Readonly<Record<string, string | undefined>>;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
/** Load the runtime's token counter on first use. */
|
|
62
|
+
export declare const counter: typeof loadTokenCounter;
|
|
61
63
|
/**
|
|
62
64
|
* Every skill this session actually loaded, grouped by where it comes from,
|
|
63
65
|
* priced in tokens.
|
package/dist/catalog.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.mts","names":[],"sources":["../src/services/skillCatalog/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"catalog.d.mts","names":[],"sources":["../src/services/skillCatalog/index.ts"],"mappings":";;;;;KAmBY;UAEK;EACf;EACA;EACA;EACA;EACA,OAAO;;EAEP;EACA;;;;;;;;EAQA;;UAGe;EACf;EACA,QAAQ;;UAGO;EACf,KAAK;EACL;EACA,QAAQ;;UAGO;EACf,QAAQ;EACR;;EAEA;;EAEA;;EAEA;;UAGe;EACf;;EAEA,IAAI;;EAEJ;EACA,2BAA2B;;EAE3B,4BAA4B;;EAE5B,sBAAsB;;EAEtB;;EAEA;EACA,cAAc,SAAS;;;qBAIZ,gBAAO;;;;;;;;;;;wBAsHE,kBAAkB,SAAS,sBAAsB,QAAQ"}
|
package/dist/catalog.mjs
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { listDomainNamesAsync, resolvePluginEntriesAsync } from "@agimon-ai/po-config/domains";
|
|
3
3
|
import { BACKGROUND_CONTEXT, getOrThrow } from "@agimon-ai/po-core/platform";
|
|
4
|
+
import { loadTokenCounter } from "@agimon-ai/po-core/tokenCount";
|
|
4
5
|
import { materializePluginEntries } from "@agimon-ai/po-domain/plugins";
|
|
5
6
|
import { formatSkillsForPrompt, loadSkillsFromDir } from "@earendil-works/pi-coding-agent";
|
|
6
7
|
//#region src/services/skillCatalog/index.ts
|
|
7
8
|
const SKILLS_DIRECTORY = "skills";
|
|
8
9
|
const SHARED_SKILLS_OWNER = ".claude/skills";
|
|
9
10
|
const bodyTokenCache = /* @__PURE__ */ new WeakMap();
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* `gpt-tokenizer` carries its whole vocabulary and costs about a tenth of a
|
|
14
|
-
* second to load. This module is reachable from the skills extension, which Pi
|
|
15
|
-
* loads at session start, so a top-level import would charge every session for
|
|
16
|
-
* a surface most of them never open.
|
|
17
|
-
*/
|
|
18
|
-
let tokenizer;
|
|
19
|
-
async function counter() {
|
|
20
|
-
tokenizer ??= import("gpt-tokenizer");
|
|
21
|
-
return (await tokenizer).countTokens;
|
|
22
|
-
}
|
|
11
|
+
/** Load the runtime's token counter on first use. */
|
|
12
|
+
const counter = loadTokenCounter;
|
|
23
13
|
/**
|
|
24
14
|
* Matches a directory against the active set.
|
|
25
15
|
*
|
package/dist/catalog.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.mjs","names":[],"sources":["../src/services/skillCatalog/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport {\n listDomainNamesAsync,\n type PluginSkillDiscovery,\n resolvePluginEntriesAsync,\n} from '@agimon-ai/po-config/domains';\nimport { BACKGROUND_CONTEXT, type FileSystem, getOrThrow } from '@agimon-ai/po-core/platform';\nimport type { SkillSourceContribution } from '@agimon-ai/po-core/skills';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { formatSkillsForPrompt, loadSkillsFromDir, type Skill } from '@earendil-works/pi-coding-agent';\n\nconst SKILLS_DIRECTORY = 'skills';\nconst SHARED_SKILLS_OWNER = '.claude/skills';\n\n// Per capability so remote filesystems never share counts with local paths.\nconst bodyTokenCache = new WeakMap<FileSystem, Map<string, { mtimeMs: number; size: number; tokens: number }>>();\n\nexport type SkillGroupKey = 'extensions' | 'help' | 'plugins' | 'default';\n\nexport interface SkillEntry {\n name: string;\n description: string;\n filePath: string;\n baseDir: string;\n group: SkillGroupKey;\n /** Package name for an extension, plugin directory name, or `.claude/skills`. */\n owner: string;\n modelInvocable: boolean;\n /**\n * What removing this skill would save from the `<available_skills>` block.\n *\n * Marginal rather than proportional: the block has fixed framing that no\n * single skill pays for, so the useful figure is what actually goes away.\n * Bodies are excluded because they load on demand and are not a resting cost.\n */\n promptTokens?: number;\n}\n\nexport interface SkillOwnerNode {\n owner: string;\n skills: SkillEntry[];\n}\n\nexport interface SkillGroup {\n key: SkillGroupKey;\n label: string;\n owners: SkillOwnerNode[];\n}\n\nexport interface SkillCatalog {\n groups: SkillGroup[];\n skillCount: number;\n /** Tokens the `<available_skills>` prompt block costs on every request. */\n promptTokens: number;\n /** Tokens every loaded SKILL.md costs in full, if all of them were read. */\n bodyTokens: number;\n /** Frontmatter and read failures, surfaced instead of thrown. */\n diagnostics: string[];\n}\n\nexport interface SkillCatalogOptions {\n repoRoot: string;\n /** The host's fs; Pi's skill walker below still reads the local disk directly. */\n fs: FileSystem;\n /** Exact files the current selection resolved to, from `HarnessState.skillDirectories`. */\n activeSkillDirectories: readonly string[];\n extensionSources: readonly SkillSourceContribution[];\n /** Accepted Pi discovery snapshot. Reused without walking or parsing bodies again. */\n discoveredSkills?: readonly Skill[];\n /** Activation-gated wrappers already accepted by the merged active-skill view. */\n helpSkills?: readonly Skill[];\n /** Bounded Help activation and collision diagnostics. */\n helpDiagnostics?: readonly string[];\n /** Home and admitted environment that locate the Po home (`PO_HOME`) and its plugin store. */\n homeDirectory?: string;\n environment?: Readonly<Record<string, string | undefined>>;\n}\n\n/**\n * The tokenizer, loaded on first use rather than at import.\n *\n * `gpt-tokenizer` carries its whole vocabulary and costs about a tenth of a\n * second to load. This module is reachable from the skills extension, which Pi\n * loads at session start, so a top-level import would charge every session for\n * a surface most of them never open.\n */\nlet tokenizer: Promise<typeof import('gpt-tokenizer')> | undefined;\n\nexport async function counter(): Promise<(text: string) => number> {\n tokenizer ??= import('gpt-tokenizer');\n return (await tokenizer).countTokens;\n}\n\n/**\n * Matches a directory against the active set.\n *\n * A domain that lists a plugin subset puts individual skill directories in the\n * set rather than the plugin's `skills` root, so containment has to be checked\n * both ways: the set may hold an ancestor of the directory, or a descendant of\n * it.\n */\nfunction createActiveMatcher(directories: readonly string[]): (directory: string) => boolean {\n const active = directories.map((directory) => path.resolve(directory));\n return (directory) => {\n const resolved = path.resolve(directory);\n return active.some(\n (entry) =>\n entry === resolved || entry.startsWith(`${resolved}${path.sep}`) || resolved.startsWith(`${entry}${path.sep}`),\n );\n };\n}\n\nfunction collect(\n directory: string,\n group: SkillGroupKey,\n owner: string,\n isActive: (directory: string) => boolean,\n loaded: Skill[],\n diagnostics: string[],\n discovery: PluginSkillDiscovery = 'recursive',\n descriptors?: readonly Skill[],\n): SkillEntry[] {\n const result =\n descriptors === undefined\n ? loadSkillsFromDir({ dir: directory, source: owner })\n : {\n skills: descriptors.filter((skill) => skill.filePath.startsWith(`${path.resolve(directory)}${path.sep}`)),\n diagnostics: [],\n };\n for (const diagnostic of result.diagnostics) {\n diagnostics.push(`${diagnostic.path ?? directory}: ${diagnostic.message}`);\n }\n // Checked per skill, not per root: a subset domain selects some of a plugin's\n // skills and leaves the rest on disk, unloaded and therefore not listed.\n const root = path.resolve(directory);\n const kept = result.skills.filter((skill) => {\n const skillDirectory = path.dirname(skill.filePath);\n if (discovery === 'direct-children' && path.dirname(skillDirectory) !== root) return false;\n return isActive(skillDirectory);\n });\n // Kept in their loaded form as well, because the prompt-block cost is measured\n // by handing them back to Pi's own formatter.\n loaded.push(...kept);\n return kept\n .map((skill) => ({\n name: skill.name,\n description: skill.description,\n filePath: skill.filePath,\n baseDir: skill.baseDir,\n group,\n owner,\n modelInvocable: !skill.disableModelInvocation,\n }))\n .sort((left, right) => left.name.localeCompare(right.name));\n}\n\nfunction sortOwners(owners: SkillOwnerNode[]): SkillOwnerNode[] {\n return owners.sort((left, right) => left.owner.localeCompare(right.owner));\n}\n\nfunction collectHelpSkills(skills: readonly Skill[], loaded: Skill[], diagnostics: string[]): SkillOwnerNode[] {\n const occupiedNames = new Set(loaded.map((skill) => skill.name));\n const owners = new Map<string, SkillEntry[]>();\n const candidates = [...skills].sort(\n (left, right) =>\n left.sourceInfo.source.localeCompare(right.sourceInfo.source) ||\n left.name.localeCompare(right.name) ||\n left.filePath.localeCompare(right.filePath),\n );\n for (const skill of candidates) {\n if (occupiedNames.has(skill.name)) {\n diagnostics.push(\n `Help ${skill.sourceInfo.source} [HELP_SKILL_COLLISION]: '${skill.name}' was ignored because a normal skill wins.`,\n );\n continue;\n }\n occupiedNames.add(skill.name);\n loaded.push(skill);\n const owner = skill.sourceInfo.source;\n const entries = owners.get(owner) ?? [];\n entries.push({\n name: skill.name,\n description: skill.description,\n filePath: skill.filePath,\n baseDir: skill.baseDir,\n group: 'help',\n owner,\n modelInvocable: !skill.disableModelInvocation,\n });\n owners.set(owner, entries);\n }\n return sortOwners(\n [...owners.entries()].map(([owner, entries]) => ({\n owner,\n skills: entries.sort((left, right) => left.name.localeCompare(right.name)),\n })),\n );\n}\n\n/**\n * Every skill this session actually loaded, grouped by where it comes from,\n * priced in tokens.\n *\n * Discovery runs over `loadSkillsFromDir` from Pi rather than the harness's own\n * walker so the listing matches what Pi would load, including its ignore-file\n * handling; the same skills are then handed to Pi's `formatSkillsForPrompt` so\n * the always-on figure is the real prompt block rather than a reconstruction of\n * it.\n */\nexport async function buildSkillCatalog(options: SkillCatalogOptions): Promise<SkillCatalog> {\n const { fs, repoRoot } = options;\n const isActive = createActiveMatcher(options.activeSkillDirectories);\n const diagnostics: string[] = [...(options.helpDiagnostics ?? [])];\n const loaded: Skill[] = [];\n\n const extensionOwners: SkillOwnerNode[] = [];\n for (const entry of options.extensionSources) {\n const skills = entry.directories.flatMap((directory) =>\n collect(\n directory,\n 'extensions',\n entry.source,\n () => true,\n loaded,\n diagnostics,\n 'recursive',\n options.discoveredSkills,\n ),\n );\n if (skills.length > 0) extensionOwners.push({ owner: entry.source, skills });\n }\n\n const context = BACKGROUND_CONTEXT;\n const pluginOwners: SkillOwnerNode[] = [];\n const { homeDirectory, environment } = options;\n const domainPlugins = await materializePluginEntries(\n await resolvePluginEntriesAsync(\n fs,\n repoRoot,\n await listDomainNamesAsync(fs, repoRoot, context, homeDirectory, environment),\n [],\n context,\n homeDirectory,\n environment,\n ),\n { homeDirectory, environment },\n );\n for (const entry of domainPlugins) {\n const directory = path.join(entry.directory, SKILLS_DIRECTORY);\n const present = await fs.exists(directory, context);\n if (!present.ok || !present.value) continue;\n const owner = path.basename(entry.directory);\n const skills = collect(\n directory,\n 'plugins',\n owner,\n isActive,\n loaded,\n diagnostics,\n entry.skillDiscovery,\n options.discoveredSkills,\n );\n if (skills.length > 0) pluginOwners.push({ owner, skills });\n }\n\n const sharedDirectory = path.join(repoRoot, '.claude', SKILLS_DIRECTORY);\n const sharedSkills = collect(\n sharedDirectory,\n 'default',\n SHARED_SKILLS_OWNER,\n isActive,\n loaded,\n diagnostics,\n 'recursive',\n options.discoveredSkills,\n );\n const defaultOwners = sharedSkills.length > 0 ? [{ owner: SHARED_SKILLS_OWNER, skills: sharedSkills }] : [];\n const helpOwners = collectHelpSkills(options.helpSkills ?? [], loaded, diagnostics);\n\n const groups: SkillGroup[] = [\n { key: 'extensions', label: 'extensions', owners: sortOwners(extensionOwners) },\n { key: 'help', label: 'Help', owners: helpOwners },\n { key: 'plugins', label: 'plugins', owners: sortOwners(pluginOwners) },\n { key: 'default', label: 'default', owners: defaultOwners },\n ];\n\n const countTokens = await counter();\n const prompt = formatSkillsForPrompt(loaded);\n const framingTokens = countTokens(formatSkillsForPrompt([]));\n const marginal = new Map<string, number>();\n for (const skill of loaded) {\n marginal.set(skill.name, Math.max(0, countTokens(formatSkillsForPrompt([skill])) - framingTokens));\n }\n for (const group of groups) {\n for (const owner of group.owners) {\n for (const skill of owner.skills) {\n const tokens = marginal.get(skill.name);\n if (tokens !== undefined) skill.promptTokens = tokens;\n }\n }\n }\n let bodyTokens = 0;\n let cachedCounts = bodyTokenCache.get(fs);\n if (!cachedCounts) {\n cachedCounts = new Map();\n bodyTokenCache.set(fs, cachedCounts);\n }\n for (const skill of loaded) {\n try {\n const info = getOrThrow(await fs.fileInfo(skill.filePath, context));\n let cached = cachedCounts.get(skill.filePath);\n if (!cached || cached.mtimeMs !== info.mtimeMs || cached.size !== info.size) {\n cached = {\n mtimeMs: info.mtimeMs,\n size: info.size,\n tokens: countTokens(getOrThrow(await fs.readTextFile(skill.filePath, context))),\n };\n cachedCounts.set(skill.filePath, cached);\n }\n bodyTokens += cached.tokens;\n } catch (error) {\n diagnostics.push(`${skill.filePath}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n return {\n groups,\n skillCount: loaded.length,\n promptTokens: prompt ? countTokens(prompt) : 0,\n bodyTokens,\n diagnostics,\n };\n}\n\n/** The skills a name resolves to, used to decide what `enter` can invoke. */\nexport function findSkill(catalog: SkillCatalog, name: string): SkillEntry | undefined {\n for (const group of catalog.groups) {\n for (const owner of group.owners) {\n const match = owner.skills.find((skill) => skill.name === name);\n if (match) return match;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;AAYA,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAG5B,MAAM,iCAAiB,IAAI,QAAoF;;;;;;;;;AAuE/G,IAAI;AAEJ,eAAsB,UAA6C;CACjE,cAAc,OAAO;CACrB,QAAQ,MAAM,UAAA,CAAW;AAC3B;;;;;;;;;AAUA,SAAS,oBAAoB,aAAgE;CAC3F,MAAM,SAAS,YAAY,KAAK,cAAc,KAAK,QAAQ,SAAS,CAAC;CACrE,QAAQ,cAAc;EACpB,MAAM,WAAW,KAAK,QAAQ,SAAS;EACvC,OAAO,OAAO,MACX,UACC,UAAU,YAAY,MAAM,WAAW,GAAG,WAAW,KAAK,KAAK,KAAK,SAAS,WAAW,GAAG,QAAQ,KAAK,KAAK,CACjH;CACF;AACF;AAEA,SAAS,QACP,WACA,OACA,OACA,UACA,QACA,aACA,YAAkC,aAClC,aACc;CACd,MAAM,SACJ,gBAAgB,KAAA,IACZ,kBAAkB;EAAE,KAAK;EAAW,QAAQ;CAAM,CAAC,IACnD;EACE,QAAQ,YAAY,QAAQ,UAAU,MAAM,SAAS,WAAW,GAAG,KAAK,QAAQ,SAAS,IAAI,KAAK,KAAK,CAAC;EACxG,aAAa,CAAC;CAChB;CACN,KAAK,MAAM,cAAc,OAAO,aAC9B,YAAY,KAAK,GAAG,WAAW,QAAQ,UAAU,IAAI,WAAW,SAAS;CAI3E,MAAM,OAAO,KAAK,QAAQ,SAAS;CACnC,MAAM,OAAO,OAAO,OAAO,QAAQ,UAAU;EAC3C,MAAM,iBAAiB,KAAK,QAAQ,MAAM,QAAQ;EAClD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AM,GAAG,SAAS,MAAM,UAAU,OAAO,CAAC;EAClE,IAAI,SAAS,aAAa,IAAI,MAAM,QAAQ;EAC5C,IAAI,CAAC,UAAU,OAAO,YAAY,KAAK,WAAW,OAAO,SAAS,KAAK,MAAM;GAC3E,SAAS;IACP,SAAS,KAAK;IACd,MAAM,KAAK;IACX,QAAQ,YAAY,WAAW,MAAM,GAAG,aAAa,MAAM,UAAU,OAAO,CAAC,CAAC;GAChF;GACA,aAAa,IAAI,MAAM,UAAU,MAAM;EACzC;EACA,cAAc,OAAO;CACvB,SAAS,OAAO;EACd,YAAY,KAAK,GAAG,MAAM,SAAS,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;CACjG;CAGF,OAAO;EACL;EACA,YAAY,OAAO;EACnB,cAAc,SAAS,YAAY,MAAM,IAAI;EAC7C;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"catalog.mjs","names":[],"sources":["../src/services/skillCatalog/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport {\n listDomainNamesAsync,\n type PluginSkillDiscovery,\n resolvePluginEntriesAsync,\n} from '@agimon-ai/po-config/domains';\nimport { BACKGROUND_CONTEXT, type FileSystem, getOrThrow } from '@agimon-ai/po-core/platform';\nimport type { SkillSourceContribution } from '@agimon-ai/po-core/skills';\nimport { loadTokenCounter } from '@agimon-ai/po-core/tokenCount';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { formatSkillsForPrompt, loadSkillsFromDir, type Skill } from '@earendil-works/pi-coding-agent';\n\nconst SKILLS_DIRECTORY = 'skills';\nconst SHARED_SKILLS_OWNER = '.claude/skills';\n\n// Per capability so remote filesystems never share counts with local paths.\nconst bodyTokenCache = new WeakMap<FileSystem, Map<string, { mtimeMs: number; size: number; tokens: number }>>();\n\nexport type SkillGroupKey = 'extensions' | 'help' | 'plugins' | 'default';\n\nexport interface SkillEntry {\n name: string;\n description: string;\n filePath: string;\n baseDir: string;\n group: SkillGroupKey;\n /** Package name for an extension, plugin directory name, or `.claude/skills`. */\n owner: string;\n modelInvocable: boolean;\n /**\n * What removing this skill would save from the `<available_skills>` block.\n *\n * Marginal rather than proportional: the block has fixed framing that no\n * single skill pays for, so the useful figure is what actually goes away.\n * Bodies are excluded because they load on demand and are not a resting cost.\n */\n promptTokens?: number;\n}\n\nexport interface SkillOwnerNode {\n owner: string;\n skills: SkillEntry[];\n}\n\nexport interface SkillGroup {\n key: SkillGroupKey;\n label: string;\n owners: SkillOwnerNode[];\n}\n\nexport interface SkillCatalog {\n groups: SkillGroup[];\n skillCount: number;\n /** Tokens the `<available_skills>` prompt block costs on every request. */\n promptTokens: number;\n /** Tokens every loaded SKILL.md costs in full, if all of them were read. */\n bodyTokens: number;\n /** Frontmatter and read failures, surfaced instead of thrown. */\n diagnostics: string[];\n}\n\nexport interface SkillCatalogOptions {\n repoRoot: string;\n /** The host's fs; Pi's skill walker below still reads the local disk directly. */\n fs: FileSystem;\n /** Exact files the current selection resolved to, from `HarnessState.skillDirectories`. */\n activeSkillDirectories: readonly string[];\n extensionSources: readonly SkillSourceContribution[];\n /** Accepted Pi discovery snapshot. Reused without walking or parsing bodies again. */\n discoveredSkills?: readonly Skill[];\n /** Activation-gated wrappers already accepted by the merged active-skill view. */\n helpSkills?: readonly Skill[];\n /** Bounded Help activation and collision diagnostics. */\n helpDiagnostics?: readonly string[];\n /** Home and admitted environment that locate the Po home (`PO_HOME`) and its plugin store. */\n homeDirectory?: string;\n environment?: Readonly<Record<string, string | undefined>>;\n}\n\n/** Load the runtime's token counter on first use. */\nexport const counter = loadTokenCounter;\n\n/**\n * Matches a directory against the active set.\n *\n * A domain that lists a plugin subset puts individual skill directories in the\n * set rather than the plugin's `skills` root, so containment has to be checked\n * both ways: the set may hold an ancestor of the directory, or a descendant of\n * it.\n */\nfunction createActiveMatcher(directories: readonly string[]): (directory: string) => boolean {\n const active = directories.map((directory) => path.resolve(directory));\n return (directory) => {\n const resolved = path.resolve(directory);\n return active.some(\n (entry) =>\n entry === resolved || entry.startsWith(`${resolved}${path.sep}`) || resolved.startsWith(`${entry}${path.sep}`),\n );\n };\n}\n\nfunction collect(\n directory: string,\n group: SkillGroupKey,\n owner: string,\n isActive: (directory: string) => boolean,\n loaded: Skill[],\n diagnostics: string[],\n discovery: PluginSkillDiscovery = 'recursive',\n descriptors?: readonly Skill[],\n): SkillEntry[] {\n const result =\n descriptors === undefined\n ? loadSkillsFromDir({ dir: directory, source: owner })\n : {\n skills: descriptors.filter((skill) => skill.filePath.startsWith(`${path.resolve(directory)}${path.sep}`)),\n diagnostics: [],\n };\n for (const diagnostic of result.diagnostics) {\n diagnostics.push(`${diagnostic.path ?? directory}: ${diagnostic.message}`);\n }\n // Checked per skill, not per root: a subset domain selects some of a plugin's\n // skills and leaves the rest on disk, unloaded and therefore not listed.\n const root = path.resolve(directory);\n const kept = result.skills.filter((skill) => {\n const skillDirectory = path.dirname(skill.filePath);\n if (discovery === 'direct-children' && path.dirname(skillDirectory) !== root) return false;\n return isActive(skillDirectory);\n });\n // Kept in their loaded form as well, because the prompt-block cost is measured\n // by handing them back to Pi's own formatter.\n loaded.push(...kept);\n return kept\n .map((skill) => ({\n name: skill.name,\n description: skill.description,\n filePath: skill.filePath,\n baseDir: skill.baseDir,\n group,\n owner,\n modelInvocable: !skill.disableModelInvocation,\n }))\n .sort((left, right) => left.name.localeCompare(right.name));\n}\n\nfunction sortOwners(owners: SkillOwnerNode[]): SkillOwnerNode[] {\n return owners.sort((left, right) => left.owner.localeCompare(right.owner));\n}\n\nfunction collectHelpSkills(skills: readonly Skill[], loaded: Skill[], diagnostics: string[]): SkillOwnerNode[] {\n const occupiedNames = new Set(loaded.map((skill) => skill.name));\n const owners = new Map<string, SkillEntry[]>();\n const candidates = [...skills].sort(\n (left, right) =>\n left.sourceInfo.source.localeCompare(right.sourceInfo.source) ||\n left.name.localeCompare(right.name) ||\n left.filePath.localeCompare(right.filePath),\n );\n for (const skill of candidates) {\n if (occupiedNames.has(skill.name)) {\n diagnostics.push(\n `Help ${skill.sourceInfo.source} [HELP_SKILL_COLLISION]: '${skill.name}' was ignored because a normal skill wins.`,\n );\n continue;\n }\n occupiedNames.add(skill.name);\n loaded.push(skill);\n const owner = skill.sourceInfo.source;\n const entries = owners.get(owner) ?? [];\n entries.push({\n name: skill.name,\n description: skill.description,\n filePath: skill.filePath,\n baseDir: skill.baseDir,\n group: 'help',\n owner,\n modelInvocable: !skill.disableModelInvocation,\n });\n owners.set(owner, entries);\n }\n return sortOwners(\n [...owners.entries()].map(([owner, entries]) => ({\n owner,\n skills: entries.sort((left, right) => left.name.localeCompare(right.name)),\n })),\n );\n}\n\n/**\n * Every skill this session actually loaded, grouped by where it comes from,\n * priced in tokens.\n *\n * Discovery runs over `loadSkillsFromDir` from Pi rather than the harness's own\n * walker so the listing matches what Pi would load, including its ignore-file\n * handling; the same skills are then handed to Pi's `formatSkillsForPrompt` so\n * the always-on figure is the real prompt block rather than a reconstruction of\n * it.\n */\nexport async function buildSkillCatalog(options: SkillCatalogOptions): Promise<SkillCatalog> {\n const { fs, repoRoot } = options;\n const isActive = createActiveMatcher(options.activeSkillDirectories);\n const diagnostics: string[] = [...(options.helpDiagnostics ?? [])];\n const loaded: Skill[] = [];\n\n const extensionOwners: SkillOwnerNode[] = [];\n for (const entry of options.extensionSources) {\n const skills = entry.directories.flatMap((directory) =>\n collect(\n directory,\n 'extensions',\n entry.source,\n () => true,\n loaded,\n diagnostics,\n 'recursive',\n options.discoveredSkills,\n ),\n );\n if (skills.length > 0) extensionOwners.push({ owner: entry.source, skills });\n }\n\n const context = BACKGROUND_CONTEXT;\n const pluginOwners: SkillOwnerNode[] = [];\n const { homeDirectory, environment } = options;\n const domainPlugins = await materializePluginEntries(\n await resolvePluginEntriesAsync(\n fs,\n repoRoot,\n await listDomainNamesAsync(fs, repoRoot, context, homeDirectory, environment),\n [],\n context,\n homeDirectory,\n environment,\n ),\n { homeDirectory, environment },\n );\n for (const entry of domainPlugins) {\n const directory = path.join(entry.directory, SKILLS_DIRECTORY);\n const present = await fs.exists(directory, context);\n if (!present.ok || !present.value) continue;\n const owner = path.basename(entry.directory);\n const skills = collect(\n directory,\n 'plugins',\n owner,\n isActive,\n loaded,\n diagnostics,\n entry.skillDiscovery,\n options.discoveredSkills,\n );\n if (skills.length > 0) pluginOwners.push({ owner, skills });\n }\n\n const sharedDirectory = path.join(repoRoot, '.claude', SKILLS_DIRECTORY);\n const sharedSkills = collect(\n sharedDirectory,\n 'default',\n SHARED_SKILLS_OWNER,\n isActive,\n loaded,\n diagnostics,\n 'recursive',\n options.discoveredSkills,\n );\n const defaultOwners = sharedSkills.length > 0 ? [{ owner: SHARED_SKILLS_OWNER, skills: sharedSkills }] : [];\n const helpOwners = collectHelpSkills(options.helpSkills ?? [], loaded, diagnostics);\n\n const groups: SkillGroup[] = [\n { key: 'extensions', label: 'extensions', owners: sortOwners(extensionOwners) },\n { key: 'help', label: 'Help', owners: helpOwners },\n { key: 'plugins', label: 'plugins', owners: sortOwners(pluginOwners) },\n { key: 'default', label: 'default', owners: defaultOwners },\n ];\n\n const countTokens = await counter();\n const prompt = formatSkillsForPrompt(loaded);\n const framingTokens = countTokens(formatSkillsForPrompt([]));\n const marginal = new Map<string, number>();\n for (const skill of loaded) {\n marginal.set(skill.name, Math.max(0, countTokens(formatSkillsForPrompt([skill])) - framingTokens));\n }\n for (const group of groups) {\n for (const owner of group.owners) {\n for (const skill of owner.skills) {\n const tokens = marginal.get(skill.name);\n if (tokens !== undefined) skill.promptTokens = tokens;\n }\n }\n }\n let bodyTokens = 0;\n let cachedCounts = bodyTokenCache.get(fs);\n if (!cachedCounts) {\n cachedCounts = new Map();\n bodyTokenCache.set(fs, cachedCounts);\n }\n for (const skill of loaded) {\n try {\n const info = getOrThrow(await fs.fileInfo(skill.filePath, context));\n let cached = cachedCounts.get(skill.filePath);\n if (!cached || cached.mtimeMs !== info.mtimeMs || cached.size !== info.size) {\n cached = {\n mtimeMs: info.mtimeMs,\n size: info.size,\n tokens: countTokens(getOrThrow(await fs.readTextFile(skill.filePath, context))),\n };\n cachedCounts.set(skill.filePath, cached);\n }\n bodyTokens += cached.tokens;\n } catch (error) {\n diagnostics.push(`${skill.filePath}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n return {\n groups,\n skillCount: loaded.length,\n promptTokens: prompt ? countTokens(prompt) : 0,\n bodyTokens,\n diagnostics,\n };\n}\n\n/** The skills a name resolves to, used to decide what `enter` can invoke. */\nexport function findSkill(catalog: SkillCatalog, name: string): SkillEntry | undefined {\n for (const group of catalog.groups) {\n for (const owner of group.owners) {\n const match = owner.skills.find((skill) => skill.name === name);\n if (match) return match;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;AAaA,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAG5B,MAAM,iCAAiB,IAAI,QAAoF;;AAgE/G,MAAa,UAAU;;;;;;;;;AAUvB,SAAS,oBAAoB,aAAgE;CAC3F,MAAM,SAAS,YAAY,KAAK,cAAc,KAAK,QAAQ,SAAS,CAAC;CACrE,QAAQ,cAAc;EACpB,MAAM,WAAW,KAAK,QAAQ,SAAS;EACvC,OAAO,OAAO,MACX,UACC,UAAU,YAAY,MAAM,WAAW,GAAG,WAAW,KAAK,KAAK,KAAK,SAAS,WAAW,GAAG,QAAQ,KAAK,KAAK,CACjH;CACF;AACF;AAEA,SAAS,QACP,WACA,OACA,OACA,UACA,QACA,aACA,YAAkC,aAClC,aACc;CACd,MAAM,SACJ,gBAAgB,KAAA,IACZ,kBAAkB;EAAE,KAAK;EAAW,QAAQ;CAAM,CAAC,IACnD;EACE,QAAQ,YAAY,QAAQ,UAAU,MAAM,SAAS,WAAW,GAAG,KAAK,QAAQ,SAAS,IAAI,KAAK,KAAK,CAAC;EACxG,aAAa,CAAC;CAChB;CACN,KAAK,MAAM,cAAc,OAAO,aAC9B,YAAY,KAAK,GAAG,WAAW,QAAQ,UAAU,IAAI,WAAW,SAAS;CAI3E,MAAM,OAAO,KAAK,Q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IAAI,IAAI;EACvB,eAAe,IAAI,IAAI,YAAY;CACrC;CACA,KAAK,MAAM,SAAS,QAClB,IAAI;EACF,MAAM,OAAO,WAAW,MAAM,GAAG,SAAS,MAAM,UAAU,OAAO,CAAC;EAClE,IAAI,SAAS,aAAa,IAAI,MAAM,QAAQ;EAC5C,IAAI,CAAC,UAAU,OAAO,YAAY,KAAK,WAAW,OAAO,SAAS,KAAK,MAAM;GAC3E,SAAS;IACP,SAAS,KAAK;IACd,MAAM,KAAK;IACX,QAAQ,YAAY,WAAW,MAAM,GAAG,aAAa,MAAM,UAAU,OAAO,CAAC,CAAC;GAChF;GACA,aAAa,IAAI,MAAM,UAAU,MAAM;EACzC;EACA,cAAc,OAAO;CACvB,SAAS,OAAO;EACd,YAAY,KAAK,GAAG,MAAM,SAAS,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;CACjG;CAGF,OAAO;EACL;EACA,YAAY,OAAO;EACnB,cAAc,SAAS,YAAY,MAAM,IAAI;EAC7C;EACA;CACF;AACF"}
|
|
@@ -20,17 +20,29 @@ var Skills_help_guides_native_default = defineFill({
|
|
|
20
20
|
questionKey: "skill.guides.whatAreSkills",
|
|
21
21
|
question: "What are skills?",
|
|
22
22
|
order: 0,
|
|
23
|
-
answerKey: "skill.
|
|
24
|
-
answer: "Skills are
|
|
25
|
-
keywords: [
|
|
23
|
+
answerKey: "skill.help.about.answer",
|
|
24
|
+
answer: "Skills are reusable instruction guides that Po loads on demand for specific tasks.\nPo discovers them from active plugins, shared .claude/skills folders, and your repository's .po/skills folder.",
|
|
25
|
+
keywords: [
|
|
26
|
+
"instructions",
|
|
27
|
+
"catalog",
|
|
28
|
+
"guides",
|
|
29
|
+
"markdown",
|
|
30
|
+
"skills"
|
|
31
|
+
]
|
|
26
32
|
}, {
|
|
27
33
|
id: "use",
|
|
28
34
|
questionKey: "skill.guides.howDoIUseASkill",
|
|
29
35
|
question: "How do I use a skill?",
|
|
30
36
|
order: 1,
|
|
31
|
-
answerKey: "skill.
|
|
32
|
-
answer: "Send /skills to
|
|
33
|
-
keywords: [
|
|
37
|
+
answerKey: "skill.help.use.answer",
|
|
38
|
+
answer: "Send /skills to see every skill available in this session.\nSend /skill:name followed by your request to run a specific skill, or simply ask Po to use the right skill for your task.",
|
|
39
|
+
keywords: [
|
|
40
|
+
"skills",
|
|
41
|
+
"invoke",
|
|
42
|
+
"slash",
|
|
43
|
+
"list",
|
|
44
|
+
"command"
|
|
45
|
+
]
|
|
34
46
|
}]
|
|
35
47
|
}
|
|
36
48
|
});
|
|
@@ -1 +1 @@
|
|
|
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","fillSkills","toolLoadSkill","toolSearchSkills"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/fill/_lib/helpGuides.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.native.ts","../../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":["/** README-grounded starter guidance shared by the web and native fills. */\nexport const helpGuides = {\n version: 1,\n category: 'customise',\n labelKey: 'skill.guides.skills',\n label: 'Skills',\n guides: [\n {\n id: 'about',\n questionKey: 'skill.guides.whatAreSkills',\n question: 'What are skills?',\n order: 0,\n answerKey:\n 'skill.guides.skillsAreInstructionsPoLoadsWhenNeededForATaskTheyComeFromPluginsSharedClaudeSkillsAndRepositoryPoSkillsFolders',\n answer:\n 'Skills are instructions Po loads when needed for a task. They come from plugins, shared .claude/skills, and repository .po/skills folders.',\n keywords: ['instructions', 'catalog'],\n },\n {\n id: 'use',\n questionKey: 'skill.guides.howDoIUseASkill',\n question: 'How do I use a skill?',\n order: 1,\n answerKey:\n 'skill.guides.sendSkillsToListDiscoveredSkillsUseSkillNameFollowedByYourRequestToInvokeASkillByItsExactNameOrAskPoToFindASuitableSkill',\n answer:\n 'Send /skills to list discovered skills. Use /skill:name followed by your request to invoke a skill by its exact name, or ask Po to find a suitable skill.',\n keywords: ['skills', 'invoke'],\n },\n ],\n} as const;\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { helpGuides } from './_lib/helpGuides';\n\nexport default defineFill({\n slot: 'help.guides',\n id: 'Skills',\n order: 270,\n data: helpGuides,\n});\n","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 fillSkills from '../src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.native';\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 if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nexport const nativePlugin = defineNativePlugin({\n id: 'skill',\n packageName: '@agimon-ai/po-skill',\n session: {\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'help.guides', id: 'skills' }, fillSkills)]; },\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['load_skill'] }, toolLoadSkill), via({ tools: ['search_skills'] }, toolSearchSkills)]; },\n },\n});\n"],"mappings":";;;;;;;;ACIA,IAAA,oCAAe,WAAW;CACxB,MAAM;CACN,IAAI;CACJ,OAAO;CACP,MAAM;EDNN,SAAS;EACT,UAAU;EACV,UAAU;EACV,OAAO;EACP,QAAQ,CACN;GACE,IAAI;GACJ,aAAa;GACb,UAAU;GACV,OAAO;GACP,WACE;GACF,QACE;GACF,UAAU,CAAC,gBAAgB,SAAS;EACtC,GACA;GACE,IAAI;GACJ,aAAa;GACb,UAAU;GACV,OAAO;GACP,WACE;GACF,QACE;GACF,UAAU,CAAC,UAAU,QAAQ;EAC/B,CACF;CCrBM;AACR,CAAC;;;;ACDD,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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A,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,YAAY7C,OAAOqC,MAAMQ,WAAWnB,IAAI;EACxCoB,UAAUT,MAAMS,SAASW;EACzBT,YAAYX,MAAMW,WAAWS;EAC7BP,OAAOb,MAAMc,OAAOxB;EAAGiB,mBAAA,CAAA,CAAA;CACzB;AACF,EAAE;;;ACnGF,IAAA,+BAAe,mBAAmB,EAAE,SAAS,wBAAwB,CAAC;;;ACGtE,MAAM,OAAU,UAAmC,UAAsB;CACvE,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,MAAM,cAAc;CACpB,OAAO;EAAE,GAAG;EAAU,GAAG;EAAa,GAAI,YAAY,cAAc,KAAA,IAAY,CAAC,IAAI,EACnF,WAAW,YAAY,UAAU,KAAK,cAAc;GAAE,UAAU;GAAY,GAAG;EAAS,EAAE,EAC5F;CAAG;AACL;AAEA,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,aAAa;CACb,SAAS;EACP,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAe,IAAI;GAAS,GAAGc,iCAAU,CAAC;EAAG;EAChH,IAAI,gBAAyD;GAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,GAAGC,yBAAa,GAAG,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,GAAGC,4BAAgB,CAAC;EAAG;CAC9K;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","fillSkills","toolLoadSkill","toolSearchSkills"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/fill/_lib/helpGuides.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.native.ts","../../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":["/** Starter guidance shared by the web and native fills. */\nexport const helpGuides = {\n version: 1,\n category: 'customise',\n labelKey: 'skill.guides.skills',\n label: 'Skills',\n guides: [\n {\n id: 'about',\n questionKey: 'skill.guides.whatAreSkills',\n question: 'What are skills?',\n order: 0,\n answerKey: 'skill.help.about.answer',\n answer:\n \"Skills are reusable instruction guides that Po loads on demand for specific tasks.\\nPo discovers them from active plugins, shared .claude/skills folders, and your repository's .po/skills folder.\",\n keywords: ['instructions', 'catalog', 'guides', 'markdown', 'skills'],\n },\n {\n id: 'use',\n questionKey: 'skill.guides.howDoIUseASkill',\n question: 'How do I use a skill?',\n order: 1,\n answerKey: 'skill.help.use.answer',\n answer:\n 'Send /skills to see every skill available in this session.\\nSend /skill:name followed by your request to run a specific skill, or simply ask Po to use the right skill for your task.',\n keywords: ['skills', 'invoke', 'slash', 'list', 'command'],\n },\n ],\n} as const;\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { helpGuides } from './_lib/helpGuides';\n\nexport default defineFill({\n slot: 'help.guides',\n id: 'Skills',\n order: 270,\n data: helpGuides,\n});\n","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 fillSkills from '../src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.native';\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 if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nexport const nativePlugin = defineNativePlugin({\n id: 'skill',\n packageName: '@agimon-ai/po-skill',\n session: {\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'help.guides', id: 'skills' }, fillSkills)]; },\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['load_skill'] }, toolLoadSkill), via({ tools: ['search_skills'] }, toolSearchSkills)]; },\n },\n});\n"],"mappings":";;;;;;;;ACIA,IAAA,oCAAe,WAAW;CACxB,MAAM;CACN,IAAI;CACJ,OAAO;CACP,MAAM;EDNN,SAAS;EACT,UAAU;EACV,UAAU;EACV,OAAO;E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IAAI,EACnF,WAAW,YAAY,UAAU,KAAK,cAAc;GAAE,UAAU;GAAY,GAAG;EAAS,EAAE,EAC5F;CAAG;AACL;AAEA,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,aAAa;CACb,SAAS;EACP,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAe,IAAI;GAAS,GAAGc,iCAAU,CAAC;EAAG;EAChH,IAAI,gBAAyD;GAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,GAAGC,yBAAa,GAAG,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,GAAGC,4BAAgB,CAAC;EAAG;CAC9K;AACF,CAAC"}
|
package/dist/extensions/web.mjs
CHANGED
|
@@ -18,17 +18,29 @@ var Skills_help_guides_web_default = defineFill({
|
|
|
18
18
|
questionKey: "skill.guides.whatAreSkills",
|
|
19
19
|
question: "What are skills?",
|
|
20
20
|
order: 0,
|
|
21
|
-
answerKey: "skill.
|
|
22
|
-
answer: "Skills are
|
|
23
|
-
keywords: [
|
|
21
|
+
answerKey: "skill.help.about.answer",
|
|
22
|
+
answer: "Skills are reusable instruction guides that Po loads on demand for specific tasks.\nPo discovers them from active plugins, shared .claude/skills folders, and your repository's .po/skills folder.",
|
|
23
|
+
keywords: [
|
|
24
|
+
"instructions",
|
|
25
|
+
"catalog",
|
|
26
|
+
"guides",
|
|
27
|
+
"markdown",
|
|
28
|
+
"skills"
|
|
29
|
+
]
|
|
24
30
|
}, {
|
|
25
31
|
id: "use",
|
|
26
32
|
questionKey: "skill.guides.howDoIUseASkill",
|
|
27
33
|
question: "How do I use a skill?",
|
|
28
34
|
order: 1,
|
|
29
|
-
answerKey: "skill.
|
|
30
|
-
answer: "Send /skills to
|
|
31
|
-
keywords: [
|
|
35
|
+
answerKey: "skill.help.use.answer",
|
|
36
|
+
answer: "Send /skills to see every skill available in this session.\nSend /skill:name followed by your request to run a specific skill, or simply ask Po to use the right skill for your task.",
|
|
37
|
+
keywords: [
|
|
38
|
+
"skills",
|
|
39
|
+
"invoke",
|
|
40
|
+
"slash",
|
|
41
|
+
"list",
|
|
42
|
+
"command"
|
|
43
|
+
]
|
|
32
44
|
}]
|
|
33
45
|
}
|
|
34
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.mjs","names":["fillSkills","toolLoadSkill","toolSearchSkills"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/fill/_lib/helpGuides.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.web.ts","../../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":["/** README-grounded starter guidance shared by the web and native fills. */\nexport const helpGuides = {\n version: 1,\n category: 'customise',\n labelKey: 'skill.guides.skills',\n label: 'Skills',\n guides: [\n {\n id: 'about',\n questionKey: 'skill.guides.whatAreSkills',\n question: 'What are skills?',\n order: 0,\n answerKey:\n 'skill.guides.skillsAreInstructionsPoLoadsWhenNeededForATaskTheyComeFromPluginsSharedClaudeSkillsAndRepositoryPoSkillsFolders',\n answer:\n 'Skills are instructions Po loads when needed for a task. They come from plugins, shared .claude/skills, and repository .po/skills folders.',\n keywords: ['instructions', 'catalog'],\n },\n {\n id: 'use',\n questionKey: 'skill.guides.howDoIUseASkill',\n question: 'How do I use a skill?',\n order: 1,\n answerKey:\n 'skill.guides.sendSkillsToListDiscoveredSkillsUseSkillNameFollowedByYourRequestToInvokeASkillByItsExactNameOrAskPoToFindASuitableSkill',\n answer:\n 'Send /skills to list discovered skills. Use /skill:name followed by your request to invoke a skill by its exact name, or ask Po to find a suitable skill.',\n keywords: ['skills', 'invoke'],\n },\n ],\n} as const;\n","import { defineFill } from '@agimon-ai/po-core/web';\n\nimport { helpGuides } from './_lib/helpGuides';\n\nexport default defineFill({\n slot: 'help.guides',\n id: 'Skills',\n order: 270,\n data: helpGuides,\n});\n","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 fillSkills from '../src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.web';\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 if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nexport const webPlugin = defineWebPlugin({\n id: 'skill',\n packageName: '@agimon-ai/po-skill',\n session: {\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'help.guides', id: 'skills' }, fillSkills)]; },\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['load_skill'] }, toolLoadSkill), via({ tools: ['search_skills'] }, toolSearchSkills)]; },\n },\n});\n"],"mappings":";;;;;;ACIA,IAAA,iCAAe,WAAW;CACxB,MAAM;CACN,IAAI;CACJ,OAAO;CACP,MAAM;EDNN,SAAS;EACT,UAAU;EACV,UAAU;EACV,OAAO;EACP,QAAQ,CACN;GACE,IAAI;GACJ,aAAa;GACb,UAAU;GACV,OAAO;GACP,WACE;GACF,QACE;GACF,UAAU,CAAC,gBAAgB,SAAS;EACtC,GACA;GACE,IAAI;GACJ,aAAa;GACb,UAAU;GACV,OAAO;GACP,WACE;GACF,QACE;GACF,UAAU,CAAC,UAAU,QAAQ;EAC/B,CACF;CCrBM;AACR,CAAC;;;;ACDD,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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AG;AACL;AAEA,MAAa,YAAY,gBAAgB;CACvC,IAAI;CACJ,aAAa;CACb,SAAS;EACP,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAe,IAAI;GAAS,GAAGA,8BAAU,CAAC;EAAG;EAChH,IAAI,gBAAyD;GAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,GAAGC,sBAAa,GAAG,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,GAAGC,yBAAgB,CAAC;EAAG;CAC9K;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"web.mjs","names":["fillSkills","toolLoadSkill","toolSearchSkills"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/fill/_lib/helpGuides.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.web.ts","../../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":["/** Starter guidance shared by the web and native fills. */\nexport const helpGuides = {\n version: 1,\n category: 'customise',\n labelKey: 'skill.guides.skills',\n label: 'Skills',\n guides: [\n {\n id: 'about',\n questionKey: 'skill.guides.whatAreSkills',\n question: 'What are skills?',\n order: 0,\n answerKey: 'skill.help.about.answer',\n answer:\n \"Skills are reusable instruction guides that Po loads on demand for specific tasks.\\nPo discovers them from active plugins, shared .claude/skills folders, and your repository's .po/skills folder.\",\n keywords: ['instructions', 'catalog', 'guides', 'markdown', 'skills'],\n },\n {\n id: 'use',\n questionKey: 'skill.guides.howDoIUseASkill',\n question: 'How do I use a skill?',\n order: 1,\n answerKey: 'skill.help.use.answer',\n answer:\n 'Send /skills to see every skill available in this session.\\nSend /skill:name followed by your request to run a specific skill, or simply ask Po to use the right skill for your task.',\n keywords: ['skills', 'invoke', 'slash', 'list', 'command'],\n },\n ],\n} as const;\n","import { defineFill } from '@agimon-ai/po-core/web';\n\nimport { helpGuides } from './_lib/helpGuides';\n\nexport default defineFill({\n slot: 'help.guides',\n id: 'Skills',\n order: 270,\n data: helpGuides,\n});\n","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 fillSkills from '../src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.web';\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 if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nexport const webPlugin = defineWebPlugin({\n id: 'skill',\n packageName: '@agimon-ai/po-skill',\n session: {\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'help.guides', id: 'skills' }, fillSkills)]; },\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['load_skill'] }, toolLoadSkill), via({ tools: ['search_skills'] }, toolSearchSkills)]; },\n },\n});\n"],"mappings":";;;;;;ACIA,IAAA,iCAAe,WAAW;CACxB,MAAM;CACN,IAAI;CACJ,OAAO;CACP,MAAM;EDNN,SAAS;EACT,UAAU;EACV,UAAU;EACV,OAAO;EACP,QAAQ,CACN;GACE,IAAI;GACJ,aAAa;GACb,UAAU;GACV,OAAO;GACP,WAAW;GACX,QACE;GACF,UAAU;IAAC;IAAgB;IAAW;IAAU;IAAY;GAAQ;EACtE,GACA;GACE,IAAI;GACJ,aAAa;GACb,UAAU;GACV,OAAO;GACP,WAAW;GACX,QACE;GACF,UAAU;IAAC;IAAU;IAAU;IAAS;IAAQ;GAAS;EAC3D,CACF;CCnBM;AACR,CAAC;;;;ACDD,SAAgB,WAAW,QAA+B,QAAwB;CAChF,IAAI,WAAW,MAAM,OAAO;CAC5B,OAAO,OAAO,QACX,SAAS,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AAc,KAAA,IAAY,CAAC,IAAI,EACnF,WAAW,YAAY,UAAU,KAAK,cAAc;GAAE,UAAU;GAAY,GAAG;EAAS,EAAE,EAC5F;CAAG;AACL;AAEA,MAAa,YAAY,gBAAgB;CACvC,IAAI;CACJ,aAAa;CACb,SAAS;EACP,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAe,IAAI;GAAS,GAAGA,8BAAU,CAAC;EAAG;EAChH,IAAI,gBAAyD;GAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,GAAGC,sBAAa,GAAG,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,GAAGC,yBAAgB,CAAC;EAAG;CAC9K;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":1,"platformRequirements":{},"sourceFiles":["LICENSE","README.md","generated/mcp-ui.ts","generated/mcp.ts","generated/native.ts","generated/server.ts","generated/web.ts","llms.txt","locales/vi.json","locales/zh-CN.json","package.json","src/constants/skillInventory.ts","src/exports/apiContracts.ts","src/exports/catalog.ts","src/exports/index.ts","src/extensions/workspaces/sessions/(backend)/_lib/skillCommands.ts","src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts","src/extensions/workspaces/sessions/(backend)/command/skills.server.ts","src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server.ts","src/extensions/workspaces/sessions/(backend)/resource/skills.server.ts","src/extensions/workspaces/sessions/(backend)/root.server.ts","src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp.ts","src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.ts","src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.native.ts","src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.web.ts","src/extensions/workspaces/sessions/(frontend)/fill/_lib/helpGuides.ts","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_lib/skillToolView.ts","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.mcp.tsx","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.web.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.mcp.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.web.tsx","src/prompts/codemode-how-to-skills/SKILL.md","src/prompts/help-how-to-author-skill/SKILL.md","src/prompts/help-how-to-skill/SKILL.md","src/schemas/apiContracts.ts","src/schemas/mcpSkillTools.ts","src/services/deferredSkills/index.edge.ts","src/services/deferredSkills/index.ts","src/services/mcpSkillTools/index.ts","src/services/mcpSkills/index.ts","src/services/serverInventory/catalog.ts","src/services/serverInventory/grouping.ts","src/services/serverInventory/index.edge.ts","src/services/serverInventory/index.ts","src/services/skillCatalog/index.ts","src/services/skillNamespace/index.ts","src/types/skills.ts","tsdown.config.ts"],"sourceRevision":"
|
|
1
|
+
{"version":1,"platformRequirements":{},"sourceFiles":["LICENSE","README.md","generated/mcp-ui.ts","generated/mcp.ts","generated/native.ts","generated/server.ts","generated/web.ts","llms.txt","locales/vi.json","locales/zh-CN.json","package.json","src/constants/skillInventory.ts","src/exports/apiContracts.ts","src/exports/catalog.ts","src/exports/index.ts","src/extensions/workspaces/sessions/(backend)/_lib/skillCommands.ts","src/extensions/workspaces/sessions/(backend)/_lib/skillServer.ts","src/extensions/workspaces/sessions/(backend)/command/skills.server.ts","src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-skills.server.ts","src/extensions/workspaces/sessions/(backend)/resource/skills.server.ts","src/extensions/workspaces/sessions/(backend)/root.server.ts","src/extensions/workspaces/sessions/(backend)/skill/discovered.mcp.ts","src/extensions/workspaces/sessions/(backend)/skill/help-how-to-author-skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/skill/help-how-to-skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/tool/load_skill.mcp.ts","src/extensions/workspaces/sessions/(backend)/tool/search_skills.mcp.ts","src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.native.ts","src/extensions/workspaces/sessions/(frontend)/fill/Skills.help.guides.web.ts","src/extensions/workspaces/sessions/(frontend)/fill/_lib/helpGuides.ts","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/LoadSkillToolMessage.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.stories.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_components/SearchSkillsToolMessage.tsx","src/extensions/workspaces/sessions/(frontend)/tool/_lib/skillToolView.ts","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.mcp.tsx","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/load_skill.web.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.mcp.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.native.tsx","src/extensions/workspaces/sessions/(frontend)/tool/search_skills.web.tsx","src/prompts/codemode-how-to-skills/SKILL.md","src/prompts/help-how-to-author-skill/SKILL.md","src/prompts/help-how-to-skill/SKILL.md","src/schemas/apiContracts.ts","src/schemas/mcpSkillTools.ts","src/services/deferredSkills/index.edge.ts","src/services/deferredSkills/index.ts","src/services/mcpSkillTools/index.ts","src/services/mcpSkills/index.ts","src/services/serverInventory/catalog.ts","src/services/serverInventory/grouping.ts","src/services/serverInventory/index.edge.ts","src/services/serverInventory/index.ts","src/services/skillCatalog/index.ts","src/services/skillNamespace/index.ts","src/types/skills.ts","tsdown.config.ts"],"sourceRevision":"1c73d2eda329b571fb02ea42696a7dd0","manifestRevision":"451f3d5f174f82996ad00ba39dd24cb1","outputFiles":["LICENSE","README.md","dist/apiContracts.cjs","dist/apiContracts.mjs","dist/catalog.cjs","dist/catalog.mjs","dist/extensions/mcp-ui.mjs","dist/extensions/mcp.cjs","dist/extensions/mcp.mjs","dist/extensions/native.mjs","dist/extensions/server.cjs","dist/extensions/server.mjs","dist/extensions/web.mjs","dist/index.cjs","dist/index.mjs","dist/rolldown-runtime-VH7oDXx4.cjs","dist/skills-Ccvg1Hcz.mjs","dist/skills-ComtgYb1.cjs","llms.txt","locales/vi.json","locales/zh-CN.json","src/prompts/codemode-how-to-skills/SKILL.md","src/prompts/help-how-to-author-skill/SKILL.md","src/prompts/help-how-to-skill/SKILL.md"],"outputRevision":"54a4040662a41fafc2febe5bcbe8e2f3"}
|
package/llms.txt
CHANGED
package/locales/vi.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"skill.guides.howDoIUseASkill": "Làm sao để dùng kỹ năng?",
|
|
3
|
-
"skill.guides.sendSkillsToListDiscoveredSkillsUseSkillNameFollowedByYourRequestToInvokeASkillByItsExactNameOrAskPoToFindASuitableSkill": "Gửi /skills để liệt kê các kỹ năng đã tìm thấy. Dùng /skill:name kèm yêu cầu để gọi kỹ năng theo đúng tên, hoặc nhờ Po tìm kỹ năng phù hợp.",
|
|
4
3
|
"skill.guides.skills": "Kỹ năng",
|
|
5
|
-
"skill.guides.skillsAreInstructionsPoLoadsWhenNeededForATaskTheyComeFromPluginsSharedClaudeSkillsAndRepositoryPoSkillsFolders": "Kỹ năng là hướng dẫn Po tải khi cần cho một tác vụ. Chúng đến từ plugin, thư mục dùng chung .claude/skills và thư mục .po/skills trong kho mã.",
|
|
6
4
|
"skill.guides.whatAreSkills": "Kỹ năng là gì?",
|
|
5
|
+
"skill.help.about.answer": "Kỹ năng là các hướng dẫn dùng lại được mà Po nạp theo nhu cầu cho từng tác vụ cụ thể.\nPo tự tìm kỹ năng từ plugin đang bật, thư mục dùng chung .claude/skills và thư mục .po/skills của kho mã nguồn.",
|
|
6
|
+
"skill.help.use.answer": "Gửi /skills để xem tất cả kỹ năng khả dụng trong phiên này.\nGửi /skill:name kèm yêu cầu để gọi một kỹ năng cụ thể, hoặc đơn giản nhờ Po chọn kỹ năng phù hợp cho công việc của bạn.",
|
|
7
7
|
"skill.mcp.loadSkill": "Tải kỹ năng",
|
|
8
8
|
"skill.mcp.query": "Truy vấn",
|
|
9
9
|
"skill.mcp.searchSkills": "Tìm kỹ năng",
|
package/locales/zh-CN.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"skill.guides.howDoIUseASkill": "如何使用技能?",
|
|
3
|
-
"skill.guides.sendSkillsToListDiscoveredSkillsUseSkillNameFollowedByYourRequestToInvokeASkillByItsExactNameOrAskPoToFindASuitableSkill": "发送 /skills 列出已发现的技能。使用 /skill:name 并附上请求,按准确名称调用技能,或请 Po 寻找合适的技能。",
|
|
4
3
|
"skill.guides.skills": "技能",
|
|
5
|
-
"skill.guides.skillsAreInstructionsPoLoadsWhenNeededForATaskTheyComeFromPluginsSharedClaudeSkillsAndRepositoryPoSkillsFolders": "技能是 Po 在任务需要时加载的指令。它们来自插件、共享的 .claude/skills 和仓库的 .po/skills 文件夹。",
|
|
6
4
|
"skill.guides.whatAreSkills": "什么是技能?",
|
|
5
|
+
"skill.help.about.answer": "技能是 Po 在处理特定任务时按需加载的可复用操作指南。\nPo 会自动从已启用的插件、共享的 .claude/skills 目录以及仓库的 .po/skills 目录中发现技能。",
|
|
6
|
+
"skill.help.use.answer": "发送 /skills 查看当前会话可用的所有技能。\n发送 /skill:name 加上你的需求即可调用指定技能,或者直接让 Po 为你的任务选用合适的技能。",
|
|
7
7
|
"skill.mcp.loadSkill": "加载技能",
|
|
8
8
|
"skill.mcp.query": "查询",
|
|
9
9
|
"skill.mcp.searchSkills": "搜索技能",
|
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.216",
|
|
4
4
|
"description": "Session skill catalogue, deferred skill discovery, and the skill browser for Po.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-skills",
|
|
@@ -74,18 +74,18 @@
|
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@agimon-ai/po-config": "0.0.0-alpha.
|
|
78
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
79
|
-
"@agimon-ai/po-domain": "0.0.0-alpha.
|
|
80
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
77
|
+
"@agimon-ai/po-config": "0.0.0-alpha.216",
|
|
78
|
+
"@agimon-ai/po-core": "0.0.0-alpha.216",
|
|
79
|
+
"@agimon-ai/po-domain": "0.0.0-alpha.216",
|
|
80
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.216",
|
|
81
81
|
"@deepseek-ai/cordis": "4.0.5",
|
|
82
82
|
"gpt-tokenizer": "4.1.0",
|
|
83
83
|
"typebox": "1.4.2"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
87
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
88
|
-
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.
|
|
86
|
+
"@agimon-ai/po-build": "0.0.0-alpha.216",
|
|
87
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.216",
|
|
88
|
+
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.216",
|
|
89
89
|
"@deepseek-ai/cordis": "4.0.5",
|
|
90
90
|
"@earendil-works/pi-coding-agent": "1.6.1",
|
|
91
91
|
"@types/node": "26.6.5",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"vitest": "5.0.4"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
104
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.216",
|
|
105
105
|
"@earendil-works/pi-coding-agent": "1.6.1",
|
|
106
106
|
"react-native": "0.88.1",
|
|
107
107
|
"react-native-unistyles": "^3.5.3"
|
|
@@ -33,20 +33,37 @@ To relate a skill to another, use one of three explicit forms. Prose and backtic
|
|
|
33
33
|
- A literal Markdown link to another skill's file, such as `[lint](../codemode-how-to-lint/SKILL.md)`, recorded as `references`.
|
|
34
34
|
- `@skill:<name>` in the body, for example `@skill:codemode-how-to-lint`, when the skill cannot know where the other is installed. Also recorded as `references`.
|
|
35
35
|
|
|
36
|
-
The same rules apply to repository, plugin and Po package skills: Po parses the text it already read for the session. Relations declared in code come first and the file adds to them; a `requires` hides a link to the same skill. Brain shows every relation and reports malformed frontmatter or a target this session does not have. A relation never loads the target or grants access: the agent loads it with `load_skill` only when it needs it.
|
|
36
|
+
The same rules apply to repository, plugin, and Po package skills: Po parses the text it already read for the session. Relations declared in code come first and the file adds to them; a `requires` hides a link to the same skill. Brain shows every relation and reports malformed frontmatter or a target this session does not have. A relation never loads the target or grants access: the agent loads it with `load_skill` (or `skills.load` in code mode) only when it needs it.
|
|
37
37
|
|
|
38
38
|
## Choose the distribution path
|
|
39
39
|
|
|
40
|
-
- For discovered plugin skills, ship `skills/<name>/SKILL.md` and configure the plugin and optional skill subset in `domains.yaml`. po-skill registers each loaded skill once with an any-of gate for its admitting domains. Shared `.claude/skills` follow domains that keep shared skills; repository `.po/skills` are unconditional. Do not register discovered plugin skills again from the package.
|
|
41
|
-
- For guidance that should appear only while Po Help is active, put it at `src/prompts/<name>/SKILL.md`, publish `src/prompts`, link
|
|
40
|
+
- For discovered plugin skills, ship `skills/<name>/SKILL.md` and configure the plugin and optional skill subset in `domains.yaml`. `po-skill` registers each loaded skill once with an any-of gate for its admitting domains. Shared `.claude/skills` follow domains that keep shared skills; repository `.po/skills` are unconditional. Do not register discovered plugin skills again from the package.
|
|
41
|
+
- For guidance that should appear only while Po Help is active, put it at `src/prompts/<name>/SKILL.md`, publish `src/prompts` and `llms.txt` in `package.json`, link every prompt from the package's H1-led `llms.txt`, and register it through a named server resource route.
|
|
42
42
|
- For repository content selected by domains, place the skill in the plugin or shared skill source configured by `domains.yaml`; do not hard-code that directory into the Skill package.
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
## Contribute a Help skill or tool from a package
|
|
45
45
|
|
|
46
|
-
On the server host, contribute
|
|
46
|
+
On the server host, contribute a Help-gated skill through a named `src/extensions/workspaces/sessions/(backend)/resource/<name>.server.ts` route using `defineResource`, `PO_HELP_WHEN`, and `packageResourcePath`:
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
```ts
|
|
49
|
+
import { defineResource } from '@agimon-ai/po-core/extensionFile';
|
|
50
|
+
import { PO_HELP_WHEN } from '@agimon-ai/po-core/help';
|
|
51
|
+
import { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';
|
|
52
|
+
|
|
53
|
+
export default defineResource({
|
|
54
|
+
name: 'help-how-to-example',
|
|
55
|
+
description: 'Configure and troubleshoot the Example package in Help mode.',
|
|
56
|
+
when: PO_HELP_WHEN,
|
|
57
|
+
kind: 'skill' as const,
|
|
58
|
+
path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-example/SKILL.md'),
|
|
59
|
+
read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-example/SKILL.md'),
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Include a clear `description` and an absolute `path` resolved with `packageResourcePath(import.meta.url, ...)`; a `read` callback alone does not make the skill discoverable in the agent prompt. Keep every link in `llms.txt` inside the published package. Keep ordinary runtime and code-mode skills under their existing conditions (or pinned without `PO_HELP_WHEN` when always active).
|
|
64
|
+
|
|
65
|
+
Package-owned Help tools use ordinary named `tool/*.server.ts` routes with `when: PO_HELP_WHEN` and runtime active checks, not documentation descriptors. The Distribution package's `diagnose_setup` route and Help's `help_status` tool show the complete server pattern. Bound diagnostics to the current session, omit secrets, and use existing approval mechanisms for repairs.
|
|
49
66
|
|
|
50
67
|
## Verification
|
|
51
68
|
|
|
52
|
-
Validate the skill frontmatter, ensure every relative reference resolves, and test the packed package rather than relying on checkout-only files. For discovered skills, cover domain swaps, shared-skill opt-outs, and duplicate source admission.
|
|
69
|
+
Validate the skill frontmatter, ensure every relative reference resolves, and test the packed package rather than relying on checkout-only files. For discovered skills, cover domain swaps, shared-skill opt-outs, and duplicate source admission. Test the actual prompt and tool surface before activation, while Help is active, and after deactivation; stale calls must be rejected without removing ordinary capabilities. Use `/skills` in an interactive session to confirm the expected owner and invocation name. Do not add remote MCP exposure merely because a local Help contribution exists.
|
|
@@ -5,11 +5,11 @@ description: Use Po's skill catalog and deferred discovery. Use when browsing av
|
|
|
5
5
|
|
|
6
6
|
# Use Po skills
|
|
7
7
|
|
|
8
|
-
Open the skill
|
|
8
|
+
Open the skill catalog with `/skills`. The catalog groups normal session skills, package Help skills, plugin skills, and extension-contributed directories by owner.
|
|
9
9
|
|
|
10
10
|
For agent tool calls, use `load_skill` with the exact name. With at most 20 active skills, its description lists the names and descriptions. Above 20, use `search_skills` to find skills by name or description, then load the chosen name. Search returns metadata only, not skill instructions or paths. Where code mode binds live objects, both tools are replaced by `skills.search` and `skills.load` (see `codemode-how-to-skills`), and the prompt lists only pinned guides.
|
|
11
11
|
|
|
12
|
-
Invoke a skill with `/skill:<name>`. Po expands deferred skills
|
|
12
|
+
Invoke a skill with `/skill:<name>`. Po expands deferred skills when the command runs, so a skill can be invoked even when its full body was not placed in the initial prompt. Help skills appear only while Help mode is active.
|
|
13
13
|
|
|
14
14
|
When a skill is missing:
|
|
15
15
|
|