Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

feat(platform): core modules — pathString, text, paths, env, exec

2 months ago

d38940a
Authored
Max Weinbach7/7/2026, 11:49:22 AM
The Phase 1 foundation (docs/platform-abstraction-plan.md §1.2-1.6), each
export platform-parameterized so every branch runs on every host:

- pathString: browser-safe pure string path ops, REQUIRED style param
  (kills the runtimePlatform()->linux fallback trap), \?\ de-namespacing
  (fixes the workspacePath UNC-server-'?' mis-parse), differential suite
  vs node:path.win32/posix on ~2000 generated inputs.
- text: the EOL/encoding contract — replaceRespectingEol (read/edit CRLF
  fix engine), BOM/UTF-16 decodeTextBuffer, code-point-safe
  decodeChildOutput, splitLines, subscribeLines.
- paths: sync-native realpath canonicalize (one engine — Bun has no async
  native), fail-direction case-folding (crossesProtectedMetadata folds
  win32+darwin deny-side; isInside folds win32-only accept-side so
  case-sensitive APFS never widens sandbox scope), home() with
  COWORK_HOME_OVERRIDE only, coworkPaths, portable filename validation,
  glob normalization preserving POSIX escapes.
- env: win32-only case-insensitive lookup (POSIX stays exact — 7 copies
  were insensitive on Linux too), spelling-preserving setEnv, quote-aware
  win32 PATH split, runtimePathDirs (the ONE Scripts-dir answer),
  defaultChildEnv/childEnv (SystemRoot et al guaranteed), per-platform
  sandboxEnvAllowlist (+USERPROFILE/APPDATA/LOCALAPPDATA/PYTHONUTF8 on
  win32), minimalSandboxEnv.
- exec: PATHEXT-aware which() (the ONE resolver), classifyExecutable,
  BatBadBut-safe resolveSpawn (cmd shims wrapped with typed
  UnsafeShimArgumentError on unquotable args), binaryName.
- pathImpl: shared internal platform->node:path mapping (was 4 copies).
- index: barrel with cross-module semantics documented.
- test/helpers/platform: pinHome, symlinkOrJunction, expectPrivateMode,
  forEachPlatform for the Phase 6 suite un-forking.

625 tests. Adversarially reviewed (verdict: ship); duplicated helpers
hoisted per review. New tests use hostPlatform()/import.meta.dir so the
boundary ratchet stays clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Parent2bbcf19

18 files changed
  • src/platform/env.ts+330−0
  • src/platform/exec.ts+261−0
  • src/platform/index.ts+25−0
  • src/platform/pathImpl.ts+15−0
  • src/platform/pathString.ts+795−0
  • src/platform/paths.ts+564−0
  • src/platform/shell.ts+2−5
  • src/platform/text.ts+316−0
test/helpers/platform.ts
+116
−0
  • test/platform/env.test.ts+566−0
  • test/platform/exec.test.ts+495−0
  • test/platform/helpers.test.ts+217−0
  • test/platform/pathString.test.ts+689−0
  • test/platform/paths.test.ts+787−0
  • test/platform/shellPlan.test.ts+2−3
  • test/platform/text.test.ts+474−0
  • test/prompt.test.ts+2−1
  • test/tools/tools.bash.test.ts+2−1