MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / chdir

Method chdir

packages/kaos/src/ssh.ts:565–582  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

563 // ── Directory operations (async) ───────────────────────────────────
564
565 async chdir(path: string): Promise<void> {
566 let target: string;
567 if (isAbsolute(path)) {
568 target = path;
569 } else {
570 target = resolve(this._cwd, path);
571 }
572 // Resolve to the real path via SFTP
573 const resolved = await sftpRealpath(this._sftp, target);
574 // Verify the resolved target is actually a directory. Without this
575 // guard, `realpath` happily returns file paths, causing later relative
576 // reads/writes/execs to treat a regular file as a working directory.
577 const attrs = await sftpStat(this._sftp, resolved);
578 if (!attrs.isDirectory()) {
579 throw new KaosValueError(`${resolved} is not a directory`);
580 }
581 this._cwd = resolved;
582 }
583
584 async stat(path: string, options?: { followSymlinks?: boolean }): Promise<StatResult> {
585 const resolved = this._resolvePath(path);

Callers

nothing calls this directly

Calls 3

sftpRealpathFunction · 0.85
sftpStatFunction · 0.85
resolveFunction · 0.50

Tested by

no test coverage detected