(target)
| 239 | } |
| 240 | |
| 241 | export async function computeBudgetProfile(target) { |
| 242 | if (target.kind === "skill") { |
| 243 | return computeSkillBudget(target.path); |
| 244 | } |
| 245 | if (target.kind === "plugin") { |
| 246 | const manifest = await readJson(path.join(target.path, ".codex-plugin", "plugin.json")); |
| 247 | return computePluginBudget(target.path, manifest); |
| 248 | } |
| 249 | |
| 250 | const files = await gatherDeferredTextFiles(target.path); |
| 251 | const components = []; |
| 252 | for (const filePath of files) { |
| 253 | const content = await readText(filePath); |
| 254 | components.push( |
| 255 | createComponent( |
| 256 | relativePath(target.path, filePath), |
| 257 | filePath, |
| 258 | estimateTokenCount(content), |
| 259 | "Generic text file budget", |
| 260 | ), |
| 261 | ); |
| 262 | } |
| 263 | return { |
| 264 | kind: target.kind, |
| 265 | trigger_cost_tokens: { value: 0, components: [] }, |
| 266 | invoke_cost_tokens: { value: 0, components: [] }, |
| 267 | deferred_cost_tokens: { value: sumTokenCounts(components), components }, |
| 268 | }; |
| 269 | } |
| 270 | |
| 271 | export function applyBudgetBands(rawBudget, baseline) { |
| 272 | const profile = baseline?.[rawBudget.kind] || baseline?.directory || baseline?.skill; |
no test coverage detected