(skillRoot)
| 78 | } |
| 79 | |
| 80 | export 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 | |
| 126 | export async function computePluginBudget(pluginRoot, manifest) { |
| 127 | const manifestPath = path.join(pluginRoot, ".codex-plugin", "plugin.json"); |
no test coverage detected