@agimon-ai/doompi-skill 0.0.1-alpha.26 → 0.0.1-alpha.28
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/adapters/skillCatalog.cjs +1 -1
- package/dist/adapters/skillCatalog.cjs.map +1 -1
- package/dist/adapters/skillCatalog.d.cts +8 -0
- package/dist/adapters/skillCatalog.d.cts.map +1 -1
- package/dist/adapters/skillCatalog.d.mts +8 -0
- package/dist/adapters/skillCatalog.d.mts.map +1 -1
- package/dist/adapters/skillCatalog.mjs +1 -1
- package/dist/adapters/skillCatalog.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("node:fs");t=e.__toESM(t,1);let n=require("node:path");n=e.__toESM(n,1);let r=require("@agimon-ai/doompi-config/domains"),i=require("@earendil-works/pi-coding-agent"),a=require("@agimon-ai/doompi-domain/plugins");const o=`skills`,s=`.claude/skills`;let c;async function l(){return c??=import(`gpt-tokenizer`),(await c).countTokens}function u(e){let t=e.map(e=>n.default.resolve(e));return e=>{let r=n.default.resolve(e);return t.some(e=>e===r||e.startsWith(`${r}${n.default.sep}`)||r.startsWith(`${e}${n.default.sep}`))}}function d(e,t,r,a,o,s,c=`recursive`){let l=(0,i.loadSkillsFromDir)({dir:e,source:r});for(let t of l.diagnostics)s.push(`${t.path??e}: ${t.message}`);let u=n.default.resolve(e),d=l.skills.filter(e=>{let t=n.default.dirname(e.filePath);return c===`direct-children`&&n.default.dirname(t)!==u?!1:a(t)});return o.push(...d),d.map(e=>({name:e.name,description:e.description,filePath:e.filePath,baseDir:e.baseDir,group:t,owner:r,modelInvocable:!e.disableModelInvocation})).sort((e,t)=>e.name.localeCompare(t.name))}function f(e){return e.sort((e,t)=>e.owner.localeCompare(t.owner))}function p(e,t,n){let r=new Set(t.map(e=>e.name)),i=new Map,a=[...e].sort((e,t)=>e.sourceInfo.source.localeCompare(t.sourceInfo.source)||e.name.localeCompare(t.name)||e.filePath.localeCompare(t.filePath));for(let e of a){if(r.has(e.name)){n.push(`Help ${e.sourceInfo.source} [HELP_SKILL_COLLISION]: '${e.name}' was ignored because a normal skill wins.`);continue}r.add(e.name),t.push(e);let a=e.sourceInfo.source,o=i.get(a)??[];o.push({name:e.name,description:e.description,filePath:e.filePath,baseDir:e.baseDir,group:`help`,owner:a,modelInvocable:!e.disableModelInvocation}),i.set(a,o)}return f([...i.entries()].map(([e,t])=>({owner:e,skills:t.sort((e,t)=>e.name.localeCompare(t.name))})))}async function m(e){let{repoRoot:c}=e,m=u(e.activeSkillDirectories),h=[...e.helpDiagnostics??[]],g=[],_=[];for(let t of e.extensionSources){let e=t.directories.flatMap(e=>d(e,`extensions`,t.source,()=>!0,g,h));e.length>0&&_.push({owner:t.source,skills:e})}let v=[],y=await(0,a.materializePluginEntries)((0,r.resolvePluginEntries)(c,(0,r.listDomainNames)(c),[]));for(let e of y){let r=n.default.join(e.directory,o);if(!t.default.existsSync(r))continue;let i=n.default.basename(e.directory),a=d(r,`plugins`,i,m,g,h,e.skillDiscovery);a.length>0&&v.push({owner:i,skills:a})}let b=d(n.default.join(c,`.claude`,o),`default`,s,m,g,h),x=b.length>0?[{owner:s,skills:b}]:[],S=p(e.helpSkills??[],g,h),C=[{key:`extensions`,label:`extensions`,owners:f(_)},{key:`help`,label:`Help`,owners:S},{key:`plugins`,label:`plugins`,owners:f(v)},{key:`default`,label:`default`,owners:x}],w=await l(),T=(0,i.formatSkillsForPrompt)(g),E=0;for(let e of g)try{
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("node:fs");t=e.__toESM(t,1);let n=require("node:path");n=e.__toESM(n,1);let r=require("@agimon-ai/doompi-config/domains"),i=require("@earendil-works/pi-coding-agent"),a=require("@agimon-ai/doompi-domain/plugins");const o=`skills`,s=`.claude/skills`;let c;async function l(){return c??=import(`gpt-tokenizer`),(await c).countTokens}function u(e){let t=e.map(e=>n.default.resolve(e));return e=>{let r=n.default.resolve(e);return t.some(e=>e===r||e.startsWith(`${r}${n.default.sep}`)||r.startsWith(`${e}${n.default.sep}`))}}function d(e,t,r,a,o,s,c=`recursive`){let l=(0,i.loadSkillsFromDir)({dir:e,source:r});for(let t of l.diagnostics)s.push(`${t.path??e}: ${t.message}`);let u=n.default.resolve(e),d=l.skills.filter(e=>{let t=n.default.dirname(e.filePath);return c===`direct-children`&&n.default.dirname(t)!==u?!1:a(t)});return o.push(...d),d.map(e=>({name:e.name,description:e.description,filePath:e.filePath,baseDir:e.baseDir,group:t,owner:r,modelInvocable:!e.disableModelInvocation})).sort((e,t)=>e.name.localeCompare(t.name))}function f(e){return e.sort((e,t)=>e.owner.localeCompare(t.owner))}function p(e,t,n){let r=new Set(t.map(e=>e.name)),i=new Map,a=[...e].sort((e,t)=>e.sourceInfo.source.localeCompare(t.sourceInfo.source)||e.name.localeCompare(t.name)||e.filePath.localeCompare(t.filePath));for(let e of a){if(r.has(e.name)){n.push(`Help ${e.sourceInfo.source} [HELP_SKILL_COLLISION]: '${e.name}' was ignored because a normal skill wins.`);continue}r.add(e.name),t.push(e);let a=e.sourceInfo.source,o=i.get(a)??[];o.push({name:e.name,description:e.description,filePath:e.filePath,baseDir:e.baseDir,group:`help`,owner:a,modelInvocable:!e.disableModelInvocation}),i.set(a,o)}return f([...i.entries()].map(([e,t])=>({owner:e,skills:t.sort((e,t)=>e.name.localeCompare(t.name))})))}async function m(e){let{repoRoot:c}=e,m=u(e.activeSkillDirectories),h=[...e.helpDiagnostics??[]],g=[],_=[];for(let t of e.extensionSources){let e=t.directories.flatMap(e=>d(e,`extensions`,t.source,()=>!0,g,h));e.length>0&&_.push({owner:t.source,skills:e})}let v=[],y=await(0,a.materializePluginEntries)((0,r.resolvePluginEntries)(c,(0,r.listDomainNames)(c),[]));for(let e of y){let r=n.default.join(e.directory,o);if(!t.default.existsSync(r))continue;let i=n.default.basename(e.directory),a=d(r,`plugins`,i,m,g,h,e.skillDiscovery);a.length>0&&v.push({owner:i,skills:a})}let b=d(n.default.join(c,`.claude`,o),`default`,s,m,g,h),x=b.length>0?[{owner:s,skills:b}]:[],S=p(e.helpSkills??[],g,h),C=[{key:`extensions`,label:`extensions`,owners:f(_)},{key:`help`,label:`Help`,owners:S},{key:`plugins`,label:`plugins`,owners:f(v)},{key:`default`,label:`default`,owners:x}],w=await l(),T=(0,i.formatSkillsForPrompt)(g),E=w((0,i.formatSkillsForPrompt)([])),D=new Map;for(let e of g)D.set(e.name,Math.max(0,w((0,i.formatSkillsForPrompt)([e]))-E));for(let e of C)for(let t of e.owners)for(let e of t.skills){let t=D.get(e.name);t!==void 0&&(e.promptTokens=t)}let O=0;for(let e of g)try{O+=w(t.default.readFileSync(e.filePath,`utf8`))}catch(t){h.push(`${e.filePath}: ${t instanceof Error?t.message:String(t)}`)}return{groups:C,skillCount:g.length,promptTokens:T?w(T):0,bodyTokens:O,diagnostics:h}}function h(e,t){for(let n of e.groups)for(let e of n.owners){let n=e.skills.find(e=>e.name===t);if(n)return n}}exports.buildSkillCatalog=m,exports.counter=l,exports.findSkill=h;
|
|
2
2
|
//# sourceMappingURL=skillCatalog.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skillCatalog.cjs","names":["path","loadSkillsFromDir","materializePluginEntries","resolvePluginEntries","listDomainNames","fs","formatSkillsForPrompt"],"sources":["../../src/adapters/skillCatalog.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { listDomainNames, type PluginSkillDiscovery, resolvePluginEntries } from '@agimon-ai/doompi-config/domains';\nimport type { SkillSourceContribution } from '@agimon-ai/doompi-extension-contracts/skills';\nimport { formatSkillsForPrompt, loadSkillsFromDir, type Skill } from '@earendil-works/pi-coding-agent';\nimport { materializePluginEntries } from '@agimon-ai/doompi-domain/plugins';\n\nconst SKILLS_DIRECTORY = 'skills';\nconst SHARED_SKILLS_OWNER = '.claude/skills';\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\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 /** Exact files the current selection resolved to, from `HarnessState.skillDirectories`. */\n activeSkillDirectories: readonly string[];\n extensionSources: readonly SkillSourceContribution[];\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}\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): SkillEntry[] {\n const result = loadSkillsFromDir({ dir: directory, source: owner });\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 { 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(directory, 'extensions', entry.source, () => true, loaded, diagnostics),\n );\n if (skills.length > 0) extensionOwners.push({ owner: entry.source, skills });\n }\n\n const pluginOwners: SkillOwnerNode[] = [];\n const domainPlugins = await materializePluginEntries(resolvePluginEntries(repoRoot, listDomainNames(repoRoot), []));\n for (const entry of domainPlugins) {\n const directory = path.join(entry.directory, SKILLS_DIRECTORY);\n if (!fs.existsSync(directory)) continue;\n const owner = path.basename(entry.directory);\n const skills = collect(directory, 'plugins', owner, isActive, loaded, diagnostics, entry.skillDiscovery);\n if (skills.length > 0) pluginOwners.push({ owner, skills });\n }\n\n const sharedDirectory = path.join(repoRoot, '.claude', SKILLS_DIRECTORY);\n const sharedSkills = collect(sharedDirectory, 'default', SHARED_SKILLS_OWNER, isActive, loaded, diagnostics);\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 let bodyTokens = 0;\n for (const skill of loaded) {\n try {\n bodyTokens += countTokens(fs.readFileSync(skill.filePath, 'utf8'));\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":"wRAOA,MAAM,EAAmB,SACnB,EAAsB,iBAwD5B,IAAI,EAEJ,eAAsB,GAA6C,CAEjE,MADA,KAAc,OAAO,kBACb,MAAM,EAAA,CAAW,WAC3B,CAUA,SAAS,EAAoB,EAAgE,CAC3F,IAAM,EAAS,EAAY,IAAK,GAAcA,EAAAA,QAAK,QAAQ,CAAS,CAAC,EACrE,MAAQ,IAAc,CACpB,IAAM,EAAWA,EAAAA,QAAK,QAAQ,CAAS,EACvC,OAAO,EAAO,KACX,GACC,IAAU,GAAY,EAAM,WAAW,GAAG,IAAWA,EAAAA,QAAK,KAAK,GAAK,EAAS,WAAW,GAAG,IAAQA,EAAAA,QAAK,KAAK,CACjH,CACF,CACF,CAEA,SAAS,EACP,EACA,EACA,EACA,EACA,EACA,EACA,EAAkC,YACpB,CACd,IAAM,G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|
|
1
|
+
{"version":3,"file":"skillCatalog.cjs","names":["path","loadSkillsFromDir","materializePluginEntries","resolvePluginEntries","listDomainNames","fs","formatSkillsForPrompt"],"sources":["../../src/adapters/skillCatalog.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { listDomainNames, type PluginSkillDiscovery, resolvePluginEntries } from '@agimon-ai/doompi-config/domains';\nimport type { SkillSourceContribution } from '@agimon-ai/doompi-extension-contracts/skills';\nimport { formatSkillsForPrompt, loadSkillsFromDir, type Skill } from '@earendil-works/pi-coding-agent';\nimport { materializePluginEntries } from '@agimon-ai/doompi-domain/plugins';\n\nconst SKILLS_DIRECTORY = 'skills';\nconst SHARED_SKILLS_OWNER = '.claude/skills';\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 /** Exact files the current selection resolved to, from `HarnessState.skillDirectories`. */\n activeSkillDirectories: readonly string[];\n extensionSources: readonly SkillSourceContribution[];\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}\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): SkillEntry[] {\n const result = loadSkillsFromDir({ dir: directory, source: owner });\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 { 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(directory, 'extensions', entry.source, () => true, loaded, diagnostics),\n );\n if (skills.length > 0) extensionOwners.push({ owner: entry.source, skills });\n }\n\n const pluginOwners: SkillOwnerNode[] = [];\n const domainPlugins = await materializePluginEntries(resolvePluginEntries(repoRoot, listDomainNames(repoRoot), []));\n for (const entry of domainPlugins) {\n const directory = path.join(entry.directory, SKILLS_DIRECTORY);\n if (!fs.existsSync(directory)) continue;\n const owner = path.basename(entry.directory);\n const skills = collect(directory, 'plugins', owner, isActive, loaded, diagnostics, entry.skillDiscovery);\n if (skills.length > 0) pluginOwners.push({ owner, skills });\n }\n\n const sharedDirectory = path.join(repoRoot, '.claude', SKILLS_DIRECTORY);\n const sharedSkills = collect(sharedDirectory, 'default', SHARED_SKILLS_OWNER, isActive, loaded, diagnostics);\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 for (const skill of loaded) {\n try {\n bodyTokens += countTokens(fs.readFileSync(skill.filePath, 'utf8'));\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":"wRAOA,MAAM,EAAmB,SACnB,EAAsB,iBAgE5B,IAAI,EAEJ,eAAsB,GAA6C,CAEjE,MADA,KAAc,OAAO,kBACb,MAAM,EAAA,CAAW,WAC3B,CAUA,SAAS,EAAoB,EAAgE,CAC3F,IAAM,EAAS,EAAY,IAAK,GAAcA,EAAAA,QAAK,QAAQ,CAAS,CAAC,EACrE,MAAQ,IAAc,CACpB,IAAM,EAAWA,EAAAA,QAAK,QAAQ,CAAS,EACvC,OAAO,EAAO,KACX,GACC,IAAU,GAAY,EAAM,WAAW,GAAG,IAAWA,EAAAA,QAAK,KAAK,GAAK,EAAS,WAAW,GAAG,IAAQA,EAAAA,QAAK,KAAK,CACjH,CACF,CACF,CAEA,SAAS,EACP,EACA,EACA,EACA,EACA,EACA,EACA,EAAkC,YACpB,CACd,IAAM,GAAA,EAASC,EAAAA,kBAAAA,CAAkB,CAAE,IAAK,EAAW,OAAQ,CAAM,CAAC,EAClE,IAAK,IAAM,KAAc,EAAO,YAC9B,EAAY,KAAK,GAAG,EAAW,MAAQ,EAAU,IAAI,EAAW,SAAS,EAI3E,IAAM,EAAOD,EAAAA,QAAK,QAAQ,CAAS,EAC7B,EAAO,EAAO,OAAO,OAAQ,GAAU,CAC3C,IAAM,EAAiBA,EAAAA,QAAK,QAAQ,EAAM,QAAQ,EAElD,OADI,IAAc,mBAAqBA,EAAAA,QAAK,QAAQ,CAAc,IAAM,EAAa,GAC9E,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I,EAC9D,GAAI,EAAO,OAAO,CACpB,CAGJ"}
|
|
@@ -11,6 +11,14 @@ interface SkillEntry {
|
|
|
11
11
|
/** Package name for an extension, plugin directory name, or `.claude/skills`. */
|
|
12
12
|
owner: string;
|
|
13
13
|
modelInvocable: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* What removing this skill would save from the `<available_skills>` block.
|
|
16
|
+
*
|
|
17
|
+
* Marginal rather than proportional: the block has fixed framing that no
|
|
18
|
+
* single skill pays for, so the useful figure is what actually goes away.
|
|
19
|
+
* Bodies are excluded because they load on demand and are not a resting cost.
|
|
20
|
+
*/
|
|
21
|
+
promptTokens?: number;
|
|
14
22
|
}
|
|
15
23
|
interface SkillOwnerNode {
|
|
16
24
|
owner: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skillCatalog.d.cts","names":[],"sources":["../../src/adapters/skillCatalog.ts"],"mappings":";;;KAUY;UAEK;EACf;EACA;EACA;EACA;EACA,OAAO;;EAEP;EACA;;UAGe;EACf;EACA,QAAQ;;UAGO;EACf,KAAK;EACL;EACA,QAAQ;;UAGO;EACf,QAAQ;EACR;;EAEA;;EAEA;;EAEA;;UAGe;EACf;;EAEA;EACA,2BAA2B;;EAE3B,sBAAsB;;EAEtB;;iBAaoB,WAAW,SAAS;;;;;;;;;;;iBAkHpB,kBAAkB,SAAS,sBAAsB,QAAQ"}
|
|
1
|
+
{"version":3,"file":"skillCatalog.d.cts","names":[],"sources":["../../src/adapters/skillCatalog.ts"],"mappings":";;;KAUY;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;EACA,2BAA2B;;EAE3B,sBAAsB;;EAEtB;;iBAaoB,WAAW,SAAS;;;;;;;;;;;iBAkHpB,kBAAkB,SAAS,sBAAsB,QAAQ"}
|
|
@@ -11,6 +11,14 @@ interface SkillEntry {
|
|
|
11
11
|
/** Package name for an extension, plugin directory name, or `.claude/skills`. */
|
|
12
12
|
owner: string;
|
|
13
13
|
modelInvocable: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* What removing this skill would save from the `<available_skills>` block.
|
|
16
|
+
*
|
|
17
|
+
* Marginal rather than proportional: the block has fixed framing that no
|
|
18
|
+
* single skill pays for, so the useful figure is what actually goes away.
|
|
19
|
+
* Bodies are excluded because they load on demand and are not a resting cost.
|
|
20
|
+
*/
|
|
21
|
+
promptTokens?: number;
|
|
14
22
|
}
|
|
15
23
|
interface SkillOwnerNode {
|
|
16
24
|
owner: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skillCatalog.d.mts","names":[],"sources":["../../src/adapters/skillCatalog.ts"],"mappings":";;;KAUY;UAEK;EACf;EACA;EACA;EACA;EACA,OAAO;;EAEP;EACA;;UAGe;EACf;EACA,QAAQ;;UAGO;EACf,KAAK;EACL;EACA,QAAQ;;UAGO;EACf,QAAQ;EACR;;EAEA;;EAEA;;EAEA;;UAGe;EACf;;EAEA;EACA,2BAA2B;;EAE3B,sBAAsB;;EAEtB;;iBAaoB,WAAW,SAAS;;;;;;;;;;;iBAkHpB,kBAAkB,SAAS,sBAAsB,QAAQ"}
|
|
1
|
+
{"version":3,"file":"skillCatalog.d.mts","names":[],"sources":["../../src/adapters/skillCatalog.ts"],"mappings":";;;KAUY;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;EACA,2BAA2B;;EAE3B,sBAAsB;;EAEtB;;iBAaoB,WAAW,SAAS;;;;;;;;;;;iBAkHpB,kBAAkB,SAAS,sBAAsB,QAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"node:fs";import t from"node:path";import{listDomainNames as n,resolvePluginEntries as r}from"@agimon-ai/doompi-config/domains";import{formatSkillsForPrompt as i,loadSkillsFromDir as a}from"@earendil-works/pi-coding-agent";import{materializePluginEntries as o}from"@agimon-ai/doompi-domain/plugins";const s=`skills`,c=`.claude/skills`;let l;async function u(){return l??=import(`gpt-tokenizer`),(await l).countTokens}function d(e){let n=e.map(e=>t.resolve(e));return e=>{let r=t.resolve(e);return n.some(e=>e===r||e.startsWith(`${r}${t.sep}`)||r.startsWith(`${e}${t.sep}`))}}function f(e,n,r,i,o,s,c=`recursive`){let l=a({dir:e,source:r});for(let t of l.diagnostics)s.push(`${t.path??e}: ${t.message}`);let u=t.resolve(e),d=l.skills.filter(e=>{let n=t.dirname(e.filePath);return c===`direct-children`&&t.dirname(n)!==u?!1:i(n)});return o.push(...d),d.map(e=>({name:e.name,description:e.description,filePath:e.filePath,baseDir:e.baseDir,group:n,owner:r,modelInvocable:!e.disableModelInvocation})).sort((e,t)=>e.name.localeCompare(t.name))}function p(e){return e.sort((e,t)=>e.owner.localeCompare(t.owner))}function m(e,t,n){let r=new Set(t.map(e=>e.name)),i=new Map,a=[...e].sort((e,t)=>e.sourceInfo.source.localeCompare(t.sourceInfo.source)||e.name.localeCompare(t.name)||e.filePath.localeCompare(t.filePath));for(let e of a){if(r.has(e.name)){n.push(`Help ${e.sourceInfo.source} [HELP_SKILL_COLLISION]: '${e.name}' was ignored because a normal skill wins.`);continue}r.add(e.name),t.push(e);let a=e.sourceInfo.source,o=i.get(a)??[];o.push({name:e.name,description:e.description,filePath:e.filePath,baseDir:e.baseDir,group:`help`,owner:a,modelInvocable:!e.disableModelInvocation}),i.set(a,o)}return p([...i.entries()].map(([e,t])=>({owner:e,skills:t.sort((e,t)=>e.name.localeCompare(t.name))})))}async function h(a){let{repoRoot:l}=a,h=d(a.activeSkillDirectories),g=[...a.helpDiagnostics??[]],_=[],v=[];for(let e of a.extensionSources){let t=e.directories.flatMap(t=>f(t,`extensions`,e.source,()=>!0,_,g));t.length>0&&v.push({owner:e.source,skills:t})}let y=[],b=await o(r(l,n(l),[]));for(let n of b){let r=t.join(n.directory,s);if(!e.existsSync(r))continue;let i=t.basename(n.directory),a=f(r,`plugins`,i,h,_,g,n.skillDiscovery);a.length>0&&y.push({owner:i,skills:a})}let x=f(t.join(l,`.claude`,s),`default`,c,h,_,g),S=x.length>0?[{owner:c,skills:x}]:[],C=m(a.helpSkills??[],_,g),w=[{key:`extensions`,label:`extensions`,owners:p(v)},{key:`help`,label:`Help`,owners:C},{key:`plugins`,label:`plugins`,owners:p(y)},{key:`default`,label:`default`,owners:S}],T=await u(),E=i(_),D=0;for(let t of _)try{
|
|
1
|
+
import e from"node:fs";import t from"node:path";import{listDomainNames as n,resolvePluginEntries as r}from"@agimon-ai/doompi-config/domains";import{formatSkillsForPrompt as i,loadSkillsFromDir as a}from"@earendil-works/pi-coding-agent";import{materializePluginEntries as o}from"@agimon-ai/doompi-domain/plugins";const s=`skills`,c=`.claude/skills`;let l;async function u(){return l??=import(`gpt-tokenizer`),(await l).countTokens}function d(e){let n=e.map(e=>t.resolve(e));return e=>{let r=t.resolve(e);return n.some(e=>e===r||e.startsWith(`${r}${t.sep}`)||r.startsWith(`${e}${t.sep}`))}}function f(e,n,r,i,o,s,c=`recursive`){let l=a({dir:e,source:r});for(let t of l.diagnostics)s.push(`${t.path??e}: ${t.message}`);let u=t.resolve(e),d=l.skills.filter(e=>{let n=t.dirname(e.filePath);return c===`direct-children`&&t.dirname(n)!==u?!1:i(n)});return o.push(...d),d.map(e=>({name:e.name,description:e.description,filePath:e.filePath,baseDir:e.baseDir,group:n,owner:r,modelInvocable:!e.disableModelInvocation})).sort((e,t)=>e.name.localeCompare(t.name))}function p(e){return e.sort((e,t)=>e.owner.localeCompare(t.owner))}function m(e,t,n){let r=new Set(t.map(e=>e.name)),i=new Map,a=[...e].sort((e,t)=>e.sourceInfo.source.localeCompare(t.sourceInfo.source)||e.name.localeCompare(t.name)||e.filePath.localeCompare(t.filePath));for(let e of a){if(r.has(e.name)){n.push(`Help ${e.sourceInfo.source} [HELP_SKILL_COLLISION]: '${e.name}' was ignored because a normal skill wins.`);continue}r.add(e.name),t.push(e);let a=e.sourceInfo.source,o=i.get(a)??[];o.push({name:e.name,description:e.description,filePath:e.filePath,baseDir:e.baseDir,group:`help`,owner:a,modelInvocable:!e.disableModelInvocation}),i.set(a,o)}return p([...i.entries()].map(([e,t])=>({owner:e,skills:t.sort((e,t)=>e.name.localeCompare(t.name))})))}async function h(a){let{repoRoot:l}=a,h=d(a.activeSkillDirectories),g=[...a.helpDiagnostics??[]],_=[],v=[];for(let e of a.extensionSources){let t=e.directories.flatMap(t=>f(t,`extensions`,e.source,()=>!0,_,g));t.length>0&&v.push({owner:e.source,skills:t})}let y=[],b=await o(r(l,n(l),[]));for(let n of b){let r=t.join(n.directory,s);if(!e.existsSync(r))continue;let i=t.basename(n.directory),a=f(r,`plugins`,i,h,_,g,n.skillDiscovery);a.length>0&&y.push({owner:i,skills:a})}let x=f(t.join(l,`.claude`,s),`default`,c,h,_,g),S=x.length>0?[{owner:c,skills:x}]:[],C=m(a.helpSkills??[],_,g),w=[{key:`extensions`,label:`extensions`,owners:p(v)},{key:`help`,label:`Help`,owners:C},{key:`plugins`,label:`plugins`,owners:p(y)},{key:`default`,label:`default`,owners:S}],T=await u(),E=i(_),D=T(i([])),O=new Map;for(let e of _)O.set(e.name,Math.max(0,T(i([e]))-D));for(let e of w)for(let t of e.owners)for(let e of t.skills){let t=O.get(e.name);t!==void 0&&(e.promptTokens=t)}let k=0;for(let t of _)try{k+=T(e.readFileSync(t.filePath,`utf8`))}catch(e){g.push(`${t.filePath}: ${e instanceof Error?e.message:String(e)}`)}return{groups:w,skillCount:_.length,promptTokens:E?T(E):0,bodyTokens:k,diagnostics:g}}function g(e,t){for(let n of e.groups)for(let e of n.owners){let n=e.skills.find(e=>e.name===t);if(n)return n}}export{h as buildSkillCatalog,u as counter,g as findSkill};
|
|
2
2
|
//# sourceMappingURL=skillCatalog.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skillCatalog.mjs","names":[],"sources":["../../src/adapters/skillCatalog.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { listDomainNames, type PluginSkillDiscovery, resolvePluginEntries } from '@agimon-ai/doompi-config/domains';\nimport type { SkillSourceContribution } from '@agimon-ai/doompi-extension-contracts/skills';\nimport { formatSkillsForPrompt, loadSkillsFromDir, type Skill } from '@earendil-works/pi-coding-agent';\nimport { materializePluginEntries } from '@agimon-ai/doompi-domain/plugins';\n\nconst SKILLS_DIRECTORY = 'skills';\nconst SHARED_SKILLS_OWNER = '.claude/skills';\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\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 /** Exact files the current selection resolved to, from `HarnessState.skillDirectories`. */\n activeSkillDirectories: readonly string[];\n extensionSources: readonly SkillSourceContribution[];\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}\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): SkillEntry[] {\n const result = loadSkillsFromDir({ dir: directory, source: owner });\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 { 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(directory, 'extensions', entry.source, () => true, loaded, diagnostics),\n );\n if (skills.length > 0) extensionOwners.push({ owner: entry.source, skills });\n }\n\n const pluginOwners: SkillOwnerNode[] = [];\n const domainPlugins = await materializePluginEntries(resolvePluginEntries(repoRoot, listDomainNames(repoRoot), []));\n for (const entry of domainPlugins) {\n const directory = path.join(entry.directory, SKILLS_DIRECTORY);\n if (!fs.existsSync(directory)) continue;\n const owner = path.basename(entry.directory);\n const skills = collect(directory, 'plugins', owner, isActive, loaded, diagnostics, entry.skillDiscovery);\n if (skills.length > 0) pluginOwners.push({ owner, skills });\n }\n\n const sharedDirectory = path.join(repoRoot, '.claude', SKILLS_DIRECTORY);\n const sharedSkills = collect(sharedDirectory, 'default', SHARED_SKILLS_OWNER, isActive, loaded, diagnostics);\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 let bodyTokens = 0;\n for (const skill of loaded) {\n try {\n bodyTokens += countTokens(fs.readFileSync(skill.filePath, 'utf8'));\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":"wTAOA,MAAM,EA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ACL,SACA,WAAY,EAAO,OACnB,aAAc,EAAS,EAAY,CAAM,EAAI,EAC7C,aACA,aACF,CACF,CAGA,SAAgB,EAAU,EAAuB,EAAsC,CACrF,IAAK,IAAM,KAAS,EAAQ,OAC1B,IAAK,IAAM,KAAS,EAAM,OAAQ,CAChC,IAAM,EAAQ,EAAM,OAAO,KAAM,GAAU,EAAM,OAAS,CAAI,EAC9D,GAAI,EAAO,OAAO,CACpB,CAGJ"}
|
|
1
|
+
{"version":3,"file":"skillCatalog.mjs","names":[],"sources":["../../src/adapters/skillCatalog.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { listDomainNames, type PluginSkillDiscovery, resolvePluginEntries } from '@agimon-ai/doompi-config/domains';\nimport type { SkillSourceContribution } from '@agimon-ai/doompi-extension-contracts/skills';\nimport { formatSkillsForPrompt, loadSkillsFromDir, type Skill } from '@earendil-works/pi-coding-agent';\nimport { materializePluginEntries } from '@agimon-ai/doompi-domain/plugins';\n\nconst SKILLS_DIRECTORY = 'skills';\nconst SHARED_SKILLS_OWNER = '.claude/skills';\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 /** Exact files the current selection resolved to, from `HarnessState.skillDirectories`. */\n activeSkillDirectories: readonly string[];\n extensionSources: readonly SkillSourceContribution[];\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}\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): SkillEntry[] {\n const result = loadSkillsFromDir({ dir: directory, source: owner });\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 { 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(directory, 'extensions', entry.source, () => true, loaded, diagnostics),\n );\n if (skills.length > 0) extensionOwners.push({ owner: entry.source, skills });\n }\n\n const pluginOwners: SkillOwnerNode[] = [];\n const domainPlugins = await materializePluginEntries(resolvePluginEntries(repoRoot, listDomainNames(repoRoot), []));\n for (const entry of domainPlugins) {\n const directory = path.join(entry.directory, SKILLS_DIRECTORY);\n if (!fs.existsSync(directory)) continue;\n const owner = path.basename(entry.directory);\n const skills = collect(directory, 'plugins', owner, isActive, loaded, diagnostics, entry.skillDiscovery);\n if (skills.length > 0) pluginOwners.push({ owner, skills });\n }\n\n const sharedDirectory = path.join(repoRoot, '.claude', SKILLS_DIRECTORY);\n const sharedSkills = collect(sharedDirectory, 'default', SHARED_SKILLS_OWNER, isActive, loaded, diagnostics);\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 for (const skill of loaded) {\n try {\n bodyTokens += countTokens(fs.readFileSync(skill.filePath, 'utf8'));\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":"wTAOA,MAAM,EAAmB,SACnB,EAAsB,iBAgE5B,IAAI,EAEJ,eAAsB,GAA6C,CAEjE,MADA,KAAc,OAAO,kBACb,MAAM,EAAA,CAAW,WAC3B,CAUA,SAAS,EAAoB,EAAgE,CAC3F,IAAM,EAAS,EAAY,IAAK,GAAc,EAAK,QAAQ,CAAS,CAAC,EACrE,MAAQ,IAAc,CACpB,IAAM,EAAW,EAAK,QAAQ,CAAS,EACvC,OAAO,EAAO,KACX,GACC,IAAU,GAAY,EAAM,WAAW,GAAG,IAAW,EAAK,KAAK,GAAK,EAAS,WAAW,GAAG,IAAQ,EAAK,KAAK,CACjH,CACF,CACF,CAEA,SAAS,EACP,EACA,EACA,EACA,EACA,EACA,EACA,EAAkC,YACpB,CACd,IAAM,EAAS,EAAkB,CAAE,IAAK,EAAW,OAAQ,CAAM,CAAC,EAClE,IAAK,IAAM,KAAc,EAAO,YAC9B,EAAY,KAAK,GAAG,EAAW,MAAQ,EAAU,IAAI,EAAW,SAAS,EAI3E,IAAM,EAAO,EAAK,QAAQ,CAAS,EAC7B,EA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J"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/doompi-skill",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.28",
|
|
4
4
|
"description": "Session skill catalogue, deferred skill discovery, and the skill browser for DoomPi.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-skills",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@deepseek-ai/cordis": "4.0.1",
|
|
63
63
|
"gpt-tokenizer": "4.0.0",
|
|
64
|
-
"@agimon-ai/doompi-config": "0.0.1-alpha.
|
|
65
|
-
"@agimon-ai/doompi-domain": "0.0.1-alpha.
|
|
66
|
-
"@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.
|
|
67
|
-
"@agimon-ai/doompi-telemetry": "0.0.1-alpha.
|
|
68
|
-
"@agimon-ai/doompi-ui": "0.0.1-alpha.
|
|
64
|
+
"@agimon-ai/doompi-config": "0.0.1-alpha.49",
|
|
65
|
+
"@agimon-ai/doompi-domain": "0.0.1-alpha.28",
|
|
66
|
+
"@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.49",
|
|
67
|
+
"@agimon-ai/doompi-telemetry": "0.0.1-alpha.49",
|
|
68
|
+
"@agimon-ai/doompi-ui": "0.0.1-alpha.50"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@deepseek-ai/cordis": "4.0.1",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"tsdown": "0.22.14",
|
|
77
77
|
"typescript": "7.0.2",
|
|
78
78
|
"vitest": "4.1.11",
|
|
79
|
-
"@agimon-ai/vibe-lint-plugin-doom-extension": "0.0.1-alpha.
|
|
79
|
+
"@agimon-ai/vibe-lint-plugin-doom-extension": "0.0.1-alpha.47"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"@earendil-works/pi-coding-agent": "0.84.4",
|