Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions src/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ async function main() {
format: "cjs",
sourcesContent: false,
platform: "node",
loader: {
".node": "file",
},
}

const srcDir = __dirname
Expand Down Expand Up @@ -67,6 +70,59 @@ async function main() {
// Copy tree-sitter files to dist directory
copyPaths([["services/continuedev/tree-sitter", "tree-sitter"]], srcDir, distDir)

// Helper function to find and copy a package
// This dynamically resolves package locations to avoid hardcoded version numbers
const copyPackage = (packageName) => {
let packageSource = null
try {
const require = createRequire(import.meta.url)
const packagePath = require.resolve(`${packageName}/package.json`)
packageSource = path.dirname(packagePath)
} catch (err) {
// Fallback: try to find it in pnpm structure
const pnpmDir = path.join(srcDir, "../node_modules/.pnpm")
if (fs.existsSync(pnpmDir)) {
const entries = fs.readdirSync(pnpmDir)
for (const entry of entries) {
if (entry.startsWith(`${packageName}@`)) {
const packagePath = path.join(pnpmDir, entry, "node_modules", packageName)
if (fs.existsSync(packagePath)) {
packageSource = packagePath
break
}
}
}
}
Comment on lines +82 to +95
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we care about this fallback or should we just fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3/4 packages use the fallback

}

if (packageSource && fs.existsSync(packageSource)) {
const packageDest = path.join(distDir, "node_modules", packageName)
try {
fs.cpSync(packageSource, packageDest, { recursive: true })
console.log(`[${name}] Copied ${packageName} package to dist/node_modules/${packageName}`)
return true
} catch (err) {
console.error(`[${name}] Failed to copy ${packageName} package:`, err)
return false
}
} else {
console.warn(`[${name}] ${packageName} source not found`)
return false
}
}

// Copy sqlite3 and sqlite native bindings to dist directory
// This is necessary because they are marked as external in esbuild
// and contain platform-specific .node binaries that must be included
copyPackage("sqlite3")
copyPackage("sqlite")
Comment on lines +117 to +118
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need both?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, though I'm not sure why


// Copy bindings package (required by sqlite3)
copyPackage("bindings")

// Copy file-uri-to-path (required by bindings)
copyPackage("file-uri-to-path")

// Copy JSDOM xhr-sync-worker.js to fix runtime resolution
const jsdomWorkerDest = path.join(distDir, "xhr-sync-worker.js")

Expand Down
28 changes: 14 additions & 14 deletions src/services/ghost/GhostServiceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GhostModel } from "./GhostModel"
import { GhostStatusBar } from "./GhostStatusBar"
import { GhostCodeActionProvider } from "./GhostCodeActionProvider"
import { GhostInlineCompletionProvider } from "./classic-auto-complete/GhostInlineCompletionProvider"
//import { NewAutocompleteProvider } from "./new-auto-complete/NewAutocompleteProvider"
import { NewAutocompleteProvider } from "./new-auto-complete/NewAutocompleteProvider"
import { GhostServiceSettings, TelemetryEventName } from "@roo-code/types"
import { ContextProxy } from "../../core/config/ContextProxy"
import { ProviderSettingsManager } from "../../core/config/ProviderSettingsManager"
Expand Down Expand Up @@ -36,7 +36,7 @@ export class GhostServiceManager {
// VSCode Providers
public codeActionProvider: GhostCodeActionProvider
public inlineCompletionProvider: GhostInlineCompletionProvider
//private newAutocompleteProvider: NewAutocompleteProvider | null = null
private newAutocompleteProvider: NewAutocompleteProvider | null = null
private inlineCompletionProviderDisposable: vscode.Disposable | null = null

private ignoreController?: Promise<RooIgnoreController>
Expand Down Expand Up @@ -126,18 +126,18 @@ export class GhostServiceManager {
}

// Dispose new autocomplete provider if switching away from it
//if (!useNewAutocomplete && this.newAutocompleteProvider) {
// this.newAutocompleteProvider.dispose()
// this.newAutocompleteProvider = null
//}
if (!useNewAutocomplete && this.newAutocompleteProvider) {
this.newAutocompleteProvider.dispose()
this.newAutocompleteProvider = null
}

if (shouldBeRegistered) {
if (useNewAutocomplete) {
// Initialize new autocomplete provider if not already created
//if (!this.newAutocompleteProvider) {
// this.newAutocompleteProvider = new NewAutocompleteProvider(this.context, this.cline)
// await this.newAutocompleteProvider.load()
//}
if (!this.newAutocompleteProvider) {
this.newAutocompleteProvider = new NewAutocompleteProvider(this.context, this.cline)
await this.newAutocompleteProvider.load()
}
// New autocomplete provider registers itself internally
} else {
// Register classic provider
Expand Down Expand Up @@ -458,10 +458,10 @@ export class GhostServiceManager {
}

// Dispose new autocomplete provider if it exists
//if (this.newAutocompleteProvider) {
// this.newAutocompleteProvider.dispose()
// this.newAutocompleteProvider = null
//}
if (this.newAutocompleteProvider) {
this.newAutocompleteProvider.dispose()
this.newAutocompleteProvider = null
}

this.disposeIgnoreController()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const GhostServiceSettingsView = ({
<Bot className="w-4" />
<div>{t("kilocode:ghost.title")}</div>
</div>
IK BEN MARK 3
</SectionHeader>

<Section className="flex flex-col gap-5">
Expand Down