MCPcopy Create free account
hub / github.com/openai/plugins / computeSkillBudget

Function computeSkillBudget

plugins/plugin-eval/src/core/budget.js:80–124  ·  view source on GitHub ↗
(skillRoot)

Source from the content-addressed store, hash-verified

78}
79
80export async function computeSkillBudget(skillRoot) {
81 const skillPath = path.join(skillRoot, "SKILL.md");
82 const content = await readText(skillPath);
83 const parsed = parseFrontmatter(content);
84 const name = parsed.data?.name || path.basename(skillRoot);
85 const description = parsed.data?.description || "";
86 const invocationPolicy = await readInvocationPolicy(skillRoot);
87
88 const triggerComponents = invocationPolicy.allowImplicitInvocation ? [
89 createComponent("skill-name", skillPath, estimateTokenCount(name), "Always-loaded skill identifier"),
90 createComponent(
91 "skill-description",
92 skillPath,
93 estimateTokenCount(description),
94 "Always-loaded trigger description",
95 ),
96 ] : [];
97
98 const invokeComponents = [
99 createComponent("skill-file", skillPath, estimateTokenCount(content), "Loaded when the skill is invoked"),
100 ];
101
102 const deferredComponents = await computeDeferredComponents(skillRoot, [skillPath]);
103
104 return {
105 kind: "skill",
106 method: invocationPolicy.allowImplicitInvocation ? "estimated-static" : "estimated-static-policy-aware",
107 invocation_policy: {
108 allow_implicit_invocation: invocationPolicy.allowImplicitInvocation,
109 ...(invocationPolicy.path ? { path: invocationPolicy.path } : {}),
110 },
111 trigger_cost_tokens: {
112 value: sumTokenCounts(triggerComponents),
113 components: triggerComponents,
114 },
115 invoke_cost_tokens: {
116 value: sumTokenCounts(invokeComponents),
117 components: invokeComponents,
118 },
119 deferred_cost_tokens: {
120 value: sumTokenCounts(deferredComponents),
121 components: deferredComponents,
122 },
123 };
124}
125
126export async function computePluginBudget(pluginRoot, manifest) {
127 const manifestPath = path.join(pluginRoot, ".codex-plugin", "plugin.json");

Callers 2

collectSkillSamplesFunction · 0.90
computeBudgetProfileFunction · 0.85

Calls 7

readTextFunction · 0.90
parseFrontmatterFunction · 0.90
estimateTokenCountFunction · 0.90
sumTokenCountsFunction · 0.90
readInvocationPolicyFunction · 0.85
createComponentFunction · 0.85

Tested by

no test coverage detected