Skip to content

Commit 91afa88

Browse files
committed
some stuff that makes 0 sense to me but it works
1 parent a4a87ab commit 91afa88

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

lib/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync } from "fs"
22
import { join, dirname } from "path"
33
import { homedir } from "os"
4-
import * as jsoncParser from "jsonc-parser"
4+
import { parse } from "jsonc-parser/lib/esm/main.js"
55
import type { PluginInput } from "@opencode-ai/plugin"
66

77
type Permission = "ask" | "allow" | "deny"
@@ -824,7 +824,7 @@ function loadConfigFile(configPath: string): ConfigLoadResult {
824824
}
825825

826826
try {
827-
const parsed = jsoncParser.parse(fileContent, undefined, { allowTrailingComma: true })
827+
const parsed = parse(fileContent, undefined, { allowTrailingComma: true })
828828
if (parsed === undefined || parsed === null) {
829829
return { data: null, parseError: "Config file is empty or invalid" }
830830
}

lib/token-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { SessionState, WithParts } from "./state"
22
import { AssistantMessage, UserMessage } from "@opencode-ai/sdk/v2"
33
import { Logger } from "./logger"
4-
import { countTokens as anthropicCountTokens } from "@anthropic-ai/tokenizer"
4+
import * as _anthropicTokenizer from "@anthropic-ai/tokenizer"
5+
const anthropicCountTokens = (_anthropicTokenizer.countTokens ??
6+
(_anthropicTokenizer as any).default?.countTokens) as typeof _anthropicTokenizer.countTokens
57
import { getLastUserMessage } from "./messages/query"
68

79
export function getCurrentTokenUsage(state: SessionState, messages: WithParts[]): number {

0 commit comments

Comments
 (0)