Environment:3641397194 wq Gpt6 Astra Cross Platform FS
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, File_System |
| Last Updated | 2026-10-26 14:00 GMT |
Overview
Cross-platform filesystem environment handling Windows, macOS, and Linux path resolution, symlink/junction/hardlink detection, and platform-specific directory layouts.
Description
This environment defines the filesystem capabilities required by seat detection, transaction, and path-guard implementations. The codebase must handle three distinct platform behaviors: Windows drive letters and UNC paths (with `\\?\` namespace prefixes), POSIX paths, and macOS directory structures. The `guardPath` function performs ancestor-walk traversal to detect symlinks, junctions, and hardlinks at any depth. The `detectDirectory` function resolves per-seat config directories using platform-specific data home paths (`LOCALAPPDATA` on Windows, `~/Library/Application Support` on macOS, `~/.local/share` or `XDG_DATA_HOME` on Linux).
Usage
Use this environment for implementations that perform filesystem operations requiring cross-platform path normalization and symlink/hardlink safety checks: detectDirectory (seat config resolution), SeatTransactions (crash-safe file writes), and basePlan (per-seat write plan computation). Any code that writes to or reads from user configuration directories requires this environment.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Windows / macOS / Linux | Must support `process.platform` branching |
| Filesystem | NTFS / APFS / ext4 | Must support `lstatSync`, `realpathSync.native` |
| Permissions | User-level read/write | Config directories under user home |
Dependencies
System Packages
- Node.js `node:fs` module (lstatSync, realpathSync, statSync, existsSync)
- Node.js `node:path` module (resolve, dirname, relative, isAbsolute, parse)
- Node.js `node:os` module (homedir, platform)
Python Packages
N/A — filesystem operations are implemented entirely in JavaScript.
Credentials
No credentials required. Optional environment variables for custom config directories:
- `CODEX_HOME` / `CODEX_DIR` — Codex config directory override
- `CLAUDE_CONFIG_DIR` / `CLAUDE_HOME` — Claude config directory override
- `GROK_HOME` / `GROK_DIR` — Grok config directory override
- `DSH_HOME` — DeepSeek harness home override
- `GLM_HOME` / `ZHIPU_HOME` / `ZCODE_HOME` — GLM/ZCode config override
- `GEMINI_HOME` / `GEMINI_DIR` — Gemini config override
- `CURSOR_HOME` — Cursor config override
- `MIMOCODE_HOME` / `XDG_CONFIG_HOME` — MiniMax config override
- `KIMI_CODE_HOME` — Kimi code home override
- `WORKBUDDY_HOME` — WorkBuddy home override
- `DOUBAO_USER_SKILLS` — Doubao skills directory override
Quick Install
# No additional install needed — uses Node.js built-in fs/path/os modules
# Ensure Node.js is available on the target platform
node -e "console.log(process.platform, require('node:os').homedir())"
Code Evidence
Platform-specific data home from `detect-directory.js:9-13`:
function platformDataHome({env=process.env,home=os.homedir(),platform=process.platform}={}){
if(platform==='win32')return String(env.LOCALAPPDATA||'').trim()||path.join(home,'AppData','Local');
if(platform==='darwin')return path.join(home,'Library','Application Support');
return String(env.XDG_DATA_HOME||'').trim()||path.join(home,'.local','share');
}
DOS/UNC namespace prefix stripping from `seat-transactions.js:11-17`:
function absolutePath(value) {
return path.resolve(process.platform === 'win32'
? value.replace(/^\\\\\?\\UNC\\/i, '\\\\').replace(/^\\\\\?\\([a-z]:\\)/i, '$1') : value);
}
Symlink/hardlink detection from `seat-transactions.js:19-39`:
function guardPath(file) {
const normalize = (value) => process.platform === 'win32' ? absolutePath(value).toLowerCase() : absolutePath(value);
for (let part = absolutePath(file); ; part = path.dirname(part)) {
let stat;
try { stat = fs.lstatSync(part); } catch (error) { if (error.code === 'ENOENT' && path.dirname(part) !== part) continue; throw error; }
if (stat.isSymbolicLink()) throw new Error('目标路径包含符号链接或目录联接,请选择普通目录');
if (stat.isFile() && stat.nlink > 1) throw new Error('目标文件包含硬链接,请先使用独立副本');
// ...
}
}
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `目标路径包含符号链接或目录联接,请选择普通目录` | Symlink or junction detected in path ancestry | Use a real directory without symlinks/junctions |
| `目标文件包含硬链接,请先使用独立副本` | File has `nlink > 1` (hardlinked) | Copy the file to break the hardlink |
| `请明确选择绝对目录` / `请选择专用目录,不要选择磁盘根目录` | Root or relative path selected | Choose a dedicated absolute directory, not a drive root |
| `所选路径不是目录` | Path points to a file, not a directory | Select a directory path |
Compatibility Notes
- Windows: Strips `\\?\` and `\\?\UNC\` namespace prefixes before ancestor walk; path comparison uses `toLowerCase()` for case-insensitive matching.
- macOS: Uses `~/Library/Application Support` as the platform data home.
- Linux: Respects `XDG_DATA_HOME` and `XDG_CONFIG_HOME` conventions.
- File mode preservation: On POSIX, `fs.chmodSync` is called after atomic write to preserve exact permission bits (umask masking); on Windows, mode bits are not applied.