Skip to content

Commit a879cac

Browse files
committed
helper to convert file:// to path
1 parent 218d047 commit a879cac

7 files changed

Lines changed: 23 additions & 31 deletions

File tree

packages/cli/src/nodehost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { glob } from "glob"
99
import { debug as debug_, error, info, warn } from "./log"
1010
import { execa } from "execa"
1111
import { join } from "node:path"
12-
import { createNodePath } from "./nodepath"
12+
import { createNodePath } from "../../core/src/path"
1313
import { DockerManager } from "./docker"
1414
import { createWorkspaceFileSystem } from "../../core/src/workspace"
1515
import { filterGitIgnore } from "../../core/src/gitignore"
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
isAbsolute,
1010
} from "node:path"
1111
import { changeext } from "../../core/src/fs"
12+
import { fileURLToPath } from "node:url"
1213

1314
/**
1415
* Creates a frozen object that provides various path manipulation functions.
@@ -30,5 +31,6 @@ export function createNodePath(): Path {
3031
resolve, // Resolve a sequence of paths to an absolute path
3132
isAbsolute, // Check if a path is absolute
3233
changeext,
33-
})
34+
resolveFileURL: fileURLToPath,
35+
} satisfies Path)
3436
}

packages/core/src/testhost.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
UTF8Encoder,
1212
setRuntimeHost,
1313
RuntimeHost,
14-
AzureTokenResolver,
1514
ModelConfigurations,
1615
ModelConfiguration,
1716
} from "./host"

packages/core/src/types/prompt_template.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,12 @@ interface Path {
18271827
* @param ext
18281828
*/
18291829
changeext(path: string, ext: string): string
1830+
1831+
/**
1832+
* Converts a file://... to a path
1833+
* @param fileUrl
1834+
*/
1835+
resolveFileURL(fileUrl: string): string
18301836
}
18311837

18321838
interface Fenced {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
script({ model: "echo" })
2+
3+
const __filename = path.resolveFileURL(import.meta.url)
4+
const __dirname = path.dirname(__filename)
5+
6+
console.log("Current file path:", __filename)
7+
console.log("Current directory:", __dirname)
8+
const langgraph = await workspace.readText(path.join(__dirname, "langgraph.md"))
9+
10+
console.log(`langgraph.md content: ${langgraph.content.length}`)
11+
if (!langgraph) throw new Error("Failed to read langgraph.md")

packages/vscode/src/vshost.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as vscode from "vscode"
2-
import { createVSPath } from "./vspath"
2+
import { createNodePath } from "../../core/src/path"
33
import { TerminalServerManager } from "./servermanager"
44
import { Uri } from "vscode"
55
import { ExtensionState } from "./state"
66
import { Utils } from "vscode-uri"
7-
import { checkFileExists, readFileText } from "./fs"
87
import { filterGitIgnore } from "../../core/src/gitignore"
98
import { setHost, Host } from "../../core/src/host"
109
import { TraceOptions } from "../../core/src/trace"
@@ -18,7 +17,7 @@ import {
1817

1918
export class VSCodeHost extends EventTarget implements Host {
2019
userState: any = {}
21-
readonly path = createVSPath()
20+
readonly path = createNodePath()
2221
readonly server: TerminalServerManager
2322
constructor(readonly state: ExtensionState) {
2423
super()

packages/vscode/src/vspath.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)