File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export function setProjectRoot(dir: string) {
1818
1919export function getProjectRoot ( ) {
2020 if ( ! projectRoot ) {
21- projectRoot = findGitRoot ( )
21+ projectRoot = findGitRoot ( ) ?? process . cwd ( )
2222 }
2323 return projectRoot
2424}
Original file line number Diff line number Diff line change 1+ import { API_KEY_ENV_VAR } from '@codebuff/common/old-constants'
12import { CodebuffClient } from '@codebuff/sdk'
23
3- import { API_KEY_ENV_VAR } from '@codebuff/common/old-constants'
4- import { findGitRoot } from './git'
54import { getAuthTokenDetails } from './auth'
65import { loadAgentDefinitions } from './load-agent-definitions'
76import { logger } from './logger'
7+ import { getProjectRoot } from '../project-files'
88
99let clientInstance : CodebuffClient | null = null
1010
@@ -28,12 +28,12 @@ export function getCodebuffClient(): CodebuffClient | null {
2828 return null
2929 }
3030
31- const gitRoot = findGitRoot ( )
31+ const projectRoot = getProjectRoot ( )
3232 try {
3333 const agentDefinitions = loadAgentDefinitions ( )
3434 clientInstance = new CodebuffClient ( {
3535 apiKey,
36- cwd : gitRoot ,
36+ cwd : projectRoot ,
3737 agentDefinitions,
3838 } )
3939 } catch ( error ) {
@@ -128,7 +128,11 @@ export function formatToolOutput(output: unknown): string {
128128 . map ( ( item ) => {
129129 if ( item . type === 'json' ) {
130130 // Handle errorMessage in the value object
131- if ( item . value && typeof item . value === 'object' && 'errorMessage' in item . value ) {
131+ if (
132+ item . value &&
133+ typeof item . value === 'object' &&
134+ 'errorMessage' in item . value
135+ ) {
132136 return String ( item . value . errorMessage )
133137 }
134138 return toYaml ( item . value )
Original file line number Diff line number Diff line change 11import { dirname , join } from 'path'
22import { existsSync } from 'fs'
33
4- export function findGitRoot ( ) : string {
4+ export function findGitRoot ( ) : string | null {
55 let currentDir = process . cwd ( )
66
77 while ( currentDir !== dirname ( currentDir ) ) {
@@ -11,5 +11,5 @@ export function findGitRoot(): string {
1111 currentDir = dirname ( currentDir )
1212 }
1313
14- return process . cwd ( )
14+ return null
1515}
You can’t perform that action at this time.
0 commit comments