LocalWorkspace
@a16njs/models / LocalWorkspace
Class: LocalWorkspace
Defined in: workspace.ts:115
Workspace backed by the local filesystem.
All operations delegate to Node.js fs/promises.
Example
const ws = new LocalWorkspace('source', '/project');
const content = await ws.read('.cursor/rules/my-rule.mdc');
await ws.write('.claude/rules/my-rule.md', content);
Implements
Constructors
Constructor
new LocalWorkspace(
id,root):LocalWorkspace
Defined in: workspace.ts:121
Create a new LocalWorkspace.
Parameters
id
string
Unique identifier for this workspace
root
string
Absolute path to the workspace root directory
Returns
LocalWorkspace
Properties
id
readonlyid:string
Defined in: workspace.ts:122
Unique identifier for this workspace
Implementation of
root
readonlyroot:string
Defined in: workspace.ts:123
Absolute path to the workspace root directory
Implementation of
Methods
resolve()
resolve(
relativePath):string
Defined in: workspace.ts:126
Resolve a relative path within this workspace to an absolute path.
Parameters
relativePath
string
Path relative to workspace root
Returns
string
Absolute path
Implementation of
exists()
exists(
relativePath):Promise<boolean>
Defined in: workspace.ts:131
Check if a path exists in this workspace.
Parameters
relativePath
string
Path relative to workspace root
Returns
Promise<boolean>
true if the path exists
Implementation of
read()
read(
relativePath):Promise<string>
Defined in: workspace.ts:140
Read a file from this workspace.
Parameters
relativePath
string
Path relative to workspace root
Returns
Promise<string>
File content as UTF-8 string
Throws
If the file does not exist
Implementation of
write()
write(
relativePath,content):Promise<void>
Defined in: workspace.ts:144
Write a file to this workspace. Creates parent directories as needed.
Parameters
relativePath
string
Path relative to workspace root
content
string
File content as UTF-8 string
Returns
Promise<void>
Throws
If the workspace is read-only
Implementation of
readdir()
readdir(
relativePath):Promise<WorkspaceEntry[]>
Defined in: workspace.ts:150
List entries in a directory.
Parameters
relativePath
string
Path relative to workspace root
Returns
Promise<WorkspaceEntry[]>
Array of directory entries
Throws
If the directory does not exist
Implementation of
mkdir()
mkdir(
relativePath):Promise<void>
Defined in: workspace.ts:159
Create a directory (and any missing parents).
Parameters
relativePath
string
Path relative to workspace root
Returns
Promise<void>