Path lexical parse
path-lexical-parse · version 1.0.0 · File paths (lexical) · free, no key needed
Decompose a file path into its lexical components without accessing the filesystem.
Use when you need to: path lexical parse · parse file path · path decomposition.
Supported
- path lexical parse
- parse file path
- path decomposition
- file path components
- path stem extension
Not supported
- stat file
- resolve symlinks
- filesystem access
- real path resolution
Behavior
- Detect format from path string unless explicit format is provided.
- Windows detection: drive letter (C:), UNC (\\server\share), or backslash without forward slash.
- ext includes the leading dot; stem is base without ext.
- If base starts with "." and has no other dot, stem=base, ext="".
- segments are normalized (no "." or ".." retained).
- Empty string path is rejected (min length 1 byte).
- Paths exceeding 4096 bytes are rejected.
Input
path(string, required): min length 1; max length 4096format(one of "posix", "windows", "auto", optional)
Output
format(one of "posix", "windows", required)root(string, required)dir(string, required)base(string, required)stem(string, required)ext(string, required)drive(string or null, required)is_unc(boolean, required)is_absolute(boolean, required)segments(array of string, required)
Limits
- max path bytes: 4096
- max segments: 1024
Example
Request input:
{
"path": "/usr/local/bin/node"
}
Response:
{
"result": {
"format": "posix",
"root": "/",
"dir": "/usr/local/bin",
"base": "node",
"stem": "node",
"ext": "",
"drive": null,
"is_unc": false,
"is_absolute": true,
"segments": [
"usr",
"local",
"bin",
"node"
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "path-lexical-parse",
"version": "1.0.0",
"input": {
"path": "/usr/local/bin/node"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/path-lexical-parse/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"path":"/usr/local/bin/node"}'
The machine-readable contract is at /v1/tools/path-lexical-parse/versions/1.0.0.
CLI
node cli.mjs run path-lexical-parse 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Path lexical normalize: Normalize a path lexically: collapse redundant separators, resolve "." and ".." segments.
- Path set classify: Classify an array of file paths by file extension, depth histogram, and path format.
- Path lexical common ancestor: Compute the deepest common ancestor directory of a set of paths.
- Path lexical contains: Check whether a child path is lexically inside a parent directory.
- Path lexical join: Join an array of path segments lexically, resolving absolute reset boundaries and normalizing separators.
- Path lexical relative: Compute the lexical relative path from one path to another without filesystem access.