Skip to content

Commit 3b56d08

Browse files
committed
style: await usage consistency
1 parent 9b1e617 commit 3b56d08

File tree

41 files changed

+231
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+231
-130
lines changed

cli/scripts/build-binary.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ async function ensureOpenTuiNativeBundle(targetInfo: TargetInfo) {
296296
)
297297
}
298298

299-
const metadata = (await metadataResponse.json()) as {
299+
const metadataResponseBody = await metadataResponse.json()
300+
const metadata = metadataResponseBody as {
300301
versions?: Record<
301302
string,
302303
{
@@ -325,7 +326,8 @@ async function ensureOpenTuiNativeBundle(targetInfo: TargetInfo) {
325326
tempDir,
326327
`${packageName.split('/').pop() ?? 'package'}-${version}.tgz`,
327328
)
328-
await Bun.write(tarballPath, await tarballResponse.arrayBuffer())
329+
const tarballBuffer = await tarballResponse.arrayBuffer()
330+
await Bun.write(tarballPath, tarballBuffer)
329331

330332
for (const target of missingTargets) {
331333
mkdirSync(target.packagesDir, { recursive: true })

cli/src/hooks/use-claude-quota-query.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export async function fetchClaudeQuota(
6767
throw new Error(`Failed to fetch Claude quota: ${response.status}`)
6868
}
6969

70-
const data = (await response.json()) as ClaudeQuotaResponse
70+
const responseBody = await response.json()
71+
const data = responseBody as ClaudeQuotaResponse
7172

7273
// Parse the response into a more usable format
7374
const fiveHour = data.five_hour

cli/src/hooks/use-usage-query.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export async function fetchUsageData({
6767
throw new Error(`Failed to fetch usage: ${response.status}`)
6868
}
6969

70-
const data = (await response.json()) as UsageResponse
70+
const responseBody = await response.json()
71+
const data = responseBody as UsageResponse
7172
return data
7273
}
7374

cli/src/login/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function formatUrl(url: string, maxWidth?: number): string[] {
5858
* Generates a unique fingerprint ID for CLI authentication
5959
*/
6060
export function generateFingerprintId(): string {
61-
return `codecane-cli-${Math.random().toString(36).substring(2, 15)}`
61+
return `codebuff-cli-${Math.random().toString(36).substring(2, 15)}`
6262
}
6363

6464
/**

cli/src/native/ripgrep.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const getRipgrepPath = async (): Promise<string> => {
1919
const outPath = path.join(binaryDir, rgFileName)
2020

2121
// Check if already extracted
22-
if (await Bun.file(outPath).exists()) {
22+
const outPathExists = await Bun.file(outPath).exists()
23+
if (outPathExists) {
2324
return outPath
2425
}
2526

@@ -44,7 +45,8 @@ const getRipgrepPath = async (): Promise<string> => {
4445
}
4546

4647
// Copy SDK's bundled binary to binary directory for portability
47-
await Bun.write(outPath, await Bun.file(embeddedRgPath).arrayBuffer())
48+
const embeddedBuffer = await Bun.file(embeddedRgPath).arrayBuffer()
49+
await Bun.write(outPath, embeddedBuffer)
4850

4951
// Make executable on Unix systems
5052
if (process.platform !== 'win32') {

cli/src/utils/codebuff-api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ export function createCodebuffApiClient(
331331

332332
if (response.ok) {
333333
try {
334-
const data = (await response.json()) as T
334+
const responseBody = await response.json()
335+
const data = responseBody as T
335336
return { ok: true, status: response.status, data }
336337
} catch {
337338
// Response was OK but no JSON body (e.g., 204 No Content)

cli/src/utils/codebuff-client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ export async function getCodebuffClient(): Promise<CodebuffClient | null> {
7878
agentDefinitions,
7979
overrideTools: {
8080
ask_user: async (input: ClientToolCall<'ask_user'>['input']) => {
81-
const response = (await AskUserBridge.request(
81+
const askUserResponse = await AskUserBridge.request(
8282
'cli-override',
8383
input.questions,
84-
)) as {
84+
)
85+
const response = askUserResponse as {
8586
answers?: Array<{ questionIndex: number; selectedOption: string }>
8687
skipped?: boolean
8788
}

common/src/mcp/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ export async function callMCPTool(
124124
if (!client) {
125125
throw new Error(`callTool: client not found with id: ${clientId}`)
126126
}
127-
const content = ((await client.callTool(...args)) as CallToolResult).content
127+
const callResult = await client.callTool(...args)
128+
const result = callResult as CallToolResult
129+
const content = result.content
128130

129131
return content.map((c: (typeof content)[number]) => {
130132
if (c.type === 'text') {

common/src/project-file-tree.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ export async function getProjectFileTree(params: {
5252

5353
while (queue.length > 0 && totalFiles < maxFiles) {
5454
const { node, fullPath, ignore: currentIgnore } = queue.shift()!
55+
const parsedIgnore = await parseGitignore({
56+
fullDirPath: fullPath,
57+
projectRoot,
58+
fs,
59+
})
5560
const mergedIgnore = ignore
5661
.default()
5762
.add(currentIgnore)
58-
.add(await parseGitignore({ fullDirPath: fullPath, projectRoot, fs }))
63+
.add(parsedIgnore)
5964

6065
try {
6166
const files = await fs.readdir(fullPath)
@@ -167,7 +172,8 @@ export async function parseGitignore(params: {
167172
]
168173

169174
for (const ignoreFilePath of ignoreFiles) {
170-
if (!(await fileExists({ filePath: ignoreFilePath, fs }))) continue
175+
const ignoreFileExists = await fileExists({ filePath: ignoreFilePath, fs })
176+
if (!ignoreFileExists) continue
171177

172178
let ignoreContent: string
173179
try {

common/src/testing/mock-modules.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ export async function mockModule(
1717
modulePath: string,
1818
renderMocks: () => Record<string, any>,
1919
): Promise<MockResult> {
20-
let original = originalModuleCache[modulePath] ?? {
21-
...(await import(modulePath)),
20+
let original = originalModuleCache[modulePath]
21+
if (!original) {
22+
const moduleExports = await import(modulePath)
23+
original = {
24+
...moduleExports,
25+
}
26+
originalModuleCache[modulePath] = original
2227
}
23-
originalModuleCache[modulePath] = original
2428
let mocks = renderMocks()
2529
let result = {
2630
...original,

0 commit comments

Comments
 (0)