feat: experimental codemode (#34677)
This commit is contained in:
parent
04d236ceed
commit
cb93114424
37 changed files with 11329 additions and 45 deletions
10
packages/codemode/src/token.ts
Normal file
10
packages/codemode/src/token.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Token estimation for budgeting model-facing text. Copied from
|
||||
* `@opencode-ai/core/util/token` (chars / 4) so this package stays
|
||||
* dependency-free; keep the two in sync if the heuristic ever changes.
|
||||
*/
|
||||
export * as Token from "./token.js"
|
||||
|
||||
const CHARS_PER_TOKEN = 4
|
||||
|
||||
export const estimate = (input: string) => Math.max(0, Math.round(input.length / CHARS_PER_TOKEN))
|
||||
Loading…
Add table
Add a link
Reference in a new issue