Skip to content

Route server and daemon host paths through the shared parser - #6753

Merged
ymichael merged 1 commit into
mainfrom
bb/route-host-paths-through-the-shared-parser-thr_reaprmkcxe
Nov 2, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/route-host-paths-through-the-shared-parser-thr_reaprmkcxe

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

After #4659 added the shared host-path parser (packages/domain/src/host-path.ts), the server files route, the skills listing and the daemon skill-tree check kept their own path code. The copies disagreed. Skill dirname/basename/join used a drive-letter regex, so UNC paths were treated as POSIX and resolved to the wrong folder. File preview rootPath accepted a rootless \foo. Relative paths starting with a drive letter (C:/x) passed the files route, thread open and skill reads, but the daemon rejected them. Skill reads returned 404 for malformed paths that every other route rejects with 400.

What changed

  • @bb/domain: new getRelativeHostPathSegments next to the absolute-path parser.
  • apps/server/src/routes/files.ts: uses the shared normalize/join and the shared relative check. Windows separators in URL paths are still turned into / before the check.
  • routes/relative-route-path.ts deleted; thread open calls the shared check.
  • Skills listing and shared skills use the shared dirname/basename/join (wrapped in services/lib/host-path.ts) and the shared relative check. Hidden files still return 404; malformed paths now return 400.
  • apps/host-daemon/src/injected-skills.ts: isSafeTreePath uses the shared check plus its depth limit. No wire change.

Net: 119 added, 137 removed.

How you verified

  • One test table in packages/domain/test/host-path.test.ts runs every removed check's cases (and the newly rejected ones) against getRelativeHostPathSegments; added UNC dirname/basename cases.
  • Updated public-project-skills.test.ts: references/../../secrets.md now expects 400.
  • pnpm exec turbo run test lint --filter=@bb/server --filter=@bb/host-daemon --filter=@bb/domain and turbo run typecheck for server and daemon pass.

AGENT GENERATED

The files route, skills listing, thread-open check and daemon skill-tree
check each kept their own host-path code after #4659. Absolute paths now
use the shared parser in @bb/domain, and one new
getRelativeHostPathSegments replaces the three relative-path checks plus
the daemon's.

Drift fixed:
- skill dirname/basename/join treated UNC paths as POSIX
- file preview rootPath accepted a rootless "\foo"
- relative paths with a drive prefix ("C:/x") passed the files route,
  thread open and skill reads (the daemon already rejected them)
- skill reads returned 404 for malformed paths such as "a/../../b";
  they now return 400 like every other route. Hidden files still 404.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 79e4174 into main Nov 2, 2026
50 checks passed
@ymichael
ymichael deleted the bb/route-host-paths-through-the-shared-parser-thr_reaprmkcxe branch November 2, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant